You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "LinShunKang (via GitHub)" <gi...@apache.org> on 2023/04/19 07:09:56 UTC

[GitHub] [kafka] LinShunKang commented on a diff in pull request #12545: KIP-863: Reduce CompletedFetch#parseRecord() memory copy

LinShunKang commented on code in PR #12545:
URL: https://github.com/apache/kafka/pull/12545#discussion_r1170898685


##########
clients/src/main/java/org/apache/kafka/common/serialization/DoubleDeserializer.java:
##########
@@ -35,4 +41,22 @@ public Double deserialize(String topic, byte[] data) {
         }
         return Double.longBitsToDouble(value);
     }
+
+    @Override
+    public Double deserialize(String topic, Headers headers, ByteBuffer data) {
+        if (data == null) {
+            return null;
+        }
+
+        if (data.remaining() != 8) {
+            throw new SerializationException("Size of data received by DoubleDeserializer is not 8");
+        }
+
+        final ByteOrder srcOrder = data.order();
+        data.order(BIG_ENDIAN);
+
+        final double value = data.getDouble(data.position());

Review Comment:
   @showuon 
   Because DoubleDeserializer and other Number Deserializers use BIG_ENDIAN byte order to read from byte[], and the current byte order of ByteBuffer may not be BIG_ENDIAN, we set the byte order of ByteBuffer to BIG_ENDIAN to be consistent with the byte order used when reading from byte[].



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