This is an automated email from the ASF dual-hosted git repository.

leerho pushed a commit to branch thetaRework
in repository https://gitbox.apache.org/repos/asf/datasketches-java.git


The following commit(s) were added to refs/heads/thetaRework by this push:
     new 6b2d7ab2d Make classes Final where possible
6b2d7ab2d is described below

commit 6b2d7ab2dd0fbb4e4e543c7c4c2f003ff81bed31
Author: Lee Rhodes <[email protected]>
AuthorDate: Wed Jun 18 15:01:56 2025 -0700

    Make classes Final where possible
    
    Make use of MemorySegmentStatus where required
---
 .../java/org/apache/datasketches/theta2/BitPacking.java |  4 +++-
 .../theta2/BytesCompactCompressedHashIterator.java      |  2 +-
 .../datasketches/theta2/BytesCompactHashIterator.java   |  2 +-
 .../theta2/ConcurrentBackgroundThetaPropagation.java    |  2 +-
 .../theta2/DirectCompactCompressedSketch.java           |  2 +-
 .../datasketches/theta2/ForwardCompatibility.java       |  2 ++
 .../datasketches/theta2/HeapCompactHashIterator.java    |  2 +-
 .../apache/datasketches/theta2/HeapCompactSketch.java   |  2 +-
 .../apache/datasketches/theta2/HeapHashIterator.java    |  2 +-
 .../apache/datasketches/theta2/IntersectionImpl.java    |  2 +-
 .../apache/datasketches/theta2/JaccardSimilarity.java   |  2 ++
 .../theta2/MemoryCompactCompressedHashIterator.java     |  2 +-
 .../apache/datasketches/theta2/MemoryHashIterator.java  |  2 +-
 .../apache/datasketches/theta2/SetOperationBuilder.java |  2 +-
 .../java/org/apache/datasketches/theta2/Sketch.java     | 17 -----------------
 .../apache/datasketches/theta2/UpdateSketchBuilder.java |  2 +-
 .../theta2/WrappedCompactCompressedSketch.java          |  6 +++---
 17 files changed, 22 insertions(+), 33 deletions(-)

diff --git a/src/main/java/org/apache/datasketches/theta2/BitPacking.java 
b/src/main/java/org/apache/datasketches/theta2/BitPacking.java
index e2b6be2fd..66d5a245e 100644
--- a/src/main/java/org/apache/datasketches/theta2/BitPacking.java
+++ b/src/main/java/org/apache/datasketches/theta2/BitPacking.java
@@ -24,7 +24,9 @@ import 
org.apache.datasketches.common.SketchesArgumentException;
 /**
  * Used as part of Theta compression.
  */
