MCPcopy Create free account
hub / github.com/apache/impala / Open

Method Open

be/src/exec/aggregation-node.cc:44–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44Status AggregationNode::Open(RuntimeState* state) {
45 SCOPED_TIMER(runtime_profile_->total_time_counter());
46 ScopedOpenEventAdder ea(this);
47 // Open the child before consuming resources in this node.
48 RETURN_IF_ERROR(child(0)->Open(state));
49 RETURN_IF_ERROR(ExecNode::Open(state));
50 for (auto& agg : aggs_) RETURN_IF_ERROR(agg->Open(state));
51 RowBatch child_batch(child(0)->row_desc(), state->batch_size(), mem_tracker());
52
53 int num_aggs = aggs_.size();
54 // Create mini batches.
55 vector<unique_ptr<RowBatch>> mini_batches;
56 if (!replicate_input_ && num_aggs > 1) {
57 for (int i = 0; i < num_aggs; ++i) {
58 mini_batches.push_back(make_unique<RowBatch>(
59 child(0)->row_desc(), state->batch_size(), mem_tracker()));
60 }
61 }
62
63 // Read all the rows from the child and process them.
64 bool eos = false;
65 do {
66 RETURN_IF_CANCELLED(state);
67 RETURN_IF_ERROR(children_[0]->GetNext(state, &child_batch, &eos));
68
69 if (num_aggs == 1) {
70 RETURN_IF_ERROR(aggs_[0]->AddBatch(state, &child_batch));
71 child_batch.Reset();
72 if (fast_limit_check_) {
73 DCHECK(limit() > -1);
74 if (aggs_[0]->GetNumKeys() >= limit()) {
75 eos = true;
76 runtime_profile_->AddInfoString("FastLimitCheckExceededRows",
77 SimpleItoa(aggs_[0]->GetNumKeys() - limit()));
78 VLOG_QUERY << Substitute("the number of rows ($0) returned from the "
79 "aggregation node has exceeded the limit of $1", aggs_[0]->GetNumKeys(),
80 limit());
81 break;
82 }
83 }
84 continue;
85 }
86
87 if (replicate_input_) {
88 for (auto& agg : aggs_) RETURN_IF_ERROR(agg->AddBatch(state, &child_batch));
89 child_batch.Reset();
90 continue;
91 }
92
93 // Separate input batch into mini batches destined for the different aggs.
94 int num_tuples = child(0)->row_desc()->tuple_descriptors().size();
95 DCHECK_EQ(num_aggs, num_tuples);
96 int num_rows = child_batch.num_rows();
97 if (num_rows > 0) {
98 RETURN_IF_ERROR(SplitMiniBatches(&child_batch, &mini_batches));
99
100 for (int i = 0; i < num_tuples; ++i) {
101 RowBatch* mini_batch = mini_batches[i].get();

Callers

nothing calls this directly

Calls 15

SimpleItoaFunction · 0.85
SubstituteFunction · 0.85
OKFunction · 0.85
total_time_counterMethod · 0.80
batch_sizeMethod · 0.80
push_backMethod · 0.80
AddInfoStringMethod · 0.80
getMethod · 0.65
row_descMethod · 0.45
sizeMethod · 0.45
GetNextMethod · 0.45
AddBatchMethod · 0.45

Tested by

no test coverage detected