ClickHouse/src/Processors/ISource.h

51 lines
1.2 KiB
C++
Raw Normal View History

#pragma once
#include <Processors/IProcessor.h>
namespace DB
{
class ISource : public IProcessor
{
private:
2022-05-31 14:43:38 +00:00
ReadProgressCounters read_progress;
bool read_progress_was_set = false;
2022-05-20 19:49:31 +00:00
bool auto_progress;
protected:
OutputPort & output;
2019-02-07 18:51:53 +00:00
bool has_input = false;
bool finished = false;
bool got_exception = false;
2019-04-29 18:43:50 +00:00
Port::Data current_chunk;
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();
virtual void progress(size_t read_rows, size_t read_bytes);
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;
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-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
/// 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; }
};
using SourcePtr = std::shared_ptr<ISource>;
}