mapleFU commented on code in PR #39807:
URL: https://github.com/apache/arrow/pull/39807#discussion_r1471298716


##########
cpp/src/arrow/io/compressed.cc:
##########
@@ -261,21 +262,39 @@ class CompressedInputStream::Impl {
     }
   }
 
-  bool closed() { return !is_open_; }
+  bool closed() const { return !is_open_; }
 
   Result<int64_t> Tell() const { return total_pos_; }
 
   // Read compressed data if necessary
   Status EnsureCompressedData() {
     int64_t compressed_avail = compressed_ ? compressed_->size() - 
compressed_pos_ : 0;
     if (compressed_avail == 0) {
+      // Ensure compressed_ buffer is allocated with kChunkSize.
+      if (compressed_ == nullptr) {
+        ARROW_ASSIGN_OR_RAISE(compressed_, AllocateResizableBuffer(kChunkSize, 
pool_));
+      } else {
+        RETURN_NOT_OK(compressed_->Resize(kChunkSize, 
/*shrink_to_fit=*/false));
+      }
       // No compressed data available, read a full chunk
-      ARROW_ASSIGN_OR_RAISE(compressed_, raw_->Read(kChunkSize));
+      ARROW_ASSIGN_OR_RAISE(int64_t read_size,
+                            raw_->Read(kChunkSize, 
compressed_->mutable_data_as<void>()));

Review Comment:
   Aha we have a `supports_zero_copy()`, can we use this to optimize it?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to