blob: 0de3ed37a61e734fc24d1a1f7a49dcf87f95f871 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#include <Processors/ISink.h>
namespace DB
{
ISink::ISink(Block header)
: IProcessor({std::move(header)}, {}), input(inputs.front())
{
}
ISink::Status ISink::prepare()
{
if (!was_on_start_called)
return Status::Ready;
if (has_input)
return Status::Ready;
if (input.isFinished())
{
if (!was_on_finish_called)
return Status::Ready;
return Status::Finished;
}
input.setNeeded();
if (!input.hasData())
return Status::NeedData;
current_chunk = input.pull(true);
has_input = true;
return Status::Ready;
}
void ISink::work()
{
if (!was_on_start_called)
{
was_on_start_called = true;
onStart();
}
else if (has_input)
{
has_input = false;
consume(std::move(current_chunk));
}
else if (!was_on_finish_called)
{
was_on_finish_called = true;
onFinish();
}
}
}
|