This is an automated email from the ASF dual-hosted git repository. leerho pushed a commit to branch ffm_phase3 in repository https://gitbox.apache.org/repos/asf/datasketches-java.git
commit daf0b14ed269bfd5fb4403df52e287b3a46041fe Author: Lee Rhodes <[email protected]> AuthorDate: Mon Jul 7 11:07:58 2025 -0700 Minor fixes for a SpotBugs issue --- .../apache/datasketches/common/MemorySegmentStatus.java | 5 ----- .../apache/datasketches/hll/SizeAndModeTransitions.java | 17 +++++++++++------ .../java/org/apache/datasketches/theta/SketchTest.java | 3 --- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/apache/datasketches/common/MemorySegmentStatus.java b/src/main/java/org/apache/datasketches/common/MemorySegmentStatus.java index 2047d893e..6a4bde853 100644 --- a/src/main/java/org/apache/datasketches/common/MemorySegmentStatus.java +++ b/src/main/java/org/apache/datasketches/common/MemorySegmentStatus.java @@ -44,8 +44,6 @@ public interface MemorySegmentStatus { * Returns true if an internally referenced MemorySegment has the same backing resource as <i>that</i>, * or equivalently, if their two memory regions overlap. This applies to both on-heap and off-heap MemorySegments. * - * <p>This returns false if either segment is <i>null</i> or not alive.</p> - * * <p><b>Note:</b> If both segments are on-heap and not read-only, it can be determined if they were derived from * the same backing memory (array). However, this is not always possible off-heap. Because of this asymmetry, this definition * of "isSameResource" is confined to the existence of an overlap.</p> @@ -59,8 +57,6 @@ public interface MemorySegmentStatus { * Returns true if the two given MemorySegments have to the same backing resource, or equivalently, * if the two memory regions overlap. This applies to both on-heap and off-heap MemorySegments. * - * <p>This returns false if either segment is <i>null</i> or not alive.</p> - * * <p><b>Note:</b> If both segments are on-heap and not read-only, it can be determined if they were derived from * the same backing memory (array). However, this is not always possible off-heap. Because of this asymmetry, this definition * of "isSameResource" is confined to the existence of an overlap.</p> @@ -70,7 +66,6 @@ public interface MemorySegmentStatus { * @return true if the two given MemorySegments have to the same backing resource. */ static boolean isSameResource(final MemorySegment seg1, final MemorySegment seg2) { - if ((seg1 == null) || (seg2 == null) || !seg1.scope().isAlive() || !seg2.scope().isAlive()) { return false; } final Optional<MemorySegment> opt = seg1.asOverlappingSlice(seg2); return opt.isPresent(); } diff --git a/src/test/java/org/apache/datasketches/hll/SizeAndModeTransitions.java b/src/test/java/org/apache/datasketches/hll/SizeAndModeTransitions.java index 0d4b921bc..25173ea44 100644 --- a/src/test/java/org/apache/datasketches/hll/SizeAndModeTransitions.java +++ b/src/test/java/org/apache/datasketches/hll/SizeAndModeTransitions.java @@ -33,22 +33,27 @@ public class SizeAndModeTransitions { static String[] hdr = {"Type", "Store", "LgK", "N", "Mode", "ActCBytes", "CmpBytes", "ActUBytes", "UpdBytes", "MaxBytes", "Estimate"}; @Test - public void checkHLL8Heap() { + public void checkHLL8with_withoutSeg() { + checkHLL8Heap(true); + checkHLL8Heap(false); + } + + private void checkHLL8Heap(final boolean withSeg) { final TgtHllType tgtHllType = TgtHllType.HLL_8; - final boolean offHeap = false; final int lgK = 10; final int N = 97; printf(hfmt, (Object[]) hdr); - final int maxBytes = HllSketch.getMaxUpdatableSerializationBytes(lgK, tgtHllType); + MemorySegment wseg = null; HllSketch sk; - if (offHeap) { + if (withSeg) { + final int maxBytes = HllSketch.getMaxUpdatableSerializationBytes(lgK, tgtHllType); wseg = MemorySegment.ofArray(new byte[maxBytes]); sk = new HllSketch(lgK, tgtHllType, wseg); } else { - sk = new HllSketch(lgK, tgtHllType); + sk = new HllSketch(lgK, tgtHllType); //without segment } - final String store = offHeap ? "MemorySegment" : "Heap"; + final String store = withSeg ? "MemorySegment" : "Heap"; for (int i = 1; i <= N; i++) { sk.update(i); if (i == 7) { checkAtN(sk, tgtHllType, store, lgK, i, "LIST", 36, 40, 1064); } diff --git a/src/test/java/org/apache/datasketches/theta/SketchTest.java b/src/test/java/org/apache/datasketches/theta/SketchTest.java index 3332cd590..729912cd3 100644 --- a/src/test/java/org/apache/datasketches/theta/SketchTest.java +++ b/src/test/java/org/apache/datasketches/theta/SketchTest.java @@ -343,9 +343,6 @@ public class SketchTest { final DirectCompactSketch dcs = (DirectCompactSketch) sketch.compact(false, cseg); assertTrue(MemorySegmentStatus.isSameResource(dcs.getMemorySegment(), cseg)); assertFalse(dcs.isOrdered()); - - final Sketch sk = Sketches.updateSketchBuilder().setNominalEntries(k).build(); - assertFalse(MemorySegmentStatus.isSameResource(sk.getMemorySegment(),seg)); } @Test --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
