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

Method Open

be/src/exec/topn-node.cc:311–379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

309}
310
311Status TopNNode::Open(RuntimeState* state) {
312 SCOPED_TIMER(runtime_profile_->total_time_counter());
313 ScopedOpenEventAdder ea(this);
314 RETURN_IF_ERROR(ExecNode::Open(state));
315 RETURN_IF_CANCELLED(state);
316 RETURN_IF_ERROR(QueryMaintenance(state));
317
318 RETURN_IF_ERROR(child(0)->Open(state));
319
320 RETURN_IF_ERROR(
321 order_cmp_->Open(pool_, state, expr_perm_pool(), expr_results_pool()));
322 RETURN_IF_ERROR(ScalarExprEvaluator::Open(output_tuple_expr_evals_, state));
323 if (is_partitioned()) {
324 // Set up state required by partitioned top-N implementation. Claim reservation
325 // after the child has been opened to reduce the peak reservation requirement.
326 if (!buffer_pool_client()->is_registered()) {
327 RETURN_IF_ERROR(ClaimBufferReservation(state));
328 }
329 RETURN_IF_ERROR(
330 partition_cmp_->Open(pool_, state, expr_perm_pool(), expr_results_pool()));
331 RETURN_IF_ERROR(intra_partition_order_cmp_->Open(
332 pool_, state, expr_perm_pool(), expr_results_pool()));
333 RETURN_IF_ERROR(sorter_->Open());
334 }
335
336 // Allocate memory for a temporary tuple.
337 tmp_tuple_ = reinterpret_cast<Tuple*>(
338 tuple_pool_->Allocate(output_tuple_desc_->byte_size()));
339
340 // Limit of 0, no need to fetch anything from children.
341 const TopNPlanNode& pnode = static_cast<const TopNPlanNode&>(plan_node_);
342 if (pnode.heap_capacity() != 0) {
343 RowBatch batch(child(0)->row_desc(), state->batch_size(), mem_tracker());
344 bool eos;
345 do {
346 batch.Reset();
347 RETURN_IF_ERROR(child(0)->GetNext(state, &batch, &eos));
348 {
349 SCOPED_TIMER(insert_batch_timer_);
350 TopNPlanNode::InsertBatchFn insert_batch_fn = codegend_insert_batch_fn_.load();
351 if (insert_batch_fn != nullptr) {
352 insert_batch_fn(this, state, &batch);
353 } else if (is_partitioned()) {
354 InsertBatchPartitioned(state, &batch);
355 } else {
356 InsertBatchUnpartitioned(state, &batch);
357 }
358 DCHECK(is_partitioned() || heap_->DCheckConsistency());
359 if (is_partitioned()) {
360 if (partition_heaps_.size() > FLAGS_partitioned_topn_in_mem_partitions_limit ||
361 tuple_pool_->total_reserved_bytes() >
362 FLAGS_partitioned_topn_soft_limit_bytes) {
363 RETURN_IF_ERROR(EvictPartitions(state, /*evict_final=*/false));
364 }
365 } else if (rows_to_reclaim_ > 2 * unpartitioned_capacity()) {
366 RETURN_IF_ERROR(ReclaimTuplePool(state));
367 }
368 }

Callers

nothing calls this directly

Calls 15

OKFunction · 0.85
total_time_counterMethod · 0.80
is_registeredMethod · 0.80
batch_sizeMethod · 0.80
total_reserved_bytesMethod · 0.80
AllocateMethod · 0.45
byte_sizeMethod · 0.45
heap_capacityMethod · 0.45
row_descMethod · 0.45
ResetMethod · 0.45
GetNextMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected