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


##########
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:
   > Also, the `data.position()` could be removed because by default, it'll 
read from current position of the byte buffer.
   
   @showuon 
   I use ByteBuffer.getDouble(int) instead of ByteBuffer.getDouble(), 
considering that ByteBuffer.getDouble(int) does not modify the offsets of the 
ByteBuffer.



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