leerho commented on code in PR #676:
URL: https://github.com/apache/datasketches-java/pull/676#discussion_r2229731709


##########
src/main/java/org/apache/datasketches/count/CountMinSketch.java:
##########
@@ -384,20 +441,22 @@ public void serialize(ByteArrayOutputStream buf) {
    * @return The deserialized CountMinSketch.
    */
   public static CountMinSketch deserialize(final byte[] b, final long seed) {
-    ByteBuffer buf = ByteBuffer.allocate(b.length);
-    buf.put(b);
-    buf.flip();
-
-    final byte preambleLongs = buf.get();
-    final byte serialVersion = buf.get();
-    final byte familyId = buf.get();
-    final byte flagsByte = buf.get();
-    final int NULL_32 = buf.getInt();
-
-    final int numBuckets = buf.getInt();
-    final byte numHashes = buf.get();
-    final short seedHash = buf.getShort();
-    final byte NULL_8 = buf.get();
+    final MemorySegment buf = MemorySegment.ofArray(b);
+    long offset = 0;
+
+    final byte preambleLongs = buf.get(JAVA_BYTE, offset++);
+    final byte serialVersion = buf.get(JAVA_BYTE, offset++);
+    final byte familyId = buf.get(JAVA_BYTE, offset++);
+    final byte flagsByte = buf.get(JAVA_BYTE, offset++);
+    final int NULL_32 = buf.get(JAVA_INT_UNALIGNED, offset);
+    offset += 4;
+
+    final int numBuckets = buf.get(JAVA_INT_UNALIGNED, offset);
+    offset += 4;
+    final byte numHashes = buf.get(JAVA_BYTE, offset++);
+    final short seedHash = buf.get(JAVA_SHORT_UNALIGNED, offset);
+    offset += 2;
+    final byte NULL_8 = buf.get(JAVA_BYTE, offset++);
 

Review Comment:
   The variables preambleLongs, serialVersion, familyId, NULL_32 and NULL_8 are 
not used.  



-- 
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: dev-unsubscr...@datasketches.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@datasketches.apache.org
For additional commands, e-mail: dev-h...@datasketches.apache.org

Reply via email to