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


##########
src/test/java/org/apache/datasketches/quantiles/DoublesSketchTest.java:
##########
@@ -140,50 +139,37 @@ public void checkEmptyExceptions() {
 
   @Test
   public void directSketchShouldMoveOntoHeapEventually() {
-    try (WritableHandle wdh = WritableMemory.allocateDirect(1000,
-            ByteOrder.nativeOrder(), new DefaultMemoryRequestServer())) {
-      WritableMemory mem = wdh.getWritable();
-      UpdateDoublesSketch sketch = DoublesSketch.builder().build(mem);
-      Assert.assertTrue(sketch.isSameResource(mem));
-      for (int i = 0; i < 1000; i++) {
-        sketch.update(i);
-      }
-      Assert.assertFalse(sketch.isSameResource(mem));
-    } catch (final Exception e) {
-      throw new RuntimeException(e);
+    WritableMemory wmem = WritableMemory.allocateDirect(1000, 
ByteOrder.nativeOrder(), new DefaultMemoryRequestServer());
+    UpdateDoublesSketch sketch = DoublesSketch.builder().build(wmem);
+    Assert.assertTrue(sketch.isSameResource(wmem));
+    for (int i = 0; i < 1000; i++) {
+      sketch.update(i);
     }
+    println(sketch.toString());
   }
 
   @Test
   public void directSketchShouldMoveOntoHeapEventually2() {
     int i = 0;
-    try (WritableHandle wdh =
-        WritableMemory.allocateDirect(50, ByteOrder.LITTLE_ENDIAN, new 
DefaultMemoryRequestServer())) {
-      WritableMemory mem = wdh.getWritable();
-      UpdateDoublesSketch sketch = DoublesSketch.builder().build(mem);
-      Assert.assertTrue(sketch.isSameResource(mem));
-      for (; i < 1000; i++) {
-        if (sketch.isSameResource(mem)) {
-          sketch.update(i);
-        } else {
-          //println("MOVED OUT at i = " + i);
-          break;
-        }
+    WritableMemory wmem = WritableMemory.allocateDirect(50, 
ByteOrder.LITTLE_ENDIAN, new DefaultMemoryRequestServer());
+    UpdateDoublesSketch sketch = DoublesSketch.builder().build(wmem);
+    Assert.assertTrue(sketch.isSameResource(wmem));
+    for (; i < 1000; i++) {
+      if (wmem.isAlive()) {
+        sketch.update(i);
+      } else {
+        println("Sketch Move to Heap at i = " + i);
+        break;
       }
-    } catch (final Exception e) {
-      throw new RuntimeException(e);
     }
   }
 
   @Test
   public void checkEmptyDirect() {

Review Comment:
   Right. In the process of applying a test, I discovered a minor bug in 
DoublesByteArrayImp::convertToByteArray(...).  This test was generating an 
empty sketch, which should result in a returned byte[] of only 8 bytes.  And it 
was 8 bytes, but the preLongs value in byte 0 was 2 instead of 1.  This is now 
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