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


##########
cpp/src/arrow/io/compressed.cc:
##########
@@ -284,8 +308,12 @@ class CompressedInputStream::Impl {
     int64_t decompress_size = kDecompressSize;
 
     while (true) {
-      ARROW_ASSIGN_OR_RAISE(decompressed_,
-                            AllocateResizableBuffer(decompress_size, pool_));
+      if (decompressed_ == nullptr) {
+        ARROW_ASSIGN_OR_RAISE(decompressed_,
+                              AllocateResizableBuffer(decompress_size, pool_));
+      } else {
+        RETURN_NOT_OK(decompressed_->Resize(decompress_size, 
/*shrink_to_fit=*/false));

Review Comment:
   I'll note that mimalloc has 
[mi_expand](https://microsoft.github.io/mimalloc/group__malloc.html#gaaee66a1d483c3e28f585525fb96707e4)
 and jemalloc has [xallocx](https://jemalloc.net/jemalloc.3.html) which could 
be used to implement a resize-in-place API at the MemoryPool level. This would 
be useful in many instances of resizing a scratch space without caring about 
the contents.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to