This is an automated email from the ASF dual-hosted git repository. leerho pushed a commit to branch ffm_phase7 in repository https://gitbox.apache.org/repos/asf/datasketches-java.git
commit ea4f453f1e4dd03625cc3d1c277af669e7ed83fa Author: Lee Rhodes <[email protected]> AuthorDate: Wed Jul 23 14:54:08 2025 -0700 Minor updates to MemorySegmentRequest related files. --- .../common/MemorySegmentRequestExtension.java | 14 +++--------- .../kll/KllMemorySegmentRequestApp.java | 26 ++++++++-------------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/main/java/org/apache/datasketches/common/MemorySegmentRequestExtension.java b/src/main/java/org/apache/datasketches/common/MemorySegmentRequestExtension.java index 27d3c5b9b..d6d1c4371 100644 --- a/src/main/java/org/apache/datasketches/common/MemorySegmentRequestExtension.java +++ b/src/main/java/org/apache/datasketches/common/MemorySegmentRequestExtension.java @@ -36,7 +36,7 @@ public final class MemorySegmentRequestExtension implements MemorySegmentRequest if (prevSeg.isNative()) { final Arena arena = Arena.ofConfined(); final MemorySegment seg = arena.allocate(newByteSize); - table.put(seg, arena); //println("Add"); + table.put(seg, arena); //System.out.println("Add"); return seg; } else { if (newByteSize > Integer.MAX_VALUE) { @@ -51,7 +51,7 @@ public final class MemorySegmentRequestExtension implements MemorySegmentRequest final Arena arena = table.get(prevSeg); if ((arena != null) && arena.scope().isAlive()) { arena.close(); - table.remove(prevSeg); //println("Remove"); + table.remove(prevSeg); //System.out.println("Remove"); } //else ignore } @@ -62,17 +62,9 @@ public final class MemorySegmentRequestExtension implements MemorySegmentRequest for (final Enumeration<Arena> e = table.elements(); e.hasMoreElements();) { final Arena arena = e.nextElement(); if (arena.scope().isAlive()) { - arena.close(); //println("Closed remaining Arenas in the Hashtable"); + arena.close(); //System.out.println("Closed a remaining Arena in the Hashtable"); } } } -// /** -// * Println Object o -// * @param o object to print -// */ -// private static void println(final Object o) { -// System.out.println(o.toString()); -// } - } diff --git a/src/test/java/org/apache/datasketches/kll/KllMemorySegmentRequestApp.java b/src/test/java/org/apache/datasketches/kll/KllMemorySegmentRequestApp.java index 319b66a88..ed6d9a027 100644 --- a/src/test/java/org/apache/datasketches/kll/KllMemorySegmentRequestApp.java +++ b/src/test/java/org/apache/datasketches/kll/KllMemorySegmentRequestApp.java @@ -29,41 +29,33 @@ public class KllMemorySegmentRequestApp { final int k = 200; //The allocation of the original off-heap MemorySegment for the KllLongsSketch - //Note that we target the size to only handle k values, which is quite small. + //Note that this targets the size to only handle k values, which is quite small. final int numBytes = getMaxSerializedSizeBytes(k, k, LONGS_SKETCH, true); final Arena arena = Arena.ofConfined(); final MemorySegment seg = arena.allocate(numBytes); - //Our custom extension of the MemorySegmentRequest interface (see below). + //Use the custom extension of the MemorySegmentRequest interface. final MemorySegmentRequestExtension memSegReqExt = new MemorySegmentRequestExtension(); - //We create a new KllLongsSketch and pass our custom extension + //Create a new KllLongsSketch and pass the custom extension final KllLongsSketch sk = KllLongsSketch.newDirectInstance(k, seg, memSegReqExt); - //We update the sketch with way more data than the original MemorySegment can handle, forcing it to expand. + //Update the sketch with way more data than the original MemorySegment can handle, forcing it to request larger MemorySegments. for (int n = 1; n <= (10 * k); n++) { sk.update(n); } - //We make sure the sketch got all the data: + //Check to make sure the sketch got all the data: assertEquals(sk.getMaxItem(), 10 * k); assertEquals(sk.getMinItem(), 1); assertEquals(sk.getN(), 10 * k); - //We confirm that the last MemorySegment used by the sketch is, in fact, not the same as the original one we allocated. + //Confirm that the last MemorySegment used by the sketch is, in fact, not the same as the original one that was allocated. assertFalse(sk.getMemorySegment().equals(seg)); - //We are all done with the sketch. We cleanup any unclosed off-heap MemorySegments. + //All done with the sketch. Cleanup any unclosed off-heap MemorySegments. memSegReqExt.cleanup(); - //We close the original off-heap allocated MemorySegment. - arena.close(); println("Close original MemorySegment"); - } - - /** - * Println Object o - * @param o object to print - */ - static void println(final Object o) { - //System.out.println(o.toString()); + //Close the original off-heap allocated MemorySegment. + arena.close(); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
