iemejia commented on code in PR #3571:
URL: https://github.com/apache/parquet-java/pull/3571#discussion_r3342802926


##########
parquet-common/src/main/java/org/apache/parquet/bytes/ConcatenatingByteBufferCollector.java:
##########
@@ -78,6 +83,30 @@ public void writeAllTo(OutputStream out) throws IOException {
     }
   }
 
+  /**
+   * Writes all collected slabs to the given output stream, releasing each 
slab's
+   * {@link ByteBuffer} back to the allocator immediately after it has been 
written.
+   * This progressively frees memory during the write rather than holding all 
slabs
+   * until {@link #close()} is called.
+   *
+   * <p>After this method returns, the collector is empty and {@link #size()} 
returns 0.
+   * Calling {@link #close()} afterwards is safe but has no additional effect.
+   *
+   * @param out the output stream to write to
+   * @throws IOException if an I/O error occurs
+   */
+  public void writeAllToAndRelease(OutputStream out) throws IOException {
+    WritableByteChannel channel = Channels.newChannel(out);

Review Comment:
   No, closing the channel would close the underlying `OutputStream` which is 
owned by the caller. The channel from `Channels.newChannel(out)` is just a 
stateless wrapper with no independent resources to release. I've added a 
comment explaining this in the updated code.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to