| 343 | } |
| 344 | |
| 345 | Status HdfsSequenceScanner::ProcessRange(RowBatch* row_batch) { |
| 346 | SeqFileHeader* seq_header = reinterpret_cast<SeqFileHeader*>(header_); |
| 347 | // Block compressed is handled separately to minimize function calls. |
| 348 | if (seq_header->is_compressed && !seq_header->is_row_compressed) { |
| 349 | return ProcessBlockCompressedScanRange(row_batch); |
| 350 | } |
| 351 | |
| 352 | // We count the time here since there is too much overhead to do |
| 353 | // this on each record. |
| 354 | SCOPED_TIMER(scan_node_->materialize_tuple_timer()); |
| 355 | int64_t num_rows_read = 0; |
| 356 | |
| 357 | const bool copy_strings = !seq_header->is_compressed && !string_slot_offsets_.empty(); |
| 358 | const bool has_materialized_slots = !scan_node_->materialized_slots().empty(); |
| 359 | while (!eos_) { |
| 360 | DCHECK_GT(record_locations_.size(), 0); |
| 361 | TupleRow* tuple_row_mem = row_batch->GetRow(row_batch->AddRow()); |
| 362 | |
| 363 | // Get the next compressed or uncompressed record and parse it. |
| 364 | RETURN_IF_ERROR(GetRecord(&record_locations_[0].record, &record_locations_[0].len)); |
| 365 | bool add_row = false; |
| 366 | if (has_materialized_slots) { |
| 367 | char* col_start; |
| 368 | uint8_t* record_start = record_locations_[0].record; |
| 369 | int num_tuples = 0; |
| 370 | int num_fields = 0; |
| 371 | char* row_end_loc; |
| 372 | RETURN_IF_ERROR(delimited_text_parser_->ParseFieldLocations( |
| 373 | 1, record_locations_[0].len, reinterpret_cast<char**>(&record_start), |
| 374 | &row_end_loc, field_locations_.data(), &num_tuples, &num_fields, &col_start)); |
| 375 | DCHECK_EQ(num_tuples, 1); |
| 376 | |
| 377 | uint8_t error_in_row = false; |
| 378 | uint8_t errors[num_fields]; |
| 379 | memset(errors, 0, num_fields); |
| 380 | MemPool* pool = row_batch->tuple_data_pool(); |
| 381 | add_row = WriteCompleteTuple(pool, field_locations_.data(), |
| 382 | tuple_, tuple_row_mem, template_tuple_, &errors[0], &error_in_row); |
| 383 | if (UNLIKELY(error_in_row)) { |
| 384 | ReportTupleParseError(field_locations_.data(), errors); |
| 385 | RETURN_IF_ERROR(parse_status_); |
| 386 | } |
| 387 | if (add_row && copy_strings) { |
| 388 | if (UNLIKELY(!tuple_->CopyStrings("HdfsSequenceScanner::ProcessRange()", |
| 389 | state_, string_slot_offsets_.data(), string_slot_offsets_.size(), pool, |
| 390 | &parse_status_))) { |
| 391 | return parse_status_; |
| 392 | } |
| 393 | } |
| 394 | } else { |
| 395 | add_row = WriteTemplateTuples(tuple_row_mem, 1) > 0; |
| 396 | } |
| 397 | num_rows_read++; |
| 398 | if (add_row) RETURN_IF_ERROR(CommitRows(1, row_batch)); |
| 399 | |
| 400 | // Sequence files don't end with syncs. |
| 401 | if (stream_->eof()) { |
| 402 | eos_ = true; |
nothing calls this directly
no test coverage detected