You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/08/08 02:41:43 UTC

[GitHub] [kafka] showuon commented on a change in pull request #11187: [WIP] KAFKA-5966: let CacheFunction#key return ByteBuffer

showuon commented on a change in pull request #11187:
URL: https://github.com/apache/kafka/pull/11187#discussion_r684704095



##########
File path: clients/src/main/java/org/apache/kafka/common/utils/Bytes.java
##########
@@ -40,6 +41,26 @@ public static Bytes wrap(byte[] bytes) {
         return new Bytes(bytes);
     }
 
+    /**
+     * Create a Bytes using the byte buffer. If the provided byteBuffer contains the whole content, we can directly
+     * use the backed array. If the byteBuffer has only partial of the content (ex: a sliced byteBuffer), we'll do array copy
+     *
+     * @param byteBuffer    The byteBuffer becomes the backing storage for the object.
+     */
+    public static Bytes wrap(ByteBuffer byteBuffer) {

Review comment:
       Create a `Bytes.wrap` for byteBuffer instance, and see if we can re-use the backed array directly, or we need to do array copy.




-- 
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: jira-unsubscribe@kafka.apache.org

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