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


##########
src/main/java/org/apache/datasketches/common/ArrayOfDoublesSerDe.java:
##########
@@ -29,28 +31,58 @@
  */
 public class ArrayOfDoublesSerDe extends ArrayOfItemsSerDe<Double> {
 
+  @Override
+  public byte[] serializeToByteArray(final Double item) {
+    final byte[] byteArr = new byte[Double.BYTES];
+    putDoubleLE(byteArr, 0, item.doubleValue());
+    return byteArr;
+  }
+
   @Override
   public byte[] serializeToByteArray(final Double[] items) {
     final byte[] bytes = new byte[Double.BYTES * items.length];
     final WritableMemory mem = WritableMemory.writableWrap(bytes);
-    long offsetBytes = 0;
+    long offset = 0;
     for (int i = 0; i < items.length; i++) {
-      mem.putDouble(offsetBytes, items[i]);
-      offsetBytes += Double.BYTES;
+      mem.putDouble(offset, items[i]);
+      offset += Double.BYTES;
     }
     return bytes;
   }
 
   @Override
-  public Double[] deserializeFromMemory(final Memory mem, final int length) {
-    Util.checkBounds(0, Double.BYTES, mem.getCapacity());
-    final Double[] array = new Double[length];
-    long offsetBytes = 0;
-    for (int i = 0; i < length; i++) {
-      array[i] = mem.getDouble(offsetBytes);
-      offsetBytes += Double.BYTES;
+  public Double deserializeOneFromMemory(final Memory mem, final long offset) {
+    return mem.getDouble(offset);
+  }
+
+  @Override
+  @Deprecated
+  public Double[] deserializeFromMemory(final Memory mem, final int numItems) {
+    return deserializeFromMemory(mem, 0, numItems);
+  }
+
+  @Override
+  public Double[] deserializeFromMemory(final Memory mem, final long 
offsetBytes, final int numItems) {
+    long offset = offsetBytes;
+    Util.checkBounds(offset, Double.BYTES * numItems, mem.getCapacity());

Review Comment:
   All fixed.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to