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

Method ProcessRange

be/src/exec/text/hdfs-text-scanner.cc:378–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

376}
377
378Status HdfsTextScanner::ProcessRange(RowBatch* row_batch, int* num_tuples) {
379 DCHECK(scan_state_ == FIRST_TUPLE_FOUND || scan_state_ == PAST_SCAN_RANGE);
380
381 MemPool* pool = row_batch->tuple_data_pool();
382 bool eosr = stream_->eosr() || scan_state_ == PAST_SCAN_RANGE;
383 while (true) {
384 if (!eosr && byte_buffer_ptr_ == byte_buffer_end_) {
385 RETURN_IF_ERROR(FillByteBufferWrapper(pool, &eosr));
386 }
387
388 TupleRow* tuple_row_mem = row_batch->GetRow(row_batch->AddRow());
389 int max_tuples = row_batch->capacity() - row_batch->num_rows();
390
391 if (scan_state_ == PAST_SCAN_RANGE) {
392 // byte_buffer_ptr_ is already set from FinishScanRange()
393 max_tuples = 1;
394 eosr = true;
395 }
396
397 *num_tuples = 0;
398 int num_fields = 0;
399
400 DCHECK_GT(max_tuples, 0);
401
402 batch_start_ptr_ = byte_buffer_ptr_;
403 char* col_start = byte_buffer_ptr_;
404 {
405 // Parse the bytes for delimiters and store their offsets in field_locations_
406 SCOPED_TIMER(parse_delimiter_timer_);
407 RETURN_IF_ERROR(delimited_text_parser_->ParseFieldLocations(max_tuples,
408 byte_buffer_end_ - byte_buffer_ptr_, &byte_buffer_ptr_,
409 row_end_locations_.data(), field_locations_.data(), num_tuples,
410 &num_fields, &col_start));
411 }
412
413 // Materialize the tuples into the in memory format for this query
414 int num_tuples_materialized = 0;
415 if (scan_node_->materialized_slots().size() != 0 &&
416 (num_fields > 0 || *num_tuples > 0)) {
417 // There can be one partial tuple which returned no more fields from this buffer.
418 DCHECK_LE(*num_tuples, num_fields + 1);
419 if (!boundary_column_.IsEmpty()) {
420 RETURN_IF_ERROR(CopyBoundaryField(field_locations_.data(), pool));
421 boundary_column_.Clear();
422 }
423 num_tuples_materialized = WriteFields(num_fields, *num_tuples, pool, tuple_row_mem);
424 DCHECK_GE(num_tuples_materialized, 0);
425 RETURN_IF_ERROR(parse_status_);
426 if (*num_tuples > 0) {
427 // If we saw any tuple delimiters, clear the boundary_row_.
428 boundary_row_.Clear();
429 }
430 } else if (*num_tuples != 0) {
431 SCOPED_TIMER(scan_node_->materialize_tuple_timer());
432 // If we are doing count(*) then we return tuples only containing partition keys
433 boundary_row_.Clear();
434 num_tuples_materialized = WriteTemplateTuples(tuple_row_mem, *num_tuples);
435 }

Callers

nothing calls this directly

Calls 15

OKFunction · 0.85
tuple_data_poolMethod · 0.80
ParseFieldLocationsMethod · 0.80
rows_read_counterMethod · 0.80
ReturnCurrentColumnMethod · 0.80
ReachedLimitSharedMethod · 0.80
eosrMethod · 0.45
GetRowMethod · 0.45
AddRowMethod · 0.45
capacityMethod · 0.45
num_rowsMethod · 0.45

Tested by

no test coverage detected