2018-05-23 20:19:33 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Processors/IProcessor.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class ISource : public IProcessor
|
|
|
|
{
|
2022-05-09 10:28:05 +00:00
|
|
|
private:
|
2022-05-31 14:43:38 +00:00
|
|
|
ReadProgressCounters read_progress;
|
2022-05-09 10:28:05 +00:00
|
|
|
bool read_progress_was_set = false;
|
2022-05-20 19:49:31 +00:00
|
|
|
bool auto_progress;
|
2022-05-09 10:28:05 +00:00
|
|
|
|
2018-05-23 20:19:33 +00:00
|
|
|
protected:
|
|
|
|
OutputPort & output;
|
2019-02-07 18:51:53 +00:00
|
|
|
bool has_input = false;
|
2018-05-23 20:19:33 +00:00
|
|
|
bool finished = false;
|
2019-04-30 09:45:13 +00:00
|
|
|
bool got_exception = false;
|
2019-04-29 18:43:50 +00:00
|
|
|
Port::Data current_chunk;
|
2018-05-23 20:19:33 +00:00
|
|
|
|
2022-05-31 17:56:48 +00:00
|
|
|
std::shared_ptr<const StorageLimitsList> storage_limits;
|
|
|
|
|
2020-12-04 10:52:57 +00:00
|
|
|
virtual Chunk generate();
|
|
|
|
virtual std::optional<Chunk> tryGenerate();
|
2018-05-23 20:19:33 +00:00
|
|
|
|
2022-05-09 10:28:05 +00:00
|
|
|
virtual void progress(size_t read_rows, size_t read_bytes);
|
|
|
|
|
2018-05-23 20:19:33 +00:00
|
|
|
public:
|
2022-05-25 19:45:48 +00:00
|
|
|
explicit ISource(Block header, bool enable_auto_progress = true);
|
2022-05-31 14:43:38 +00:00
|
|
|
~ISource() override;
|
2018-05-23 20:19:33 +00:00
|
|
|
|
|
|
|
Status prepare() override;
|
|
|
|
void work() override;
|
|
|
|
|
|
|
|
OutputPort & getPort() { return output; }
|
2019-02-19 18:41:18 +00:00
|
|
|
const OutputPort & getPort() const { return output; }
|
2022-05-09 10:28:05 +00:00
|
|
|
|
2022-05-31 17:56:48 +00:00
|
|
|
void setStorageLimits(const std::shared_ptr<const StorageLimitsList> & storage_limits_) override;
|
2022-05-31 14:43:38 +00:00
|
|
|
|
2022-05-09 10:28:05 +00:00
|
|
|
/// Default implementation for all the sources.
|
2022-06-01 17:39:12 +00:00
|
|
|
std::optional<ReadProgress> getReadProgress() final;
|
2022-05-20 19:49:31 +00:00
|
|
|
|
|
|
|
void addTotalRowsApprox(size_t value) { read_progress.total_rows_approx += value; }
|
2018-05-23 20:19:33 +00:00
|
|
|
};
|
|
|
|
|
2019-10-20 09:12:42 +00:00
|
|
|
using SourcePtr = std::shared_ptr<ISource>;
|
|
|
|
|
2018-05-23 20:19:33 +00:00
|
|
|
}
|