2019-03-26 18:28:37 +00:00
|
|
|
#pragma once
|
2019-10-04 15:40:05 +00:00
|
|
|
#include <Processors/Sources/SourceWithProgress.h>
|
2019-03-26 18:28:37 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2019-04-17 14:38:16 +00:00
|
|
|
class IBlockInputStream;
|
|
|
|
using BlockInputStreamPtr = std::shared_ptr<IBlockInputStream>;
|
|
|
|
|
2019-10-10 14:16:15 +00:00
|
|
|
/// Wrapper for IBlockInputStream which implements ISourceWithProgress.
|
2019-10-04 15:40:05 +00:00
|
|
|
class SourceFromInputStream : public ISourceWithProgress
|
2019-03-26 18:28:37 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-08-03 11:02:40 +00:00
|
|
|
explicit SourceFromInputStream(BlockInputStreamPtr stream_, bool force_add_aggregating_info_ = false);
|
2019-03-26 18:28:37 +00:00
|
|
|
String getName() const override { return "SourceFromInputStream"; }
|
|
|
|
|
2019-04-17 14:38:16 +00:00
|
|
|
Status prepare() override;
|
|
|
|
void work() override;
|
|
|
|
|
2019-03-26 18:28:37 +00:00
|
|
|
Chunk generate() override;
|
|
|
|
|
2019-04-17 14:38:16 +00:00
|
|
|
IBlockInputStream & getStream() { return *stream; }
|
|
|
|
|
|
|
|
void addTotalsPort();
|
2019-03-26 18:28:37 +00:00
|
|
|
|
2019-10-04 15:40:05 +00:00
|
|
|
/// Implementation for methods from ISourceWithProgress.
|
|
|
|
void setLimits(const LocalLimits & limits_) final { stream->setLimits(limits_); }
|
|
|
|
void setQuota(QuotaForIntervals & quota_) final { stream->setQuota(quota_); }
|
|
|
|
void setProcessListElement(QueryStatus * elem) final { stream->setProcessListElement(elem); }
|
|
|
|
void setProgressCallback(const ProgressCallback & callback) final { stream->setProgressCallback(callback); }
|
|
|
|
void addTotalRowsApprox(size_t value) final { stream->addTotalRowsApprox(value); }
|
|
|
|
|
2019-03-26 18:28:37 +00:00
|
|
|
private:
|
2019-04-05 15:45:46 +00:00
|
|
|
bool has_aggregate_functions = false;
|
2019-04-12 13:09:36 +00:00
|
|
|
bool force_add_aggregating_info;
|
2019-04-17 14:38:16 +00:00
|
|
|
BlockInputStreamPtr stream;
|
|
|
|
|
|
|
|
Chunk totals;
|
|
|
|
bool has_totals_port = false;
|
|
|
|
bool has_totals = false;
|
2019-04-17 16:14:52 +00:00
|
|
|
|
|
|
|
bool is_generating_finished = false;
|
|
|
|
bool is_stream_finished = false;
|
2019-04-25 13:34:59 +00:00
|
|
|
bool is_stream_started = false;
|
2019-03-26 18:28:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|