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

Method ReadCompressedBlock

be/src/exec/sequence/hdfs-sequence-scanner.cc:523–570  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

521}
522
523Status HdfsSequenceScanner::ReadCompressedBlock() {
524 int64_t num_buffered_records;
525 RETURN_IF_FALSE(stream_->ReadVLong(
526 &num_buffered_records, &parse_status_));
527 if (num_buffered_records < 0) {
528 if (state_->LogHasSpace()) {
529 stringstream ss;
530 ss << stream_->filename()
531 << " Bad compressed block record count: " << num_buffered_records;
532 state_->LogError(ErrorMsg(TErrorCode::GENERAL, ss.str()));
533 }
534 return Status("bad record count");
535 }
536
537 // Skip the compressed key length and key buffers, we don't need them.
538 RETURN_IF_FALSE(stream_->SkipText(&parse_status_));
539 RETURN_IF_FALSE(stream_->SkipText(&parse_status_));
540
541 // Skip the compressed value length buffer. We don't need these either since the
542 // records are in Text format with length included.
543 RETURN_IF_FALSE(stream_->SkipText(&parse_status_));
544
545 // Read the compressed value buffer from the unbuffered stream.
546 int64_t block_size = 0;
547 RETURN_IF_FALSE(stream_->ReadVLong(&block_size, &parse_status_));
548 // Check for a reasonable size
549 if (block_size > MAX_BLOCK_SIZE || block_size < 0) {
550 stringstream ss;
551 ss << stream_->filename() << " Compressed block size is: " << block_size;
552 return Status(ss.str());
553 }
554
555 uint8_t* compressed_data = nullptr;
556 RETURN_IF_FALSE(stream_->ReadBytes(block_size, &compressed_data, &parse_status_));
557
558 {
559 int64_t len;
560 SCOPED_TIMER(decompress_timer_);
561 RETURN_IF_ERROR(decompressor_->ProcessBlock(false, block_size, compressed_data,
562 &len, &unparsed_data_buffer_));
563 VLOG_FILE << "Decompressed " << block_size << " to " << len;
564 next_record_in_compressed_block_ = unparsed_data_buffer_;
565 next_record_in_compressed_block_len_ = len;
566 data_buffer_end_ = unparsed_data_buffer_ + len;
567 }
568 num_buffered_records_in_compressed_block_ = num_buffered_records;
569 return Status::OK();
570}

Callers

nothing calls this directly

Calls 11

ErrorMsgClass · 0.85
OKFunction · 0.85
ReadVLongMethod · 0.80
LogHasSpaceMethod · 0.80
SkipTextMethod · 0.80
ReadBytesMethod · 0.80
StatusClass · 0.50
filenameMethod · 0.45
LogErrorMethod · 0.45
strMethod · 0.45
ProcessBlockMethod · 0.45

Tested by

no test coverage detected