Skip to content

Commit

Permalink
use Result<bool> rather than bool* and Status
Browse files Browse the repository at this point in the history
  • Loading branch information
mapleFU committed Apr 11, 2024
1 parent 582e9d4 commit a740df3
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions cpp/src/arrow/io/compressed.cc
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,7 @@ class CompressedInputStream::Impl {
}

// Try to feed more data into the decompressed_ buffer.
Status RefillDecompressed(bool* has_data) {
// First try to read data from the decompressor, unless we haven't read any
// compressed data yet.
Result<bool> RefillDecompressed() {
if (compressed_ && compressed_->size() != 0) {
if (decompressor_->IsFinished()) {
// We just went over the end of a previous compressed stream.
Expand All @@ -377,13 +375,11 @@ class CompressedInputStream::Impl {
if (!fresh_decompressor_ && !decompressor_->IsFinished()) {
return Status::IOError("Truncated compressed stream");
}
*has_data = false;
return Status::OK();
return false;
}
RETURN_NOT_OK(DecompressData());
}
*has_data = true;
return Status::OK();
return true;
}

Result<int64_t> Read(int64_t nbytes, void* out) {
Expand All @@ -401,7 +397,7 @@ class CompressedInputStream::Impl {

// At this point, no more decompressed data remains, so we need to
// decompress more
RETURN_NOT_OK(RefillDecompressed(&decompressor_has_data));
ARROW_ASSIGN_OR_RAISE(decompressor_has_data, RefillDecompressed());
}

total_pos_ += total_read;
Expand Down

0 comments on commit a740df3

Please sign in to comment.