ClickHouse/dbms/src/Processors/Transforms/CreatingSetsTransform.h

64 lines
1.7 KiB
C++
Raw Normal View History

2019-03-26 14:11:38 +00:00
#pragma once
#include <Processors/IProcessor.h>
#include <Interpreters/SubqueryForSet.h>
#include <Common/Stopwatch.h>
namespace DB
{
2019-04-10 12:38:57 +00:00
struct Progress;
using ProgressCallback = std::function<void(const Progress & progress)>;
2019-03-26 14:11:38 +00:00
/// This processor creates sets during execution.
/// Don't return any data. Sets are created when Finish status is returned.
/// In general, several work() methods need to be called to finish.
/// TODO: several independent processors can be created for each subquery. Make subquery a piece of pipeline.
class CreatingSetsTransform : public IProcessor
{
public:
CreatingSetsTransform(
Block out_header,
const SubqueriesForSets & subqueries_for_sets_,
2019-04-05 10:52:07 +00:00
const SizeLimits & network_transfer_limits,
const Context & context);
2019-03-26 14:11:38 +00:00
2019-04-05 10:52:07 +00:00
String getName() const override { return "CreatingSetsTransform"; }
2019-03-26 14:11:38 +00:00
Status prepare() override;
void work() override;
2019-04-10 12:38:57 +00:00
void setProgressCallback(const ProgressCallback & callback);
void setProcessListElement(QueryStatus * status);
2019-03-26 14:11:38 +00:00
protected:
bool finished = false;
private:
SubqueriesForSets subqueries_for_sets;
SubqueriesForSets::iterator cur_subquery;
bool started_cur_subquery = false;
BlockOutputStreamPtr table_out;
UInt64 elapsed_nanoseconds = 0;
bool done_with_set = true;
bool done_with_join = true;
bool done_with_table = true;
SizeLimits network_transfer_limits;
2019-04-05 10:52:07 +00:00
const Context & context;
2019-03-26 14:11:38 +00:00
size_t rows_to_transfer = 0;
size_t bytes_to_transfer = 0;
using Logger = Poco::Logger;
Logger * log = &Logger::get("CreatingSetsBlockInputStream");
2019-04-09 11:09:46 +00:00
bool is_initialized = false;
void init();
2019-03-26 14:11:38 +00:00
void startSubquery(SubqueryForSet & subquery);
void finishSubquery(SubqueryForSet & subquery);
};
}