zheguang commented on code in PR #21706:
URL: https://github.com/apache/kafka/pull/21706#discussion_r2935206398


##########
streams/src/main/java/org/apache/kafka/streams/state/internals/ValueTimestampHeadersDeserializer.java:
##########
@@ -139,17 +139,4 @@ static Headers headers(final byte[] 
rawValueTimestampHeaders) {
         final byte[] rawHeaders = readBytes(buffer, headersSize);
         return HeadersDeserializer.deserialize(rawHeaders);
     }
-    /**
-     * Extract raw value from serialized ValueTimestampHeaders.
-     */
-    static byte[] rawValue(final byte[] rawValueTimestampHeaders) {
-        if (rawValueTimestampHeaders == null) {
-            return null;
-        }
-
-        final ByteBuffer buffer = ByteBuffer.wrap(rawValueTimestampHeaders);
-        final int headersSize = ByteUtils.readVarint(buffer);
-        buffer.position(buffer.position() + headersSize + Long.BYTES);
-        return readBytes(buffer, buffer.remaining());
-    }

Review Comment:
   Great pointer.  `value()` indeed can just call `rawPlainValue()`.  So I just 
added this change in this PR.
   
   ~~For the others, let me find out in the context of KAFKA-20303~~
   
   I made the change in this PR anyways to find out ... yes there is a speedup 
to `headers` and `timestsamp` for empty headers:
   ```
   RawBytesExtractionBenchmark.testHeadersWithoutHeaders                 thrpt  
 15  10158.764 ±   85.564  ops/s
   RawBytesExtractionBenchmark.testHeadersWithoutHeadersOpt              thrpt  
 15  14824.176 ± 1244.455  ops/s
   RawBytesExtractionBenchmark.testTimestampWithoutHeaders               thrpt  
 15  14858.778 ±   39.301  ops/s
   RawBytesExtractionBenchmark.testTimestampWithoutHeadersOpt            thrpt  
 15  19832.718 ±  916.980  ops/s
   ```



##########
streams/src/main/java/org/apache/kafka/streams/state/internals/ValueTimestampHeadersDeserializer.java:
##########
@@ -139,17 +139,4 @@ static Headers headers(final byte[] 
rawValueTimestampHeaders) {
         final byte[] rawHeaders = readBytes(buffer, headersSize);
         return HeadersDeserializer.deserialize(rawHeaders);
     }
-    /**
-     * Extract raw value from serialized ValueTimestampHeaders.
-     */
-    static byte[] rawValue(final byte[] rawValueTimestampHeaders) {
-        if (rawValueTimestampHeaders == null) {
-            return null;
-        }
-
-        final ByteBuffer buffer = ByteBuffer.wrap(rawValueTimestampHeaders);
-        final int headersSize = ByteUtils.readVarint(buffer);
-        buffer.position(buffer.position() + headersSize + Long.BYTES);
-        return readBytes(buffer, buffer.remaining());
-    }

Review Comment:
   Great pointer.  `value()` indeed can just call `rawPlainValue()`.  So I just 
added this change in this PR.
   
   ~~For the others, let me find out in the context of KAFKA-20303~~
   
   I made the change in this PR anyways to find out ... yes there is a speedup 
to `headers` and `timestsamp` for empty headers:
   ```
   RawBytesExtractionBenchmark.testHeadersWithoutHeaders                 thrpt  
 15  10158.764 ±   85.564  ops/s
   RawBytesExtractionBenchmark.testHeadersWithoutHeadersOpt              thrpt  
 15  14824.176 ± 1244.455  ops/s
   
   RawBytesExtractionBenchmark.testTimestampWithoutHeaders               thrpt  
 15  14858.778 ±   39.301  ops/s
   RawBytesExtractionBenchmark.testTimestampWithoutHeadersOpt            thrpt  
 15  19832.718 ±  916.980  ops/s
   ```



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

Reply via email to