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

Method GetNext

be/src/exec/data-source-scan-node.cc:454–525  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

452}
453
454Status DataSourceScanNode::GetNext(RuntimeState* state, RowBatch* row_batch, bool* eos) {
455 SCOPED_TIMER(runtime_profile_->total_time_counter());
456 ScopedGetNextEventAdder ea(this, eos);
457 RETURN_IF_ERROR(ExecDebugAction(TExecNodePhase::GETNEXT, state));
458 RETURN_IF_CANCELLED(state);
459 RETURN_IF_ERROR(QueryMaintenance(state));
460 if (ReachedLimit()) {
461 *eos = true;
462 return Status::OK();
463 }
464 *eos = false;
465
466 // create new tuple buffer for row_batch
467 MemPool* tuple_pool = row_batch->tuple_data_pool();
468 int64_t tuple_buffer_size;
469 uint8_t* tuple_buffer;
470 RETURN_IF_ERROR(
471 row_batch->ResizeAndAllocateTupleBuffer(state, &tuple_buffer_size, &tuple_buffer));
472 Tuple* tuple = reinterpret_cast<Tuple*>(tuple_buffer);
473 ScalarExprEvaluator* const* evals = conjunct_evals_.data();
474 int num_conjuncts = conjuncts_.size();
475 DCHECK_EQ(num_conjuncts, conjunct_evals_.size());
476 int64_t rows_read = 0;
477
478 while (true) {
479 {
480 SCOPED_TIMER(materialize_tuple_timer());
481 if (tuple_desc_->slots().size() > 0) {
482 // Copy rows until we hit the limit/capacity or until we exhaust input_batch_
483 while (!ReachedLimit() && !row_batch->AtCapacity() && InputBatchHasNext()) {
484 // TODO Timezone depends on flag use_local_tz_for_unix_timestamp_conversions.
485 // Check if this is the intended behaviour.
486 RETURN_IF_ERROR(MaterializeNextRow(
487 state->time_zone_for_unix_time_conversions(), tuple_pool, tuple));
488 ++rows_read;
489 int row_idx = row_batch->AddRow();
490 TupleRow* tuple_row = row_batch->GetRow(row_idx);
491 tuple_row->SetTuple(tuple_idx_, tuple);
492
493 if (ExecNode::EvalConjuncts(evals, num_conjuncts, tuple_row)) {
494 row_batch->CommitLastRow();
495 tuple = reinterpret_cast<Tuple*>(
496 reinterpret_cast<uint8_t*>(tuple) + tuple_desc_->byte_size());
497 IncrementNumRowsReturned(1);
498 }
499 ++next_row_idx_;
500 }
501 } else {
502 // For count(*)
503 if (InputBatchHasNext()) {
504 // Generate one output RowBatch for one input batch
505 rows_read += num_rows_;
506 next_row_idx_ += num_rows_;
507 IncrementNumRowsReturned(num_rows_);
508 row_batch->limit_capacity(rows_read);
509 row_batch->CommitRows(rows_read);
510 }
511 }

Callers 1

FetchBatchMethod · 0.45

Calls 15

OKFunction · 0.85
total_time_counterMethod · 0.80
tuple_data_poolMethod · 0.80
CommitLastRowMethod · 0.80
limit_capacityMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45
AtCapacityMethod · 0.45
AddRowMethod · 0.45
GetRowMethod · 0.45

Tested by

no test coverage detected