2018-05-23 20:19:33 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Processors/IProcessor.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/** Has one input and one output.
|
|
|
|
* Simply pull a block from input, transform it, and push it to output.
|
|
|
|
*/
|
|
|
|
class ISimpleTransform : public IProcessor
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
InputPort & input;
|
|
|
|
OutputPort & output;
|
|
|
|
|
2020-04-22 13:52:07 +00:00
|
|
|
Port::Data input_data;
|
|
|
|
Port::Data output_data;
|
2019-02-07 18:51:53 +00:00
|
|
|
bool has_input = false;
|
2020-04-22 13:52:07 +00:00
|
|
|
bool has_output = false;
|
2019-03-25 16:58:59 +00:00
|
|
|
bool no_more_data_needed = false;
|
2019-02-22 17:45:56 +00:00
|
|
|
const bool skip_empty_chunks;
|
2018-05-23 20:19:33 +00:00
|
|
|
|
2019-03-05 16:07:41 +00:00
|
|
|
/// Set input port NotNeeded after chunk was pulled.
|
|
|
|
/// Input port will become needed again only after data was transformed.
|
|
|
|
/// This allows to escape caching chunks in input port, which can lead to uneven data distribution.
|
2020-04-22 13:52:07 +00:00
|
|
|
bool set_input_not_needed_after_read = true;
|
|
|
|
|
|
|
|
virtual void transform(Chunk & input_chunk, Chunk & output_chunk)
|
|
|
|
{
|
|
|
|
transform(input_chunk);
|
|
|
|
output_chunk.swap(input_chunk);
|
|
|
|
}
|
2019-03-05 16:07:41 +00:00
|
|
|
|
2020-01-22 07:46:14 +00:00
|
|
|
virtual bool needInputData() const { return true; }
|
2019-03-25 16:58:59 +00:00
|
|
|
void stopReading() { no_more_data_needed = true; }
|
2018-05-23 20:19:33 +00:00
|
|
|
|
|
|
|
public:
|
2019-08-03 11:02:40 +00:00
|
|
|
ISimpleTransform(Block input_header_, Block output_header_, bool skip_empty_chunks_);
|
2018-05-23 20:19:33 +00:00
|
|
|
|
2022-06-22 13:05:07 +00:00
|
|
|
virtual void transform(Chunk &) = 0;
|
2021-09-08 14:08:57 +00:00
|
|
|
|
2018-05-23 20:19:33 +00:00
|
|
|
Status prepare() override;
|
|
|
|
void work() override;
|
|
|
|
|
|
|
|
InputPort & getInputPort() { return input; }
|
|
|
|
OutputPort & getOutputPort() { return output; }
|
2019-03-05 16:07:41 +00:00
|
|
|
|
|
|
|
void setInputNotNeededAfterRead(bool value) { set_input_not_needed_after_read = value; }
|
2018-05-23 20:19:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|