findepi commented on code in PR #4537:
URL: https://github.com/apache/iceberg/pull/4537#discussion_r901345504


##########
core/src/main/java/org/apache/iceberg/io/IOUtil.java:
##########
@@ -46,6 +50,21 @@ public static void readFully(InputStream stream, byte[] 
bytes, int offset, int l
     }
   }
 
+  /**
+   * Writes a buffer into a stream, making multiple write calls if necessary.
+   */
+  public static void writeFully(OutputStream outputStream, ByteBuffer buffer) 
throws IOException {
+    if (!buffer.hasRemaining()) {
+      return;
+    }
+    byte[] chunk = new byte[WRITE_CHUNK_SIZE];

Review Comment:
   > Alternatively, you could pass the temporary buffer in.
   
   This poses sizing challenge. I.e. the caller needs to provide a reasonably 
sized buffer.
   
   > Rather than allocating every time this is called, can you create a 
ThreadLocal to share this buffer?
   
   Sure, this is feasible. Do you happen to know what would be the expected 
reuse ratio for such a buffer?
   
   Alternatively we can have a static buffer pool that lends buffers to the 
current thread.
   (assuming we have a problem that we want to fix here)



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