Try to feed more data into the decompressed_ buffer. Returns whether there is more data to read.
| 358 | // Try to feed more data into the decompressed_ buffer. |
| 359 | // Returns whether there is more data to read. |
| 360 | Result<bool> RefillDecompressed() { |
| 361 | // First try to read data from the decompressor, unless we haven't read any |
| 362 | // compressed data yet. |
| 363 | if (compressed_ && compressed_->size() != 0) { |
| 364 | if (decompressor_->IsFinished()) { |
| 365 | // We just went over the end of a previous compressed stream. |
| 366 | RETURN_NOT_OK(decompressor_->Reset()); |
| 367 | fresh_decompressor_ = true; |
| 368 | } |
| 369 | RETURN_NOT_OK(DecompressData()); |
| 370 | } |
| 371 | int64_t decompress_avail = decompressed_buffer_available(); |
| 372 | if (decompress_avail == 0) { |
| 373 | // Got nothing from existing `compressed_` and `decompressor_`, |
| 374 | // need to read more compressed data. |
| 375 | RETURN_NOT_OK(EnsureCompressedData()); |
| 376 | if (compressed_buffer_available() == 0) { |
| 377 | // No more data to decompress |
| 378 | if (!fresh_decompressor_ && !decompressor_->IsFinished()) { |
| 379 | return Status::IOError("Truncated compressed stream"); |
| 380 | } |
| 381 | return false; |
| 382 | } |
| 383 | RETURN_NOT_OK(DecompressData()); |
| 384 | } |
| 385 | return true; |
| 386 | } |
| 387 | |
| 388 | Result<int64_t> Read(int64_t nbytes, void* out) { |
| 389 | auto* out_data = reinterpret_cast<uint8_t*>(out); |
nothing calls this directly
no test coverage detected