-public class BitPacking {
+public final class BitPacking {
+
+  private BitPacking() { }
 
   /**
    * The bit packing operation
diff --git 
a/src/main/java/org/apache/datasketches/theta2/BytesCompactCompressedHashIterator.java
 
b/src/main/java/org/apache/datasketches/theta2/BytesCompactCompressedHashIterator.java
index 81a985922..6a2ddddd7 100644
--- 
a/src/main/java/org/apache/datasketches/theta2/BytesCompactCompressedHashIterator.java
+++ 
b/src/main/java/org/apache/datasketches/theta2/BytesCompactCompressedHashIterator.java
@@ -22,7 +22,7 @@ package org.apache.datasketches.theta2;
 /*
  * This is to uncompress serial version 4 sketch incrementally
  */
-class BytesCompactCompressedHashIterator implements HashIterator {
+final class BytesCompactCompressedHashIterator implements HashIterator {
   private byte[] bytes;
   private int offset;
   private int entryBits;
diff --git 
a/src/main/java/org/apache/datasketches/theta2/BytesCompactHashIterator.java 
b/src/main/java/org/apache/datasketches/theta2/BytesCompactHashIterator.java
index 9a4754574..3586f54c4 100644
--- a/src/main/java/org/apache/datasketches/theta2/BytesCompactHashIterator.java
+++ b/src/main/java/org/apache/datasketches/theta2/BytesCompactHashIterator.java
@@ -24,7 +24,7 @@ import org.apache.datasketches.common.ByteArrayUtil;
 /*
  * This is to iterate over serial version 3 sketch representation
  */
-class BytesCompactHashIterator implements HashIterator {
+final class BytesCompactHashIterator implements HashIterator {
   final private byte[] bytes;
   final private int offset;
   final private int numEntries;
diff --git 
a/src/main/java/org/apache/datasketches/theta2/ConcurrentBackgroundThetaPropagation.java
 
b/src/main/java/org/apache/datasketches/theta2/ConcurrentBackgroundThetaPropagation.java
index 2d529c4ce..f578dc6a1 100644
--- 
a/src/main/java/org/apache/datasketches/theta2/ConcurrentBackgroundThetaPropagation.java
+++ 
b/src/main/java/org/apache/datasketches/theta2/ConcurrentBackgroundThetaPropagation.java
@@ -29,7 +29,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
  *
  * @author eshcar
  */
-class ConcurrentBackgroundThetaPropagation implements Runnable {
+final class ConcurrentBackgroundThetaPropagation implements Runnable {
 
   // Shared sketch to absorb the data
   private final ConcurrentSharedThetaSketch sharedThetaSketch;
diff --git 
a/src/main/java/org/apache/datasketches/theta2/DirectCompactCompressedSketch.java
 
b/src/main/java/org/apache/datasketches/theta2/DirectCompactCompressedSketch.java
index 9be51c379..8ed907321 100644
--- 
a/src/main/java/org/apache/datasketches/theta2/DirectCompactCompressedSketch.java
+++ 
b/src/main/java/org/apache/datasketches/theta2/DirectCompactCompressedSketch.java
@@ -40,7 +40,7 @@ import org.apache.datasketches.thetacommon.ThetaUtil;
  * This MemorySegment can be off-heap, which if managed properly will greatly 
reduce the need for
  * the JVM to perform garbage collection.</p>
  */
-class DirectCompactCompressedSketch extends DirectCompactSketch {
+final class DirectCompactCompressedSketch extends DirectCompactSketch {
   /**
    * Construct this sketch with the given MemorySegment.
    * @param seg Read-only MemorySegment object.
diff --git 
a/src/main/java/org/apache/datasketches/theta2/ForwardCompatibility.java 
b/src/main/java/org/apache/datasketches/theta2/ForwardCompatibility.java
index 9791a7902..a6635653c 100644
--- a/src/main/java/org/apache/datasketches/theta2/ForwardCompatibility.java
+++ b/src/main/java/org/apache/datasketches/theta2/ForwardCompatibility.java
@@ -38,6 +38,8 @@ import 
org.apache.datasketches.common.SketchesArgumentException;
  */
 final class ForwardCompatibility {
 
+  private ForwardCompatibility() { }
+
   /**
    * Convert a serialization version (SerVer) 1 sketch (~Feb 2014) to a SerVer 
3 sketch.
    * Note: SerVer 1 sketches always have (metadata) preamble-longs of 3 and 
are always stored
diff --git 
a/src/main/java/org/apache/datasketches/theta2/HeapCompactHashIterator.java 
b/src/main/java/org/apache/datasketches/theta2/HeapCompactHashIterator.java
index b10ffcaaf..bd06f6ecd 100644
--- a/src/main/java/org/apache/datasketches/theta2/HeapCompactHashIterator.java
+++ b/src/main/java/org/apache/datasketches/theta2/HeapCompactHashIterator.java
@@ -19,7 +19,7 @@
 
 package org.apache.datasketches.theta2;
 
-class HeapCompactHashIterator implements HashIterator {
+final class HeapCompactHashIterator implements HashIterator {
   private long[] cache;
   private int index;
 
diff --git 
a/src/main/java/org/apache/datasketches/theta2/HeapCompactSketch.java 
b/src/main/java/org/apache/datasketches/theta2/HeapCompactSketch.java
index 6cffd9818..1c0cbb0cc 100644
--- a/src/main/java/org/apache/datasketches/theta2/HeapCompactSketch.java
+++ b/src/main/java/org/apache/datasketches/theta2/HeapCompactSketch.java
@@ -38,7 +38,7 @@ import java.lang.foreign.MemorySegment;
  *
  * @author Lee Rhodes
  */
-class HeapCompactSketch extends CompactSketch {
+final class HeapCompactSketch extends CompactSketch {
   private final long thetaLong_; //computed
   private final int curCount_;
   private final int preLongs_; //computed
diff --git a/src/main/java/org/apache/datasketches/theta2/HeapHashIterator.java 
b/src/main/java/org/apache/datasketches/theta2/HeapHashIterator.java
index c2b098c25..29ae42a0e 100644
--- a/src/main/java/org/apache/datasketches/theta2/HeapHashIterator.java
+++ b/src/main/java/org/apache/datasketches/theta2/HeapHashIterator.java
@@ -22,7 +22,7 @@ package org.apache.datasketches.theta2;
 /**
  * @author Lee Rhodes
  */
-class HeapHashIterator implements HashIterator {
+final class HeapHashIterator implements HashIterator {
   private long[] cache;
   private long thetaLong;
   private int index;
diff --git a/src/main/java/org/apache/datasketches/theta2/IntersectionImpl.java 
b/src/main/java/org/apache/datasketches/theta2/IntersectionImpl.java
index 92ca096c3..74228b1fa 100644
--- a/src/main/java/org/apache/datasketches/theta2/IntersectionImpl.java
+++ b/src/main/java/org/apache/datasketches/theta2/IntersectionImpl.java
@@ -79,7 +79,7 @@ import org.apache.datasketches.thetacommon.ThetaUtil;
  * @author Lee Rhodes
  * @author Kevin Lang
  */
-class IntersectionImpl extends Intersection {
+final class IntersectionImpl extends Intersection {
   protected final short seedHash_;
   protected final boolean readOnly_; //True if this sketch is to be treated as 
read only
   protected final MemorySegment wseg_;
diff --git 
a/src/main/java/org/apache/datasketches/theta2/JaccardSimilarity.java 
b/src/main/java/org/apache/datasketches/theta2/JaccardSimilarity.java
index 624dcc3d7..de5fff58c 100644
--- a/src/main/java/org/apache/datasketches/theta2/JaccardSimilarity.java
+++ b/src/main/java/org/apache/datasketches/theta2/JaccardSimilarity.java
@@ -37,6 +37,8 @@ public final class JaccardSimilarity {
   private static final double[] ZEROS = {0.0, 0.0, 0.0}; // LB, Estimate, UB
   private static final double[] ONES = {1.0, 1.0, 1.0};
 
+  private JaccardSimilarity() { }
+
   /**
    * Computes the Jaccard similarity index with upper and lower bounds. The 
Jaccard similarity index
    * <i>J(A,B) = (A ^ B)/(A U B)</i> is used to measure how similar the two 
sketches are to each
diff --git 
a/src/main/java/org/apache/datasketches/theta2/MemoryCompactCompressedHashIterator.java
 
b/src/main/java/org/apache/datasketches/theta2/MemoryCompactCompressedHashIterator.java
index 31aa6ff92..11d0168a0 100644
--- 
a/src/main/java/org/apache/datasketches/theta2/MemoryCompactCompressedHashIterator.java
+++ 
b/src/main/java/org/apache/datasketches/theta2/MemoryCompactCompressedHashIterator.java
@@ -30,7 +30,7 @@ import org.apache.datasketches.common.Util;
 /*
  * This is to uncompress serial version 4 sketch incrementally
  */
-class MemoryCompactCompressedHashIterator implements HashIterator, 
MemorySegmentStatus {
+final class MemoryCompactCompressedHashIterator implements HashIterator, 
MemorySegmentStatus {
   private MemorySegment seg;
   private int offset;
   private int entryBits;
diff --git 
a/src/main/java/org/apache/datasketches/theta2/MemoryHashIterator.java 
b/src/main/java/org/apache/datasketches/theta2/MemoryHashIterator.java
index eb2137afd..3022d59ff 100644
--- a/src/main/java/org/apache/datasketches/theta2/MemoryHashIterator.java
+++ b/src/main/java/org/apache/datasketches/theta2/MemoryHashIterator.java
@@ -26,7 +26,7 @@ import java.lang.foreign.MemorySegment;
 /**
  * @author Lee Rhodes
  */
-class MemoryHashIterator implements HashIterator {
+final class MemoryHashIterator implements HashIterator {
   private MemorySegment seg;
   private int arrLongs;
   private long thetaLong;
diff --git 
a/src/main/java/org/apache/datasketches/theta2/SetOperationBuilder.java 
b/src/main/java/org/apache/datasketches/theta2/SetOperationBuilder.java
index cf64326b8..5a05a7d1f 100644
--- a/src/main/java/org/apache/datasketches/theta2/SetOperationBuilder.java
+++ b/src/main/java/org/apache/datasketches/theta2/SetOperationBuilder.java
@@ -35,7 +35,7 @@ import org.apache.datasketches.thetacommon.ThetaUtil;
  *
  * @author Lee Rhodes
  */
-public class SetOperationBuilder {
+public final class SetOperationBuilder {
   private int bLgNomLongs;
   private long bSeed;
   private ResizeFactor bRF;
diff --git a/src/main/java/org/apache/datasketches/theta2/Sketch.java 
b/src/main/java/org/apache/datasketches/theta2/Sketch.java
index e98396842..5d619c580 100644
--- a/src/main/java/org/apache/datasketches/theta2/Sketch.java
+++ b/src/main/java/org/apache/datasketches/theta2/Sketch.java
@@ -409,23 +409,6 @@ public abstract class Sketch implements 
MemorySegmentStatus {
    */
   public abstract boolean isOrdered();
 
-  /**
-   * Returns true if the backing MemorySegment of this object refers to the 
same MemorySegment of <i>that</i>.
-   * They can either have the same off-heap memory location and size, or refer 
to the same on-heap array object.
-   *
-   * <p>If both segment are off-heap, they both must have the same starting 
address and the same size.</p>
-   *
-   * <p>For on-heap segments, both segments must be based on or derived from 
the same array object and neither segment
-   * can be read-only.</p>
-   *
-   * <p>Returns false if either argument is null;</p>
-   *
-   * @param that The given MemorySegment.
-   * @return true if the backing MemorySegment of this object hierarchy refers 
to the same MemorySegment of <i>that</i>.
-   */
-  @Override
-  public abstract boolean isSameResource(final MemorySegment that);
-
   /**
    * Returns a HashIterator that can be used to iterate over the retained hash 
values of the
    * Theta sketch.
diff --git 
a/src/main/java/org/apache/datasketches/theta2/UpdateSketchBuilder.java 
b/src/main/java/org/apache/datasketches/theta2/UpdateSketchBuilder.java
index e8353888f..0326ceb06 100644
--- a/src/main/java/org/apache/datasketches/theta2/UpdateSketchBuilder.java
+++ b/src/main/java/org/apache/datasketches/theta2/UpdateSketchBuilder.java
@@ -37,7 +37,7 @@ import org.apache.datasketches.thetacommon.ThetaUtil;
  *
  * @author Lee Rhodes
  */
-public class UpdateSketchBuilder {
+public final class UpdateSketchBuilder {
   private int bLgNomLongs;
   private long bSeed;
   private ResizeFactor bRF;
diff --git 
a/src/main/java/org/apache/datasketches/theta2/WrappedCompactCompressedSketch.java
 
b/src/main/java/org/apache/datasketches/theta2/WrappedCompactCompressedSketch.java
index 1558c49e7..3ba16c3fa 100644
--- 
a/src/main/java/org/apache/datasketches/theta2/WrappedCompactCompressedSketch.java
+++ 
b/src/main/java/org/apache/datasketches/theta2/WrappedCompactCompressedSketch.java
@@ -32,8 +32,8 @@ import org.apache.datasketches.thetacommon.ThetaUtil;
  *
  * <p>This sketch can only be associated with a Serialization Version 4 format 
binary image.</p>
  */
-class WrappedCompactCompressedSketch extends WrappedCompactSketch {
-  
+final class WrappedCompactCompressedSketch extends WrappedCompactSketch {
+
   /**
    * Construct this sketch with the given bytes.
    * @param bytes containing serialized compact compressed sketch.
@@ -66,7 +66,7 @@ class WrappedCompactCompressedSketch extends 
WrappedCompactSketch {
 
   private static final int START_PACKED_DATA_EXACT_MODE = 8;
   private static final int START_PACKED_DATA_ESTIMATION_MODE = 16;
-  
+
   @Override
   public int getRetainedEntries(final boolean valid) { //compact is always 
valid
     // number of entries is stored using variable length encoding


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

Reply via email to