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



##########
File path: 
streams/src/main/java/org/apache/kafka/streams/state/internals/MergedSortedCacheSessionStoreIterator.java
##########
@@ -45,8 +47,8 @@
 
     @Override
     Windowed<Bytes> deserializeCacheKey(final Bytes cacheKey) {
-        final byte[] binaryKey = cacheFunction.key(cacheKey).get();
-        final byte[] keyBytes = SessionKeySchema.extractKeyBytes(binaryKey);
+        final ByteBuffer binaryKey = cacheFunction.key(cacheKey);
+        final ByteBuffer keyBytes = 
SessionKeySchema.extractKeyBytes(binaryKey);
         final Window window = SessionKeySchema.extractWindow(binaryKey);

Review comment:
       This is a good example that we avoided unnecessary array copy.
   Before:
   1. `cacheFunction.key(cacheKey)`  -> do an array copy
   2. `SessionKeySchema.extractKeyBytes(binaryKey)` -> do an array copy
   
   After:
   1. `cacheFunction.key(cacheKey)`  -> no array copy, just return sliced byte 
buffer
   2. `SessionKeySchema.extractKeyBytes(binaryKey)` -> no array copy, just 
return sliced byte buffer
   




-- 
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-unsubscr...@kafka.apache.org

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


Reply via email to