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

Method DecompressStreamToBuffer

be/src/exec/hdfs-scanner.cc:820–862  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

818}
819
820Status HdfsScanner::DecompressStreamToBuffer(uint8_t** buffer, int64_t* bytes_read,
821 MemPool* pool, bool* eosr) {
822 // We're about to create a new decompression buffer (if we can't reuse). Attach the
823 // memory from previous decompression rounds to 'pool'.
824 if (!decompressor_->reuse_output_buffer()) {
825 if (pool != nullptr) {
826 pool->AcquireData(data_buffer_pool_.get(), false);
827 } else {
828 data_buffer_pool_->FreeAll();
829 }
830 }
831
832 uint8_t* decompressed_buffer = nullptr;
833 int64_t decompressed_len = 0;
834 // Set bytes_to_read = -1 because we don't know how much data decompressor need.
835 // Just read the first available buffer within the scan range.
836 Status status = DecompressStream(-1, &decompressed_buffer, &decompressed_len,
837 eosr);
838 if (status.code() == TErrorCode::COMPRESSED_FILE_DECOMPRESSOR_NO_PROGRESS) {
839 // It's possible (but very unlikely) that ProcessBlockStreaming() wasn't able to
840 // make progress if the compressed buffer returned by GetBytes() is too small.
841 // (Note that this did not even occur in simple experiments where the input buffer
842 // is always 1 byte, but we need to handle this case to be defensive.) In this
843 // case, try again with a reasonably large fixed size buffer. If we still did not
844 // make progress, then return an error.
845 LOG(INFO) << status.GetDetail();
846 // Number of bytes to read when the previous attempt to streaming decompress did not
847 // make progress.
848 constexpr int64_t COMPRESSED_DATA_FIXED_READ_SIZE = 1 * 1024 * 1024;
849 status = DecompressStream(COMPRESSED_DATA_FIXED_READ_SIZE, &decompressed_buffer,
850 &decompressed_len, eosr);
851 }
852 RETURN_IF_ERROR(status);
853 *buffer = decompressed_buffer;
854 *bytes_read = decompressed_len;
855
856 if (*eosr) {
857 DCHECK(stream_->eosr());
858 context_->ReleaseCompletedResources(true);
859 }
860
861 return Status::OK();
862}
863
864Status HdfsScanner::DecompressStream(int64_t bytes_to_read,
865 uint8_t** decompressed_buffer, int64_t* decompressed_len, bool *eosr) {

Callers

nothing calls this directly

Calls 9

OKFunction · 0.85
reuse_output_bufferMethod · 0.80
AcquireDataMethod · 0.80
codeMethod · 0.80
GetDetailMethod · 0.80
getMethod · 0.65
FreeAllMethod · 0.45
eosrMethod · 0.45

Tested by

no test coverage detected