You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "adoroszlai (via GitHub)" <gi...@apache.org> on 2023/11/04 11:16:38 UTC

Re: [PR] HDDS-9611. Avoid unnecessary buffer conversion. [ozone]

adoroszlai commented on code in PR #5542:
URL: https://github.com/apache/ozone/pull/5542#discussion_r1382374594


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/helpers/ChunkUtils.java:
##########
@@ -180,6 +183,15 @@ private static long writeDataToChannel(FileChannel channel, ChunkBuffer data,
     }
   }
 
+  public static ChunkBuffer readData(long len, int bufferCapacity,
+      CheckedConsumer<ByteBuffer[], StorageContainerException> readMethod)
+      throws StorageContainerException {
+    final ByteBuffer[] buffers = BufferUtils.assignByteBuffers(len,
+        bufferCapacity);
+    readMethod.accept(buffers);
+    return ChunkBuffer.wrap(Lists.newArrayList(buffers));

Review Comment:
   `ChunkBuffer` doesn't change the list's size, and it creates a defensive copy anyway.  So I think we could use `Arrays.asList()` 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: issues-unsubscribe@ozone.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org