| 376 | } |
| 377 | |
| 378 | Status 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 | } |
nothing calls this directly
no test coverage detected