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

Method Open

be/src/exec/analytic-eval-node.cc:199–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199Status AnalyticEvalNode::Open(RuntimeState* state) {
200 SCOPED_TIMER(runtime_profile_->total_time_counter());
201 ScopedOpenEventAdder ea(this);
202 RETURN_IF_ERROR(ExecNode::Open(state));
203 RETURN_IF_CANCELLED(state);
204 RETURN_IF_ERROR(QueryMaintenance(state));
205 RETURN_IF_ERROR(child(0)->Open(state));
206
207 // Claim reservation after the child has been opened to reduce the peak reservation
208 // requirement.
209 if (!buffer_pool_client()->is_registered()) {
210 RETURN_IF_ERROR(ClaimBufferReservation(state));
211 }
212 DCHECK(input_stream_ == nullptr);
213 input_stream_.reset(new BufferedTupleStream(state, child(0)->row_desc(),
214 buffer_pool_client(), resource_profile_.spillable_buffer_size,
215 resource_profile_.spillable_buffer_size));
216 RETURN_IF_ERROR(input_stream_->Init(label(), true));
217 bool success;
218 RETURN_IF_ERROR(input_stream_->PrepareForReadWrite(true, &success));
219 DCHECK(success) << "Had reservation: " << buffer_pool_client()->DebugString();
220
221 for (int i = 0; i < analytic_fn_evals_.size(); ++i) {
222 RETURN_IF_ERROR(analytic_fn_evals_[i]->Open(state));
223 FunctionContext* agg_fn_ctx = analytic_fn_evals_[i]->agg_fn_ctx();
224 if (!has_first_val_null_offset_ &&
225 "first_value_rewrite" == analytic_fns_[i]->fn_name() &&
226 agg_fn_ctx->GetNumArgs() == 2) {
227 DCHECK(!has_first_val_null_offset_);
228 first_val_null_offset_ =
229 reinterpret_cast<BigIntVal*>(agg_fn_ctx->GetConstantArg(1))->val;
230 VLOG_FILE << id() << " FIRST_VAL rewrite null offset: " << first_val_null_offset_;
231 has_first_val_null_offset_ = true;
232 }
233 }
234
235 if (partition_by_eq_expr_eval_ != nullptr) {
236 RETURN_IF_ERROR(partition_by_eq_expr_eval_->Open(state));
237 }
238
239 if (order_by_eq_expr_eval_ != nullptr) {
240 RETURN_IF_ERROR(order_by_eq_expr_eval_->Open(state));
241 }
242
243 // Initialize the tuple that was allocated in Prepare().
244 // TODO: zeroing out curr_tuple_ shouldn't be strictly necessary.
245 curr_tuple_->Init(intermediate_tuple_desc_->byte_size());
246 AggFnEvaluator::Init(analytic_fn_evals_, curr_tuple_);
247 curr_tuple_init_ = true;
248 // Check for failures during AggFnEvaluator::Init().
249 RETURN_IF_ERROR(state->GetQueryStatus());
250
251 // Initialize state for the first partition.
252 RETURN_IF_ERROR(InitNextPartition(state, 0));
253 if (curr_child_batch_ == nullptr) {
254 curr_child_batch_.reset(
255 new RowBatch(child(0)->row_desc(), state->batch_size(), mem_tracker()));
256 }

Callers

nothing calls this directly

Calls 15

OKFunction · 0.85
total_time_counterMethod · 0.80
is_registeredMethod · 0.80
PrepareForReadWriteMethod · 0.80
agg_fn_ctxMethod · 0.80
GetNumArgsMethod · 0.80
GetConstantArgMethod · 0.80
batch_sizeMethod · 0.80
resetMethod · 0.65
row_descMethod · 0.45
InitMethod · 0.45
DebugStringMethod · 0.45

Tested by

no test coverage detected