From d1e10c3d75312ff9f40ec11949aedcd01520be4d Mon Sep 17 00:00:00 2001
From: Lee Rhodes This a stateless operation and has no impact on the internal state of this operator.
- * Thus, this is not an accumulating update and does not interact with the {@link #setA(Sketch)},
- * {@link #notB(Sketch)}, {@link #getResult(boolean)}, or
+ * Thus, this is not an accumulating update and does not interact with the {@link #setA(ThetaSketch)},
+ * {@link #notB(ThetaSketch)}, {@link #getResult(boolean)}, or
* {@link #getResult(boolean, MemorySegment, boolean)} methods. If either argument is null an exception is thrown. This a stateless operation and has no impact on the internal state of this operator.
- * Thus, this is not an accumulating update and does not interact with the {@link #setA(Sketch)},
- * {@link #notB(Sketch)}, {@link #getResult(boolean)}, or
+ * Thus, this is not an accumulating update and does not interact with the {@link #setA(ThetaSketch)},
+ * {@link #notB(ThetaSketch)}, {@link #getResult(boolean)}, or
* {@link #getResult(boolean, MemorySegment, boolean)} methods. If either argument is null an exception is thrown. An input argument of null or empty is ignored. This a stateless operation and has no impact on the internal state of this operator.
* Thus, this is not an accumulating update and is independent of the {@link #setA(Sketch)},
- * {@link #notB(Sketch)}, {@link #notB(org.apache.datasketches.theta.Sketch)}, and
+ * {@link #notB(Sketch)}, {@link #notB(org.apache.datasketches.theta.ThetaSketch)}, and
* {@link #getResult(boolean)} methods. If either argument is null an exception is thrown. This a stateless operation and has no impact on the internal state of this operator.
* Thus, this is not an accumulating update and is independent of the {@link #setA(Sketch)},
- * {@link #notB(Sketch)}, {@link #notB(org.apache.datasketches.theta.Sketch)}, and
+ * {@link #notB(Sketch)}, {@link #notB(org.apache.datasketches.theta.ThetaSketch)}, and
* {@link #getResult(boolean)} methods. If either argument is null an exception is thrown. A CompactSketch is the simplest form of a Theta Sketch. It consists of a compact list
+ * A CompactThetaSketch is the simplest form of a ThetaSketches. It consists of a compact list
* (i.e., no intervening spaces) of hash values, which may be ordered or not, a value for theta
- * and a seed hash. A CompactSketch is immutable (read-only),
+ * and a seed hash. A CompactThetaSketch is immutable (read-only),
* and the space required when stored is only the space required for the hash values and 8 to 24
- * bytes of preamble. An empty CompactSketch consumes only 8 bytes. double getLowerBoundForBoverA(
*/
public static double getLowerBoundForBoverA(
final Sketch sketchA,
- final org.apache.datasketches.theta.Sketch sketchB) {
+ final org.apache.datasketches.theta.ThetaSketch sketchB) {
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
checkThetas(thetaLongA, thetaLongB);
@@ -133,7 +133,7 @@ public static double getUpperBoundForBoverA(
*/
public static double getUpperBoundForBoverA(
final Sketch sketchA,
- final org.apache.datasketches.theta.Sketch sketchB) {
+ final org.apache.datasketches.theta.ThetaSketch sketchB) {
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
checkThetas(thetaLongA, thetaLongB);
@@ -181,7 +181,7 @@ public static double getEstimateOfBoverA(
*/
public static double getEstimateOfBoverA(
final Sketch sketchA,
- final org.apache.datasketches.theta.Sketch sketchB) {
+ final org.apache.datasketches.theta.ThetaSketch sketchB) {
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
checkThetas(thetaLongA, thetaLongB);
diff --git a/src/main/java/org/apache/datasketches/tuple/AnotB.java b/src/main/java/org/apache/datasketches/tuple/AnotB.java
index a6d33a7e6..75c80a8d8 100644
--- a/src/main/java/org/apache/datasketches/tuple/AnotB.java
+++ b/src/main/java/org/apache/datasketches/tuple/AnotB.java
@@ -78,7 +78,7 @@ public final class AnotB {
static {
try {
- GET_CACHE = org.apache.datasketches.theta.Sketch.class.getDeclaredMethod("getCache");
+ GET_CACHE = org.apache.datasketches.theta.ThetaSketch.class.getDeclaredMethod("getCache");
GET_CACHE.setAccessible(true);
} catch (final Exception e) {
throw new SketchesStateException("Could not reflect getCache(): " + e);
@@ -199,7 +199,7 @@ public void notB(final Sketch skB) {
* second (or n+1th) argument B of A-AND-NOT-B.
* Performs an AND NOT operation with the existing internal state of this AnotB operator.
* Calls to this method can be intermingled with calls to
- * {@link #notB(org.apache.datasketches.theta.Sketch)}.
+ * {@link #notB(org.apache.datasketches.theta.ThetaSketch)}.
*
* skB) {
*
* @param skB The incoming Theta sketch for the second (or following) argument B.
*/
- public void notB(final org.apache.datasketches.theta.Sketch skB) {
+ public void notB(final org.apache.datasketches.theta.ThetaSketch skB) {
if (skB == null) { return; } //ignore
final long thetaLongB = skB.getThetaLong();
@@ -268,7 +268,7 @@ public void notB(final org.apache.datasketches.theta.Sketch skB) {
/**
* Gets the result of the multistep, stateful operation AnotB that have been executed with calls
* to {@link #setA(Sketch)} and ({@link #notB(Sketch)} or
- * {@link #notB(org.apache.datasketches.theta.Sketch)}).
+ * {@link #notB(org.apache.datasketches.theta.ThetaSketch)}).
*
* @param reset If true, clears this operator to the empty state after this result is
* returned. Set this to false if you wish to obtain an intermediate result.
@@ -291,7 +291,7 @@ public CompactSketch getResult(final boolean reset) {
*
* CompactSketch aNotB(
*
* CompactSketch aNotB(
justification = "hashArr and summaryArr are guaranteed to be valid due to the switch on CornerCase")
public static CompactSketch aNotB(
final Sketch skA,
- final org.apache.datasketches.theta.Sketch skB) {
+ final org.apache.datasketches.theta.ThetaSketch skB) {
if (skA == null || skB == null) {
throw new SketchesArgumentException("Neither argument may be null for this stateless operation.");
}
@@ -553,7 +553,7 @@ private static DataArrays getCopyOfResultArraysTheta(
final int countA,
final long[] hashArrA,
final S[] summaryArrA,
- final org.apache.datasketches.theta.Sketch skB) {
+ final org.apache.datasketches.theta.ThetaSketch skB) {
final DataArrays daB = new DataArrays<>();
//Rebuild/get hashtable of skB
diff --git a/src/main/java/org/apache/datasketches/tuple/HashTables.java b/src/main/java/org/apache/datasketches/tuple/HashTables.java
index bd42f4980..419b3dad6 100644
--- a/src/main/java/org/apache/datasketches/tuple/HashTables.java
+++ b/src/main/java/org/apache/datasketches/tuple/HashTables.java
@@ -58,7 +58,7 @@ void fromSketch(final Sketch sketch) {
}
//must have valid entries
- void fromSketch(final org.apache.datasketches.theta.Sketch sketch, final S summary) {
+ void fromSketch(final org.apache.datasketches.theta.ThetaSketch sketch, final S summary) {
numKeys = sketch.getRetainedEntries(true);
lgTableSize = getLgTableSize(numKeys);
@@ -123,7 +123,7 @@ HashTables getIntersectHashTables(
//For Theta Sketches
HashTables getIntersectHashTables(
- final org.apache.datasketches.theta.Sketch nextThetaSketch,
+ final org.apache.datasketches.theta.ThetaSketch nextThetaSketch,
final long thetaLong,
final SummarySetOperations summarySetOps,
final S summary) {
diff --git a/src/main/java/org/apache/datasketches/tuple/Intersection.java b/src/main/java/org/apache/datasketches/tuple/Intersection.java
index b6f53249a..6467ad055 100644
--- a/src/main/java/org/apache/datasketches/tuple/Intersection.java
+++ b/src/main/java/org/apache/datasketches/tuple/Intersection.java
@@ -89,7 +89,7 @@ public CompactSketch intersect(
*/
public CompactSketch intersect(
final Sketch tupleSketch,
- final org.apache.datasketches.theta.Sketch
+ final org.apache.datasketches.theta.ThetaSketch
thetaSketch, final S summary) {
reset();
intersect(tupleSketch);
@@ -148,7 +148,7 @@ public void intersect(final Sketch tupleSketch) {
* @param summary the given proxy summary for the theta sketch, which doesn't have one.
* It will be copied for each matching index. It must not be null.
*/
- public void intersect(final org.apache.datasketches.theta.Sketch thetaSketch, final S summary) {
+ public void intersect(final org.apache.datasketches.theta.ThetaSketch thetaSketch, final S summary) {
if (thetaSketch == null) { throw new SketchesArgumentException("Sketch must not be null"); }
if (summary == null) { throw new SketchesArgumentException("Summary cannot be null."); }
final boolean firstCall = firstCall_;
@@ -173,7 +173,7 @@ public void intersect(final org.apache.datasketches.theta.Sketch thetaSketch, fi
// input sketch will have valid entries > 0
if (firstCall) {
- final org.apache.datasketches.theta.Sketch firstSketch = thetaSketch;
+ final org.apache.datasketches.theta.ThetaSketch firstSketch = thetaSketch;
//Copy firstSketch data into local instance hashTables_
hashTables_.fromSketch(firstSketch, summary);
}
diff --git a/src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java b/src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java
index 73c6c7fe0..2a57a16a5 100644
--- a/src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java
+++ b/src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java
@@ -125,7 +125,7 @@ public static double[] jaccard(
*/
public static double[] jaccard(
final Sketch sketchA,
- final org.apache.datasketches.theta.Sketch sketchB,
+ final org.apache.datasketches.theta.ThetaSketch sketchB,
final S summary, final SummarySetOperations summarySetOps) {
// Null case checks
if (summary == null) {
@@ -227,7 +227,7 @@ public static boolean exactlyEqual(
*/
public static boolean exactlyEqual(
final Sketch sketchA,
- final org.apache.datasketches.theta.Sketch sketchB,
+ final org.apache.datasketches.theta.ThetaSketch sketchB,
final S summary, final SummarySetOperations summarySetOps) {
// Null case checks
if (summary == null) {
@@ -303,7 +303,7 @@ public static boolean similarityTest(
* with at least 97.7% confidence.
*/
public static boolean similarityTest(
- final Sketch measured, final org.apache.datasketches.theta.Sketch expected,
+ final Sketch measured, final org.apache.datasketches.theta.ThetaSketch expected,
final S summary, final SummarySetOperations summarySetOps,
final double threshold) {
//index 0: the lower bound
@@ -357,7 +357,7 @@ public static boolean dissimilarityTest(
* with at least 97.7% confidence.
*/
public static boolean dissimilarityTest(
- final Sketch measured, final org.apache.datasketches.theta.Sketch expected,
+ final Sketch measured, final org.apache.datasketches.theta.ThetaSketch expected,
final S summary, final SummarySetOperations summarySetOps,
final double threshold) {
//index 0: the lower bound
diff --git a/src/main/java/org/apache/datasketches/tuple/Union.java b/src/main/java/org/apache/datasketches/tuple/Union.java
index f67626d1b..9c663f88a 100644
--- a/src/main/java/org/apache/datasketches/tuple/Union.java
+++ b/src/main/java/org/apache/datasketches/tuple/Union.java
@@ -89,7 +89,7 @@ public CompactSketch union(final Sketch tupleSketchA, final Sketch tupl
* @return the result ordered CompactSketch on the heap.
*/
public CompactSketch union(final Sketch tupleSketch,
- final org.apache.datasketches.theta.Sketch thetaSketch, final S summary) {
+ final org.apache.datasketches.theta.ThetaSketch thetaSketch, final S summary) {
reset();
union(tupleSketch);
union(thetaSketch, summary);
@@ -120,7 +120,7 @@ public void union(final Sketch tupleSketch) {
* @param summary the given proxy summary for the theta sketch, which doesn't have one. This may
* not be null.
*/
- public void union(final org.apache.datasketches.theta.Sketch thetaSketch, final S summary) {
+ public void union(final org.apache.datasketches.theta.ThetaSketch thetaSketch, final S summary) {
if (summary == null) {
throw new SketchesArgumentException("Summary cannot be null."); }
if (thetaSketch == null || thetaSketch.isEmpty()) { return; }
diff --git a/src/test/java/org/apache/datasketches/theta/AnotBimplTest.java b/src/test/java/org/apache/datasketches/theta/AnotBimplTest.java
index 6482712e8..6960fbc32 100644
--- a/src/test/java/org/apache/datasketches/theta/AnotBimplTest.java
+++ b/src/test/java/org/apache/datasketches/theta/AnotBimplTest.java
@@ -215,7 +215,7 @@ public void checkAnotBnotC() {
final UpdateSketch cU = UpdateSketch.builder().setNominalEntries(k).build();
for (int i=k/2; i<3*k/4; i++) { cU.update(i); } //third 256
- final int segBytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int segBytes = ThetaSketch.getMaxUpdateSketchBytes(k);
CompactSketch result1, result2, result3;
final MemorySegment wseg1 = MemorySegment.ofArray(new byte[segBytes]);
@@ -259,7 +259,7 @@ public void checkAnotBnotC_sameMemorySegment() {
final UpdateSketch c = UpdateSketch.builder().setNominalEntries(k).build();
for (int i=k/2; i<3*k/4; i++) { c.update(i); } //third 256
- final int segBytes = Sketch.getMaxCompactSketchBytes(a.getRetainedEntries(true));
+ final int segBytes = ThetaSketch.getMaxCompactSketchBytes(a.getRetainedEntries(true));
final MemorySegment seg = MemorySegment.ofArray(new byte[segBytes]);
CompactSketch result1, result2;
diff --git a/src/test/java/org/apache/datasketches/theta/CompactSketchTest.java b/src/test/java/org/apache/datasketches/theta/CompactSketchTest.java
index fc35891b3..4b2feb1bc 100644
--- a/src/test/java/org/apache/datasketches/theta/CompactSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/CompactSketchTest.java
@@ -63,14 +63,14 @@ public void checkHeapifyWrap(final int k, final int u, final boolean ordered) {
CompactSketch refSk = usk.compact(ordered, null);
final byte[] barr = refSk.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(barr);
- CompactSketch testSk = (CompactSketch) Sketch.heapify(srcSeg);
+ CompactSketch testSk = (CompactSketch) ThetaSketch.heapify(srcSeg);
checkByRange(refSk, testSk, u, ordered);
/**Via byte[]**/
final byte[] byteArray = refSk.toByteArray();
final MemorySegment heapROSeg = MemorySegment.ofArray(byteArray).asReadOnly();
- testSk = (CompactSketch)Sketch.heapify(heapROSeg);
+ testSk = (CompactSketch)ThetaSketch.heapify(heapROSeg);
checkByRange(refSk, testSk, u, ordered);
@@ -83,19 +83,19 @@ public void checkHeapifyWrap(final int k, final int u, final boolean ordered) {
/**Via CompactSketch.compact**/
refSk = usk.compact(ordered, directSeg);
- testSk = (CompactSketch)Sketch.wrap(directSeg);
+ testSk = (CompactSketch)ThetaSketch.wrap(directSeg);
checkByRange(refSk, testSk, u, ordered);
/**Via CompactSketch.compact**/
- testSk = (CompactSketch)Sketch.wrap(directSeg);
+ testSk = (CompactSketch)ThetaSketch.wrap(directSeg);
checkByRange(refSk, testSk, u, ordered);
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
- private static void checkByRange(final Sketch refSk, final Sketch testSk, final int u, final boolean ordered) {
+ private static void checkByRange(final ThetaSketch refSk, final ThetaSketch testSk, final int u, final boolean ordered) {
if (u == 0) {
checkEmptySketch(testSk);
} else if (u == 1) {
@@ -105,7 +105,7 @@ private static void checkByRange(final Sketch refSk, final Sketch testSk, final
}
}
- private static void checkEmptySketch(final Sketch testSk) {
+ private static void checkEmptySketch(final ThetaSketch testSk) {
assertEquals(testSk.getFamily(), Family.COMPACT);
assertTrue(testSk instanceof EmptyCompactSketch);
assertTrue(testSk.isEmpty());
@@ -123,7 +123,7 @@ private static void checkEmptySketch(final Sketch testSk) {
assertEquals(testSk.getCompactPreambleLongs(), 1);
}
- private static void checkSingleItemSketch(final Sketch testSk, final Sketch refSk) {
+ private static void checkSingleItemSketch(final ThetaSketch testSk, final ThetaSketch refSk) {
assertEquals(testSk.getFamily(), Family.COMPACT);
assertTrue(testSk instanceof SingleItemSketch);
assertFalse(testSk.isEmpty());
@@ -141,7 +141,7 @@ private static void checkSingleItemSketch(final Sketch testSk, final Sketch refS
assertEquals(testSk.getCompactPreambleLongs(), 1);
}
- private static void checkOtherCompactSketch(final Sketch testSk, final Sketch refSk, final boolean ordered) {
+ private static void checkOtherCompactSketch(final ThetaSketch testSk, final ThetaSketch refSk, final boolean ordered) {
assertEquals(testSk.getFamily(), Family.COMPACT);
assertFalse(testSk.isEmpty());
assertNotNull(testSk.iterator());
@@ -179,7 +179,7 @@ public void checkDirectSingleItemSketch() {
final int bytes = sk.getCompactBytes();
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
sk.compact(true, wseg);
- final Sketch csk2 = Sketch.heapify(wseg);
+ final ThetaSketch csk2 = ThetaSketch.heapify(wseg);
assertTrue(csk2 instanceof SingleItemSketch);
}
@@ -443,10 +443,10 @@ public void checkMultipleItemHeapCompactSketch() {
public void checkHeapifySingleItemSketch() {
final UpdateSketch sk = UpdateSketch.builder().build();
sk.update(1);
- final int bytes = Sketch.getMaxCompactSketchBytes(2); //1 more than needed
+ final int bytes = ThetaSketch.getMaxCompactSketchBytes(2); //1 more than needed
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
sk.compact(false, wseg);
- final Sketch csk = Sketch.heapify(wseg);
+ final ThetaSketch csk = ThetaSketch.heapify(wseg);
assertTrue(csk instanceof SingleItemSketch);
}
@@ -456,7 +456,7 @@ public void checkHeapifyEmptySketch() {
final MemorySegment wseg = MemorySegment.ofArray(new byte[16]); //empty, but extra bytes
final CompactSketch csk = sk.compact(false, wseg); //ignores order because it is empty
assertTrue(csk instanceof DirectCompactSketch);
- final Sketch csk2 = Sketch.heapify(wseg);
+ final ThetaSketch csk2 = ThetaSketch.heapify(wseg);
assertTrue(csk2 instanceof EmptyCompactSketch);
}
diff --git a/src/test/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketchTest.java b/src/test/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketchTest.java
index e0816b0e5..f12d5809e 100644
--- a/src/test/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketchTest.java
@@ -101,10 +101,10 @@ public void checkHeapifyByteArrayExact() {
final byte[] serArr = shared.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(serArr).asReadOnly();
- final Sketch recoveredShared = Sketch.heapify(srcSeg);
+ final ThetaSketch recoveredShared = ThetaSketch.heapify(srcSeg);
//reconstruct to Native/Direct
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
shared = sl.bldr.buildSharedFromSketch((UpdateSketch)recoveredShared, wseg);
final UpdateSketch local2 = sl.bldr.buildLocal(shared);
@@ -143,10 +143,10 @@ public void checkHeapifyByteArrayEstimating() {
final byte[] serArr = shared.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(serArr).asReadOnly();
- final Sketch recoveredShared = Sketch.heapify(srcSeg);
+ final ThetaSketch recoveredShared = ThetaSketch.heapify(srcSeg);
//reconstruct to Native/Direct
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
shared = sl.bldr.buildSharedFromSketch((UpdateSketch)recoveredShared, wseg);
final UpdateSketch local2 = sl.bldr.buildLocal(shared);
@@ -179,7 +179,7 @@ public void checkWrapMemorySegmentEst() {
final double sk1ub = local.getUpperBound(2);
assertTrue(local.isEstimationMode());
- final Sketch local2 = Sketch.wrap(sl.wseg);
+ final ThetaSketch local2 = ThetaSketch.wrap(sl.wseg);
assertEquals(local2.getEstimate(), sk1est);
assertEquals(local2.getLowerBound(2), sk1lb);
@@ -503,7 +503,7 @@ public void checkConstructReconstructFromMemorySegment() {
final UpdateSketch recoveredShared = UpdateSketch.wrap(seg);
//reconstruct to Native/Direct
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
shared = sl.bldr.buildSharedFromSketch(recoveredShared, wseg);
final UpdateSketch local2 = sl.bldr.buildLocal(shared);
@@ -558,7 +558,7 @@ public void checkHeapifyIllegalFamilyID_heapify() {
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
sl.wseg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Family ID byte
//try to heapify the corrupted seg
- Sketch.heapify(sl.wseg); //catch in Sketch.constructHeapSketch
+ ThetaSketch.heapify(sl.wseg); //catch in Sketch.constructHeapSketch
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -627,7 +627,7 @@ public void checkBadSerVer() {
assertEquals(shared.getRetainedEntries(false), k);
sl.wseg.set(JAVA_BYTE, SER_VER_BYTE, (byte) 0); //corrupt the SerVer byte
- Sketch.wrap(sl.wseg);
+ ThetaSketch.wrap(sl.wseg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -638,7 +638,7 @@ public void checkWrapIllegalFamilyID_wrap() {
sl.wseg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Sketch ID byte
//try to wrap the corrupted seg
- Sketch.wrap(sl.wseg); //catch in Sketch.constructDirectSketch
+ ThetaSketch.wrap(sl.wseg); //catch in Sketch.constructDirectSketch
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -662,7 +662,7 @@ public void checkHeapifySeedConflict() {
final UpdateSketch shared = sl.shared;
final MemorySegment srcSeg = MemorySegment.ofArray(shared.toByteArray()).asReadOnly();
- Sketch.heapify(srcSeg, seed2);
+ ThetaSketch.heapify(srcSeg, seed2);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -672,7 +672,7 @@ public void checkCorruptLgNomLongs() {
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
sl.wseg.set(JAVA_BYTE, LG_NOM_LONGS_BYTE, (byte)2); //corrupt
- Sketch.heapify(sl.wseg, Util.DEFAULT_UPDATE_SEED);
+ ThetaSketch.heapify(sl.wseg, Util.DEFAULT_UPDATE_SEED);
}
@Test(expectedExceptions = UnsupportedOperationException.class)
@@ -696,7 +696,7 @@ static void println(final String s) {
//System.out.println(s); //disable here
}
- private static void checkMemorySegmentDirectProxyMethods(final Sketch local, final Sketch shared) {
+ private static void checkMemorySegmentDirectProxyMethods(final ThetaSketch local, final ThetaSketch shared) {
assertEquals(
local.hasMemorySegment(),
shared.hasMemorySegment());
@@ -704,7 +704,7 @@ private static void checkMemorySegmentDirectProxyMethods(final Sketch local, fin
}
//Does not check hasMemorySegment(), isOffHeap()
- private static void checkOtherProxyMethods(final Sketch local, final Sketch shared) {
+ private static void checkOtherProxyMethods(final ThetaSketch local, final ThetaSketch shared) {
assertEquals(local.getCompactBytes(), shared.getCompactBytes());
assertEquals(local.getCurrentBytes(), shared.getCurrentBytes());
assertEquals(local.getEstimate(), shared.getEstimate());
diff --git a/src/test/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketchTest.java b/src/test/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketchTest.java
index c354fd344..e3f4e8823 100644
--- a/src/test/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketchTest.java
@@ -64,11 +64,11 @@ public void checkBadSerVer() {
final byte[] serArr = shared.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(serArr);
- final Sketch sk = Sketch.heapify(seg, sl.seed);
+ final ThetaSketch sk = ThetaSketch.heapify(seg, sl.seed);
assertTrue(sk instanceof HeapQuickSelectSketch); //Intentional promotion to Parent
seg.set(JAVA_BYTE, SER_VER_BYTE, (byte) 0); //corrupt the SerVer byte
- Sketch.heapify(seg, sl.seed);
+ ThetaSketch.heapify(seg, sl.seed);
}
@Test
@@ -115,7 +115,7 @@ public void checkIllegalSketchID_UpdateSketch() {
seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Sketch ID byte
//try to heapify the corrupted seg
- Sketch.heapify(seg, sl.seed);
+ ThetaSketch.heapify(seg, sl.seed);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -126,7 +126,7 @@ public void checkHeapifySeedConflict() {
final SharedLocal sl = new SharedLocal(lgK, lgK, seed);
final byte[] byteArray = sl.shared.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(byteArray);
- Sketch.heapify(srcSeg, seed2);
+ ThetaSketch.heapify(srcSeg, seed2);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -136,7 +136,7 @@ public void checkHeapifyCorruptLgNomLongs() {
final byte[] serArr = sl.shared.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(serArr);
srcSeg.set(JAVA_BYTE, LG_NOM_LONGS_BYTE, (byte)2); //corrupt
- Sketch.heapify(srcSeg, Util.DEFAULT_UPDATE_SEED);
+ ThetaSketch.heapify(srcSeg, Util.DEFAULT_UPDATE_SEED);
}
@Test(expectedExceptions = UnsupportedOperationException.class)
@@ -162,10 +162,10 @@ public void checkHeapifyByteArrayExact() {
final byte[] serArr = shared.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(serArr).asReadOnly();
- final Sketch recoveredShared = UpdateSketch.heapify(srcSeg);
+ final ThetaSketch recoveredShared = UpdateSketch.heapify(srcSeg);
//reconstruct to Native/Direct
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
shared = sl.bldr.buildSharedFromSketch((UpdateSketch)recoveredShared, wseg);
final UpdateSketch local2 = sl.bldr.buildLocal(shared);
@@ -203,7 +203,7 @@ public void checkHeapifyByteArrayEstimating() {
final MemorySegment srcSeg = MemorySegment.ofArray(serArr).asReadOnly();
final UpdateSketch recoveredShared = UpdateSketch.heapify(srcSeg, sl.seed);
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
shared = sl.bldr.buildSharedFromSketch(recoveredShared, wseg);
final UpdateSketch local2 = sl.bldr.buildLocal(shared);
@@ -242,7 +242,7 @@ public void checkHeapifyMemorySegmentEstimating() {
final MemorySegment srcSeg = MemorySegment.ofArray(serArr).asReadOnly();
final UpdateSketch recoveredShared = UpdateSketch.heapify(srcSeg, Util.DEFAULT_UPDATE_SEED);
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
shared = sl.bldr.buildSharedFromSketch(recoveredShared, wseg);
final UpdateSketch local2 = sl.bldr.buildLocal(shared);
@@ -577,7 +577,7 @@ public void checkMinReqBytes() {
final byte[] byteArray = sl.shared.toByteArray();
final byte[] badBytes = Arrays.copyOfRange(byteArray, 0, 24); //corrupt no. bytes
final MemorySegment seg = MemorySegment.ofArray(badBytes).asReadOnly();
- Sketch.heapify(seg);
+ ThetaSketch.heapify(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -591,7 +591,7 @@ public void checkThetaAndLgArrLongs() {
final MemorySegment seg = MemorySegment.ofArray(badArray);
PreambleUtil.insertLgArrLongs(seg, 4); //corrupt
PreambleUtil.insertThetaLong(seg, Long.MAX_VALUE / 2); //corrupt
- Sketch.heapify(seg);
+ ThetaSketch.heapify(seg);
}
@Test
diff --git a/src/test/java/org/apache/datasketches/theta/DirectQuickSelectSketchTest.java b/src/test/java/org/apache/datasketches/theta/DirectQuickSelectSketchTest.java
index a06206ff5..7f3f79281 100644
--- a/src/test/java/org/apache/datasketches/theta/DirectQuickSelectSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/DirectQuickSelectSketchTest.java
@@ -76,7 +76,7 @@ public void checkBadSerVer() {
wseg.set(JAVA_BYTE, SER_VER_BYTE, (byte) 0); //corrupt the SerVer byte
- Sketch.wrap(wseg);
+ ThetaSketch.wrap(wseg);
} catch (final Exception e) {
if (e instanceof SketchesArgumentException) {}
else { throw new RuntimeException(e); }
@@ -117,7 +117,7 @@ public void checkHeapifyIllegalFamilyID_heapify() {
seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Family ID byte
//try to heapify the corrupted seg
- Sketch.heapify(seg); //catch in Sketch.constructHeapSketch
+ ThetaSketch.heapify(seg); //catch in Sketch.constructHeapSketch
}
@Test
@@ -173,7 +173,7 @@ public void checkWrapIllegalFamilyID_wrap() {
seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Sketch ID byte
//try to wrap the corrupted seg
- Sketch.wrap(seg); //catch in Sketch.constructDirectSketch
+ ThetaSketch.wrap(seg); //catch in Sketch.constructDirectSketch
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -200,7 +200,7 @@ public void checkHeapifySeedConflict() {
final UpdateSketch usk = UpdateSketch.builder().setSeed(seed1).setNominalEntries(k).build(wseg);
final byte[] byteArray = usk.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(byteArray);
- Sketch.heapify(srcSeg, seed2);
+ ThetaSketch.heapify(srcSeg, seed2);
} catch (final Exception e) {
if (e instanceof SketchesArgumentException) {}
else { throw new RuntimeException(e); }
@@ -215,7 +215,7 @@ public void checkCorruptLgNomLongs() {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
UpdateSketch.builder().setNominalEntries(k).build(wseg);
wseg.set(JAVA_BYTE, LG_NOM_LONGS_BYTE, (byte)2); //corrupt
- Sketch.heapify(wseg, Util.DEFAULT_UPDATE_SEED);
+ ThetaSketch.heapify(wseg, Util.DEFAULT_UPDATE_SEED);
} catch (final Exception e) {
if (e instanceof SketchesArgumentException) {}
else { throw new RuntimeException(e); }
@@ -237,7 +237,7 @@ public void checkHeapifyByteArrayExact() {
assertEquals(bytes, byteArray.length);
final MemorySegment srcSeg = MemorySegment.ofArray(byteArray);
- final Sketch usk2 = Sketch.heapify(srcSeg);
+ final ThetaSketch usk2 = ThetaSketch.heapify(srcSeg);
assertEquals(usk2.getEstimate(), k, 0.0);
assertEquals(usk2.getLowerBound(2), k, 0.0);
assertEquals(usk2.getUpperBound(2), k, 0.0);
@@ -271,7 +271,7 @@ public void checkHeapifyByteArrayEstimating() {
final byte[] byteArray = usk.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(byteArray);
- final Sketch usk2 = Sketch.heapify(srcSeg);
+ final ThetaSketch usk2 = ThetaSketch.heapify(srcSeg);
assertEquals(usk2.getEstimate(), uskEst);
assertEquals(usk2.getLowerBound(2), uskLB);
assertEquals(usk2.getUpperBound(2), uskUB);
@@ -297,7 +297,7 @@ public void checkWrapMemorySegmentEst() {
final double sk1ub = sk1.getUpperBound(2);
assertTrue(sk1.isEstimationMode());
- final Sketch sk2 = Sketch.wrap(wseg);
+ final ThetaSketch sk2 = ThetaSketch.wrap(wseg);
assertEquals(sk2.getEstimate(), sk1est);
assertEquals(sk2.getLowerBound(2), sk1lb);
@@ -734,7 +734,7 @@ public void checkConstructReconstructFromMemorySegment() {
@Test(expectedExceptions = SketchesReadOnlyException.class)
public void updateAfterReadOnlyWrap() {
final UpdateSketch usk1 = UpdateSketch.builder().build();
- final UpdateSketch usk2 = (UpdateSketch) Sketch.wrap(MemorySegment.ofArray(usk1.toByteArray()));
+ final UpdateSketch usk2 = (UpdateSketch) ThetaSketch.wrap(MemorySegment.ofArray(usk1.toByteArray()));
usk2.update(0);
}
@@ -756,7 +756,7 @@ public void checkConstructorSrcSegCorruptions() {
final int k = 1024; //lgNomLongs = 10
final int u = k; //exact mode, lgArrLongs = 11
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
final byte[] arr1 = new byte[bytes];
final MemorySegment seg1 = MemorySegment.ofArray(arr1);
final ResizeFactor rf = ResizeFactor.X1; //0
@@ -823,7 +823,7 @@ public void checkConstructorSrcSegCorruptions() {
public void checkCorruptRFWithInsufficientArray() {
final int k = 1024; //lgNomLongs = 10
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
final byte[] arr = new byte[bytes];
final MemorySegment seg = MemorySegment.ofArray(arr);
final ResizeFactor rf = ResizeFactor.X8; // 3
@@ -867,7 +867,7 @@ public void checkBadLgNomLongs() {
public void checkMoveAndResize() {
final int k = 1 << 12;
final int u = 2 * k;
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
MemorySegment wseg;
try (Arena arena = Arena.ofConfined()) {
wseg = arena.allocate(bytes / 2);
@@ -883,7 +883,7 @@ public void checkMoveAndResize() {
public void checkReadOnlyRebuildResize() {
final int k = 1 << 12;
final int u = 2 * k;
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
MemorySegment wseg;
try (Arena arena = Arena.ofConfined()) {
wseg = arena.allocate(bytes / 2);
@@ -892,7 +892,7 @@ public void checkReadOnlyRebuildResize() {
final double est1 = sketch.getEstimate();
final byte[] serBytes = sketch.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(serBytes).asReadOnly();
- final UpdateSketch roSketch = (UpdateSketch) Sketch.wrap(seg);
+ final UpdateSketch roSketch = (UpdateSketch) ThetaSketch.wrap(seg);
final double est2 = roSketch.getEstimate();
assertEquals(est2, est1);
try {
diff --git a/src/test/java/org/apache/datasketches/theta/DirectUnionTest.java b/src/test/java/org/apache/datasketches/theta/DirectUnionTest.java
index e83651aed..c488abcb4 100644
--- a/src/test/java/org/apache/datasketches/theta/DirectUnionTest.java
+++ b/src/test/java/org/apache/datasketches/theta/DirectUnionTest.java
@@ -435,8 +435,8 @@ public void checkDirectSegmentIn() {
final MemorySegment skSeg1 = MemorySegment.ofArray(usk1.compact(false, null).toByteArray()).asReadOnly();
final MemorySegment skSeg2 = MemorySegment.ofArray(usk2.compact(true, null).toByteArray()).asReadOnly();
- final CompactSketch csk1 = (CompactSketch)Sketch.wrap(skSeg1);
- final CompactSketch csk2 = (CompactSketch)Sketch.wrap(skSeg2);
+ final CompactSketch csk1 = (CompactSketch)ThetaSketch.wrap(skSeg1);
+ final CompactSketch csk2 = (CompactSketch)ThetaSketch.wrap(skSeg2);
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]); //union segment
final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
@@ -518,7 +518,7 @@ public void checkEmptyUnionCompactResult() {
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]); //union segment
final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
- final MemorySegment seg = MemorySegment.ofArray(new byte[Sketch.getMaxCompactSketchBytes(0)]);
+ final MemorySegment seg = MemorySegment.ofArray(new byte[ThetaSketch.getMaxCompactSketchBytes(0)]);
final CompactSketch csk = union.getResult(false, seg); //DirectCompactSketch
assertTrue(csk.isEmpty());
}
@@ -530,7 +530,7 @@ public void checkEmptyUnionCompactOrderedResult() {
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]); //union segment
final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
- final MemorySegment seg = MemorySegment.ofArray(new byte[Sketch.getMaxCompactSketchBytes(0)]);
+ final MemorySegment seg = MemorySegment.ofArray(new byte[ThetaSketch.getMaxCompactSketchBytes(0)]);
final CompactSketch csk = union.getResult(true, seg); //DirectCompactSketch
assertTrue(csk.isEmpty());
}
@@ -617,7 +617,7 @@ public void checkPreambleLongsCorruption() {
final SetOperation setOp = new SetOperationBuilder().setNominalEntries(k).build(Family.UNION, seg);
println(setOp.toString());
final int familyID = PreambleUtil.extractFamilyID(seg);
- final int preLongs = Sketch.getPreambleLongs(seg);
+ final int preLongs = ThetaSketch.getPreambleLongs(seg);
assertEquals(familyID, Family.UNION.getID());
assertEquals(preLongs, Family.UNION.getMaxPreLongs());
PreambleUtil.insertPreLongs(seg, 3); //Corrupt with 3; correct value is 4
@@ -644,7 +644,7 @@ public void checkForDruidBug() {
}
usk.rebuild(); //optional but created the symptom
- final Sketch s = usk.compact();
+ final ThetaSketch s = usk.compact();
//create empty target union in off-heap segment
final MemorySegment seg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]);
diff --git a/src/test/java/org/apache/datasketches/theta/HeapAlphaSketchTest.java b/src/test/java/org/apache/datasketches/theta/HeapAlphaSketchTest.java
index 31f1992c1..38fc8f629 100644
--- a/src/test/java/org/apache/datasketches/theta/HeapAlphaSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/HeapAlphaSketchTest.java
@@ -78,7 +78,7 @@ public void checkBadSerVer() {
MemorySegment seg = MemorySegment.ofArray(byteArray);
seg.set(JAVA_BYTE, SER_VER_BYTE, (byte) 0); //corrupt the SerVer byte
- Sketch.heapify(seg, seed);
+ ThetaSketch.heapify(seg, seed);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -115,7 +115,7 @@ public void checkIllegalSketchID_UpdateSketch() {
seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Sketch ID byte
//try to heapify the corrupted seg
- Sketch.heapify(seg, seed);
+ ThetaSketch.heapify(seg, seed);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -127,7 +127,7 @@ public void checkHeapifySeedConflict() {
.setNominalEntries(k).build();
byte[] byteArray = usk.toByteArray();
MemorySegment srcSeg = MemorySegment.ofArray(byteArray).asReadOnly();
- Sketch.heapify(srcSeg, seed2);
+ ThetaSketch.heapify(srcSeg, seed2);
}
@Test
@@ -147,7 +147,7 @@ public void checkHeapifyByteArrayExact() {
assertEquals(bytes, byteArray.length);
MemorySegment srcSeg = MemorySegment.ofArray(byteArray);
- UpdateSketch usk2 = (UpdateSketch)Sketch.heapify(srcSeg, seed);
+ UpdateSketch usk2 = (UpdateSketch)ThetaSketch.heapify(srcSeg, seed);
assertEquals(usk2.getEstimate(), u, 0.0);
assertEquals(usk2.getLowerBound(2), u, 0.0);
assertEquals(usk2.getUpperBound(2), u, 0.0);
@@ -177,7 +177,7 @@ public void checkHeapifyByteArrayEstimating() {
byte[] byteArray = usk.toByteArray();
MemorySegment srcSeg = MemorySegment.ofArray(byteArray).asReadOnly();
- UpdateSketch usk2 = (UpdateSketch)Sketch.heapify(srcSeg, seed);
+ UpdateSketch usk2 = (UpdateSketch)ThetaSketch.heapify(srcSeg, seed);
assertEquals(usk2.getEstimate(), uskEst);
assertEquals(usk2.getLowerBound(2), uskLB);
assertEquals(usk2.getUpperBound(2), uskUB);
@@ -208,7 +208,7 @@ public void checkHeapifyMemorySegmentEstimating() {
byte[] byteArray = sk1.toByteArray();
MemorySegment seg = MemorySegment.ofArray(byteArray).asReadOnly();
- UpdateSketch sk2 = (UpdateSketch)Sketch.heapify(seg, Util.DEFAULT_UPDATE_SEED);
+ UpdateSketch sk2 = (UpdateSketch)ThetaSketch.heapify(seg, Util.DEFAULT_UPDATE_SEED);
assertEquals(sk2.getEstimate(), sk1est);
assertEquals(sk2.getLowerBound(2), sk1lb);
@@ -545,40 +545,40 @@ public void checkResetAndStartingSubMultiple() {
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkLBlimits0() {
int k = 512;
- Sketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ ThetaSketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
alpha.getLowerBound(0);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkUBlimits0() {
int k = 512;
- Sketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ ThetaSketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
alpha.getUpperBound(0);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkLBlimits4() {
int k = 512;
- Sketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ ThetaSketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
alpha.getLowerBound(4);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkUBlimits4() {
int k = 512;
- Sketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ ThetaSketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
alpha.getUpperBound(4);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkBadPreambleLongs() {
int k = 512;
- Sketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ ThetaSketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
byte[] byteArray = alpha.toByteArray();
MemorySegment seg = MemorySegment.ofArray(byteArray);
//corrupt:
seg.set(JAVA_BYTE, PREAMBLE_LONGS_BYTE, (byte) 4);
- Sketch.heapify(seg);
+ ThetaSketch.heapify(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
diff --git a/src/test/java/org/apache/datasketches/theta/HeapQuickSelectSketchTest.java b/src/test/java/org/apache/datasketches/theta/HeapQuickSelectSketchTest.java
index 1fd536128..dafd4e4fc 100644
--- a/src/test/java/org/apache/datasketches/theta/HeapQuickSelectSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/HeapQuickSelectSketchTest.java
@@ -76,7 +76,7 @@ public void checkBadSerVer() {
final MemorySegment seg = MemorySegment.ofArray(byteArray);
seg.set(JAVA_BYTE, SER_VER_BYTE, (byte) 0); //corrupt the SerVer byte
- Sketch.heapify(seg, seed);
+ ThetaSketch.heapify(seg, seed);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -100,7 +100,7 @@ public void checkIllegalSketchID_UpdateSketch() {
seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Sketch ID byte
//try to heapify the corrupted seg
- Sketch.heapify(seg, seed);
+ ThetaSketch.heapify(seg, seed);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -111,7 +111,7 @@ public void checkHeapifySeedConflict() {
final UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setSeed(seed1).setNominalEntries(k).build();
final byte[] byteArray = usk.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(byteArray).asReadOnly();
- Sketch.heapify(srcSeg, seed2);
+ ThetaSketch.heapify(srcSeg, seed2);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -119,7 +119,7 @@ public void checkHeapifyCorruptLgNomLongs() {
final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(16).build();
final MemorySegment srcSeg = MemorySegment.ofArray(usk.toByteArray());
srcSeg.set(JAVA_BYTE, LG_NOM_LONGS_BYTE, (byte)2); //corrupt
- Sketch.heapify(srcSeg, Util.DEFAULT_UPDATE_SEED);
+ ThetaSketch.heapify(srcSeg, Util.DEFAULT_UPDATE_SEED);
}
@Test
@@ -547,7 +547,7 @@ public void checkMinReqBytes() {
final byte[] byteArray = s1.toByteArray();
final byte[] badBytes = Arrays.copyOfRange(byteArray, 0, 24);
final MemorySegment seg = MemorySegment.ofArray(badBytes);
- Sketch.heapify(seg);
+ ThetaSketch.heapify(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -559,7 +559,7 @@ public void checkThetaAndLgArrLongs() {
final MemorySegment seg = MemorySegment.ofArray(badArray);
PreambleUtil.insertLgArrLongs(seg, 4);
PreambleUtil.insertThetaLong(seg, Long.MAX_VALUE / 2);
- Sketch.heapify(seg);
+ ThetaSketch.heapify(seg);
}
@Test
diff --git a/src/test/java/org/apache/datasketches/theta/HeapUnionTest.java b/src/test/java/org/apache/datasketches/theta/HeapUnionTest.java
index 8863a971b..bc602a6f8 100644
--- a/src/test/java/org/apache/datasketches/theta/HeapUnionTest.java
+++ b/src/test/java/org/apache/datasketches/theta/HeapUnionTest.java
@@ -389,8 +389,8 @@ public void checkDirectSegmentIn() {
final MemorySegment skSeg1 = MemorySegment.ofArray(usk1.compact(false, null).toByteArray());
final MemorySegment skSeg2 = MemorySegment.ofArray(usk2.compact(true, null).toByteArray());
- final CompactSketch csk1 = (CompactSketch)Sketch.wrap(skSeg1);
- final CompactSketch csk2 = (CompactSketch)Sketch.wrap(skSeg2);
+ final CompactSketch csk1 = (CompactSketch)ThetaSketch.wrap(skSeg1);
+ final CompactSketch csk2 = (CompactSketch)ThetaSketch.wrap(skSeg2);
final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
diff --git a/src/test/java/org/apache/datasketches/theta/HeapifyWrapSerVer3Test.java b/src/test/java/org/apache/datasketches/theta/HeapifyWrapSerVer3Test.java
index b1dba552c..79e0252af 100644
--- a/src/test/java/org/apache/datasketches/theta/HeapifyWrapSerVer3Test.java
+++ b/src/test/java/org/apache/datasketches/theta/HeapifyWrapSerVer3Test.java
@@ -82,7 +82,7 @@ public void checkHeapifySketchAssumedDefaultSeed() {
final MemorySegment cskSeg = MemorySegment.ofArray(csk.toByteArray()).asReadOnly();
CompactSketch cskResult;
- cskResult = (CompactSketch) Sketch.heapify(cskSeg);
+ cskResult = (CompactSketch) ThetaSketch.heapify(cskSeg);
assertEquals(cskResult.getEstimate(), usk.getEstimate());
assertEquals(cskResult.getSeedHash(), seedHash);
}
@@ -99,7 +99,7 @@ public void checkHeapifySketchDifferentSeed() {
final MemorySegment cskSeg = MemorySegment.ofArray(csk.toByteArray()).asReadOnly();
CompactSketch cskResult;
- cskResult = (CompactSketch) Sketch.heapify(cskSeg, seed);
+ cskResult = (CompactSketch) ThetaSketch.heapify(cskSeg, seed);
assertEquals(cskResult.getEstimate(), usk.getEstimate());
assertEquals(cskResult.getSeedHash(), seedHash);
}
@@ -162,7 +162,7 @@ public void checkWrapSketchAssumedDefaultSeed() {
//SerialVersion3 test
try(Arena arena = Arena.ofConfined()) {
offHeap = putOffHeap(MemorySegment.ofArray(csk.toByteArray()), arena);
- cskResult = (CompactSketch) Sketch.wrap(offHeap);
+ cskResult = (CompactSketch) ThetaSketch.wrap(offHeap);
assertEquals(cskResult.getEstimate(), usk.getEstimate());
assertEquals(cskResult.getSeedHash(), seedHash);
assertTrue(cskResult.isOffHeap());
@@ -183,7 +183,7 @@ public void checkWrapSketchDifferentSeed() {
//SerialVersion3 test
try(Arena arena = Arena.ofConfined()) {
offHeap = putOffHeap(MemorySegment.ofArray(csk.toByteArray()), arena);
- cskResult = (CompactSketch) Sketch.wrap(offHeap, seed);
+ cskResult = (CompactSketch) ThetaSketch.wrap(offHeap, seed);
assertEquals(cskResult.getEstimate(), usk.getEstimate());
assertEquals(cskResult.getSeedHash(), seedHash);
assertTrue(cskResult.isOffHeap());
diff --git a/src/test/java/org/apache/datasketches/theta/IteratorTest.java b/src/test/java/org/apache/datasketches/theta/IteratorTest.java
index 343142044..7e3dbd159 100644
--- a/src/test/java/org/apache/datasketches/theta/IteratorTest.java
+++ b/src/test/java/org/apache/datasketches/theta/IteratorTest.java
@@ -26,7 +26,7 @@
import org.apache.datasketches.common.Family;
import org.apache.datasketches.theta.CompactSketch;
import org.apache.datasketches.theta.HashIterator;
-import org.apache.datasketches.theta.Sketch;
+import org.apache.datasketches.theta.ThetaSketch;
import org.apache.datasketches.theta.UpdateSketch;
@@ -39,7 +39,7 @@ public class IteratorTest {
@Test
public void checkDirectCompactSketch() {
int k = 16;
- int maxBytes = Sketch.getMaxUpdateSketchBytes(k);
+ int maxBytes = ThetaSketch.getMaxUpdateSketchBytes(k);
MemorySegment wseg = MemorySegment.ofArray(new byte[maxBytes]);
UpdateSketch sk1 = UpdateSketch.builder().setNominalEntries(k).build(wseg);
println(sk1.getClass().getSimpleName());
@@ -52,7 +52,7 @@ public void checkDirectCompactSketch() {
assertEquals(count, k/2);
println("");
- Sketch sk2 = sk1.compact();
+ ThetaSketch sk2 = sk1.compact();
println(sk2.getClass().getSimpleName());
HashIterator itr2 = sk2.iterator();
count = 0;
@@ -62,7 +62,7 @@ public void checkDirectCompactSketch() {
assertEquals(count, k/2);
println("");
- Sketch sk3 = sk1.compact(false, MemorySegment.ofArray(new byte[maxBytes]));
+ ThetaSketch sk3 = sk1.compact(false, MemorySegment.ofArray(new byte[maxBytes]));
println(sk3.getClass().getSimpleName());
HashIterator itr3 = sk3.iterator();
count = 0;
diff --git a/src/test/java/org/apache/datasketches/theta/PairwiseSetOperationsTest.java b/src/test/java/org/apache/datasketches/theta/PairwiseSetOperationsTest.java
index 2d1e71103..e2682453a 100644
--- a/src/test/java/org/apache/datasketches/theta/PairwiseSetOperationsTest.java
+++ b/src/test/java/org/apache/datasketches/theta/PairwiseSetOperationsTest.java
@@ -27,7 +27,7 @@
import org.apache.datasketches.theta.CompactSketch;
import org.apache.datasketches.theta.Intersection;
import org.apache.datasketches.theta.SetOperation;
-import org.apache.datasketches.theta.Sketch;
+import org.apache.datasketches.theta.ThetaSketch;
import org.apache.datasketches.theta.Union;
import org.apache.datasketches.theta.UpdateSketch;
import org.testng.annotations.Test;
@@ -52,7 +52,7 @@ public void checkIntersectionNoOverlap() {
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
Intersection inter = SetOperation.builder().buildIntersection();
- Sketch rsk = inter.intersect(csk1, csk2);
+ ThetaSketch rsk = inter.intersect(csk1, csk2);
assertEquals(rsk.getEstimate(), 0.0);
}
@@ -73,7 +73,7 @@ public void checkIntersectionFullOverlap() {
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch rsk = inter.intersect(csk1, csk2);
+ ThetaSketch rsk = inter.intersect(csk1, csk2);
assertEquals(rsk.getEstimate(), k, 0.0);
}
@@ -98,7 +98,7 @@ public void checkIntersectionEarlyStop() {
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch rsk = inter.intersect(csk1, csk2);
+ ThetaSketch rsk = inter.intersect(csk1, csk2);
double result1 = rsk.getEstimate();
inter.intersect(csk1);
@@ -133,7 +133,7 @@ public void checkAnotBNoOverlap() {
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch rsk = anotb.aNotB(csk1, csk2);
+ ThetaSketch rsk = anotb.aNotB(csk1, csk2);
assertEquals(rsk.getEstimate(), k, 0.0);
}
@@ -154,7 +154,7 @@ public void checkAnotBFullOverlap() {
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch rsk = anotb.aNotB(csk1, csk2);
+ ThetaSketch rsk = anotb.aNotB(csk1, csk2);
assertEquals(rsk.getEstimate(), 0.0, 0.0);
}
@@ -180,7 +180,7 @@ public void checkAnotBEarlyStop() {
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch rsk = aNotB.aNotB(csk1, csk2);
+ ThetaSketch rsk = aNotB.aNotB(csk1, csk2);
double result1 = rsk.getEstimate();
CompactSketch csk3 = aNotB.aNotB(csk1, csk2);
@@ -214,9 +214,9 @@ public void checkUnionNoOverlap() {
union.union(csk1);
union.union(csk2);
- Sketch stdSk = union.getResult(true, null);
+ ThetaSketch stdSk = union.getResult(true, null);
- Sketch rsk = union.union(csk1, csk2);
+ ThetaSketch rsk = union.union(csk1, csk2);
assertEquals(rsk.getEstimate(), stdSk.getEstimate(), 0.0);
}
@@ -238,7 +238,7 @@ public void checkUnionFullOverlap() {
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch rsk = union.union(csk1, csk2);
+ ThetaSketch rsk = union.union(csk1, csk2);
assertEquals(rsk.getEstimate(), k, 0.0);
}
@@ -264,7 +264,7 @@ public void checkUnionEarlyStop() {
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch pwSk = union.union(csk1, csk2);
+ ThetaSketch pwSk = union.union(csk1, csk2);
double pwEst = pwSk.getEstimate();
union.union(csk1);
@@ -298,7 +298,7 @@ public void checkUnionCutbackToK() {
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch pwSk = union.union(csk1, csk2);
+ ThetaSketch pwSk = union.union(csk1, csk2);
double pwEst = pwSk.getEstimate();
union.union(csk1);
diff --git a/src/test/java/org/apache/datasketches/theta/PreambleUtilTest.java b/src/test/java/org/apache/datasketches/theta/PreambleUtilTest.java
index 61093c2a5..a17b6f64c 100644
--- a/src/test/java/org/apache/datasketches/theta/PreambleUtilTest.java
+++ b/src/test/java/org/apache/datasketches/theta/PreambleUtilTest.java
@@ -74,7 +74,7 @@ public void checkToString() {
final MemorySegment seg = MemorySegment.ofArray(byteArray);
final UpdateSketch quick1 = UpdateSketch.builder().setNominalEntries(k).build(seg);
- println(Sketch.toString(byteArray));
+ println(ThetaSketch.toString(byteArray));
Assert.assertTrue(quick1.isEmpty());
@@ -103,14 +103,14 @@ public void checkToStringWithPrelongsOf2() {
quick1.update(i);
}
final byte[] bytes = quick1.compact().toByteArray();
- println(Sketch.toString(bytes));
+ println(ThetaSketch.toString(bytes));
}
@Test
public void checkPreambleToStringExceptions() {
byte[] byteArr = new byte[7];
try { //check preLongs < 8 fails
- Sketch.toString(byteArr);
+ ThetaSketch.toString(byteArr);
fail("Did not throw SketchesArgumentException.");
} catch (final SketchesArgumentException e) {
//expected
@@ -118,7 +118,7 @@ public void checkPreambleToStringExceptions() {
byteArr = new byte[8];
byteArr[0] = (byte) 2; //needs min capacity of 16
try { //check preLongs == 2 fails
- Sketch.toString(MemorySegment.ofArray(byteArr).asReadOnly());
+ ThetaSketch.toString(MemorySegment.ofArray(byteArr).asReadOnly());
fail("Did not throw SketchesArgumentException.");
} catch (final SketchesArgumentException e) {
//expected
@@ -136,19 +136,19 @@ public void checkPreLongs() {
final UpdateSketch sketch = UpdateSketch.builder().setNominalEntries(16).build();
CompactSketch comp = sketch.compact(false, null);
byte[] byteArr = comp.toByteArray();
- println(Sketch.toString(byteArr)); //PreLongs = 1
+ println(ThetaSketch.toString(byteArr)); //PreLongs = 1
sketch.update(1);
comp = sketch.compact(false, null);
byteArr = comp.toByteArray();
- println(Sketch.toString(byteArr)); //PreLongs = 2
+ println(ThetaSketch.toString(byteArr)); //PreLongs = 2
for (int i=2; i<=32; i++) {
sketch.update(i);
}
comp = sketch.compact(false, null);
byteArr = comp.toByteArray();
- println(Sketch.toString(MemorySegment.ofArray(byteArr).asReadOnly())); //PreLongs = 3
+ println(ThetaSketch.toString(MemorySegment.ofArray(byteArr).asReadOnly())); //PreLongs = 3
}
@Test
diff --git a/src/test/java/org/apache/datasketches/theta/ReadOnlyMemorySegmentTest.java b/src/test/java/org/apache/datasketches/theta/ReadOnlyMemorySegmentTest.java
index ab6caf793..d196fc95b 100644
--- a/src/test/java/org/apache/datasketches/theta/ReadOnlyMemorySegmentTest.java
+++ b/src/test/java/org/apache/datasketches/theta/ReadOnlyMemorySegmentTest.java
@@ -39,7 +39,7 @@ public void wrapAndTryUpdatingUpdateSketch() {
updateSketch.update(1);
final MemorySegment seg = MemorySegment.ofBuffer(
ByteBuffer.wrap(updateSketch.toByteArray()).asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
- final UpdateSketch sketch = (UpdateSketch) Sketch.wrap(seg);
+ final UpdateSketch sketch = (UpdateSketch) ThetaSketch.wrap(seg);
assertEquals(sketch.getEstimate(), 1.0);
assertTrue(seg.isReadOnly());
@@ -58,7 +58,7 @@ public void wrapCompactUnorderedSketch() {
updateSketch.update(1);
final MemorySegment seg = MemorySegment.ofBuffer(
ByteBuffer.wrap(updateSketch.compact(false, null).toByteArray()).asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
- final Sketch sketch = Sketch.wrap(seg);
+ final ThetaSketch sketch = ThetaSketch.wrap(seg);
assertEquals(sketch.getEstimate(), 1.0);
assertTrue(seg.isReadOnly());
}
@@ -69,7 +69,7 @@ public void wrapCompactOrderedSketch() {
updateSketch.update(1);
final MemorySegment seg = MemorySegment.ofBuffer(ByteBuffer.wrap(updateSketch.compact().toByteArray())
.asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
- final Sketch sketch = Sketch.wrap(seg);
+ final ThetaSketch sketch = ThetaSketch.wrap(seg);
assertEquals(sketch.getEstimate(), 1.0);
assertTrue(seg.isReadOnly());
}
@@ -81,7 +81,7 @@ public void heapifyUpdateSketch() {
final MemorySegment seg = MemorySegment.ofBuffer(
ByteBuffer.wrap(us1.toByteArray()).asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
// downcasting is not recommended, for testing only
- final UpdateSketch us2 = (UpdateSketch) Sketch.heapify(seg);
+ final UpdateSketch us2 = (UpdateSketch) ThetaSketch.heapify(seg);
us2.update(2);
assertEquals(us2.getEstimate(), 2.0);
assertTrue(seg.isReadOnly());
@@ -93,7 +93,7 @@ public void heapifyCompactUnorderedSketch() {
updateSketch.update(1);
final MemorySegment seg = MemorySegment.ofBuffer(
ByteBuffer.wrap(updateSketch.compact(false, null).toByteArray()).asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
- final Sketch sketch = Sketch.heapify(seg);
+ final ThetaSketch sketch = ThetaSketch.heapify(seg);
assertEquals(sketch.getEstimate(), 1.0);
assertTrue(seg.isReadOnly());
}
@@ -104,7 +104,7 @@ public void heapifyCompactOrderedSketch() {
updateSketch.update(1);
final MemorySegment seg = MemorySegment.ofBuffer(
ByteBuffer.wrap(updateSketch.compact().toByteArray()).asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
- final Sketch sketch = Sketch.heapify(seg);
+ final ThetaSketch sketch = ThetaSketch.heapify(seg);
assertEquals(sketch.getEstimate(), 1.0);
assertTrue(seg.isReadOnly());
}
diff --git a/src/test/java/org/apache/datasketches/theta/SetOperationTest.java b/src/test/java/org/apache/datasketches/theta/SetOperationTest.java
index 8d4660d91..e19b405c6 100644
--- a/src/test/java/org/apache/datasketches/theta/SetOperationTest.java
+++ b/src/test/java/org/apache/datasketches/theta/SetOperationTest.java
@@ -20,7 +20,7 @@
package org.apache.datasketches.theta;
import static org.apache.datasketches.common.ResizeFactor.X4;
-import static org.apache.datasketches.theta.Sketch.getMaxUpdateSketchBytes;
+import static org.apache.datasketches.theta.ThetaSketch.getMaxUpdateSketchBytes;
import static org.apache.datasketches.thetacommon.HashOperations.minLgHashTableSize;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
@@ -347,7 +347,7 @@ private static int[] getHeapLayout(final int sketchNomEntries, final int unionNo
final int[] heapLayout = new int[6];
final int unionBytes = SetOperation.getMaxUnionBytes(unionNomEntries);
final int sketchBytes = getMaxUpdateSketchBytes(sketchNomEntries);
- final int resultBytes = Sketch.getMaxCompactSketchBytes(unionNomEntries);
+ final int resultBytes = ThetaSketch.getMaxCompactSketchBytes(unionNomEntries);
heapLayout[0] = 0; //offset for Union
heapLayout[1] = unionBytes; //offset for sketch1
heapLayout[2] = unionBytes + sketchBytes; //offset for sketch2
@@ -395,9 +395,9 @@ private static double directUnionTrial1(
//Let's recover the union and the 3rd sketch
union = Union.wrap(unionSeg);
- union.union(Sketch.wrap(sketch3seg));
+ union.union(ThetaSketch.wrap(sketch3seg));
- final Sketch resSk = union.getResult(true, resultSeg);
+ final ThetaSketch resSk = union.getResult(true, resultSeg);
final double est = resSk.getEstimate();
return est;
@@ -413,9 +413,9 @@ private static double directUnionTrial2(
final MemorySegment resultSeg = heapSeg.asSlice(heapLayout[4], heapLayout[5]-heapLayout[4]);
//Recover the 3 sketches
- final UpdateSketch sk1 = (UpdateSketch) Sketch.wrap(sketch1seg);
- final UpdateSketch sk2 = (UpdateSketch) Sketch.wrap(sketch2seg);
- final UpdateSketch sk3 = (UpdateSketch) Sketch.wrap(sketch3seg);
+ final UpdateSketch sk1 = (UpdateSketch) ThetaSketch.wrap(sketch1seg);
+ final UpdateSketch sk2 = (UpdateSketch) ThetaSketch.wrap(sketch2seg);
+ final UpdateSketch sk3 = (UpdateSketch) ThetaSketch.wrap(sketch3seg);
//confirm that each of these 3 sketches is exact.
assertEquals(sk1.getEstimate(), sketchNomEntries, 0.0);
@@ -429,7 +429,7 @@ private static double directUnionTrial2(
union.union(sk2);
union.union(sk3);
- final Sketch resSk = union.getResult(true, resultSeg);
+ final ThetaSketch resSk = union.getResult(true, resultSeg);
final double est = resSk.getEstimate();
return est;
diff --git a/src/test/java/org/apache/datasketches/theta/SetOpsCornerCasesTest.java b/src/test/java/org/apache/datasketches/theta/SetOpsCornerCasesTest.java
index 4f5380658..80a876991 100644
--- a/src/test/java/org/apache/datasketches/theta/SetOpsCornerCasesTest.java
+++ b/src/test/java/org/apache/datasketches/theta/SetOpsCornerCasesTest.java
@@ -34,7 +34,7 @@
import org.apache.datasketches.theta.CompactSketch;
import org.apache.datasketches.theta.Intersection;
import org.apache.datasketches.theta.SetOperation;
-import org.apache.datasketches.theta.Sketch;
+import org.apache.datasketches.theta.ThetaSketch;
import org.apache.datasketches.theta.Union;
import org.apache.datasketches.theta.UpdateSketch;
import org.testng.Assert;
@@ -169,36 +169,36 @@ private static void cornerCaseChecks(final State stateA, final State stateB, fin
checkCornerCase(rcskStdStatefulAnotB, rcskStdAnotB);
}
- private static CompactSketch doStdUnion(final Sketch tskA, final Sketch tskB, final int k, final MemorySegment wseg) {
+ private static CompactSketch doStdUnion(final ThetaSketch tskA, final ThetaSketch tskB, final int k, final MemorySegment wseg) {
final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
union.union(tskA);
union.union(tskB);
return union.getResult(true, wseg);
}
- private static CompactSketch doStdPairUnion(final Sketch tskA, final Sketch tskB, final int k, final MemorySegment wseg) {
+ private static CompactSketch doStdPairUnion(final ThetaSketch tskA, final ThetaSketch tskB, final int k, final MemorySegment wseg) {
final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
return union.union(tskA, tskB, true, wseg);
}
- private static CompactSketch doStdIntersection(final Sketch tskA, final Sketch tskB, final MemorySegment wseg) {
+ private static CompactSketch doStdIntersection(final ThetaSketch tskA, final ThetaSketch tskB, final MemorySegment wseg) {
final Intersection inter = SetOperation.builder().buildIntersection();
inter.intersect(tskA);
inter.intersect(tskB);
return inter.getResult(true, wseg);
}
- private static CompactSketch doStdPairIntersection(final Sketch tskA, final Sketch tskB, final MemorySegment wseg) {
+ private static CompactSketch doStdPairIntersection(final ThetaSketch tskA, final ThetaSketch tskB, final MemorySegment wseg) {
final Intersection inter = SetOperation.builder().buildIntersection();
return inter.intersect(tskA, tskB, true, wseg);
}
- private static CompactSketch doStdAnotB(final Sketch tskA, final Sketch tskB, final MemorySegment wseg) {
+ private static CompactSketch doStdAnotB(final ThetaSketch tskA, final ThetaSketch tskB, final MemorySegment wseg) {
final AnotB anotb = SetOperation.builder().buildANotB();
return anotb.aNotB(tskA, tskB, true, wseg);
}
- private static CompactSketch doStdStatefulAnotB(final Sketch tskA, final Sketch tskB, final MemorySegment wseg) {
+ private static CompactSketch doStdStatefulAnotB(final ThetaSketch tskA, final ThetaSketch tskB, final MemorySegment wseg) {
final AnotB anotb = SetOperation.builder().buildANotB();
anotb.setA(tskA);
anotb.notB(tskB);
@@ -206,7 +206,7 @@ private static CompactSketch doStdStatefulAnotB(final Sketch tskA, final Sketch
return anotb.getResult(true, wseg, true);
}
- private static CompactSketch doPwUnion(final Sketch tskA, final Sketch tskB, final int k) {
+ private static CompactSketch doPwUnion(final ThetaSketch tskA, final ThetaSketch tskB, final int k) {
CompactSketch tcskA, tcskB;
if (tskA == null) { tcskA = null; }
else { tcskA = (tskA instanceof CompactSketch) ? (CompactSketch) tskA : tskA.compact(); }
@@ -216,18 +216,18 @@ private static CompactSketch doPwUnion(final Sketch tskA, final Sketch tskB, fin
return union.union(tcskA, tcskB);
}
- private static CompactSketch doPwIntersection(final Sketch tskA, final Sketch tskB) {
+ private static CompactSketch doPwIntersection(final ThetaSketch tskA, final ThetaSketch tskB) {
final Intersection inter = SetOperation.builder().buildIntersection();
return inter.intersect(tskA, tskB);
}
- private static CompactSketch doPwAnotB(final Sketch tskA, final Sketch tskB) {
+ private static CompactSketch doPwAnotB(final ThetaSketch tskA, final ThetaSketch tskB) {
final AnotB aNotB = SetOperation.builder().buildANotB();
return aNotB.aNotB(tskA, tskB);
}
- private static void checkCornerCase(final Sketch rskA, final Sketch rskB) {
+ private static void checkCornerCase(final ThetaSketch rskA, final ThetaSketch rskB) {
final double estA = rskA.getEstimate();
final double estB = rskB.getEstimate();
final boolean emptyA = rskA.isEmpty();
@@ -494,7 +494,7 @@ private static CompactSketch generate(final State state, final int k) {
for (int i = 0; i < (4 * k); i++) {
sk.update(i);
}
- final int bytes = Sketch.getMaxCompactSketchBytes(sk.getRetainedEntries(true));
+ final int bytes = ThetaSketch.getMaxCompactSketchBytes(sk.getRetainedEntries(true));
final byte[] byteArr = new byte[bytes];
final MemorySegment wseg = MemorySegment.ofArray(byteArr);
csk = sk.compact(false, wseg);
diff --git a/src/test/java/org/apache/datasketches/theta/SingleItemSketchTest.java b/src/test/java/org/apache/datasketches/theta/SingleItemSketchTest.java
index b073ca255..a0c3cd346 100644
--- a/src/test/java/org/apache/datasketches/theta/SingleItemSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/SingleItemSketchTest.java
@@ -175,7 +175,7 @@ public void checkRestricted() {
@Test
public void unionWrapped() {
- final Sketch sketch = SingleItemSketch.create(1);
+ final ThetaSketch sketch = SingleItemSketch.create(1);
final Union union = SetOperation.builder().buildUnion();
final MemorySegment seg = MemorySegment.ofArray(sketch.toByteArray());
union.union(seg );
@@ -196,7 +196,7 @@ public void buildAndCompact() {
assertTrue(csk instanceof SingleItemSketch);
//Off-heap
- bytes = Sketch.getMaxUpdateSketchBytes(32);
+ bytes = ThetaSketch.getMaxUpdateSketchBytes(32);
MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
sk1= UpdateSketch.builder().setNominalEntries(32).build(wseg );
sk1.update(1);
@@ -205,7 +205,7 @@ public void buildAndCompact() {
csk = sk1.compact(false, null);
assertTrue(csk instanceof SingleItemSketch);
- bytes = Sketch.getMaxCompactSketchBytes(1);
+ bytes = ThetaSketch.getMaxCompactSketchBytes(1);
wseg = MemorySegment.ofArray(new byte[bytes]);
csk = sk1.compact(true, wseg );
assertTrue(csk.isOrdered());
@@ -299,7 +299,7 @@ public void checkHeapifyInstance() {
final MemorySegment wseg = MemorySegment.ofArray(new byte[16]);
final CompactSketch csk = inter.getResult(false, wseg );
assertTrue(csk.isOrdered());
- final Sketch csk2 = Sketch.heapify(wseg );
+ final ThetaSketch csk2 = ThetaSketch.heapify(wseg );
assertTrue(csk2 instanceof SingleItemSketch);
println(csk2.toString(true, true, 1, true));
}
@@ -320,10 +320,10 @@ public void checkSingleItemBadFlags() {
@Test
public void checkDirectUnionSingleItem2() {
- Sketch sk = Sketch.wrap(siSkWoutSiFlag24Bytes());
+ ThetaSketch sk = ThetaSketch.wrap(siSkWoutSiFlag24Bytes());
assertEquals(sk.getEstimate(), 1.0, 0.0);
//println(sk.toString());
- sk = Sketch.wrap(siSkWithSiFlag24Bytes());
+ sk = ThetaSketch.wrap(siSkWithSiFlag24Bytes());
assertEquals(sk.getEstimate(), 1.0, 0.0);
//println(sk.toString());
}
diff --git a/src/test/java/org/apache/datasketches/theta/SketchMiscTest.java b/src/test/java/org/apache/datasketches/theta/SketchMiscTest.java
index e46fd20e6..a920b8426 100644
--- a/src/test/java/org/apache/datasketches/theta/SketchMiscTest.java
+++ b/src/test/java/org/apache/datasketches/theta/SketchMiscTest.java
@@ -64,16 +64,16 @@ public void checkSketchMethods() {
final int k = 1024;
final MemorySegment seg = getCompactSketchMemorySegment(k, 0, k);
- CompactSketch csk2 = (CompactSketch) Sketch.heapify(seg);
+ CompactSketch csk2 = (CompactSketch) ThetaSketch.heapify(seg);
assertEquals((int)csk2.getEstimate(), k);
- csk2 = (CompactSketch) Sketch.heapify(seg, Util.DEFAULT_UPDATE_SEED);
+ csk2 = (CompactSketch) ThetaSketch.heapify(seg, Util.DEFAULT_UPDATE_SEED);
assertEquals((int)csk2.getEstimate(), k);
- csk2 = (CompactSketch) Sketch.wrap(seg);
+ csk2 = (CompactSketch) ThetaSketch.wrap(seg);
assertEquals((int)csk2.getEstimate(), k);
- csk2 = (CompactSketch) Sketch.wrap(seg, Util.DEFAULT_UPDATE_SEED);
+ csk2 = (CompactSketch) ThetaSketch.wrap(seg, Util.DEFAULT_UPDATE_SEED);
assertEquals((int)csk2.getEstimate(), k);
}
@@ -112,7 +112,7 @@ public void checkSetOpMethods() {
cSk = union2.getResult(true, null);
assertEquals((int)cSk.getEstimate(), 3*k/2);
- final int serVer = Sketch.getSerializationVersion(uSeg);
+ final int serVer = ThetaSketch.getSerializationVersion(uSeg);
assertEquals(serVer, 3);
}
@@ -127,15 +127,15 @@ public void checkUtilMethods() {
final int maxInterBytes = SetOperation.getMaxIntersectionBytes(k);
assertEquals(2*k*8+24, maxInterBytes);
- final int maxCompSkBytes = Sketch.getMaxCompactSketchBytes(k+1);
+ final int maxCompSkBytes = ThetaSketch.getMaxCompactSketchBytes(k+1);
assertEquals(24+(k+1)*8, maxCompSkBytes);
- final int compSkMaxBytes = Sketch.getCompactSketchMaxBytes(lgK); {
+ final int compSkMaxBytes = ThetaSketch.getCompactSketchMaxBytes(lgK); {
int bytes = (int)((2 << lgK) * ThetaUtil.REBUILD_THRESHOLD + Family.QUICKSELECT.getMaxPreLongs()) * Long.BYTES;
assertEquals(compSkMaxBytes, bytes);
}
- final int maxSkBytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int maxSkBytes = ThetaSketch.getMaxUpdateSketchBytes(k);
assertEquals(24+2*k*8, maxSkBytes);
}
@@ -144,7 +144,7 @@ public void checkBadSketchFamily() {
final Union union = SetOperation.builder().buildUnion();
final byte[] byteArr = union.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(byteArr);
- Sketch.getEstimate(srcSeg); //Union is not a Theta Sketch, it is an operation
+ ThetaSketch.getEstimate(srcSeg); //Union is not a Theta Sketch, it is an operation
}
@Test
diff --git a/src/test/java/org/apache/datasketches/theta/SketchTest.java b/src/test/java/org/apache/datasketches/theta/SketchTest.java
index cffee0b08..0891aea80 100644
--- a/src/test/java/org/apache/datasketches/theta/SketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/SketchTest.java
@@ -31,7 +31,7 @@
import static org.apache.datasketches.theta.PreambleUtil.COMPACT_FLAG_MASK;
import static org.apache.datasketches.theta.PreambleUtil.FLAGS_BYTE;
import static org.apache.datasketches.theta.PreambleUtil.READ_ONLY_FLAG_MASK;
-import static org.apache.datasketches.theta.Sketch.getMaxCompactSketchBytes;
+import static org.apache.datasketches.theta.ThetaSketch.getMaxCompactSketchBytes;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
@@ -108,7 +108,7 @@ public void checkGetCurrentBytes() {
assertEquals(compPreLongs, 3);
for (int i=0; i<3; i++) {
- final int maxCompBytes = Sketch.getMaxCompactSketchBytes(i);
+ final int maxCompBytes = ThetaSketch.getMaxCompactSketchBytes(i);
if (i == 0) { assertEquals(maxCompBytes, 8); }
if (i == 1) { assertEquals(maxCompBytes, 16); }
if (i > 1) { assertEquals(maxCompBytes, 24 + (i * 8)); } //assumes maybe estimation mode
@@ -182,7 +182,7 @@ public void checkWrapBadFamily() {
final UpdateSketch sketch = UpdateSketch.builder().setFamily(Family.ALPHA).setNominalEntries(1024).build();
final byte[] byteArr = sketch.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(byteArr);
- Sketch.wrap(srcSeg);
+ ThetaSketch.wrap(srcSeg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -196,7 +196,7 @@ public void checkSerVer() {
final UpdateSketch sketch = UpdateSketch.builder().setNominalEntries(1024).build();
final byte[] sketchArray = sketch.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(sketchArray);
- int serVer = Sketch.getSerializationVersion(seg);
+ int serVer = ThetaSketch.getSerializationVersion(seg);
assertEquals(serVer, 3);
final MemorySegment wseg = MemorySegment.ofArray(sketchArray);
final UpdateSketch sk2 = UpdateSketch.wrap(wseg);
@@ -207,36 +207,36 @@ public void checkSerVer() {
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkHeapifyAlphaCompactExcep() {
final int k = 512;
- final Sketch sketch1 = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ final ThetaSketch sketch1 = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
final byte[] byteArray = sketch1.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
//corrupt:
Util.setBits(seg, FLAGS_BYTE, (byte) COMPACT_FLAG_MASK);
- Sketch.heapify(seg);
+ ThetaSketch.heapify(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkHeapifyQSCompactExcep() {
final int k = 512;
- final Sketch sketch1 = UpdateSketch.builder().setFamily(QUICKSELECT).setNominalEntries(k).build();
+ final ThetaSketch sketch1 = UpdateSketch.builder().setFamily(QUICKSELECT).setNominalEntries(k).build();
final byte[] byteArray = sketch1.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
//corrupt:
Util.setBits(seg, FLAGS_BYTE, (byte) COMPACT_FLAG_MASK);
- Sketch.heapify(seg);
+ ThetaSketch.heapify(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkHeapifyNotCompactExcep() {
final int k = 512;
final UpdateSketch sketch1 = UpdateSketch.builder().setFamily(QUICKSELECT).setNominalEntries(k).build();
- final int bytes = Sketch.getMaxCompactSketchBytes(0);
+ final int bytes = ThetaSketch.getMaxCompactSketchBytes(0);
final byte[] byteArray = new byte[bytes];
final MemorySegment seg = MemorySegment.ofArray(byteArray);
sketch1.compact(false, seg);
//corrupt:
Util.clearBits(seg, FLAGS_BYTE, (byte) COMPACT_FLAG_MASK);
- Sketch.heapify(seg);
+ ThetaSketch.heapify(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -246,50 +246,50 @@ public void checkHeapifyFamilyExcep() {
final byte[] byteArray = union.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
//Improper use
- Sketch.heapify(seg);
+ ThetaSketch.heapify(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkWrapAlphaCompactExcep() {
final int k = 512;
- final Sketch sketch1 = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ final ThetaSketch sketch1 = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
final byte[] byteArray = sketch1.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
//corrupt:
Util.setBits(seg, FLAGS_BYTE, (byte) COMPACT_FLAG_MASK);
- Sketch.wrap(seg);
+ ThetaSketch.wrap(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkWrapQSCompactExcep() {
final int k = 512;
- final Sketch sketch1 = UpdateSketch.builder().setFamily(QUICKSELECT).setNominalEntries(k).build();
+ final ThetaSketch sketch1 = UpdateSketch.builder().setFamily(QUICKSELECT).setNominalEntries(k).build();
final byte[] byteArray = sketch1.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
//corrupt:
Util.setBits(seg, FLAGS_BYTE, (byte) COMPACT_FLAG_MASK);
- Sketch.wrap(seg);
+ ThetaSketch.wrap(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkWrapNotCompactExcep() {
final int k = 512;
final UpdateSketch sketch1 = UpdateSketch.builder().setFamily(QUICKSELECT).setNominalEntries(k).build();
- final int bytes = Sketch.getMaxCompactSketchBytes(0);
+ final int bytes = ThetaSketch.getMaxCompactSketchBytes(0);
final byte[] byteArray = new byte[bytes];
final MemorySegment seg = MemorySegment.ofArray(byteArray);
sketch1.compact(false, seg);
//corrupt:
Util.clearBits(seg, FLAGS_BYTE, (byte) COMPACT_FLAG_MASK);
- Sketch.wrap(seg);
+ ThetaSketch.wrap(seg);
}
@Test
public void checkValidSketchID() {
- assertFalse(Sketch.isValidSketchID(0));
- assertTrue(Sketch.isValidSketchID(ALPHA.getID()));
- assertTrue(Sketch.isValidSketchID(QUICKSELECT.getID()));
- assertTrue(Sketch.isValidSketchID(COMPACT.getID()));
+ assertFalse(ThetaSketch.isValidSketchID(0));
+ assertTrue(ThetaSketch.isValidSketchID(ALPHA.getID()));
+ assertTrue(ThetaSketch.isValidSketchID(QUICKSELECT.getID()));
+ assertTrue(ThetaSketch.isValidSketchID(COMPACT.getID()));
}
@Test
@@ -325,7 +325,7 @@ public void checkCountLessThanTheta() {
private static MemorySegment createCompactSketchMemorySegment(final int k, final int u) {
final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build();
for (int i = 0; i < u; i++) { usk.update(i); }
- final int bytes = Sketch.getMaxCompactSketchBytes(usk.getRetainedEntries(true));
+ final int bytes = ThetaSketch.getMaxCompactSketchBytes(usk.getRetainedEntries(true));
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
usk.compact(true, wseg);
return wseg;
@@ -334,27 +334,27 @@ private static MemorySegment createCompactSketchMemorySegment(final int k, final
@Test
public void checkCompactFlagsOnWrap() {
final MemorySegment wseg = createCompactSketchMemorySegment(16, 32);
- Sketch sk = Sketch.wrap(wseg);
+ ThetaSketch sk = ThetaSketch.wrap(wseg);
assertTrue(sk instanceof CompactSketch);
final int flags = PreambleUtil.extractFlags(wseg);
final int flagsNoCompact = flags & ~COMPACT_FLAG_MASK;
PreambleUtil.insertFlags(wseg, flagsNoCompact);
try {
- sk = Sketch.wrap(wseg);
+ sk = ThetaSketch.wrap(wseg);
fail();
} catch (final SketchesArgumentException e) { }
final int flagsNoReadOnly = flags & ~READ_ONLY_FLAG_MASK;
PreambleUtil.insertFlags(wseg, flagsNoReadOnly);
try {
- sk = Sketch.wrap(wseg);
+ sk = ThetaSketch.wrap(wseg);
fail();
} catch (final SketchesArgumentException e) { }
PreambleUtil.insertFlags(wseg, flags); //repair to original
PreambleUtil.insertSerVer(wseg, 5);
try {
- sk = Sketch.wrap(wseg);
+ sk = ThetaSketch.wrap(wseg);
fail();
} catch (final SketchesArgumentException e) { }
}
@@ -362,14 +362,14 @@ public void checkCompactFlagsOnWrap() {
@Test
public void checkCompactSizeAndFlagsOnHeapify() {
MemorySegment wseg = createCompactSketchMemorySegment(16, 32);
- Sketch sk = Sketch.heapify(wseg);
+ ThetaSketch sk = ThetaSketch.heapify(wseg);
assertTrue(sk instanceof CompactSketch);
final int flags = PreambleUtil.extractFlags(wseg);
final int flagsNoCompact = flags & ~READ_ONLY_FLAG_MASK;
PreambleUtil.insertFlags(wseg, flagsNoCompact);
try {
- sk = Sketch.heapify(wseg);
+ sk = ThetaSketch.heapify(wseg);
fail();
} catch (final SketchesArgumentException e) { }
@@ -377,7 +377,7 @@ public void checkCompactSizeAndFlagsOnHeapify() {
PreambleUtil.insertSerVer(wseg, 3);
//PreambleUtil.insertFamilyID(wseg, 3);
try {
- sk = Sketch.heapify(wseg);
+ sk = ThetaSketch.heapify(wseg);
fail();
} catch (final SketchesArgumentException e) { }
}
@@ -385,7 +385,7 @@ public void checkCompactSizeAndFlagsOnHeapify() {
@Test
public void check2Methods() {
final int k = 16;
- final Sketch sk = UpdateSketch.builder().setNominalEntries(k).build();
+ final ThetaSketch sk = UpdateSketch.builder().setNominalEntries(k).build();
final int bytes1 = sk.getCompactBytes();
final int bytes2 = sk.getCurrentBytes();
assertEquals(bytes1, 8);
diff --git a/src/test/java/org/apache/datasketches/theta/UnionImplTest.java b/src/test/java/org/apache/datasketches/theta/UnionImplTest.java
index 1cc7c76e7..98fdfb582 100644
--- a/src/test/java/org/apache/datasketches/theta/UnionImplTest.java
+++ b/src/test/java/org/apache/datasketches/theta/UnionImplTest.java
@@ -150,7 +150,7 @@ public void checkCorruptFamilyException() {
public void checkMoveAndResizeOffHeap() {
final int k = 1 << 12;
final int u = 2 * k;
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
MemorySegment skWseg, uWseg;
try (Arena arena = Arena.ofConfined()) {
skWseg = arena.allocate(bytes / 2); //we never populate the sketch so this size is not relevant
@@ -203,7 +203,7 @@ public void checkUnionCompactOrderedSource() {
for (int i = 0; i < k; i++) { sk.update(i); }
final double est1 = sk.getEstimate();
- final int bytes = Sketch.getCompactSketchMaxBytes(lgK);
+ final int bytes = ThetaSketch.getCompactSketchMaxBytes(lgK);
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = arena.allocate(bytes);
@@ -220,7 +220,7 @@ public void checkUnionCompactOrderedSource() {
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkCompactFlagCorruption() {
final int k = 1 << 12;
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
final MemorySegment wseg1 = MemorySegment.ofArray(new byte[bytes]);
final UpdateSketch sk = UpdateSketch.builder().setNominalEntries(k).build(wseg1);
for (int i = 0; i < k; i++) { sk.update(i); }
diff --git a/src/test/java/org/apache/datasketches/theta/UpdateSketchTest.java b/src/test/java/org/apache/datasketches/theta/UpdateSketchTest.java
index a3bdaa221..00dbb6c70 100644
--- a/src/test/java/org/apache/datasketches/theta/UpdateSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/UpdateSketchTest.java
@@ -173,13 +173,13 @@ public void checkCorruption() {
final MemorySegment wseg = MemorySegment.ofArray(sk.toByteArray());
try {
wseg.set(JAVA_BYTE, SER_VER_BYTE, (byte) 2);
- Sketch.wrap(wseg, Util.DEFAULT_UPDATE_SEED);
+ ThetaSketch.wrap(wseg, Util.DEFAULT_UPDATE_SEED);
fail();
} catch (final SketchesArgumentException e) { }
try {
wseg.set(JAVA_BYTE, SER_VER_BYTE, (byte) 3);
wseg.set(JAVA_BYTE, PREAMBLE_LONGS_BYTE, (byte) 2);
- Sketch.wrap(wseg, Util.DEFAULT_UPDATE_SEED);
+ ThetaSketch.wrap(wseg, Util.DEFAULT_UPDATE_SEED);
fail();
} catch (final SketchesArgumentException e) { }
}
diff --git a/src/test/java/org/apache/datasketches/tuple/adouble/AdoubleAnotBTest.java b/src/test/java/org/apache/datasketches/tuple/adouble/AdoubleAnotBTest.java
index a878e50dc..c8b4a8135 100644
--- a/src/test/java/org/apache/datasketches/tuple/adouble/AdoubleAnotBTest.java
+++ b/src/test/java/org/apache/datasketches/tuple/adouble/AdoubleAnotBTest.java
@@ -49,7 +49,7 @@ private static void threeMethodsWithTheta(
final AnotB
The resulting sketch will not retain any link to the source MemorySegment and all of its data will be - * copied to the heap CompactSketch.
+ * copied to the heap CompactThetaSketch. * *The {@link Util#DEFAULT_UPDATE_SEED DEFAULT_UPDATE_SEED} is assumed.
* - * @param srcSeg an image of a CompactSketch. - * @return a CompactSketch on the heap. + * @param srcSeg an image of a CompactThetaSketch. + * @return a CompactThetaSketch on the heap. */ - public static CompactSketch heapify(final MemorySegment srcSeg) { + public static CompactThetaSketch heapify(final MemorySegment srcSeg) { return heapify(srcSeg, Util.DEFAULT_UPDATE_SEED); } /** - * Heapify takes a CompactSketch image in a MemorySegment and instantiates an on-heap CompactSketch. + * Heapify takes a CompactThetaSketch image in a MemorySegment and instantiates an on-heap CompactThetaSketch. * *The resulting sketch will not retain any link to the source MemorySegment and all of its data will be - * copied to the heap CompactSketch.
+ * copied to the heap CompactThetaSketch. * *This method checks if the given expectedSeed was used to create the source MemorySegment image.
* - * @param srcSeg an image of a CompactSketch that was created using the given expectedSeed. + * @param srcSeg an image of a CompactThetaSketch that was created using the given expectedSeed. * @param expectedSeed the seed used to validate the given MemorySegment image. * See Update Hash Seed. - * @return a CompactSketch on the heap. + * @return a CompactThetaSketch on the heap. */ - public static CompactSketch heapify(final MemorySegment srcSeg, final long expectedSeed) { + public static CompactThetaSketch heapify(final MemorySegment srcSeg, final long expectedSeed) { final int serVer = extractSerVer(srcSeg); final int familyID = extractFamilyID(srcSeg); final Family family = idToFamily(familyID); @@ -111,7 +111,7 @@ public static CompactSketch heapify(final MemorySegment srcSeg, final long expec } /** - * Wrap takes the CompactSketch image in given MemorySegment and refers to it directly. + * Wrap takes the CompactThetaSketch image in given MemorySegment and refers to it directly. * There is no data copying onto the java heap. * The wrap operation enables fast read-only merging and access to all the public read-only API. * @@ -121,10 +121,10 @@ public static CompactSketch heapify(final MemorySegment srcSeg, final long expec * *The {@link Util#DEFAULT_UPDATE_SEED DEFAULT_UPDATE_SEED} is assumed.
* - * @param srcSeg an image of a Sketch. - * @return a CompactSketch backed by the given MemorySegment. + * @param srcSeg an image of a CompactThetaSketch. + * @return a CompactThetaSketch backed by the given MemorySegment. */ - public static CompactSketch wrap(final MemorySegment srcSeg) { + public static CompactThetaSketch wrap(final MemorySegment srcSeg) { return wrap(srcSeg, Util.DEFAULT_UPDATE_SEED); } @@ -139,12 +139,12 @@ public static CompactSketch wrap(final MemorySegment srcSeg) { * *This method checks if the given expectedSeed was used to create the source MemorySegment image.
* - * @param srcSeg an image of a Sketch that was created using the given expectedSeed. + * @param srcSeg an image of a CompactThetaSketch that was created using the given expectedSeed. * @param expectedSeed the seed used to validate the given MemorySegment image. * See Update Hash Seed. - * @return a CompactSketch backed by the given MemorySegment. + * @return a CompactThetaketch backed by the given MemorySegment. */ - public static CompactSketch wrap(final MemorySegment srcSeg, final long expectedSeed) { + public static CompactThetaSketch wrap(final MemorySegment srcSeg, final long expectedSeed) { final int serVer = extractSerVer(srcSeg); final int familyID = extractFamilyID(srcSeg); final Family family = Family.idToFamily(familyID); @@ -196,11 +196,11 @@ public static CompactSketch wrap(final MemorySegment srcSeg, final long expected * *This method checks if the DEFAULT_UPDATE_SEED was used to create the source byte array image.
* - * @param bytes a byte array image of a Sketch that was created using the DEFAULT_UPDATE_SEED. + * @param bytes a byte array image of a CompactThetaSketch that was created using the DEFAULT_UPDATE_SEED. * - * @return a CompactSketch backed by the given byte array except as above. + * @return a CompactThetaSketch backed by the given byte array except as above. */ - public static CompactSketch wrap(final byte[] bytes) { + public static CompactThetaSketch wrap(final byte[] bytes) { return wrap(bytes, Util.DEFAULT_UPDATE_SEED); } @@ -217,12 +217,12 @@ public static CompactSketch wrap(final byte[] bytes) { * *This method checks if the given expectedSeed was used to create the source byte array image.
* - * @param bytes a byte array image of a Sketch that was created using the given expectedSeed. + * @param bytes a byte array image of a CompactThetaSketch that was created using the given expectedSeed. * @param expectedSeed the seed used to validate the given byte array image. * See Update Hash Seed. - * @return a CompactSketch backed by the given byte array except as above. + * @return a CompactThetaSketch backed by the given byte array except as above. */ - public static CompactSketch wrap(final byte[] bytes, final long expectedSeed) { + public static CompactThetaSketch wrap(final byte[] bytes, final long expectedSeed) { final int serVer = bytes[PreambleUtil.SER_VER_BYTE]; final int familyId = bytes[PreambleUtil.FAMILY_BYTE]; final Family family = Family.idToFamily(familyId); @@ -261,10 +261,10 @@ public static CompactSketch wrap(final byte[] bytes, final long expectedSeed) { "Corrupted: Serialization Version " + serVer + " not recognized."); } - //Sketch Overrides + //ThetaSketch Overrides @Override - public abstract CompactSketch compact(final boolean dstOrdered, final MemorySegment dstSeg); + public abstract CompactThetaSketch compact(final boolean dstOrdered, final MemorySegment dstSeg); @Override public int getCompactBytes() { @@ -385,7 +385,7 @@ private byte[] toByteArrayV4() { return bytes; } - private static CompactSketch heapifyV4(final MemorySegment srcSeg, final long seed) { + private static CompactThetaSketch heapifyV4(final MemorySegment srcSeg, final long seed) { final int preLongs = ThetaSketch.getPreambleLongs(srcSeg); final int entryBits = extractEntryBitsV4(srcSeg); final int numEntriesBytes = extractNumEntriesBytesV4(srcSeg); diff --git a/src/main/java/org/apache/datasketches/theta/ConcurrentBackgroundThetaPropagation.java b/src/main/java/org/apache/datasketches/theta/ConcurrentBackgroundThetaPropagation.java index b3e863532..c12f8aa4e 100644 --- a/src/main/java/org/apache/datasketches/theta/ConcurrentBackgroundThetaPropagation.java +++ b/src/main/java/org/apache/datasketches/theta/ConcurrentBackgroundThetaPropagation.java @@ -39,7 +39,7 @@ final class ConcurrentBackgroundThetaPropagation implements Runnable { // local buffer. Updated when the propagation completes. private final AtomicBoolean localPropagationInProgress; - // Sketch to be propagated to shared sketch. Can be null if only a single hash is propagated + // ThetaSketch to be propagated to shared sketch. Can be null if only a single hash is propagated private final ThetaSketch sketchIn; // Hash of the datum to be propagated to shared sketch. Can be ConcurrentSharedThetaSketch.NOT_SINGLE_HASH diff --git a/src/main/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketch.java b/src/main/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketch.java index 76aac8d9d..5a0bbf22f 100644 --- a/src/main/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketch.java +++ b/src/main/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketch.java @@ -88,7 +88,7 @@ final class ConcurrentDirectQuickSelectSketch extends DirectQuickSelectSketch initBgPropagationService(); } - ConcurrentDirectQuickSelectSketch(final UpdateSketch sketch, final long seed, + ConcurrentDirectQuickSelectSketch(final UpdatableThetaSketch sketch, final long seed, final double maxConcurrencyError, final MemorySegment dstSeg) { super(sketch.getLgNomLongs(), seed, 1.0F, //p ResizeFactor.X1, //rf, @@ -109,7 +109,7 @@ final class ConcurrentDirectQuickSelectSketch extends DirectQuickSelectSketch updateEstimationSnapshot(); } - //Sketch overrides + //ThetaSketch overrides @Override public double getEstimate() { @@ -129,10 +129,10 @@ public byte[] toByteArray() { return res; } - //UpdateSketch overrides + //UpdatableThetaSketch overrides @Override - public UpdateSketch rebuild() { + public UpdatableThetaSketch rebuild() { super.rebuild(); updateEstimationSnapshot(); return this; diff --git a/src/main/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketch.java b/src/main/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketch.java index dddfd1548..bc7876f10 100644 --- a/src/main/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketch.java +++ b/src/main/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketch.java @@ -27,7 +27,7 @@ import org.apache.datasketches.common.SuppressFBWarnings; /** - * A concurrent shared sketch that is based on HeapQuickSelectSketch. + * A concurrent shared sketch that is based on HeapQuickSelectThetaSketch. * It reflects all data processed by a single or multiple update threads, and can serve queries at * any time. * Background propagation threads are used to propagate data from thread local buffers into this @@ -82,7 +82,7 @@ final class ConcurrentHeapQuickSelectSketch extends HeapQuickSelectSketch initBgPropagationService(); } - ConcurrentHeapQuickSelectSketch(final UpdateSketch sketch, final long seed, + ConcurrentHeapQuickSelectSketch(final UpdatableThetaSketch sketch, final long seed, final double maxConcurrencyError) { super(sketch.getLgNomLongs(), seed, 1.0F, //p ResizeFactor.X1, //rf, @@ -101,7 +101,7 @@ final class ConcurrentHeapQuickSelectSketch extends HeapQuickSelectSketch updateEstimationSnapshot(); } - //Sketch overrides + //ThetaSketch overrides @Override public double getEstimate() { @@ -121,10 +121,10 @@ public byte[] toByteArray() { return res; } - //UpdateSketch overrides + //UpdatableThetaSketch overrides @Override - public UpdateSketch rebuild() { + public UpdatableThetaSketch rebuild() { super.rebuild(); updateEstimationSnapshot(); return this; diff --git a/src/main/java/org/apache/datasketches/theta/ConcurrentHeapThetaBuffer.java b/src/main/java/org/apache/datasketches/theta/ConcurrentHeapThetaBuffer.java index 2071b74ce..ffe831020 100644 --- a/src/main/java/org/apache/datasketches/theta/ConcurrentHeapThetaBuffer.java +++ b/src/main/java/org/apache/datasketches/theta/ConcurrentHeapThetaBuffer.java @@ -42,10 +42,10 @@ * Propagation is done either synchronously by the updating thread, or asynchronously by a * background propagation thread. * - *This is a buffer, not a sketch, and it extends the HeapQuickSelectSketch + *
This is a buffer, not a sketch, and it extends the HeapQuickSelectThetaSketch * in order to leverage some of the sketch machinery to make its work simple. However, if this * buffer receives a query, like getEstimate(), the correct answer does not come from the super - * HeapQuickSelectSketch, which knows nothing about the concurrency relationship to the + * HeapQuickSelectThetaSketch, which knows nothing about the concurrency relationship to the * shared concurrent sketch, it must come from the shared concurrent sketch. As a result nearly all * of the inherited sketch methods are redirected to the shared concurrent sketch. * @@ -111,7 +111,7 @@ private void propagateToSharedSketch() { //no inspection StatementWithEmptyBody while (localPropagationInProgress.get()) { /* busy wait until previous propagation completed */ } - final CompactSketch compactSketch = compact(propagateOrderedCompact, null); + final CompactThetaSketch compactSketch = compact(propagateOrderedCompact, null); localPropagationInProgress.set(true); shared.propagate(localPropagationInProgress, compactSketch, ConcurrentSharedThetaSketch.NOT_SINGLE_HASH); @@ -119,7 +119,7 @@ private void propagateToSharedSketch() { thetaLong_ = shared.getVolatileTheta(); } - //Public Sketch overrides proxies to shared concurrent sketch + //Public ThetaSketch overrides proxies to shared ConcurrentThetaSketch @Override public int getCompactBytes() { @@ -178,7 +178,7 @@ public byte[] toByteArray() { throw new UnsupportedOperationException("Local theta buffer need not be serialized"); } - //Public UpdateSketch overrides + //Public UpdatableThetaSketch overrides @Override public void reset() { @@ -187,7 +187,7 @@ public void reset() { localPropagationInProgress.set(false); } - //Restricted UpdateSketch overrides + //Restricted UpdatableThetaSketch overrides /** * Updates buffer with given hash value. diff --git a/src/main/java/org/apache/datasketches/theta/ConcurrentSharedThetaSketch.java b/src/main/java/org/apache/datasketches/theta/ConcurrentSharedThetaSketch.java index cef561d58..eeb207d3c 100644 --- a/src/main/java/org/apache/datasketches/theta/ConcurrentSharedThetaSketch.java +++ b/src/main/java/org/apache/datasketches/theta/ConcurrentSharedThetaSketch.java @@ -124,11 +124,11 @@ boolean propagate(final AtomicBoolean localPropagationInProgress, final ThetaSke //well as the methods below. // //For the external user all of the below methods can be obtained by casting the shared - //sketch to UpdateSketch. However, these methods here also act as an alias so that an + //sketch to UpdatableThetaSketch. However, these methods here also act as an alias so that an //attempt to access these methods from the local buffer will be diverted to the shared //sketch. - //From Sketch and MemoryStatus + //From ThetaSketch and MemoryStatus int getCompactBytes(); @@ -148,11 +148,11 @@ boolean propagate(final AtomicBoolean localPropagationInProgress, final ThetaSke int getRetainedEntries(boolean valid); - CompactSketch compact(); + CompactThetaSketch compact(); - CompactSketch compact(boolean ordered, MemorySegment wseg); + CompactThetaSketch compact(boolean ordered, MemorySegment wseg); - UpdateSketch rebuild(); + UpdatableThetaSketch rebuild(); void reset(); } diff --git a/src/main/java/org/apache/datasketches/theta/DirectCompactCompressedSketch.java b/src/main/java/org/apache/datasketches/theta/DirectCompactCompressedSketch.java index f0b850eb7..9f37241d2 100644 --- a/src/main/java/org/apache/datasketches/theta/DirectCompactCompressedSketch.java +++ b/src/main/java/org/apache/datasketches/theta/DirectCompactCompressedSketch.java @@ -49,7 +49,7 @@ final class DirectCompactCompressedSketch extends DirectCompactSketch { } /** - * Wraps the given MemorySegment, which must be a SerVer 4 compressed CompactSketch image. + * Wraps the given MemorySegment, which must be a SerVer 4 compressed CompactThetaSketch image. * Must check the validity of the MemorySegment before calling. * @param srcSeg The source MemorySegment * @param seedHash The update seedHash. @@ -61,15 +61,15 @@ static DirectCompactCompressedSketch wrapInstance(final MemorySegment srcSeg, fi return new DirectCompactCompressedSketch(srcSeg); } - //Sketch Overrides + //ThetaSketch Overrides @Override - public CompactSketch compact(final boolean dstOrdered, final MemorySegment dstSeg) { + public CompactThetaSketch compact(final boolean dstOrdered, final MemorySegment dstSeg) { if (dstSeg != null) { MemorySegment.copy(seg_, 0, dstSeg, 0, getCurrentBytes()); return new DirectCompactSketch(dstSeg); } - return CompactSketch.heapify(seg_, Util.DEFAULT_UPDATE_SEED); + return CompactThetaSketch.heapify(seg_, Util.DEFAULT_UPDATE_SEED); } @Override @@ -84,7 +84,7 @@ public int getCurrentBytes() { private static final int START_PACKED_DATA_ESTIMATION_MODE = 16; @Override - public int getRetainedEntries(final boolean valid) { //valid is only relevant for the Alpha Sketch + public int getRetainedEntries(final boolean valid) { //valid is only relevant for the AlphaSketch // number of entries is stored using variable length encoding // most significant bytes with all zeros are not stored // one byte in the preamble has the number of non-zero bytes used diff --git a/src/main/java/org/apache/datasketches/theta/DirectCompactSketch.java b/src/main/java/org/apache/datasketches/theta/DirectCompactSketch.java index b5794aeb6..749d8dfed 100644 --- a/src/main/java/org/apache/datasketches/theta/DirectCompactSketch.java +++ b/src/main/java/org/apache/datasketches/theta/DirectCompactSketch.java @@ -47,7 +47,7 @@ * * @author Lee Rhodes */ -class DirectCompactSketch extends CompactSketch { +class DirectCompactSketch extends CompactThetaSketch { final MemorySegment seg_; /** @@ -59,7 +59,7 @@ class DirectCompactSketch extends CompactSketch { } /** - * Wraps the given MemorySegment, which must be a SerVer 3, CompactSketch image. + * Wraps the given MemorySegment, which must be a SerVer 3, CompactThetaSketch image. * Must check the validity of the MemorySegment before calling. The order bit must be set properly. * @param srcSeg the given MemorySegment * @param seedHash The update seedHash. @@ -71,10 +71,10 @@ static DirectCompactSketch wrapInstance(final MemorySegment srcSeg, final short return new DirectCompactSketch(srcSeg); } - //Sketch Overrides + //ThetaSketch Overrides @Override - public CompactSketch compact(final boolean dstOrdered, final MemorySegment dstSeg) { + public CompactThetaSketch compact(final boolean dstOrdered, final MemorySegment dstSeg) { return segmentToCompact(seg_, dstOrdered, dstSeg); } @@ -87,7 +87,7 @@ public int getCurrentBytes() { } @Override - public int getRetainedEntries(final boolean valid) { //valid is only relevant for the Alpha Sketch + public int getRetainedEntries(final boolean valid) { //valid is only relevant for the AlphaSketch if (checkForSingleItem(seg_)) { return 1; } final int preLongs = ThetaSketch.getPreambleLongs(seg_); return (preLongs == 1) ? 0 : extractCurCount(seg_); diff --git a/src/main/java/org/apache/datasketches/theta/DirectQuickSelectSketch.java b/src/main/java/org/apache/datasketches/theta/DirectQuickSelectSketch.java index d1cbb740f..2172a1f65 100644 --- a/src/main/java/org/apache/datasketches/theta/DirectQuickSelectSketch.java +++ b/src/main/java/org/apache/datasketches/theta/DirectQuickSelectSketch.java @@ -68,7 +68,7 @@ import org.apache.datasketches.thetacommon.ThetaUtil; /** - * The default Theta Sketch using the QuickSelect algorithm. + * The UpdatableThetaSketch using the QuickSelect algorithm in a MemorySegment. * This subclass implements methods, which affect the state (update, rebuild, reset) * *
This implementation uses data in a given MemorySegment that is owned and managed by the caller. @@ -110,8 +110,8 @@ private DirectQuickSelectSketch( * @param dstSeg the given MemorySegment object destination. It cannot be null. * It will be cleared prior to use. * @param mSegReq an implementation of the MemorySegmentRequest interface or null. - * @param unionGadget true if this sketch is implementing the Union gadget function. - * Otherwise, it is behaving as a normal QuickSelectSketch. + * @param unionGadget true if this sketch is implementing the ThetaUnion gadget function. + * Otherwise, it is behaving as a normal QuickSelectThetaSketch. */ DirectQuickSelectSketch( final int lgNomLongs, @@ -170,7 +170,7 @@ private DirectQuickSelectSketch( * @param seed See Update Hash Seed * @return instance of this sketch */ - //called from UnionImpl and UpdateSketch + //called from ThetaUnionImpl and UpdatableThetaSketch static DirectQuickSelectSketch writableWrap( final MemorySegment srcSeg, final MemorySegmentRequest mSegReq, @@ -179,7 +179,7 @@ static DirectQuickSelectSketch writableWrap( final int lgNomLongs = extractLgNomLongs(srcSeg); //byte 3 final int lgArrLongs = extractLgArrLongs(srcSeg); //byte 4 - UpdateSketch.checkUnionAndQuickSelectFamily(srcSeg, preambleLongs, lgNomLongs); + UpdatableThetaSketch.checkUnionAndQuickSelectFamily(srcSeg, preambleLongs, lgNomLongs); checkSegIntegrity(srcSeg, seed, preambleLongs, lgNomLongs, lgArrLongs); if (isResizeFactorIncorrect(srcSeg, lgNomLongs, lgArrLongs)) { @@ -200,7 +200,7 @@ static DirectQuickSelectSketch writableWrap( * @param seed See Update Hash Seed * @return instance of this sketch */ - //called from UnionImpl <- Union + //called from ThetaUnionImpl <- ThetaUnion static DirectQuickSelectSketch fastWritableWrap( final MemorySegment srcSeg, final MemorySegmentRequest mSegReq, @@ -213,12 +213,12 @@ static DirectQuickSelectSketch fastWritableWrap( return dqss; } - //Sketch + //ThetaSketch - //UpdateSketch + //UpdatableThetaSketch @Override - public UpdateSketch rebuild() { + public UpdatableThetaSketch rebuild() { final int lgNomLongs = getLgNomLongs(); final int preambleLongs = wseg_.get(JAVA_BYTE, PREAMBLE_LONGS_BYTE) & 0X3F; if (getRetainedEntries(true) > 1 << lgNomLongs) { diff --git a/src/main/java/org/apache/datasketches/theta/DirectQuickSelectSketchR.java b/src/main/java/org/apache/datasketches/theta/DirectQuickSelectSketchR.java index 7b07d660f..37fabf844 100644 --- a/src/main/java/org/apache/datasketches/theta/DirectQuickSelectSketchR.java +++ b/src/main/java/org/apache/datasketches/theta/DirectQuickSelectSketchR.java @@ -33,11 +33,11 @@ import static org.apache.datasketches.theta.PreambleUtil.P_FLOAT; import static org.apache.datasketches.theta.PreambleUtil.RETAINED_ENTRIES_INT; import static org.apache.datasketches.theta.PreambleUtil.THETA_LONG; +import static org.apache.datasketches.theta.PreambleUtil.checkSegPreambleCap; import static org.apache.datasketches.theta.PreambleUtil.extractCurCount; import static org.apache.datasketches.theta.PreambleUtil.extractLgArrLongs; import static org.apache.datasketches.theta.PreambleUtil.extractLgNomLongs; import static org.apache.datasketches.theta.PreambleUtil.extractThetaLong; -import static org.apache.datasketches.theta.PreambleUtil.checkSegPreambleCap; import static org.apache.datasketches.theta.PreambleUtil.insertThetaLong; import java.lang.foreign.MemorySegment; @@ -49,7 +49,7 @@ import org.apache.datasketches.common.SketchesReadOnlyException; /** - * The read-only Theta Sketch. + * The read-only ThetaSketch in a MemorySegment. * *
This implementation uses data in a given MemorySegment that is owned and managed by the caller. * This MemorySegment can be off-heap, which if managed properly will greatly reduce the need for @@ -58,12 +58,12 @@ * @author Lee Rhodes * @author Kevin Lang */ -class DirectQuickSelectSketchR extends UpdateSketch { +class DirectQuickSelectSketchR extends UpdatableThetaSketch { /** - * This MemorySegment reference is also used by the writable child DirectQuickSelectSketch. + * This MemorySegment reference is also used by the writable child DirectQuickSelectThetaSketch. * - *
When this class is constructed with the writable constructor, called by the writable child DirectQuickSelectSketch, + *
When this class is constructed with the writable constructor, called by the writable child DirectQuickSelectThetaSketch, * this reference can be changed, its contents can be modified.
* *When this class is constructed with the read-only constructor, called from local factories, this MemorySegment will @@ -72,10 +72,10 @@ class DirectQuickSelectSketchR extends UpdateSketch { MemorySegment wseg_; // /** - * This writable constructor is only called by the writable child DirectQuickSelectSketch and then this class provides the - * read-only methods for the DirectQuickSelectSketch class. - * @param wseg the writable MemorySegment used by the writable child DirectQuickSelectSketch. - * @param seed the seed for the update function for the writable child DirectQuickSelectSketch. + * This writable constructor is only called by the writable child DirectQuickSelectThetaSketch and then this class provides the + * read-only methods for the DirectQuickSelectThetaSketch class. + * @param wseg the writable MemorySegment used by the writable child DirectQuickSelectThetaSketch. + * @param seed the seed for the update function for the writable child DirectQuickSelectThetaSketch. */ DirectQuickSelectSketchR(final MemorySegment wseg, final long seed) { Objects.requireNonNull(wseg, "MemorySegment wseg must not be null"); @@ -106,7 +106,7 @@ static DirectQuickSelectSketchR readOnlyWrap(final MemorySegment srcSeg, final l final int lgNomLongs = extractLgNomLongs(srcSeg); //byte 3 final int lgArrLongs = extractLgArrLongs(srcSeg); //byte 4 checkSegIntegrity(srcSeg, seed, preambleLongs, lgNomLongs, lgArrLongs); - UpdateSketch.checkUnionAndQuickSelectFamily(srcSeg, preambleLongs, lgNomLongs); + UpdatableThetaSketch.checkUnionAndQuickSelectFamily(srcSeg, preambleLongs, lgNomLongs); return new DirectQuickSelectSketchR(seed, srcSeg); } @@ -122,7 +122,7 @@ static DirectQuickSelectSketchR fastReadOnlyWrap(final MemorySegment srcSeg, fin return new DirectQuickSelectSketchR(seed, srcSeg); } - //Sketch + //ThetaSketch @Override public int getCurrentBytes() { @@ -146,7 +146,7 @@ public Family getFamily() { } @Override - public int getRetainedEntries(final boolean valid) { //valid is only relevant for the Alpha Sketch + public int getRetainedEntries(final boolean valid) { //valid is only relevant for the AlphaSketch return wseg_.get(JAVA_INT_UNALIGNED, RETAINED_ENTRIES_INT); } @@ -193,7 +193,7 @@ public byte[] toByteArray() { //MY_FAMILY is stored in wseg_ return byteArray; } - //UpdateSketch + //UpdatableThetaSketch @Override public final int getLgNomLongs() { @@ -211,7 +211,7 @@ public ResizeFactor getResizeFactor() { } @Override - public UpdateSketch rebuild() { + public UpdatableThetaSketch rebuild() { throw new SketchesReadOnlyException(); } @@ -253,7 +253,7 @@ short getSeedHash() { @Override boolean isDirty() { - return false; //Always false for QuickSelectSketch + return false; //Always false for QuickSelectThetaSketch } @Override diff --git a/src/main/java/org/apache/datasketches/theta/EmptyCompactSketch.java b/src/main/java/org/apache/datasketches/theta/EmptyCompactSketch.java index 793ce1763..a5ffed2f7 100644 --- a/src/main/java/org/apache/datasketches/theta/EmptyCompactSketch.java +++ b/src/main/java/org/apache/datasketches/theta/EmptyCompactSketch.java @@ -27,11 +27,11 @@ import org.apache.datasketches.common.SketchesArgumentException; /** - * Singleton empty CompactSketch. + * Singleton empty CompactThetaSketch. * * @author Lee Rhodes */ -final class EmptyCompactSketch extends CompactSketch { +final class EmptyCompactSketch extends CompactThetaSketch { //For backward compatibility, a candidate long must have Flags= compact, read-only, // COMPACT-Family=3, SerVer=3, PreLongs=1, and be exactly 8 bytes long. The seedHash is ignored. @@ -64,7 +64,7 @@ static synchronized EmptyCompactSketch getHeapInstance(final MemorySegment srcSe // This returns with ordered flag = true independent of dstOrdered. // This is required for fast detection. // The hashSeed is ignored and set == 0. - public CompactSketch compact(final boolean dstOrdered, final MemorySegment dstWSeg) { + public CompactThetaSketch compact(final boolean dstOrdered, final MemorySegment dstWSeg) { if (dstWSeg == null) { return EmptyCompactSketch.getInstance(); } //dstWSeg.putByteArray(0, EMPTY_COMPACT_SKETCH_ARR, 0, 8); MemorySegment.copy(EMPTY_COMPACT_SKETCH_ARR, 0, dstWSeg, JAVA_BYTE, 0, 8); @@ -86,7 +86,7 @@ public int getCurrentBytes() { public double getEstimate() { return 0; } @Override - public int getRetainedEntries(final boolean valid) { //valid is only relevant for the Alpha Sketch + public int getRetainedEntries(final boolean valid) { //valid is only relevant for the AlphaSketch return 0; } @@ -111,7 +111,7 @@ public HashIterator iterator() { } /** - * Returns 8 bytes representing a CompactSketch that the following flags set: + * Returns 8 bytes representing a CompactThetaSketch that the following flags set: * ordered, compact, empty, readOnly. The SerVer is 3, the Family is COMPACT(3), * and the PreLongs = 1. The seedHash is zero. */ diff --git a/src/main/java/org/apache/datasketches/theta/HeapAlphaSketch.java b/src/main/java/org/apache/datasketches/theta/HeapAlphaSketch.java index 846fb02b6..8b64b177f 100644 --- a/src/main/java/org/apache/datasketches/theta/HeapAlphaSketch.java +++ b/src/main/java/org/apache/datasketches/theta/HeapAlphaSketch.java @@ -50,7 +50,7 @@ /** * This sketch uses the - * Theta Sketch Framework + * ThetaSketch Framework * and the * Alpha TCF algorithm * with a single cache. @@ -164,7 +164,7 @@ static HeapAlphaSketch heapifyInstance(final MemorySegment srcSeg, final long ex return has; } - //Sketch + //ThetaSketch @Override public Family getFamily() { @@ -208,7 +208,7 @@ public double getLowerBound(final int numStdDev) { } @Override - public int getRetainedEntries(final boolean valid) { //valid is only relevant for the Alpha Sketch + public int getRetainedEntries(final boolean valid) { //valid is only relevant for the AlphaSketch if (curCount_ > 0) { if (valid && isDirty()) { return HashOperations.countPart(getCache(), getLgArrLongs(), getThetaLong()); @@ -241,7 +241,7 @@ public boolean isEmpty() { } /* - * Alpha Sketch Preamble Layout ( same as Theta UpdateSketch ) + * AlphaSketch Preamble Layout ( same as UpdatableThetaSketch ) *
* Long || Start Byte Adr:
* Adr:
@@ -261,10 +261,10 @@ public byte[] toByteArray() {
return toByteArray(Family.ALPHA.getMinPreLongs(), (byte) Family.ALPHA.getID());
}
- //UpdateSketch
+ //UpdatableThetaSketch
@Override
- public UpdateSketch rebuild() {
+ public UpdatableThetaSketch rebuild() {
if (isDirty()) {
rebuildDirty();
}
@@ -348,7 +348,7 @@ UpdateReturnState hashUpdate(final long hash) {
if (r == 0) { //not yet sketch mode (has not seen k+1 inserts), but could be sampling
if (curCount_ > (1 << lgNomLongs_)) { // > k
//Reached the k+1 insert. Must be at tgt size or larger.
- //Transition to Sketch Mode. Happens only once.
+ //Transition to ThetaSketch Mode. Happens only once.
//Decrement theta, make dirty, don't bother check size, already not-empty.
thetaLong_ = (long) (thetaLong_ * alpha_);
dirty_ = true; //now may have dirty values
@@ -507,12 +507,12 @@ private void forceRebuildDirtyCache() {
* Table of sketch states and how Upper and Lower Bounds are computed
*
* Theta P Count Empty EstMode Est UB LB Comments
- * 1.0 1.0 0 T F 0 0 0 Empty Sketch-mode only sketch
- * 1.0 1.0 N F F N N N Degenerate Sketch-mode only sketch
- * <1.0 1.0 - F T est HIP HIP Normal Sketch-mode only sketch
- * P <1.0 0 T F 0 0 0 Virgin sampling sketch
- * P <1.0 N F T est HIP HIP Degenerate sampling sketch
- * <P <1.0 N F T est HIP HIP Sampling sketch also in sketch-mode
+ * 1.0 1.0 0 T F 0 0 0 Empty sketch-mode only ThetaSketch
+ * 1.0 1.0 N F F N N N Degenerate sketch-mode only ThetaSketch
+ * <1.0 1.0 - F T est HIP HIP Normal sketch-mode only ThetaSketch
+ * P <1.0 0 T F 0 0 0 Virgin sampling ThetaSketch
+ * P <1.0 N F T est HIP HIP Degenerate sampling ThetaSketch
+ * <P <1.0 N F T est HIP HIP Sampling ThetaSketch also in sketch-mode
*
* @param k alias for nominal entries.
* @param p See Sampling Probability, p.
diff --git a/src/main/java/org/apache/datasketches/theta/HeapCompactSketch.java b/src/main/java/org/apache/datasketches/theta/HeapCompactSketch.java
index 69eebff5f..2e0fed42f 100644
--- a/src/main/java/org/apache/datasketches/theta/HeapCompactSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/HeapCompactSketch.java
@@ -34,11 +34,11 @@
import java.lang.foreign.MemorySegment;
/**
- * Parent class of the Heap Compact Sketches.
+ * Parent class of the HeapCompactThetaSketches.
*
* @author Lee Rhodes
*/
-final class HeapCompactSketch extends CompactSketch {
+final class HeapCompactSketch extends CompactThetaSketch {
private final long thetaLong_; //computed
private final int curCount_;
private final int preLongs_; //computed
@@ -73,10 +73,10 @@ final class HeapCompactSketch extends CompactSketch {
checkIllegalCurCountAndEmpty(empty, curCount);
}
- //Sketch
+ //ThetaSketch
@Override
- public CompactSketch compact(final boolean dstOrdered, final MemorySegment dstSeg) {
+ public CompactThetaSketch compact(final boolean dstOrdered, final MemorySegment dstSeg) {
if ((dstSeg == null) && (!dstOrdered || (ordered_ == dstOrdered))) { return this; }
return componentsToCompact(getThetaLong(), getRetainedEntries(true), getSeedHash(), isEmpty(),
true, ordered_, dstOrdered, dstSeg, getCache().clone());
@@ -88,7 +88,7 @@ public int getCurrentBytes() {
}
@Override
- public int getRetainedEntries(final boolean valid) { //valid is only relevant for the Alpha Sketch
+ public int getRetainedEntries(final boolean valid) { //valid is only relevant for the AlphaSketch
return curCount_;
}
diff --git a/src/main/java/org/apache/datasketches/theta/HeapQuickSelectSketch.java b/src/main/java/org/apache/datasketches/theta/HeapQuickSelectSketch.java
index 89f4f21f5..a44ac9764 100644
--- a/src/main/java/org/apache/datasketches/theta/HeapQuickSelectSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/HeapQuickSelectSketch.java
@@ -74,8 +74,8 @@ private HeapQuickSelectSketch(final int lgNomLongs, final long seed, final float
* @param seed See seed
* @param p See Sampling Probability, p
* @param rf See Resize Factor
- * @param unionGadget true if this sketch is implementing the Union gadget function.
- * Otherwise, it is behaving as a normal QuickSelectSketch.
+ * @param unionGadget true if this sketch is implementing the ThetaUnion gadget function.
+ * Otherwise, it is behaving as a normal QuickSelectThetaSketch.
*/
HeapQuickSelectSketch(final int lgNomLongs, final long seed, final float p,
final ResizeFactor rf, final boolean unionGadget) {
@@ -100,7 +100,7 @@ private HeapQuickSelectSketch(final int lgNomLongs, final long seed, final float
}
/**
- * Heapify a sketch from a MemorySegment UpdateSketch or Union object
+ * Heapify a sketch from a MemorySegment UpdatableThetaSketch or ThetaUnion object
* containing sketch data.
* @param srcSeg The source MemorySegment object.
* @param seed See seed
@@ -136,7 +136,7 @@ static HeapQuickSelectSketch heapifyInstance(final MemorySegment srcSeg, final l
return hqss;
}
- //Sketch
+ //ThetaSketch
@Override
public double getEstimate() {
@@ -149,7 +149,7 @@ public Family getFamily() {
}
@Override
- public int getRetainedEntries(final boolean valid) { //valid is only relevant for the Alpha Sketch
+ public int getRetainedEntries(final boolean valid) { //valid is only relevant for the AlphaSketch
return curCount_;
}
@@ -173,10 +173,10 @@ public byte[] toByteArray() {
return toByteArray(preambleLongs_, (byte) MY_FAMILY.getID());
}
- //UpdateSketch
+ //UpdatableThetaSketch
@Override
- public UpdateSketch rebuild() {
+ public UpdatableThetaSketch rebuild() {
if (getRetainedEntries(true) > (1 << getLgNomLongs())) {
quickSelectAndRebuild();
}
diff --git a/src/main/java/org/apache/datasketches/theta/HeapUpdateSketch.java b/src/main/java/org/apache/datasketches/theta/HeapUpdateSketch.java
index 56175a019..e676a6652 100644
--- a/src/main/java/org/apache/datasketches/theta/HeapUpdateSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/HeapUpdateSketch.java
@@ -43,11 +43,11 @@
import org.apache.datasketches.thetacommon.ThetaUtil;
/**
- * The parent class for Heap Updatable Theta Sketches.
+ * The parent class for HeapUpdatableThetaSketches.
*
* @author Lee Rhodes
*/
-abstract class HeapUpdateSketch extends UpdateSketch {
+abstract class HeapUpdateSketch extends UpdatableThetaSketch {
final int lgNomLongs_;
private final float p_;
private final ResizeFactor rf_;
@@ -59,7 +59,7 @@ abstract class HeapUpdateSketch extends UpdateSketch {
rf_ = rf;
}
- //Sketch
+ //ThetaSketch
@Override
public int getCurrentBytes() {
@@ -68,7 +68,7 @@ public int getCurrentBytes() {
return preLongs + dataLongs << 3;
}
- //UpdateSketch
+ //UpdatableThetaSketch
@Override
public final int getLgNomLongs() {
@@ -92,7 +92,7 @@ short getSeedHash() {
return Util.computeSeedHash(getSeed());
}
- //Used by HeapAlphaSketch and HeapQuickSelectSketch / Theta UpdateSketch
+ //Used by HeapAlphaSketch and HeapQuickSelectThetaSketch / UpdatableThetaSketch
byte[] toByteArray(final int preLongs, final byte familyID) {
if (isDirty()) { rebuild(); }
checkIllegalCurCountAndEmpty(isEmpty(), getRetainedEntries(true));
diff --git a/src/main/java/org/apache/datasketches/theta/JaccardSimilarity.java b/src/main/java/org/apache/datasketches/theta/JaccardSimilarity.java
index 0a71d6fbc..2fc9d4fe5 100644
--- a/src/main/java/org/apache/datasketches/theta/JaccardSimilarity.java
+++ b/src/main/java/org/apache/datasketches/theta/JaccardSimilarity.java
@@ -29,7 +29,7 @@
import org.apache.datasketches.thetacommon.ThetaUtil;
/**
- * Jaccard similarity of two Theta Sketches.
+ * Jaccard similarity of two ThetaSketches.
*
* @author Lee Rhodes
*/
@@ -64,12 +64,12 @@ public static double[] jaccard(final ThetaSketch sketchA, final ThetaSketch sket
final int countA = sketchA.getRetainedEntries(true);
final int countB = sketchB.getRetainedEntries(true);
- //Create the Union
+ //Create the ThetaUnion
final int minK = 1 << ThetaUtil.MIN_LG_NOM_LONGS;
final int maxK = 1 << ThetaUtil.MAX_LG_NOM_LONGS;
final int newK = max(min(ceilingPowerOf2(countA + countB), maxK), minK);
- final Union union =
- SetOperation.builder().setNominalEntries(newK).buildUnion();
+ final ThetaUnion union =
+ ThetaSetOperation.builder().setNominalEntries(newK).buildUnion();
union.union(sketchA);
union.union(sketchB);
final ThetaSketch unionAB = union.getResult(false, null);
@@ -84,8 +84,8 @@ public static double[] jaccard(final ThetaSketch sketchA, final ThetaSketch sket
return ONES.clone();
}
- //Create the Intersection
- final Intersection inter = SetOperation.builder().buildIntersection();
+ //Create the ThetaIntersection
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
inter.intersect(sketchA);
inter.intersect(sketchB);
inter.intersect(unionAB); //ensures that intersection is a subset of the union
@@ -115,9 +115,9 @@ public static boolean exactlyEqual(final ThetaSketch sketchA, final ThetaSketch
final int countA = sketchA.getRetainedEntries(true);
final int countB = sketchB.getRetainedEntries(true);
- //Create the Union
- final Union union =
- SetOperation.builder().setNominalEntries(ceilingPowerOf2(countA + countB)).buildUnion();
+ //Create the ThetaUnion
+ final ThetaUnion union =
+ ThetaSetOperation.builder().setNominalEntries(ceilingPowerOf2(countA + countB)).buildUnion();
union.union(sketchA);
union.union(sketchB);
final ThetaSketch unionAB = union.getResult();
@@ -135,7 +135,7 @@ public static boolean exactlyEqual(final ThetaSketch sketchA, final ThetaSketch
}
/**
- * Tests similarity of a measured Sketch against an expected Sketch.
+ * Tests similarity of a measured ThetaSketch against an expected ThetaSketch.
* Computes the lower bound of the Jaccard index JLB of the measured and
* expected sketches.
* if JLB ≥ threshold, then the sketches are considered to be
@@ -157,7 +157,7 @@ public static boolean similarityTest(final ThetaSketch measured, final ThetaSket
}
/**
- * Tests dissimilarity of a measured Sketch against an expected Sketch.
+ * Tests dissimilarity of a measured ThetaSketch against an expected ThetaSketch.
* Computes the upper bound of the Jaccard index JUB of the measured and
* expected sketches.
* if JUB ≤ threshold, then the sketches are considered to be
diff --git a/src/main/java/org/apache/datasketches/theta/PreambleUtil.java b/src/main/java/org/apache/datasketches/theta/PreambleUtil.java
index 4dd993eb3..fcb7f24a4 100644
--- a/src/main/java/org/apache/datasketches/theta/PreambleUtil.java
+++ b/src/main/java/org/apache/datasketches/theta/PreambleUtil.java
@@ -41,7 +41,7 @@
* fields.
*
* The intent of the design of this class was to isolate the detailed knowledge of the bit and - * byte layout of the serialized form of the sketches derived from the Sketch class into one place. + * byte layout of the serialized form of the sketches derived from the ThetaSketch class into one place. * This allows the possibility of the introduction of different serialization * schemes with minimal impact on the rest of the library.
* @@ -50,7 +50,7 @@ * multi-byte integers (int and long) are stored in native byte order. The * byte values are treated as unsigned. * - *An empty CompactSketch only requires 8 bytes. + *
An empty CompactThetaSketch only requires 8 bytes. * Flags: notSI, Ordered*, Compact, Empty*, ReadOnly, LE. * (*) Earlier versions did not set these.
* @@ -61,7 +61,7 @@ * 0 || Seed Hash | Flags | | | FamID | SerVer | PreLongs = 1 | * * - *A SingleItemSketch (extends CompactSketch) requires an 8 byte preamble plus a single + *
A SingleItemThetaSketch (extends CompactThetaSketch) requires an 8 byte preamble plus a single * hash item of 8 bytes. Flags: SingleItem*, Ordered, Compact, notEmpty, ReadOnly, LE. * (*) Earlier versions did not set these.
* @@ -75,7 +75,7 @@ * 1 ||---------------------------Single long hash----------------------------------------| * * - *An exact (non-estimating) CompactSketch requires 16 bytes of preamble plus a compact array of + *
An exact (non-estimating) CompactThetaSketch requires 16 bytes of preamble plus a compact array of * longs.
* *@@ -91,7 +91,7 @@ * 2 ||----------------------Start of Compact Long Array----------------------------------| ** - *
An estimating CompactSketch requires 24 bytes of preamble plus a compact array of longs.
+ *An estimating CompactThetaSketch requires 24 bytes of preamble plus a compact array of longs.
* ** Long || Start Byte Adr: @@ -109,7 +109,7 @@ * 3 ||----------------------Start of Compact Long Array----------------------------------| ** - *
The compressed CompactSketch has 8 bytes of preamble in exact mode because Theta can + *
The compressed CompactThetaSketch has 8 bytes of preamble in exact mode because theta can * be assumed to be 1.0. In estimating mode, the 2nd 8 bytes is Theta as a Long. The following * table assumes estimating mode. In any case the number of retained entries starts immediately * after, followed immediately by the delta encoded compressed byte array.
@@ -139,10 +139,10 @@ * 3 ||--------Delta encoded compressed byte array starts at bytes 17-20------------------| * * - *The UpdateSketch and AlphaSketch require 24 bytes of preamble followed by a non-compact + *
The UpdatableThetaSketch and AlphaSketch require 24 bytes of preamble followed by a non-compact * array of longs representing a hash table.
* - *The following table applies to both the Theta UpdateSketch and the Alpha Sketch
+ *The following table applies to both the Theta UpdatableThetaSketch and the AlphaSketch
** Long || Start Byte Adr: * Adr: @@ -159,7 +159,7 @@ * 3 ||----------------------Start of Hash Table of longs---------------------------------| ** - *
Union objects require 32 bytes of preamble plus a non-compact array of longs representing a + *
ThetaUnion objects require 32 bytes of preamble plus a non-compact array of longs representing a * hash table.
* *
@@ -201,7 +201,7 @@ private PreambleUtil() {}
static final int RETAINED_ENTRIES_INT = 8; //8 byte aligned
static final int P_FLOAT = 12; //4 byte aligned, not used by compact
static final int THETA_LONG = 16; //8-byte aligned
- static final int UNION_THETA_LONG = 24; //8-byte aligned, only used by Union
+ static final int UNION_THETA_LONG = 24; //8-byte aligned, only used by ThetaUnion
// flag byte bit masks
static final int RESERVED_FLAG_MASK = 1; //Bit 0: Reserved, no longer used. Was BigEndian
@@ -283,17 +283,17 @@ static String preambleToString(final MemorySegment seg) {
long thetaLong = Long.MAX_VALUE; //preLongs 1 or 2
long thetaULong = thetaLong; //preLongs 1, 2 or 3
- if (preLongs == 2) { //exact (non-estimating) CompactSketch
+ if (preLongs == 2) { //exact (non-estimating) CompactThetaSketch
curCount = extractCurCount(seg);
p = extractP(seg);
}
- else if (preLongs == 3) { //Update Sketch
+ else if (preLongs == 3) { //UpdatableThetaSketch
curCount = extractCurCount(seg);
p = extractP(seg);
thetaLong = extractThetaLong(seg);
thetaULong = thetaLong;
}
- else if (preLongs == 4) { //Union
+ else if (preLongs == 4) { //ThetaUnion
curCount = extractCurCount(seg);
p = extractP(seg);
thetaLong = extractThetaLong(seg);
@@ -352,7 +352,7 @@ else if (preLongs == 3) {
return sb.toString();
}
}
- else { //preLongs == 4 (Union)
+ else { //preLongs == 4 (ThetaUnion)
sb.append("Bytes 8-11 : CurrentCount : ").append(curCount).append(LS);
sb.append("Bytes 12-15: P : ").append(p).append(LS);
sb.append("Bytes 16-23: Theta (double) : ").append(thetaDbl).append(LS);
diff --git a/src/main/java/org/apache/datasketches/theta/SingleItemSketch.java b/src/main/java/org/apache/datasketches/theta/SingleItemSketch.java
index 766e1850d..57112fedd 100644
--- a/src/main/java/org/apache/datasketches/theta/SingleItemSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/SingleItemSketch.java
@@ -37,11 +37,11 @@
import org.apache.datasketches.common.Util;
/**
- * A CompactSketch that holds only one item hash.
+ * A CompactThetaSketch that holds only one item hash.
*
* @author Lee Rhodes
*/
-final class SingleItemSketch extends CompactSketch {
+final class SingleItemSketch extends CompactThetaSketch {
private static final long DEFAULT_SEED_HASH = Util.computeSeedHash(Util.DEFAULT_UPDATE_SEED) & 0xFFFFL;
// For backward compatibility, a candidate pre0_ long must have:
@@ -49,7 +49,7 @@ final class SingleItemSketch extends CompactSketch {
// Flags mask will be 0x1F.
// SingleItem flag may not be set due to a historical bug, so we can't depend on it for now.
// However, if the above flags are correct, preLongs == 1, SerVer >= 3, FamilyID == 3,
- // and the hash seed matches, it is virtually guaranteed that we have a SingleItem Sketch.
+ // and the hash seed matches, it is virtually guaranteed that we have a SingleItemThetaSketch.
private static final long PRE0_LO6_SI = 0X00_00_3A_00_00_03_03_01L; //low 6 bytes, with SI flag
private long pre0_ = 0;
@@ -76,12 +76,12 @@ private SingleItemSketch(final long hash) {
}
/**
- * Creates a SingleItemSketch on the heap given a SingleItemSketch MemorySegment image and a seedHash.
+ * Creates a SingleItemSketch on the heap given a SingleItemThetaSketch MemorySegment image and a seedHash.
* Checks the seed hash of the given MemorySegment against the given seedHash.
* @param srcSeg the MemorySegment to be heapified.
* @param expectedSeedHash the given seedHash to be checked against the srcSeg seedHash
- * @return a SingleItemSketch
- */ //does not override Sketch
+ * @return a SingleItemThetaSketch
+ */ //does not override ThetaSketch
static SingleItemSketch heapify(final MemorySegment srcSeg, final short expectedSeedHash) {
Util.checkSeedHashes((short) extractSeedHash(srcSeg), expectedSeedHash);
final boolean singleItem = checkForSingleItem(srcSeg);
@@ -90,7 +90,7 @@ static SingleItemSketch heapify(final MemorySegment srcSeg, final short expected
}
@Override
- public CompactSketch compact(final boolean dstOrdered, final MemorySegment dstSeg) {
+ public CompactThetaSketch compact(final boolean dstOrdered, final MemorySegment dstSeg) {
if (dstSeg == null) { return this; }
else {
dstSeg.set(JAVA_LONG_UNALIGNED, 0, pre0_);
@@ -105,7 +105,7 @@ public CompactSketch compact(final boolean dstOrdered, final MemorySegment dstSe
* Create this sketch with a long.
*
* @param datum The given long datum.
- * @return a SingleItemSketch
+ * @return a SingleItemThetaSketch
*/
static SingleItemSketch create(final long datum) {
final long[] data = { datum };
@@ -120,7 +120,7 @@ static SingleItemSketch create(final long datum) {
* The special floating-point values NaN and +/- Infinity are treated as distinct.
*
* @param datum The given double datum.
- * @return a SingleItemSketch
+ * @return a SingleItemThetaSketch
*/
static SingleItemSketch create(final double datum) {
final double d = (datum == 0.0) ? 0.0 : datum; // canonicalize -0.0, 0.0
@@ -138,7 +138,7 @@ static SingleItemSketch create(final double datum) {
*
*
* @param datum The given String.
- * @return a SingleItemSketch or null
+ * @return a SingleItemThetaSketch or null
*/
static SingleItemSketch create(final String datum) {
if ((datum == null) || datum.isEmpty()) { return null; }
@@ -151,7 +151,7 @@ static SingleItemSketch create(final String datum) {
* If the byte array is null or empty no create attempt is made and the method returns null.
*
* @param data The given byte array.
- * @return a SingleItemSketch or null
+ * @return a SingleItemThetaSketch or null
*/
static SingleItemSketch create(final byte[] data) {
if ((data == null) || (data.length == 0)) { return null; }
@@ -166,7 +166,7 @@ static SingleItemSketch create(final byte[] data) {
* method but will be a little faster as it avoids the complexity of the UTF8 encoding.
*
* @param data The given char array.
- * @return a SingleItemSketch or null
+ * @return a SingleItemThetaSketch or null
*/
static SingleItemSketch create(final char[] data) {
if ((data == null) || (data.length == 0)) { return null; }
@@ -178,7 +178,7 @@ static SingleItemSketch create(final char[] data) {
* If the integer array is null or empty no create attempt is made and the method returns null.
*
* @param data The given int array.
- * @return a SingleItemSketch or null
+ * @return a SingleItemThetaSketch or null
*/
static SingleItemSketch create(final int[] data) {
if ((data == null) || (data.length == 0)) { return null; }
@@ -190,7 +190,7 @@ static SingleItemSketch create(final int[] data) {
* If the long array is null or empty no create attempt is made and the method returns null.
*
* @param data The given long array.
- * @return a SingleItemSketch or null
+ * @return a SingleItemThetaSketch or null
*/
static SingleItemSketch create(final long[] data) {
if ((data == null) || (data.length == 0)) { return null; }
@@ -204,7 +204,7 @@ static SingleItemSketch create(final long[] data) {
*
* @param datum The given long datum.
* @param seed used to hash the given value.
- * @return a SingleItemSketch
+ * @return a SingleItemThetaSketch
*/
static SingleItemSketch create(final long datum, final long seed) {
final long[] data = { datum };
@@ -220,7 +220,7 @@ static SingleItemSketch create(final long datum, final long seed) {
*
* @param datum The given double datum.
* @param seed used to hash the given value.
- * @return a SingleItemSketch
+ * @return a SingleItemThetaSketch
*/
static SingleItemSketch create(final double datum, final long seed) {
final double d = (datum == 0.0) ? 0.0 : datum; // canonicalize -0.0, 0.0
@@ -239,7 +239,7 @@ static SingleItemSketch create(final double datum, final long seed) {
*
* @param datum The given String.
* @param seed used to hash the given value.
- * @return a SingleItemSketch or null
+ * @return a SingleItemThetaSketch or null
*/
static SingleItemSketch create(final String datum, final long seed) {
if ((datum == null) || datum.isEmpty()) { return null; }
@@ -253,7 +253,7 @@ static SingleItemSketch create(final String datum, final long seed) {
*
* @param data The given byte array.
* @param seed used to hash the given value.
- * @return a SingleItemSketch or null
+ * @return a SingleItemThetaSketch or null
*/
static SingleItemSketch create(final byte[] data, final long seed) {
if ((data == null) || (data.length == 0)) { return null; }
@@ -269,7 +269,7 @@ static SingleItemSketch create(final byte[] data, final long seed) {
*
* @param data The given char array.
* @param seed used to hash the given value.
- * @return a SingleItemSketch or null
+ * @return a SingleItemThetaSketch or null
*/
static SingleItemSketch create(final char[] data, final long seed) {
if ((data == null) || (data.length == 0)) { return null; }
@@ -282,7 +282,7 @@ static SingleItemSketch create(final char[] data, final long seed) {
*
* @param data The given int array.
* @param seed used to hash the given value.
- * @return a SingleItemSketch or null
+ * @return a SingleItemThetaSketch or null
*/
static SingleItemSketch create(final int[] data, final long seed) {
if ((data == null) || (data.length == 0)) { return null; }
@@ -295,14 +295,14 @@ static SingleItemSketch create(final int[] data, final long seed) {
*
* @param data The given long array.
* @param seed used to hash the given value.
- * @return a SingleItemSketch or null
+ * @return a SingleItemThetaSketch or null
*/
static SingleItemSketch create(final long[] data, final long seed) {
if ((data == null) || (data.length == 0)) { return null; }
return new SingleItemSketch(hash(data, seed)[0] >>> 1, seed);
}
- //Sketch
+ //ThetaSketch
@Override //much faster
public int getCountLessThanThetaLong(final long thetaLong) {
@@ -330,7 +330,7 @@ public double getLowerBound(final int numStdDev) {
}
@Override
- public int getRetainedEntries(final boolean valid) { //valid is only relevant for the Alpha Sketch
+ public int getRetainedEntries(final boolean valid) { //valid is only relevant for the AlphaSketch
return 1;
}
@@ -399,7 +399,7 @@ static boolean checkForSingleItem(
// SingleItem flag may not be set due to a historical bug, so we can't depend on it for now.
// However, if the above flags are correct, preLongs == 1, SerVer >= 3, FamilyID == 3,
// and the hash seed matches (not done here), it is virtually guaranteed that we have a
- // SingleItem Sketch.
+ // SingleItemThetaSketch.
final boolean preLongsOK = preLongs == 1;
final boolean serVerOK = serVer >= 3;
final boolean famIdOK = famId == Family.COMPACT.getID();
diff --git a/src/main/java/org/apache/datasketches/theta/ThetaAnotB.java b/src/main/java/org/apache/datasketches/theta/ThetaAnotB.java
index fc523115b..afac16dee 100644
--- a/src/main/java/org/apache/datasketches/theta/ThetaAnotB.java
+++ b/src/main/java/org/apache/datasketches/theta/ThetaAnotB.java
@@ -24,30 +24,30 @@
import org.apache.datasketches.common.Family;
/**
- * Computes a set difference, A-AND-NOT-B, of two theta sketches.
+ * Computes a set difference, A-AND-NOT-B, of two ThetaSketches.
* This class includes both stateful and stateless operations.
*
* The stateful operation is as follows:
*
- * AnotB anotb = SetOperationBuilder.buildAnotB();
+ * ThetaAnotB anotb = ThetaSetOperationBuilder.buildAnotB();
*
- * anotb.setA(Sketch skA); //The first argument.
- * anotb.notB(Sketch skB); //The second (subtraction) argument.
- * anotb.notB(Sketch skC); // ...any number of additional subtractions...
+ * anotb.setA(ThetaSketch skA); //The first argument.
+ * anotb.notB(ThetaSketch skB); //The second (subtraction) argument.
+ * anotb.notB(ThetaSketch skC); // ...any number of additional subtractions...
* anotb.getResult(false); //Get an interim result.
- * anotb.notB(Sketch skD); //Additional subtractions.
- * anotb.getResult(true); //Final result and resets the AnotB operator.
+ * anotb.notB(ThetaSketch skD); //Additional subtractions.
+ * anotb.getResult(true); //Final result and resets the ThetaAnotB operator.
*
*
* The stateless operation is as follows:
*
- * AnotB anotb = SetOperationBuilder.buildAnotB();
+ * ThetaAnotB anotb = ThetaSetOperationBuilder.buildAnotB();
*
- * CompactSketch csk = anotb.aNotB(Sketch skA, Sketch skB);
+ * CompactThetaSketch csk = anotb.aNotB(ThetaSketch skA, ThetaSketch skB);
*
*
* Calling the setA operation a second time essentially clears the internal state and loads
- * the new sketch.
+ * the new ThetaSketch.
*
* The stateless and stateful operations are independent of each other with the exception of
* sharing the same update hash seed loaded as the default seed or specified by the user as an
@@ -55,12 +55,12 @@
*
* @author Lee Rhodes
*/
-public abstract class AnotB extends SetOperation {
+public abstract class ThetaAnotB extends ThetaSetOperation {
/**
* Constructor
*/
- AnotB() {}
+ ThetaAnotB() {}
@Override
public Family getFamily() {
@@ -68,9 +68,9 @@ public Family getFamily() {
}
/**
- * This is part of a multistep, stateful AnotB operation and sets the given Theta sketch as the
+ * This is part of a multistep, stateful ThetaAnotB operation and sets the given ThetaSketch as the
* first argument A of A-AND-NOT-B. This overwrites the internal state of this
- * AnotB operator with the contents of the given sketch.
+ * ThetaAnotB operator with the contents of the given sketch.
* This sets the stage for multiple following notB steps.
*
*
An input argument of null will throw an exception.
@@ -95,9 +95,9 @@ public Family getFamily() {
public abstract void setA(ThetaSketch skA);
/**
- * This is part of a multistep, stateful AnotB operation and sets the given Theta sketch as the
+ * This is part of a multistep, stateful ThetaAnotB operation and sets the given ThetaSketch as the
* second (or n+1th) argument B of A-AND-NOT-B.
- * Performs an AND NOT operation with the existing internal state of this AnotB operator.
+ * Performs an AND NOT operation with the existing internal state of this ThetaAnotB operator.
*
* An input argument of null or empty is ignored.
*
@@ -109,28 +109,28 @@ public Family getFamily() {
*
* Use {@link #getResult(boolean)} to obtain the result.
*
- * @param skB The incoming Theta sketch for the second (or following) argument B.
+ * @param skB The incoming ThetaSketch for the second (or following) argument B.
*/
public abstract void notB(ThetaSketch skB);
/**
- * Gets the result of the multistep, stateful operation AnotB that have been executed with calls
+ * Gets the result of the multistep, stateful operation ThetaAnotB that have been executed with calls
* to {@link #setA(ThetaSketch)} and ({@link #notB(ThetaSketch)} or
* {@link #notB(org.apache.datasketches.theta.ThetaSketch)}).
*
* @param reset If true, clears this operator to the empty state after this result is
* returned. Set this to false if you wish to obtain an intermediate result.
*
- * @return the result of this operation as an ordered, on-heap {@link CompactSketch}.
+ * @return the result of this operation as an ordered, on-heap {@link CompactThetaSketch}.
*/
- public abstract CompactSketch getResult(boolean reset);
+ public abstract CompactThetaSketch getResult(boolean reset);
/**
- * Gets the result of the multistep, stateful operation AnotB that have been executed with calls
+ * Gets the result of the multistep, stateful operation ThetaAnotB that have been executed with calls
* to {@link #setA(ThetaSketch)} and ({@link #notB(ThetaSketch)} or
* {@link #notB(org.apache.datasketches.theta.ThetaSketch)}).
*
- * @param dstOrdered If true, the result will be an ordered {@link CompactSketch}.
+ * @param dstOrdered If true, the result will be an ordered {@link CompactThetaSketch}.
* See Destination Ordered.
*
* @param dstSeg if not null the given MemorySegment will be the target location of the result.
@@ -138,13 +138,13 @@ public Family getFamily() {
* @param reset If true, clears this operator to the empty state after this result is
* returned. Set this to false if you wish to obtain an intermediate result.
*
- * @return the result of this operation as a {@link CompactSketch} in the given dstSeg.
+ * @return the result of this operation as a {@link CompactThetaSketch} in the given dstSeg.
*/
- public abstract CompactSketch getResult(boolean dstOrdered, MemorySegment dstSeg, boolean reset);
+ public abstract CompactThetaSketch getResult(boolean dstOrdered, MemorySegment dstSeg, boolean reset);
/**
* Perform A-and-not-B set operation on the two given sketches and return the result as an
- * ordered CompactSketch on the heap.
+ * ordered CompactThetaSketch on the heap.
*
* This a stateless operation and has no impact on the internal state of this operator.
* Thus, this is not an accumulating update and does not interact with the {@link #setA(ThetaSketch)},
@@ -164,15 +164,15 @@ public Family getFamily() {
*
* @param skA The incoming sketch for the first argument. It must not be null.
* @param skB The incoming sketch for the second argument. It must not be null.
- * @return an ordered CompactSketch on the heap
+ * @return an ordered CompactThetaSketch on the heap
*/
- public CompactSketch aNotB(final ThetaSketch skA, final ThetaSketch skB) {
+ public CompactThetaSketch aNotB(final ThetaSketch skA, final ThetaSketch skB) {
return aNotB(skA, skB, true, null);
}
/**
* Perform A-and-not-B set operation on the two given sketches and return the result as a
- * CompactSketch.
+ * CompactThetaSketch.
*
*
This a stateless operation and has no impact on the internal state of this operator.
* Thus, this is not an accumulating update and does not interact with the {@link #setA(ThetaSketch)},
@@ -195,9 +195,9 @@ public CompactSketch aNotB(final ThetaSketch skA, final ThetaSketch skB) {
* @param dstOrdered
* See Destination Ordered.
* @param dstSeg the destination MemorySegment
- * @return the result as a CompactSketch.
+ * @return the result as a CompactThetaSketch.
*/
- public abstract CompactSketch aNotB(ThetaSketch skA, ThetaSketch skB, boolean dstOrdered,
+ public abstract CompactThetaSketch aNotB(ThetaSketch skA, ThetaSketch skB, boolean dstOrdered,
MemorySegment dstSeg);
}
diff --git a/src/main/java/org/apache/datasketches/theta/ThetaAnotBimpl.java b/src/main/java/org/apache/datasketches/theta/ThetaAnotBimpl.java
index dc9ecb657..5fcefdad0 100644
--- a/src/main/java/org/apache/datasketches/theta/ThetaAnotBimpl.java
+++ b/src/main/java/org/apache/datasketches/theta/ThetaAnotBimpl.java
@@ -38,7 +38,7 @@
* @author Lee Rhodes
* @author Kevin Lang
*/
-final class AnotBimpl extends AnotB {
+final class ThetaAnotBimpl extends ThetaAnotB {
private final short seedHash_;
private boolean empty_;
private long thetaLong_;
@@ -46,20 +46,20 @@ final class AnotBimpl extends AnotB {
private int curCount_;
/**
- * Construct a new AnotB SetOperation on the java heap. Called by SetOperation.Builder.
+ * Construct a new ThetaAnotB on the java heap. Called by ThetaSetOperationBuilder.
*
* @param seed See seed
*/
- AnotBimpl(final long seed) {
+ ThetaAnotBimpl(final long seed) {
this(Util.computeSeedHash(seed));
}
/**
- * Construct a new AnotB SetOperation on the java heap.
+ * Construct a new ThetaAnotB on the java heap.
*
* @param seedHash 16 bit hash of the chosen update seed.
*/
- private AnotBimpl(final short seedHash) {
+ private ThetaAnotBimpl(final short seedHash) {
seedHash_ = seedHash;
reset();
}
@@ -99,21 +99,21 @@ public void notB(final ThetaSketch skB) {
}
@Override
- public CompactSketch getResult(final boolean reset) {
+ public CompactThetaSketch getResult(final boolean reset) {
return getResult(true, null, reset);
}
@Override
- public CompactSketch getResult(final boolean dstOrdered, final MemorySegment dstSeg,
+ public CompactThetaSketch getResult(final boolean dstOrdered, final MemorySegment dstSeg,
final boolean reset) {
- final CompactSketch result = CompactOperations.componentsToCompact(
+ final CompactThetaSketch result = CompactOperations.componentsToCompact(
thetaLong_, curCount_, seedHash_, empty_, true, false, dstOrdered, dstSeg, hashArr_.clone());
if (reset) { reset(); }
return result;
}
@Override
- public CompactSketch aNotB(final ThetaSketch skA, final ThetaSketch skB, final boolean dstOrdered,
+ public CompactThetaSketch aNotB(final ThetaSketch skA, final ThetaSketch skB, final boolean dstOrdered,
final MemorySegment dstSeg) {
if ((skA == null) || (skB == null)) {
throw new SketchesArgumentException("Neither argument may be null");
@@ -154,7 +154,7 @@ int getRetainedEntries() {
private static long[] getHashArrA(final ThetaSketch skA) { //returns a new array
//Get skA cache as array
- final CompactSketch cskA = skA.compact(false, null); //sorting not required
+ final CompactThetaSketch cskA = skA.compact(false, null); //sorting not required
return cskA.getCache().clone();
}
@@ -166,7 +166,7 @@ private static long[] getResultHashArr( //returns a new array
// Rebuild or get hashtable of skB
final long[] hashTableB; //read only
- if (skB instanceof CompactSketch) {
+ if (skB instanceof CompactThetaSketch) {
hashTableB = convertToHashTable(skB, minThetaLong, ThetaUtil.REBUILD_THRESHOLD);
} else {
hashTableB = skB.getCache();
diff --git a/src/main/java/org/apache/datasketches/theta/ThetaIntersection.java b/src/main/java/org/apache/datasketches/theta/ThetaIntersection.java
index 4482df91c..a1d0809cd 100644
--- a/src/main/java/org/apache/datasketches/theta/ThetaIntersection.java
+++ b/src/main/java/org/apache/datasketches/theta/ThetaIntersection.java
@@ -33,7 +33,7 @@
*
* @author Lee Rhodes
*/
-public abstract class Intersection extends SetOperation {
+public abstract class ThetaIntersection extends ThetaSetOperation {
@Override
public Family getFamily() {
@@ -41,22 +41,22 @@ public Family getFamily() {
}
/**
- * Gets the result of this operation as an ordered CompactSketch on the Java heap.
+ * Gets the result of this operation as an ordered CompactThetaSketch on the Java heap.
* This does not disturb the underlying data structure of this intersection.
* The {@link #intersect(ThetaSketch)} method must have been called at least once, otherwise an
- * exception will be thrown. This is because a virgin Intersection object represents the
+ * exception will be thrown. This is because a virgin intersection represents the
* Universal Set, which has an infinite number of values.
- * @return the result of this operation as an ordered CompactSketch on the Java heap
+ * @return the result of this operation as an ordered CompactThetaSketch on the Java heap
*/
- public CompactSketch getResult() {
+ public CompactThetaSketch getResult() {
return getResult(true, null);
}
/**
- * Gets the result of this operation as a CompactSketch in the given dstSeg.
+ * Gets the result of this operation as a CompactThetaSketch in the given dstSeg.
* This does not disturb the underlying data structure of this intersection.
* The {@link #intersect(ThetaSketch)} method must have been called at least once, otherwise an
- * exception will be thrown. This is because a virgin Intersection object represents the
+ * exception will be thrown. This is because a virgin intersection represents the
* Universal Set, which has an infinite number of values.
*
*
Note that presenting an intersection with an empty sketch sets the internal
@@ -71,10 +71,10 @@ public CompactSketch getResult() {
*
* @param dstSeg the destination MemorySegment.
*
- * @return the result of this operation as a CompactSketch stored in the given dstSeg,
+ * @return the result of this operation as a CompactThetaSketch stored in the given dstSeg,
* which can be either on or off-heap..
*/
- public abstract CompactSketch getResult(boolean dstOrdered, MemorySegment dstSeg);
+ public abstract CompactThetaSketch getResult(boolean dstOrdered, MemorySegment dstSeg);
/**
* Returns true if there is a valid intersection result available
@@ -83,7 +83,7 @@ public CompactSketch getResult() {
public abstract boolean hasResult();
/**
- * Resets this Intersection for stateful operations only.
+ * Resets this ThetaIntersection for stateful operations only.
* The seed remains intact, otherwise reverts to
* the Universal Set: theta = 1.0, no retained data and empty = false.
*/
@@ -106,52 +106,52 @@ public CompactSketch getResult() {
/**
* Perform intersect set operation on the two given sketch arguments and return the result as an
- * ordered CompactSketch on the heap.
+ * ordered CompactThetaSketch on the heap.
* @param a The first sketch argument
* @param b The second sketch argument
- * @return an ordered CompactSketch on the heap
+ * @return an ordered CompactThetaSketch on the heap
*/
- public CompactSketch intersect(final ThetaSketch a, final ThetaSketch b) {
+ public CompactThetaSketch intersect(final ThetaSketch a, final ThetaSketch b) {
return intersect(a, b, true, null);
}
/**
* Perform intersect set operation on the two given sketches and return the result as a
- * CompactSketch.
+ * CompactThetaSketch.
* @param a The first sketch argument
* @param b The second sketch argument
* @param dstOrdered
* See Destination Ordered.
* @param dstSeg the destination MemorySegment.
- * @return the result as a CompactSketch.
+ * @return the result as a CompactThetaSketch.
*/
- public abstract CompactSketch intersect(ThetaSketch a, ThetaSketch b, boolean dstOrdered,
+ public abstract CompactThetaSketch intersect(ThetaSketch a, ThetaSketch b, boolean dstOrdered,
MemorySegment dstSeg);
/**
- * Factory: Wrap an Intersection target around the given source MemorySegment containing intersection data.
+ * Factory: Wrap a ThetaIntersection target around the given source MemorySegment containing intersection data.
* This method assumes the Default Update Seed.
* If the given source MemorySegment is read-only, the returned object will also be read-only.
* @param srcSeg The source MemorySegment image.
- * @return an Intersection that wraps a source MemorySegment that contains an Intersection image
+ * @return a ThetaIntersection that wraps a source MemorySegment that contains a ThetaIntersection image
*/
- public static Intersection wrap(final MemorySegment srcSeg) {
+ public static ThetaIntersection wrap(final MemorySegment srcSeg) {
return wrap(srcSeg, Util.DEFAULT_UPDATE_SEED);
}
/**
- * Factory: Wrap an Intersection target around the given source MemorySegment containing intersection data.
+ * Factory: Wrap a ThetaIntersection target around the given source MemorySegment containing intersection data.
* If the given source MemorySegment is read-only, the returned object will also be read-only.
* @param srcSeg The source MemorySegment image.
* @param expectedSeed See seed
- * @return an Intersection that wraps a source MemorySegment that contains an Intersection image
+ * @return a ThetaIntersection that wraps a source MemorySegment that contains a ThetaIntersection image
*/
- public static Intersection wrap(final MemorySegment srcSeg, final long expectedSeed) {
+ public static ThetaIntersection wrap(final MemorySegment srcSeg, final long expectedSeed) {
final int serVer = srcSeg.get(JAVA_BYTE, SER_VER_BYTE);
if (serVer != 3) {
throw new SketchesArgumentException("SerVer must be 3: " + serVer);
}
- return IntersectionImpl.wrapInstance(srcSeg, expectedSeed, srcSeg.isReadOnly() );
+ return ThetaIntersectionImpl.wrapInstance(srcSeg, expectedSeed, srcSeg.isReadOnly() );
}
}
diff --git a/src/main/java/org/apache/datasketches/theta/ThetaIntersectionImpl.java b/src/main/java/org/apache/datasketches/theta/ThetaIntersectionImpl.java
index 54a513831..3dfdf4fa1 100644
--- a/src/main/java/org/apache/datasketches/theta/ThetaIntersectionImpl.java
+++ b/src/main/java/org/apache/datasketches/theta/ThetaIntersectionImpl.java
@@ -73,7 +73,7 @@
import org.apache.datasketches.thetacommon.ThetaUtil;
/**
- * Intersection operation for Theta Sketches.
+ * The intersection operation for ThetaSketches.
*
*
This implementation uses data either on-heap or off-heap in a given MemorySegment
* that is owned and managed by the caller.
@@ -83,13 +83,13 @@
* @author Lee Rhodes
* @author Kevin Lang
*/
-final class IntersectionImpl extends Intersection {
+final class ThetaIntersectionImpl extends ThetaIntersection {
private final short seedHash_;
private final boolean readOnly_; //True if this sketch is to be treated as read only
private final MemorySegment wseg_;
private final int maxLgArrLongs_; //only used with MemorySegment, not serialized
- //Note: Intersection does not use lgNomLongs or k, per se.
+ //Note: intersection operation does not use lgNomLongs or k, per se.
private int lgArrLongs_; //current size of hash table
private int curCount_; //curCount of HT, if < 0 means Universal Set (US) is true
private long thetaLong_;
@@ -103,14 +103,14 @@ final class IntersectionImpl extends Intersection {
* @param dstSegFlag The given MemorySegment is a Destination (new offHeap) MemorySegment.
* @param readOnly True if MemorySegment is to be treated as read only.
*/
- private IntersectionImpl(final MemorySegment wseg, final long seed, final boolean dstSegFlag,
+ private ThetaIntersectionImpl(final MemorySegment wseg, final long seed, final boolean dstSegFlag,
final boolean readOnly) {
readOnly_ = readOnly;
if (wseg != null) {
wseg_ = wseg;
if (dstSegFlag) { //DstSeg: compute & store seedHash, no seedHash checking
- IntersectionImpl.checkMinSizeMemorySegment(wseg);
- maxLgArrLongs_ = !readOnly ? IntersectionImpl.getMaxLgArrLongs(wseg) : 0; //Only Off Heap
+ ThetaIntersectionImpl.checkMinSizeMemorySegment(wseg);
+ maxLgArrLongs_ = !readOnly ? ThetaIntersectionImpl.getMaxLgArrLongs(wseg) : 0; //Only Off Heap
seedHash_ = Util.computeSeedHash(seed);
wseg_.set(JAVA_SHORT_UNALIGNED, SEED_HASH_SHORT, seedHash_);
} else { //SrcSeg:gets and stores the seedHash, checks seg_seedHash against the seed
@@ -126,36 +126,36 @@ private IntersectionImpl(final MemorySegment wseg, final long seed, final boolea
}
/**
- * Factory: Construct a new Intersection target on the java heap.
- * Called by SetOperationBuilder, test.
+ * Factory: Construct a new ThetaIntersection target on the java heap.
+ * Called by ThetaSetOperationBuilder, test.
*
* @param seed See Seed
* @return a new IntersectionImpl on the Java heap
*/
- static IntersectionImpl initNewHeapInstance(final long seed) {
+ static ThetaIntersectionImpl initNewHeapInstance(final long seed) {
final boolean dstSegFlag = false;
final boolean readOnly = false;
- final IntersectionImpl impl = new IntersectionImpl(null, seed, dstSegFlag, readOnly);
+ final ThetaIntersectionImpl impl = new ThetaIntersectionImpl(null, seed, dstSegFlag, readOnly);
impl.hardReset();
return impl;
}
/**
- * Factory: Construct a new Intersection target direct to the given destination MemorySegment.
- * Called by SetOperationBuilder, test.
+ * Factory: Construct a new ThetaIntersection target direct to the given destination MemorySegment.
+ * Called by ThetaSetOperationBuilder, test.
*
* @param seed See Seed
* @param dstSeg destination MemorySegment
* @return a new IntersectionImpl that may be off-heap
*/
- static IntersectionImpl initNewDirectInstance(final long seed, final MemorySegment dstSeg) {
+ static ThetaIntersectionImpl initNewDirectInstance(final long seed, final MemorySegment dstSeg) {
//Load Preamble
//Pre0
dstSeg.asSlice(0, CONST_PREAMBLE_LONGS << 3).fill((byte)0);
insertPreLongs(dstSeg, CONST_PREAMBLE_LONGS); //RF not used = 0
insertSerVer(dstSeg, SER_VER);
insertFamilyID(dstSeg, Family.INTERSECTION.getID());
- //lgNomLongs not used by Intersection
+ //lgNomLongs not used by this intersection operation
//lgArrLongs set by hardReset
//flags are already 0: reserved = readOnly = compact = ordered = empty = false;
//seedHash loaded and checked in IntersectionImpl constructor
@@ -168,7 +168,7 @@ static IntersectionImpl initNewDirectInstance(final long seed, final MemorySegme
//Initialize
final boolean dstSegFlag = true;
final boolean readOnly = false;
- final IntersectionImpl impl = new IntersectionImpl(dstSeg, seed, dstSegFlag, readOnly);
+ final ThetaIntersectionImpl impl = new ThetaIntersectionImpl(dstSeg, seed, dstSegFlag, readOnly);
impl.hardReset();
return impl;
}
@@ -179,11 +179,11 @@ static IntersectionImpl initNewDirectInstance(final long seed, final MemorySegme
* @param seed See seed
* @return a IntersectionImpl instance on the Java heap
*/
- static IntersectionImpl heapifyInstance(final MemorySegment srcSeg, final long seed) {
+ static ThetaIntersectionImpl heapifyInstance(final MemorySegment srcSeg, final long seed) {
final boolean dstSegFlag = false;
final boolean readOnly = false;
- IntersectionImpl.segChecks(srcSeg);
- final IntersectionImpl impl = new IntersectionImpl(null, seed, dstSegFlag, readOnly);
+ ThetaIntersectionImpl.segChecks(srcSeg);
+ final ThetaIntersectionImpl impl = new ThetaIntersectionImpl(null, seed, dstSegFlag, readOnly);
//Initialize
impl.lgArrLongs_ = extractLgArrLongs(srcSeg);
@@ -198,20 +198,20 @@ static IntersectionImpl heapifyInstance(final MemorySegment srcSeg, final long s
}
/**
- * Factory: Wrap an Intersection target around the given source MemorySegment containing intersection data.
+ * Factory: Wrap a ThetaIntersection target around the given source MemorySegment containing intersection data.
* If the given source MemorySegment is read-only, the returned object will also be read-only.
* @param srcSeg The source MemorySegment image.
* @param seed See seed
* @param readOnly True if MemorySegment is to be treated as read only
- * @return a IntersectionImpl that wraps a source MemorySegment that contains an Intersection image
+ * @return a IntersectionImpl that wraps a source MemorySegment that contains a ThetaIntersection image
*/
- static IntersectionImpl wrapInstance(
+ static ThetaIntersectionImpl wrapInstance(
final MemorySegment srcSeg,
final long seed,
final boolean readOnly) {
final boolean dstSegFlag = false;
- IntersectionImpl.segChecks(srcSeg);
- final IntersectionImpl impl = new IntersectionImpl(srcSeg, seed, dstSegFlag, readOnly);
+ ThetaIntersectionImpl.segChecks(srcSeg);
+ final ThetaIntersectionImpl impl = new ThetaIntersectionImpl(srcSeg, seed, dstSegFlag, readOnly);
impl.lgArrLongs_ = extractLgArrLongs(srcSeg);
impl.curCount_ = extractCurCount(srcSeg);
impl.thetaLong_ = extractThetaLong(srcSeg);
@@ -220,12 +220,12 @@ static IntersectionImpl wrapInstance(
}
@Override
- public CompactSketch intersect(final ThetaSketch a, final ThetaSketch b, final boolean dstOrdered, final MemorySegment dstSeg) {
+ public CompactThetaSketch intersect(final ThetaSketch a, final ThetaSketch b, final boolean dstOrdered, final MemorySegment dstSeg) {
if ((wseg_ != null) && readOnly_) { throw new SketchesReadOnlyException(); }
hardReset();
intersect(a);
intersect(b);
- final CompactSketch csk = getResult(dstOrdered, dstSeg);
+ final CompactThetaSketch csk = getResult(dstOrdered, dstSeg);
hardReset();
return csk;
}
@@ -233,7 +233,7 @@ public CompactSketch intersect(final ThetaSketch a, final ThetaSketch b, final b
@Override
public void intersect(final ThetaSketch sketchIn) {
if (sketchIn == null) {
- throw new SketchesArgumentException("Intersection argument must not be null.");
+ throw new SketchesArgumentException("The input argument must not be null.");
}
if ((wseg_ != null) && readOnly_) { throw new SketchesReadOnlyException(); }
if (empty_ || sketchIn.isEmpty()) { //empty rule
@@ -311,7 +311,7 @@ else if ((curCount_ > 0) && (sketchInEntries > 0)) {
MemorySegment getMemorySegment() { return wseg_; }
@Override
- public CompactSketch getResult(final boolean dstOrdered, final MemorySegment dstSeg) {
+ public CompactThetaSketch getResult(final boolean dstOrdered, final MemorySegment dstSeg) {
if (curCount_ < 0) {
throw new SketchesStateException(
"Calling getResult() with no intervening intersections would represent the infinite set, "
@@ -336,7 +336,7 @@ public CompactSketch getResult(final boolean dstOrdered, final MemorySegment dst
} else {
hashTable = hashTable_;
}
- compactCache = IntersectionImpl.compactCachePart(hashTable, lgArrLongs_, curCount_, thetaLong_, dstOrdered);
+ compactCache = ThetaIntersectionImpl.compactCachePart(hashTable, lgArrLongs_, curCount_, thetaLong_, dstOrdered);
srcCompact = true;
srcOrdered = dstOrdered;
return CompactOperations.componentsToCompact(
@@ -504,7 +504,7 @@ private void moveDataToTgt(final long[] arr, final int count) {
tmpCnt++;
}
}
- assert tmpCnt == count : "Intersection Count Check: got: " + tmpCnt + ", expected: " + count;
+ assert tmpCnt == count : "ThetaIntersection Count Check: got: " + tmpCnt + ", expected: " + count;
}
private void moveDataToTgt(final ThetaSketch sketch) {
@@ -530,7 +530,7 @@ private void moveDataToTgt(final ThetaSketch sketch) {
tmpCnt++;
}
}
- assert tmpCnt == count : "Intersection Count Check: got: " + tmpCnt + ", expected: " + count;
+ assert tmpCnt == count : "ThetaIntersection Count Check: got: " + tmpCnt + ", expected: " + count;
}
private void hardReset() {
@@ -618,7 +618,7 @@ private static int getMaxLgArrLongs(final MemorySegment dstSeg) {
private static void segChecks(final MemorySegment srcSeg) {
//Get Preamble
- //Note: Intersection does not use lgNomLongs (or k), per se.
+ //Note: This intersection operation does not use lgNomLongs (or k), per se.
//seedHash loaded and checked in private constructor
final int preLongs = ThetaSketch.getPreambleLongs(srcSeg);
final int serVer = extractSerVer(srcSeg);
diff --git a/src/main/java/org/apache/datasketches/theta/ThetaSetOperation.java b/src/main/java/org/apache/datasketches/theta/ThetaSetOperation.java
index 72e7a4960..4361b794e 100644
--- a/src/main/java/org/apache/datasketches/theta/ThetaSetOperation.java
+++ b/src/main/java/org/apache/datasketches/theta/ThetaSetOperation.java
@@ -37,97 +37,97 @@
*
* @author Lee Rhodes
*/
-public abstract class SetOperation implements MemorySegmentStatus {
+public abstract class ThetaSetOperation implements MemorySegmentStatus {
static final int CONST_PREAMBLE_LONGS = 3;
/**
* Constructor
*/
- SetOperation() {}
+ ThetaSetOperation() {}
/**
* Makes a new builder
*
* @return a new builder
*/
- public static final SetOperationBuilder builder() {
- return new SetOperationBuilder();
+ public static final ThetaSetOperationBuilder builder() {
+ return new ThetaSetOperationBuilder();
}
/**
- * Heapify takes the SetOperations image in MemorySegment and instantiates an on-heap
- * SetOperation using the
+ * Heapify takes the ThetaSetOperation image in MemorySegment and instantiates an on-heap
+ * ThetaSetOperation using the
* Default Update Seed.
- * The resulting SetOperation will not retain any link to the source MemorySegment.
+ * The resulting ThetaSetOperation will not retain any link to the source MemorySegment.
*
*
Note: Only certain set operators during stateful operations can be serialized and thus
* heapified.
*
- * @param srcSeg an image of a SetOperation where the image seed hash matches the default seed hash.
- * @return a Heap-based SetOperation from the given MemorySegment
+ * @param srcSeg an image of a ThetaSetOperation where the image seed hash matches the default seed hash.
+ * @return a Heap-based ThetaSetOperation from the given MemorySegment
*/
- public static SetOperation heapify(final MemorySegment srcSeg) {
+ public static ThetaSetOperation heapify(final MemorySegment srcSeg) {
return heapify(srcSeg, Util.DEFAULT_UPDATE_SEED);
}
/**
- * Heapify takes the SetOperation image in MemorySegment and instantiates an on-heap
- * SetOperation using the given expectedSeed.
- * The resulting SetOperation will not retain any link to the source MemorySegment.
+ * Heapify takes the ThetaSetOperation image in MemorySegment and instantiates an on-heap
+ * ThetaSetOperation using the given expectedSeed.
+ * The resulting ThetaSetOperation will not retain any link to the source MemorySegment.
*
* Note: Only certain set operators during stateful operations can be serialized and thus
* heapified.
*
- * @param srcSeg an image of a SetOperation where the hash of the given expectedSeed matches the image seed hash.
+ * @param srcSeg an image of a ThetaSetOperation where the hash of the given expectedSeed matches the image seed hash.
* @param expectedSeed the seed used to validate the given MemorySegment image.
* See Update Hash Seed.
- * @return a Heap-based SetOperation from the given MemorySegment
+ * @return a Heap-based ThetaSetOperation from the given MemorySegment
*/
- public static SetOperation heapify(final MemorySegment srcSeg, final long expectedSeed) {
+ public static ThetaSetOperation heapify(final MemorySegment srcSeg, final long expectedSeed) {
final byte famID = srcSeg.get(JAVA_BYTE, FAMILY_BYTE);
final Family family = idToFamily(famID);
switch (family) {
case UNION : {
- return UnionImpl.heapifyInstance(srcSeg, expectedSeed);
+ return ThetaUnionImpl.heapifyInstance(srcSeg, expectedSeed);
}
case INTERSECTION : {
- return IntersectionImpl.heapifyInstance(srcSeg, expectedSeed);
+ return ThetaIntersectionImpl.heapifyInstance(srcSeg, expectedSeed);
}
default: {
- throw new SketchesArgumentException("SetOperation cannot heapify family: "
+ throw new SketchesArgumentException("ThetaSetOperation cannot heapify family: "
+ family.toString());
}
}
}
/**
- * Wrap takes the SetOperation image in MemorySegment and refers to it directly.
+ * Wrap takes the ThetaSetOperation image in MemorySegment and refers to it directly.
* There is no data copying onto the java heap.
* This method assumes the Default Update Seed.
* If the given source MemorySegment is read-only, the returned object will also be read-only.
*
* Note: Only certain set operators during stateful operations can be serialized and thus wrapped.
*
- * @param srcSeg an image of a SetOperation where the image seed hash matches the default seed hash.
- * @return a SetOperation backed by the given MemorySegment
+ * @param srcSeg an image of a ThetaSetOperation where the image seed hash matches the default seed hash.
+ * @return a ThetaSetOperation backed by the given MemorySegment
*/
- public static SetOperation wrap(final MemorySegment srcSeg) {
+ public static ThetaSetOperation wrap(final MemorySegment srcSeg) {
return wrap(srcSeg, Util.DEFAULT_UPDATE_SEED);
}
/**
- * Wrap takes the SetOperation image in MemorySegment and refers to it directly.
+ * Wrap takes the ThetaSetOperation image in MemorySegment and refers to it directly.
* There is no data copying onto the java heap.
* If the given source MemorySegment is read-only, the returned object will also be read-only.
*
* Note: Only certain set operators during stateful operations can be serialized and thus wrapped.
*
- * @param srcSeg an image of a SetOperation where the hash of the given expectedSeed matches the image seed hash.
+ * @param srcSeg an image of a ThetaSetOperation where the hash of the given expectedSeed matches the image seed hash.
* @param expectedSeed the seed used to validate the given MemorySegment image.
* See Update Hash Seed.
- * @return a SetOperation backed by the given MemorySegment
+ * @return a ThetaSetOperation backed by the given MemorySegment
*/
- public static SetOperation wrap(final MemorySegment srcSeg, final long expectedSeed) {
+ public static ThetaSetOperation wrap(final MemorySegment srcSeg, final long expectedSeed) {
final byte famID = srcSeg.get(JAVA_BYTE, FAMILY_BYTE);
final Family family = idToFamily(famID);
final int serVer = srcSeg.get(JAVA_BYTE, SER_VER_BYTE);
@@ -136,18 +136,18 @@ public static SetOperation wrap(final MemorySegment srcSeg, final long expectedS
}
switch (family) {
case UNION : {
- return UnionImpl.wrapInstance(srcSeg, expectedSeed);
+ return ThetaUnionImpl.wrapInstance(srcSeg, expectedSeed);
}
case INTERSECTION : {
- return IntersectionImpl.wrapInstance(srcSeg, expectedSeed, srcSeg.isReadOnly() );
+ return ThetaIntersectionImpl.wrapInstance(srcSeg, expectedSeed, srcSeg.isReadOnly() );
}
default:
- throw new SketchesArgumentException("SetOperation cannot wrap family: " + family.toString());
+ throw new SketchesArgumentException("ThetaSetOperation cannot wrap family: " + family.toString());
}
}
/**
- * Returns the maximum required storage bytes given a nomEntries parameter for Union operations
+ * Returns the maximum required storage bytes given a nomEntries parameter for ThetaUnion operations
* @param nomEntries Nominal Entries
* This will become the ceiling power of 2 if it is not.
* @return the maximum required storage bytes given a nomEntries parameter
@@ -158,7 +158,7 @@ public static int getMaxUnionBytes(final int nomEntries) {
}
/**
- * Returns the maximum required storage bytes given a nomEntries parameter for Intersection
+ * Returns the maximum required storage bytes given a nomEntries parameter for intersection
* operations
* @param nomEntries Nominal Entries
* This will become the ceiling power of 2 if it is not.
@@ -170,8 +170,8 @@ public static int getMaxIntersectionBytes(final int nomEntries) {
}
/**
- * Returns the maximum number of bytes for the returned CompactSketch, given the
- * value of nomEntries of the first sketch A of AnotB.
+ * Returns the maximum number of bytes for the returned CompactThetaSketch, given the
+ * value of nomEntries of the first sketch A of ThetaAnotB.
* @param nomEntries this value must be a power of 2.
* @return the maximum number of bytes.
*/
@@ -181,8 +181,8 @@ public static int getMaxAnotBResultBytes(final int nomEntries) {
}
/**
- * Gets the Family of this SetOperation
- * @return the Family of this SetOperation
+ * Gets the Family of this ThetaSetOperation
+ * @return the Family of this ThetaSetOperation
*/
public abstract Family getFamily();
diff --git a/src/main/java/org/apache/datasketches/theta/ThetaSetOperationBuilder.java b/src/main/java/org/apache/datasketches/theta/ThetaSetOperationBuilder.java
index d4af63681..d56462fd4 100644
--- a/src/main/java/org/apache/datasketches/theta/ThetaSetOperationBuilder.java
+++ b/src/main/java/org/apache/datasketches/theta/ThetaSetOperationBuilder.java
@@ -32,18 +32,18 @@
import org.apache.datasketches.thetacommon.ThetaUtil;
/**
- * For building a new SetOperation.
+ * For building a new ThetaSetOperation.
*
* @author Lee Rhodes
*/
-public final class SetOperationBuilder {
+public final class ThetaSetOperationBuilder {
private int bLgNomLongs;
private long bSeed;
private ResizeFactor bRF;
private float bP;
/**
- * Constructor for building a new SetOperation. The default configuration is
+ * Constructor for building a new ThetaSetOperation. The default configuration is
* The resulting sketch will not retain any link to the source MemorySegment.
* - *For Update Sketches this method checks if the + *
For UpdatableThetaSketches this method checks if the * Default Update Seed
* was used to create the source MemorySegment image. * - * @param srcSeg an image of a Sketch. + * @param srcSeg an image of a ThetaSketch. * - * @return a Sketch on the heap. + * @return a ThetaSketch on the heap. */ public static ThetaSketch heapify(final MemorySegment srcSeg) { return heapify(srcSeg, Util.DEFAULT_UPDATE_SEED); } /** - * Heapify takes the sketch image in MemorySegment and instantiates an on-heap Sketch. + * Heapify takes the sketch image in MemorySegment and instantiates an on-heap ThetaSketch. * *The resulting sketch will not retain any link to the source MemorySegment.
* - *For Update Sketches this method checks if the expectedSeed + *
For UpdatableThetaSketches this method checks if the expectedSeed * was used to create the source MemorySegment image.
* - * @param srcSeg an image of a Sketch that was created using the given expectedSeed. + * @param srcSeg an image of a ThetaSketch that was created using the given expectedSeed. * @param expectedSeed the seed used to validate the given MemorySegment image. * See Update Hash Seed. * Compact sketches store a 16-bit hash of the seed, but not the seed itself. - * @return a Sketch on the heap. + * @return a ThetaSketch on the heap. */ public static ThetaSketch heapify(final MemorySegment srcSeg, final long expectedSeed) { checkSegPreambleCap(srcSeg); final int familyID = extractFamilyID(srcSeg); if (familyID == Family.COMPACT.getID()) { - return CompactSketch.heapify(srcSeg, expectedSeed); + return CompactThetaSketch.heapify(srcSeg, expectedSeed); } return heapifyUpdateSketchFromMemorySegment(srcSeg, expectedSeed); } @@ -110,8 +110,8 @@ public static ThetaSketch heapify(final MemorySegment srcSeg, final long expecte * Default Update Seed * was used to create the source MemorySegment image. * - * @param srcSeg a MemorySegment with an image of a Sketch. - * @return a read-only Sketch backed by the given MemorySegment + * @param srcSeg a MemorySegment with an image of a ThetaSketch. + * @return a read-only ThetaSketch backed by the given MemorySegment */ public static ThetaSketch wrap(final MemorySegment srcSeg) { return wrap(srcSeg, Util.DEFAULT_UPDATE_SEED); @@ -131,10 +131,10 @@ public static ThetaSketch wrap(final MemorySegment srcSeg) { *This method checks if the given expectedSeed * was used to create the source MemorySegment image.
* - * @param srcSeg a MemorySegment with an image of a Sketch. + * @param srcSeg a MemorySegment with an image of a ThetaSketch. * @param expectedSeed the seed used to validate the given MemorySegment image. * See Update Hash Seed. - * @return a read-only Sketch backed by the given MemorySegment. + * @return a read-only ThetaSketch backed by the given MemorySegment. */ public static ThetaSketch wrap(final MemorySegment srcSeg, final long expectedSeed) { checkSegPreambleCap(srcSeg); @@ -143,45 +143,45 @@ public static ThetaSketch wrap(final MemorySegment srcSeg, final long expectedSe return DirectQuickSelectSketchR.readOnlyWrap(srcSeg, expectedSeed); } if (familyID == Family.COMPACT.getID()) { - return CompactSketch.wrap(srcSeg, expectedSeed); + return CompactThetaSketch.wrap(srcSeg, expectedSeed); } final Family family = Family.idToFamily(familyID); throw new SketchesArgumentException( - "Cannot wrap family: " + family + " as a Sketch"); + "Cannot wrap family: " + family + " as a ThetaSketch"); } - //Sketch interface + //ThetaSketch interface /** - * Converts this sketch to a ordered CompactSketch. + * Converts this sketch to a ordered CompactThetaSketch. * *If this.isCompact() == true this method returns this, * otherwise, this method is equivalent to * {@link #compact(boolean, MemorySegment) compact(true, null)}. * - *
A CompactSketch is always immutable.
+ *A CompactThetaSketch is always immutable.
* - * @return this sketch as an ordered CompactSketch. + * @return this sketch as an ordered CompactThetaSketch. */ - public CompactSketch compact() { - return isCompact() ? (CompactSketch)this : compact(true, null); + public CompactThetaSketch compact() { + return isCompact() ? (CompactThetaSketch)this : compact(true, null); } /** - * Convert this sketch to a CompactSketch. + * Convert this sketch to a CompactThetaSketch. * - *If this sketch is a type of UpdateSketch, the compacting process converts the hash table - * of the UpdateSketch to a simple list of the valid hash values. + *
If this sketch is a type of UpdatableThetaSketch, the compacting process converts the hash table + * of the UpdatableThetaketch to a simple list of the valid hash values. * Any hash values of zero or equal-to or greater than theta will be discarded. - * The number of valid values remaining in the CompactSketch depends on a number of factors, + * The number of valid values remaining in the CompactThetaSketch depends on a number of factors, * but may be larger or smaller than Nominal Entries (or k). * It will never exceed 2k. * If it is critical to always limit the size to no more than k, - * then rebuild() should be called on the UpdateSketch prior to calling this method.
+ * then rebuild() should be called on the UpdatableThetaSketch prior to calling this method. * - *A CompactSketch is always immutable.
+ *A CompactThetaSketch is always immutable.
* - *A new CompactSketch object is created:
+ *A new CompactThetaSketch object is created:
*Nulls and empty sketches are ignored.
* * @param sketchA The first argument * @param sketchB The second argument - * @param dstOrdered If true, the returned CompactSketch will be ordered. - * @param dstSeg If not null, the returned CompactSketch will be placed in this MemorySegment. - * @return the result CompactSketch. + * @param dstOrdered If true, the returned CompactThetaSketch will be ordered. + * @param dstSeg If not null, the returned CompactThetaSketch will be placed in this MemorySegment. + * @return the result CompactThetaSketch. */ - public abstract CompactSketch union(ThetaSketch sketchA, ThetaSketch sketchB, boolean dstOrdered, + public abstract CompactThetaSketch union(ThetaSketch sketchA, ThetaSketch sketchB, boolean dstOrdered, MemorySegment dstSeg); /** - * Perform a Union operation with this union and the given on-heap sketch of the Theta Family. - * This method is not valid for the older SetSketch, which was prior to Open Source (August, 2015). + * Perform a union operation with this ThetaUnion and the given on-heap sketch of the Theta Family. * *This method can be repeatedly called. * @@ -186,9 +185,8 @@ public abstract CompactSketch union(ThetaSketch sketchA, ThetaSketch sketchB, bo public abstract void union(ThetaSketch sketchIn); /** - * Perform a Union operation with this union and the given MemorySegment image of any sketch of the - * Theta Family. The input image may be from earlier versions of the Theta Compact Sketch, - * called the SetSketch (circa 2014), which was prior to Open Source and are compact and ordered. + * Perform a union operation with this ThetaUnion and the given MemorySegment image of any sketch of the + * Theta Family. * *
This method can be repeatedly called. * @@ -225,7 +223,7 @@ public abstract CompactSketch union(ThetaSketch sketchA, ThetaSketch sketchB, bo * method and will generally be a little slower depending on the complexity of the UTF8 encoding. *
* - *Note: this is not a Sketch Union operation. This treats the given string as a data item.
+ *Note: this is not a union operation. This treats the given string as a data item.
* * @param datum The given String. */ @@ -235,7 +233,7 @@ public abstract CompactSketch union(ThetaSketch sketchA, ThetaSketch sketchB, bo * Update this union with the given byte array item. * If the byte array is null or empty no update attempt is made and the method returns. * - *Note: this is not a Sketch Union operation. This treats the given byte array as a data + *
Note: this is not a union operation. This treats the given byte array as a data * item.
* * @param data The given byte array. @@ -246,7 +244,7 @@ public abstract CompactSketch union(ThetaSketch sketchA, ThetaSketch sketchB, bo * Update this union with the given ByteBuffer item. * If the ByteBuffer is null or empty no update attempt is made and the method returns. * - *Note: this is not a Sketch Union operation. This treats the given ByteBuffer as a data + *
Note: this is not a union operation. This treats the given ByteBuffer as a data * item.
* * @param data The given ByteBuffer. @@ -257,7 +255,7 @@ public abstract CompactSketch union(ThetaSketch sketchA, ThetaSketch sketchB, bo * Update this union with the given integer array item. * If the integer array is null or empty no update attempt is made and the method returns. * - *Note: this is not a Sketch Union operation. This treats the given integer array as a data + *
Note: this is not a union operation. This treats the given integer array as a data * item.
* * @param data The given int array. @@ -271,7 +269,7 @@ public abstract CompactSketch union(ThetaSketch sketchA, ThetaSketch sketchB, bo *Note: this will not produce the same output hash values as the {@link #update(String)} * method but will be a little faster as it avoids the complexity of the UTF8 encoding.
* - *Note: this is not a Sketch Union operation. This treats the given char array as a data + *
Note: this is not a union operation. This treats the given char array as a data * item.
* * @param data The given char array. @@ -282,7 +280,7 @@ public abstract CompactSketch union(ThetaSketch sketchA, ThetaSketch sketchB, bo * Update this union with the given long array item. * If the long array is null or empty no update attempt is made and the method returns. * - *Note: this is not a Sketch Union operation. This treats the given char array as a data + *
Note: this is not a union operation. This treats the given char array as a data * item.
* * @param data The given long array. diff --git a/src/main/java/org/apache/datasketches/theta/ThetaUnionImpl.java b/src/main/java/org/apache/datasketches/theta/ThetaUnionImpl.java index dcc773996..be0ef0014 100644 --- a/src/main/java/org/apache/datasketches/theta/ThetaUnionImpl.java +++ b/src/main/java/org/apache/datasketches/theta/ThetaUnionImpl.java @@ -41,35 +41,35 @@ import org.apache.datasketches.thetacommon.HashOperations; /** - * Shared code for the HeapUnion and DirectUnion implementations. + * Shared code for the heap union and direct union implementations. * * @author Lee Rhodes * @author Kevin Lang */ -final class UnionImpl extends Union { +final class ThetaUnionImpl extends ThetaUnion { /** - * Although the gadget object is initially an UpdateSketch, in the context of a Union it is used - * as a specialized buffer that happens to leverage much of the machinery of an UpdateSketch. + * Although the gadget object is initially an UpdatableThetaSketch, in the context of a union it is used + * as a specialized buffer that happens to leverage much of the machinery of an UpdatableThetaSketch. * However, in this context some of the key invariants of the sketch algorithm are intentionally - * violated as an optimization. As a result this object can not be considered as an UpdateSketch - * and should never be exported as an UpdateSketch. It's internal state is not necessarily + * violated as an optimization. As a result this object can not be considered as an UpdatableThetaSketch + * and should never be exported as an UpdatableThetaSketch. It's internal state is not necessarily * finalized and may contain garbage. Also its internal concept of "nominal entries" or "k" can * be meaningless. It is private for very good reasons. */ - private final UpdateSketch gadget_; + private final UpdatableThetaSketch gadget_; private final short expectedSeedHash_; //eliminates having to compute the seedHash on every union. private long unionThetaLong_; //when on-heap, this is the only copy private boolean unionEmpty_; //when on-heap, this is the only copy - private UnionImpl(final UpdateSketch gadget, final long seed) { + private ThetaUnionImpl(final UpdatableThetaSketch gadget, final long seed) { gadget_ = gadget; expectedSeedHash_ = Util.computeSeedHash(seed); } /** - * Construct a new Union SetOperation on the java heap. - * Called by SetOperationBuilder. + * Construct a new ThetaUnion on the java heap. + * Called by ThetaSetOperationBuilder. * * @param lgNomLongs See lgNomLongs * @param seed See seed @@ -77,22 +77,22 @@ private UnionImpl(final UpdateSketch gadget, final long seed) { * @param rf See Resize Factor * @return instance of this sketch */ - static UnionImpl initNewHeapInstance( + static ThetaUnionImpl initNewHeapInstance( final int lgNomLongs, final long seed, final float p, final ResizeFactor rf) { - final UpdateSketch gadget = //create with UNION family + final UpdatableThetaSketch gadget = //create with UNION family new HeapQuickSelectSketch(lgNomLongs, seed, p, rf, true); - final UnionImpl unionImpl = new UnionImpl(gadget, seed); + final ThetaUnionImpl unionImpl = new ThetaUnionImpl(gadget, seed); unionImpl.unionThetaLong_ = gadget.getThetaLong(); unionImpl.unionEmpty_ = gadget.isEmpty(); return unionImpl; } /** - * Construct a new Direct Union in the destination MemorySegment. - * Called by SetOperationBuilder. + * Construct a new direct union in the destination MemorySegment. + * Called by ThetaSetOperationBuilder. * * @param lgNomLongs See lgNomLongs. * @param seed See seed @@ -101,71 +101,71 @@ static UnionImpl initNewHeapInstance( * @param dstSeg the given MemorySegment object destination. It will be cleared prior to use. * @return this class */ - static UnionImpl initNewDirectInstance( + static ThetaUnionImpl initNewDirectInstance( final int lgNomLongs, final long seed, final float p, final ResizeFactor rf, final MemorySegment dstSeg) { - final UpdateSketch gadget = //create with UNION family + final UpdatableThetaSketch gadget = //create with UNION family new DirectQuickSelectSketch(lgNomLongs, seed, p, rf, dstSeg, null, true); - final UnionImpl unionImpl = new UnionImpl(gadget, seed); + final ThetaUnionImpl unionImpl = new ThetaUnionImpl(gadget, seed); unionImpl.unionThetaLong_ = gadget.getThetaLong(); unionImpl.unionEmpty_ = gadget.isEmpty(); return unionImpl; } /** - * Heapify a Union from a MemorySegment Union object containing data. - * Called by SetOperation. - * @param srcSeg The source MemorySegment Union object. + * Heapify a ThetaUnion from a MemorySegment object containing data. + * Called by ThetaSetOperation. + * @param srcSeg The source MemorySegment ThetaUnion object. * @param expectedSeed the seed used to validate the given MemorySegment image. * See seed * @return this class */ - static UnionImpl heapifyInstance(final MemorySegment srcSeg, final long expectedSeed) { + static ThetaUnionImpl heapifyInstance(final MemorySegment srcSeg, final long expectedSeed) { final MemorySegment srcSegRO = srcSeg.asReadOnly(); Family.UNION.checkFamilyID(extractFamilyID(srcSegRO)); - final UpdateSketch gadget = HeapQuickSelectSketch.heapifyInstance(srcSegRO, expectedSeed); - final UnionImpl unionImpl = new UnionImpl(gadget, expectedSeed); + final UpdatableThetaSketch gadget = HeapQuickSelectSketch.heapifyInstance(srcSegRO, expectedSeed); + final ThetaUnionImpl unionImpl = new ThetaUnionImpl(gadget, expectedSeed); unionImpl.unionThetaLong_ = extractUnionThetaLong(srcSegRO); unionImpl.unionEmpty_ = PreambleUtil.isEmptyFlag(srcSegRO); return unionImpl; } /** - * Fast-wrap a Union object around a Union MemorySegment object containing data. + * Fast-wrap a ThetaUnion object around a MemorySegment object containing data. * This does NO validity checking of the given MemorySegment. * @param srcSeg The source MemorySegment object. * @param expectedSeed the seed used to validate the given MemorySegment image. * See seed * @return this class */ - static UnionImpl fastWrapInstance(final MemorySegment srcSeg, final long expectedSeed) { + static ThetaUnionImpl fastWrapInstance(final MemorySegment srcSeg, final long expectedSeed) { Family.UNION.checkFamilyID(extractFamilyID(srcSeg)); - final UpdateSketch gadget = srcSeg.isReadOnly() + final UpdatableThetaSketch gadget = srcSeg.isReadOnly() ? DirectQuickSelectSketchR.fastReadOnlyWrap(srcSeg, expectedSeed) : DirectQuickSelectSketch.fastWritableWrap(srcSeg, null, expectedSeed); - final UnionImpl unionImpl = new UnionImpl(gadget, expectedSeed); + final ThetaUnionImpl unionImpl = new ThetaUnionImpl(gadget, expectedSeed); unionImpl.unionThetaLong_ = extractUnionThetaLong(srcSeg); unionImpl.unionEmpty_ = PreambleUtil.isEmptyFlag(srcSeg); return unionImpl; } /** - * Wrap a Union object around a Union MemorySegment object containing data. + * Wrap a ThetaUnion object around a MemorySegment object containing data. * @param srcSeg The source MemorySegment object. * @param expectedSeed the seed used to validate the given MemorySegment image. * See seed * @return this class */ - //Called by SetOperation and Union - static UnionImpl wrapInstance(final MemorySegment srcSeg, final long expectedSeed) { + //Called by ThetaSetOperation and ThetaUnion + static ThetaUnionImpl wrapInstance(final MemorySegment srcSeg, final long expectedSeed) { Family.UNION.checkFamilyID(extractFamilyID(srcSeg)); - final UpdateSketch gadget = srcSeg.isReadOnly() + final UpdatableThetaSketch gadget = srcSeg.isReadOnly() ? DirectQuickSelectSketchR.readOnlyWrap(srcSeg, expectedSeed) : DirectQuickSelectSketch.writableWrap(srcSeg, null, expectedSeed); - final UnionImpl unionImpl = new UnionImpl(gadget, expectedSeed); + final ThetaUnionImpl unionImpl = new ThetaUnionImpl(gadget, expectedSeed); unionImpl.unionThetaLong_ = extractUnionThetaLong(srcSeg); unionImpl.unionEmpty_ = PreambleUtil.isEmptyFlag(srcSeg); return unionImpl; @@ -188,12 +188,12 @@ MemorySegment getMemorySegment() { } @Override - public CompactSketch getResult() { + public CompactThetaSketch getResult() { return getResult(true, null); } @Override - public CompactSketch getResult(final boolean dstOrdered, final MemorySegment dstSeg) { + public CompactThetaSketch getResult(final boolean dstOrdered, final MemorySegment dstSeg) { final int gadgetCurCount = gadget_.getRetainedEntries(true); final int k = 1 << gadget_.getLgNomLongs(); final long[] gadgetCacheCopy = @@ -257,13 +257,13 @@ public byte[] toByteArray() { return gadgetByteArr; } - @Override //Stateless Union - public CompactSketch union(final ThetaSketch sketchA, final ThetaSketch sketchB, final boolean dstOrdered, + @Override //Stateless ThetaUnion + public CompactThetaSketch union(final ThetaSketch sketchA, final ThetaSketch sketchB, final boolean dstOrdered, final MemorySegment dstSeg) { reset(); union(sketchA); union(sketchB); - final CompactSketch csk = getResult(dstOrdered, dstSeg); + final CompactThetaSketch csk = getResult(dstOrdered, dstSeg); reset(); return csk; } @@ -282,7 +282,7 @@ public void union(final ThetaSketch sketchIn) { gadget_.hashUpdate(sketchIn.getCache()[0]); return; } - UnionImpl.checkSketchAndMemorySegmentFlags(sketchIn); + ThetaUnionImpl.checkSketchAndMemorySegmentFlags(sketchIn); unionThetaLong_ = min(min(unionThetaLong_, sketchIn.getThetaLong()), gadget_.getThetaLong()); //Theta rule unionEmpty_ = false; @@ -385,11 +385,11 @@ private static final void checkSketchAndMemorySegmentFlags(final ThetaSketch ske final int flags = PreambleUtil.extractFlags(seg); if ((flags & COMPACT_FLAG_MASK) > 0 ^ sketch.isCompact()) { throw new SketchesArgumentException("Possible corruption: " - + "MemorySegment Compact Flag inconsistent with Sketch"); + + "MemorySegment Compact Flag inconsistent with ThetaSketch Compact Flag"); } if ((flags & ORDERED_FLAG_MASK) > 0 ^ sketch.isOrdered()) { throw new SketchesArgumentException("Possible corruption: " - + "MemorySegment Ordered Flag inconsistent with Sketch"); + + "MemorySegment Ordered Flag inconsistent with ThetaSketch Ordered Flag"); } } diff --git a/src/main/java/org/apache/datasketches/theta/UpdatableThetaSketch.java b/src/main/java/org/apache/datasketches/theta/UpdatableThetaSketch.java index b02e8caf7..a3f511f33 100644 --- a/src/main/java/org/apache/datasketches/theta/UpdatableThetaSketch.java +++ b/src/main/java/org/apache/datasketches/theta/UpdatableThetaSketch.java @@ -50,16 +50,16 @@ import org.apache.datasketches.thetacommon.ThetaUtil; /** - * The parent class for the Update Sketch families, such as QuickSelect and Alpha. - * The primary task of an Update Sketch is to consider datums presented via the update() methods + * The parent class for the UpdatableThetaSketch families, such as QuickSelectThetaSketch and AlphaSketch. + * The primary task of an UpdatableThetaSketch is to consider datums presented via the update() methods * for inclusion in its internal cache. This is the sketch building process. * * @author Lee Rhodes */ -public abstract class UpdateSketch extends ThetaSketch { +public abstract class UpdatableThetaSketch extends ThetaSketch { private final long seed_; - UpdateSketch(final long seed) { + UpdatableThetaSketch(final long seed) { seed_ = seed; //kept only on heap, never serialized. Hoisted here for performance. } @@ -71,12 +71,12 @@ public abstract class UpdateSketch extends ThetaSketch { * Default Update Seed. * @param srcWSeg an image of a writable sketch where the image seed hash matches the default seed hash. * It must have a size of at least 24 bytes. - * @return an UpdateSketch backed by the given MemorySegment + * @return an UpdatableThetaSketch backed by the given MemorySegment * @throws SketchesArgumentException if the provided MemorySegment * is invalid, corrupted, or incompatible with this sketch type. * Callers must treat this as a fatal error for that segment. */ - public static UpdateSketch wrap(final MemorySegment srcWSeg) { + public static UpdatableThetaSketch wrap(final MemorySegment srcWSeg) { return wrap(srcWSeg, null, Util.DEFAULT_UPDATE_SEED); } @@ -92,12 +92,12 @@ public static UpdateSketch wrap(final MemorySegment srcWSeg) { * @param expectedSeed the seed used to validate the given MemorySegment image. * See Update Hash Seed. * Compact sketches store a 16-bit hash of the seed, but not the seed itself. - * @return a UpdateSketch backed by the given MemorySegment + * @return a UpdatableThetaSketch backed by the given MemorySegment * @throws SketchesArgumentException if the provided MemorySegment * is invalid, corrupted, or incompatible with this sketch type. * Callers must treat this as a fatal error for that segment. */ - public static UpdateSketch wrap( + public static UpdatableThetaSketch wrap( final MemorySegment srcWSeg, final MemorySegmentRequest mSegReq, final long expectedSeed) { @@ -108,42 +108,42 @@ public static UpdateSketch wrap( if (familyID != Family.QUICKSELECT.getID()) { final Family family = Family.idToFamily(familyID); throw new SketchesArgumentException( - "A " + family + " sketch cannot be wrapped as an UpdateSketch."); + "A " + family + " sketch cannot be wrapped as an UpdatableThetaSketch."); } if (serVer == 3 && preLongs == 3) { return DirectQuickSelectSketch.writableWrap(srcWSeg, mSegReq, expectedSeed); } else { throw new SketchesArgumentException( - "Corrupted: An UpdateSketch image must have SerVer = 3 and preLongs = 3"); + "Corrupted: An UpdatableThetaSketch image must have SerVer = 3 and preLongs = 3"); } } /** - * Instantiates an on-heap UpdateSketch from a MemorySegment. This method assumes the + * Instantiates an on-heap UpdatableThetaSketch from a MemorySegment. This method assumes the * {@link org.apache.datasketches.common.Util#DEFAULT_UPDATE_SEED}. * @param srcSeg the given MemorySegment with a sketch image. * It must have a size of at least 24 bytes. - * @return an UpdateSketch + * @return an UpdatableThetaSketch * @throws SketchesArgumentException if the provided MemorySegment * is invalid, corrupted, or incompatible with this sketch type. * Callers must treat this as a fatal error for that segment. */ - public static UpdateSketch heapify(final MemorySegment srcSeg) { + public static UpdatableThetaSketch heapify(final MemorySegment srcSeg) { return heapify(srcSeg, Util.DEFAULT_UPDATE_SEED); } /** - * Instantiates an on-heap UpdateSketch from a MemorySegment. + * Instantiates an on-heap UpdatableThetaSketch from a MemorySegment. * @param srcSeg the given MemorySegment. * It must have a size of at least 24 bytes. * @param expectedSeed the seed used to validate the given MemorySegment image. * See Update Hash Seed. - * @return an UpdateSketch + * @return an UpdatableThetaSketch * @throws SketchesArgumentException if the provided MemorySegment * is invalid, corrupted, or incompatible with this sketch type. * Callers must treat this as a fatal error for that segment. */ - public static UpdateSketch heapify(final MemorySegment srcSeg, final long expectedSeed) { + public static UpdatableThetaSketch heapify(final MemorySegment srcSeg, final long expectedSeed) { Objects.requireNonNull(srcSeg, "Source MemorySegment must not be null"); checkSegPreambleCap(srcSeg); final int familyID = extractFamilyID(srcSeg); @@ -153,10 +153,10 @@ public static UpdateSketch heapify(final MemorySegment srcSeg, final long expect return HeapQuickSelectSketch.heapifyInstance(srcSeg, expectedSeed); } - //Sketch interface + //ThetaSketch interface @Override - public CompactSketch compact(final boolean dstOrdered, final MemorySegment dstWSeg) { + public CompactThetaSketch compact(final boolean dstOrdered, final MemorySegment dstWSeg) { return componentsToCompact( getThetaLong(), getRetainedEntries(true), @@ -206,7 +206,7 @@ public boolean isSameResource(final MemorySegment that) { return this instanceof final DirectQuickSelectSketchR dqssr && dqssr.isSameResource(that); } - //UpdateSketch interface + //UpdatableThetaSketch interface /** * Returns a new builder @@ -245,7 +245,7 @@ public static final UpdateSketchBuilder builder() { * to nominal entries. * @return this sketch */ - public abstract UpdateSketch rebuild(); + public abstract UpdatableThetaSketch rebuild(); /** * Present this sketch with a long. diff --git a/src/main/java/org/apache/datasketches/theta/UpdateReturnState.java b/src/main/java/org/apache/datasketches/theta/UpdateReturnState.java index a6d5348aa..b929cfb7d 100644 --- a/src/main/java/org/apache/datasketches/theta/UpdateReturnState.java +++ b/src/main/java/org/apache/datasketches/theta/UpdateReturnState.java @@ -29,7 +29,7 @@ public enum UpdateReturnState { /** * The hash was accepted into the sketch and the retained count was incremented. */ - InsertedCountIncremented, //all UpdateSketches + InsertedCountIncremented, //all UpdatableThetaSketches /** * The hash was accepted into the sketch, the retained count was incremented. @@ -63,17 +63,17 @@ public enum UpdateReturnState { /** * The hash was rejected as a duplicate. */ - RejectedDuplicate, //all UpdateSketches hashUpdate(), enhancedHashInsert + RejectedDuplicate, //all UpdatableThetaSketches hashUpdate(), enhancedHashInsert /** * The hash was rejected because it was null or empty. */ - RejectedNullOrEmpty, //UpdateSketch.update(arr[]) + RejectedNullOrEmpty, //UpdatableThetaSketch.update(arr[]) /** * The hash was rejected because the value was negative, zero or * greater than theta. */ - RejectedOverTheta; //all UpdateSketches.hashUpdate() + RejectedOverTheta; //all UpdatableThetaSketches hashUpdate() } diff --git a/src/main/java/org/apache/datasketches/theta/UpdateSketchBuilder.java b/src/main/java/org/apache/datasketches/theta/UpdateSketchBuilder.java index d91d654b6..e607e6d9d 100644 --- a/src/main/java/org/apache/datasketches/theta/UpdateSketchBuilder.java +++ b/src/main/java/org/apache/datasketches/theta/UpdateSketchBuilder.java @@ -35,7 +35,7 @@ import org.apache.datasketches.thetacommon.ThetaUtil; /** - * For building a new UpdateSketch. + * For building a new UpdatableThetaSketch. * * @author Lee Rhodes */ @@ -55,7 +55,7 @@ public final class UpdateSketchBuilder { private int bMaxNumLocalThreads; /** - * Constructor for building a new UpdateSketch. The default configuration is + * Constructor for building a new UpdatableThetaSketch. The default configuration is *The parameters unique to the shared concurrent sketch are: @@ -411,21 +411,21 @@ public UpdateSketch build(final MemorySegment dstSeg) { *
Key parameters that are in common with other Theta sketches: + *
Key parameters that are in common with other ThetaSketches: *
The parameters unique to the shared concurrent sketch are: *
The parameters unique to the shared concurrent sketch are: *
The parameters unique to the local concurrent sketch are: @@ -501,9 +501,9 @@ public UpdateSketch buildSharedFromSketch(final UpdateSketch sketch, final Memor *
This sketch can only be associated with a Serialization Version 3 binary image format.
*/ -class WrappedCompactSketch extends CompactSketch { +class WrappedCompactSketch extends CompactThetaSketch { final byte[] bytes_; /** @@ -54,8 +54,8 @@ class WrappedCompactSketch extends CompactSketch { } /** - * Wraps the given byteArray, which must be a SerVer 3 CompactSketch image. - * @param bytes representation of serialized compressed compact sketch. + * Wraps the given byteArray, which must be a SerVer 3 CompactThetaSketch image. + * @param bytes representation of serialized CompactThetaSketch. * @param seedHash The update seedHash. * See Seed Hash. * @return this sketch @@ -65,10 +65,10 @@ static WrappedCompactSketch wrapInstance(final byte[] bytes, final short seedHas return new WrappedCompactSketch(bytes); } - //Sketch Overrides + //ThetaSketch Overrides @Override - public CompactSketch compact(final boolean dstOrdered, final MemorySegment dstSeg) { + public CompactThetaSketch compact(final boolean dstOrdered, final MemorySegment dstSeg) { return segmentToCompact(MemorySegment.ofArray(bytes_), dstOrdered, dstSeg); } @@ -80,7 +80,7 @@ public int getCurrentBytes() { } @Override - public int getRetainedEntries(final boolean valid) { //valid is only relevant for the Alpha Sketch + public int getRetainedEntries(final boolean valid) { //valid is only relevant for the AlphaSketch final int preLongs = bytes_[PREAMBLE_LONGS_BYTE]; return (preLongs == 1) ? 0 : getIntLE(bytes_, RETAINED_ENTRIES_INT); } diff --git a/src/main/java/org/apache/datasketches/theta/package-info.java b/src/main/java/org/apache/datasketches/theta/package-info.java index f203c6a8a..870f4f968 100644 --- a/src/main/java/org/apache/datasketches/theta/package-info.java +++ b/src/main/java/org/apache/datasketches/theta/package-info.java @@ -18,10 +18,10 @@ */ /** - * The theta package contains the basic sketch classes that are members of the - * Theta Sketch Framework. + * The /theta/ package contains the basic sketch classes that are members of the + * ThetaSketch Framework. * - *There is a separate Tuple package for many of the sketches that are derived from the - * same algorithms defined in the Theta Sketch Framework paper.
+ *There is a separate /tuple/ package for many of the sketches that are derived from the + * same algorithms defined in the ThetaSketch Framework paper.
*/ package org.apache.datasketches.theta; diff --git a/src/main/java/org/apache/datasketches/tuple/AnotB.java b/src/main/java/org/apache/datasketches/tuple/AnotB.java index 75c80a8d8..25b7340fb 100644 --- a/src/main/java/org/apache/datasketches/tuple/AnotB.java +++ b/src/main/java/org/apache/datasketches/tuple/AnotB.java @@ -563,7 +563,7 @@ private staticNulls and empty sketches are ignored.
* * @param tupleSketch The first argument * @param thetaSketch The second argument - * @param summary the given proxy summary for the theta sketch, which doesn't have one. + * @param summary the given proxy summary for the ThetaSketch, which doesn't have one. * This may not be null. * @return the result ordered CompactSketch on the heap. */ @@ -98,7 +98,7 @@ public CompactSketch Next, we recover the ThetaUnion SetOp and the 3 sketches and the space for the result. Then
+ * recompute the union using a ThetaUnion of the same size as the input sketches, where the end result
* will be an estimate.
*/
@Test
public void checkDirectUnionExample() {
//The first task is to compute how much off-heap space we need and set the heap large enough.
- //For the first trial, we will set the Union large enough for an exact result for THIS example.
+ //For the first trial, we will set the ThetaUnion large enough for an exact result for THIS example.
final int sketchNomEntries = 1 << 14; //16K
int unionNomEntries = 1 << 15; //32K
final int[] heapLayout = getHeapLayout(sketchNomEntries, unionNomEntries);
@@ -273,38 +273,38 @@ public void checkDirectUnionExample() {
public void setOpsExample() {
println("Set Operations Example:");
final int k = 4096;
- final UpdateSketch skA = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch skB = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch skC = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch skA = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch skB = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch skC = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=1; i<=10; i++) { skA.update(i); }
for (int i=1; i<=20; i++) { skB.update(i); }
for (int i=6; i<=15; i++) { skC.update(i); } //overlapping set
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
union.union(skA);
union.union(skB);
// ... continue to iterate on the input sketches to union
- final CompactSketch unionSk = union.getResult(); //the result union sketch
+ final CompactThetaSketch unionSk = union.getResult(); //the result union sketch
println("A U B : "+unionSk.getEstimate()); //the estimate of the union
- //Intersection is similar
+ //ThetaIntersection is similar
- final Intersection inter = SetOperation.builder().buildIntersection();
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
inter.intersect(unionSk);
inter.intersect(skC);
// ... continue to iterate on the input sketches to intersect
- final CompactSketch interSk = inter.getResult(); //the result intersection sketch
+ final CompactThetaSketch interSk = inter.getResult(); //the result intersection sketch
println("(A U B) ^ C: "+interSk.getEstimate()); //the estimate of the intersection
- //The AnotB operation is a little different as it is stateless:
+ //The ThetaAnotB operation is a little different as it is stateless:
- final AnotB aNotB = SetOperation.builder().buildANotB();
- final CompactSketch not = aNotB.aNotB(skA, skC);
+ final ThetaAnotB aNotB = ThetaSetOperation.builder().buildANotB();
+ final CompactThetaSketch not = aNotB.aNotB(skA, skC);
- println("A \\ C : "+not.getEstimate()); //the estimate of the AnotB operation
+ println("A \\ C : "+not.getEstimate()); //the estimate of the ThetaAnotB operation
}
@Test
@@ -312,15 +312,15 @@ public void checkIsSameResource() {
final int k = 16;
final MemorySegment wseg = MemorySegment.ofArray(new byte[k*16 + 32]);//288
final MemorySegment emptySeg = MemorySegment.ofArray(new byte[8]);
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(wseg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(wseg);
assertTrue(union.isSameResource(wseg));
assertFalse(union.isSameResource(emptySeg));
- final Intersection inter = SetOperation.builder().buildIntersection(wseg);
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection(wseg);
assertTrue(inter.isSameResource(wseg));
assertFalse(inter.isSameResource(emptySeg));
- final AnotB aNotB = SetOperation.builder().buildANotB();
+ final ThetaAnotB aNotB = ThetaSetOperation.builder().buildANotB();
assertFalse(aNotB.isSameResource(emptySeg));
}
@@ -338,17 +338,17 @@ static void println(final String s) {
}
/**
- * Compute offsets for MyHeap for Union, sketch1, sketch2, sketch3, resultSketch, total layout.
+ * Compute offsets for MyHeap for ThetaUnion, sketch1, sketch2, sketch3, resultSketch, total layout.
* @param sketchNomEntries the configured nominal entries of the sketch
* @param unionNomEntries configured nominal entries of the union
- * @return array of offsets for Union, sketch1, sketch2, sketch3, resultSketch, total layout
+ * @return array of offsets for ThetaUnion, sketch1, sketch2, sketch3, resultSketch, total layout
*/
private static int[] getHeapLayout(final int sketchNomEntries, final int unionNomEntries) {
final int[] heapLayout = new int[6];
- final int unionBytes = SetOperation.getMaxUnionBytes(unionNomEntries);
+ final int unionBytes = ThetaSetOperation.getMaxUnionBytes(unionNomEntries);
final int sketchBytes = getMaxUpdateSketchBytes(sketchNomEntries);
final int resultBytes = ThetaSketch.getMaxCompactSketchBytes(unionNomEntries);
- heapLayout[0] = 0; //offset for Union
+ heapLayout[0] = 0; //offset for ThetaUnion
heapLayout[1] = unionBytes; //offset for sketch1
heapLayout[2] = unionBytes + sketchBytes; //offset for sketch2
heapLayout[3] = unionBytes + 2*sketchBytes; //offset for sketch3
@@ -364,7 +364,7 @@ private static double directUnionTrial1(
final int bytes = heapLayout[1] - offset;
final MemorySegment unionSeg = heapSeg.asSlice(offset, bytes);
- Union union = SetOperation.builder().setNominalEntries(unionNomEntries).buildUnion(unionSeg);
+ ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(unionNomEntries).buildUnion(unionSeg);
final MemorySegment sketch1seg = heapSeg.asSlice(heapLayout[1], heapLayout[2]-heapLayout[1]);
final MemorySegment sketch2seg = heapSeg.asSlice(heapLayout[2], heapLayout[3]-heapLayout[2]);
@@ -372,9 +372,9 @@ private static double directUnionTrial1(
final MemorySegment resultSeg = heapSeg.asSlice(heapLayout[4], heapLayout[5]-heapLayout[4]);
//Initialize the 3 sketches
- final UpdateSketch sk1 = UpdateSketch.builder().setNominalEntries(sketchNomEntries).build(sketch1seg);
- final UpdateSketch sk2 = UpdateSketch.builder().setNominalEntries(sketchNomEntries).build(sketch2seg);
- final UpdateSketch sk3 = UpdateSketch.builder().setNominalEntries(sketchNomEntries).build(sketch3seg);
+ final UpdatableThetaSketch sk1 = UpdatableThetaSketch.builder().setNominalEntries(sketchNomEntries).build(sketch1seg);
+ final UpdatableThetaSketch sk2 = UpdatableThetaSketch.builder().setNominalEntries(sketchNomEntries).build(sketch2seg);
+ final UpdatableThetaSketch sk3 = UpdatableThetaSketch.builder().setNominalEntries(sketchNomEntries).build(sketch3seg);
//This little trial has sk1 and sk2 distinct and sk2 overlap both.
//Build the sketches.
@@ -394,7 +394,7 @@ private static double directUnionTrial1(
union.union(sk2);
//Let's recover the union and the 3rd sketch
- union = Union.wrap(unionSeg);
+ union = ThetaUnion.wrap(unionSeg);
union.union(ThetaSketch.wrap(sketch3seg));
final ThetaSketch resSk = union.getResult(true, resultSeg);
@@ -413,9 +413,9 @@ private static double directUnionTrial2(
final MemorySegment resultSeg = heapSeg.asSlice(heapLayout[4], heapLayout[5]-heapLayout[4]);
//Recover the 3 sketches
- final UpdateSketch sk1 = (UpdateSketch) ThetaSketch.wrap(sketch1seg);
- final UpdateSketch sk2 = (UpdateSketch) ThetaSketch.wrap(sketch2seg);
- final UpdateSketch sk3 = (UpdateSketch) ThetaSketch.wrap(sketch3seg);
+ final UpdatableThetaSketch sk1 = (UpdatableThetaSketch) ThetaSketch.wrap(sketch1seg);
+ final UpdatableThetaSketch sk2 = (UpdatableThetaSketch) ThetaSketch.wrap(sketch2seg);
+ final UpdatableThetaSketch sk3 = (UpdatableThetaSketch) ThetaSketch.wrap(sketch3seg);
//confirm that each of these 3 sketches is exact.
assertEquals(sk1.getEstimate(), sketchNomEntries, 0.0);
@@ -424,7 +424,7 @@ private static double directUnionTrial2(
//Create a new union in the same space with a smaller size.
Util.clear(unionSeg);
- final Union union = SetOperation.builder().setNominalEntries(unionNomEntries).buildUnion(unionSeg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(unionNomEntries).buildUnion(unionSeg);
union.union(sk1);
union.union(sk2);
union.union(sk3);
diff --git a/src/test/java/org/apache/datasketches/theta/SetOpsCornerCasesTest.java b/src/test/java/org/apache/datasketches/theta/SetOpsCornerCasesTest.java
index 80a876991..06bbd4dd7 100644
--- a/src/test/java/org/apache/datasketches/theta/SetOpsCornerCasesTest.java
+++ b/src/test/java/org/apache/datasketches/theta/SetOpsCornerCasesTest.java
@@ -30,13 +30,6 @@
import java.lang.foreign.MemorySegment;
import java.util.Random;
-import org.apache.datasketches.theta.AnotB;
-import org.apache.datasketches.theta.CompactSketch;
-import org.apache.datasketches.theta.Intersection;
-import org.apache.datasketches.theta.SetOperation;
-import org.apache.datasketches.theta.ThetaSketch;
-import org.apache.datasketches.theta.Union;
-import org.apache.datasketches.theta.UpdateSketch;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -57,38 +50,38 @@ public void checkSetOpsRandom() {
}
private static void compareSetOpsRandom(final int k, final int loA, final int hiA, final int loB, final int hiB) {
- final UpdateSketch tskA = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch tskB = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch tskA = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch tskB = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i = loA; i < hiA; i++) { tskA.update(i); }
for (int i = loB; i < hiB; i++) { tskB.update(i); }
- final CompactSketch rcskStdU = doStdUnion(tskA, tskB, k, null);
- final CompactSketch rcskPwU = doPwUnion(tskA, tskB, k);
+ final CompactThetaSketch rcskStdU = doStdUnion(tskA, tskB, k, null);
+ final CompactThetaSketch rcskPwU = doPwUnion(tskA, tskB, k);
checkCornerCase(rcskPwU, rcskStdU);
- final CompactSketch rcskStdPairU = doStdPairUnion(tskA, tskB, k, null);
+ final CompactThetaSketch rcskStdPairU = doStdPairUnion(tskA, tskB, k, null);
checkCornerCase(rcskStdPairU, rcskStdU);
- final CompactSketch rcskStdI = doStdIntersection(tskA, tskB, null);
- final CompactSketch rcskPwI = doPwIntersection(tskA, tskB);
+ final CompactThetaSketch rcskStdI = doStdIntersection(tskA, tskB, null);
+ final CompactThetaSketch rcskPwI = doPwIntersection(tskA, tskB);
checkCornerCase(rcskPwI, rcskStdI);
- final CompactSketch rcskStdPairI = doStdPairIntersection(tskA, tskB, null);
+ final CompactThetaSketch rcskStdPairI = doStdPairIntersection(tskA, tskB, null);
checkCornerCase(rcskStdPairI, rcskStdI);
- final CompactSketch rcskStdAnotB = doStdAnotB(tskA, tskB, null);
- final CompactSketch rcskPwAnotB = doPwAnotB(tskA, tskB);
+ final CompactThetaSketch rcskStdAnotB = doStdAnotB(tskA, tskB, null);
+ final CompactThetaSketch rcskPwAnotB = doPwAnotB(tskA, tskB);
checkCornerCase(rcskPwAnotB, rcskStdAnotB);
- final CompactSketch rcskStdStatefulAnotB = doStdStatefulAnotB(tskA, tskB, null);
+ final CompactThetaSketch rcskStdStatefulAnotB = doStdStatefulAnotB(tskA, tskB, null);
checkCornerCase(rcskStdStatefulAnotB, rcskStdAnotB);
}
/*******************************************/
@Test
- //Check all corner cases against standard Union, Intersection, and AnotB.
+ //Check all corner cases against standard ThetaUnion, ThetaIntersection, and ThetaAnotB.
//The unordered case is not tested
public void compareCornerCases() {
final int k = 64;
@@ -108,121 +101,121 @@ public void compareCornerCases() {
private static void cornerCaseChecksMemorySegment(final State stateA, final State stateB, final int k) {
println("StateA: " + stateA + ", StateB: " + stateB);
- final CompactSketch tcskA = generate(stateA, k);
- final CompactSketch tcskB = generate(stateB, k);
+ final CompactThetaSketch tcskA = generate(stateA, k);
+ final CompactThetaSketch tcskB = generate(stateB, k);
- MemorySegment wseg = MemorySegment.ofArray(new byte[SetOperation.getMaxUnionBytes(k)]);
+ MemorySegment wseg = MemorySegment.ofArray(new byte[ThetaSetOperation.getMaxUnionBytes(k)]);
- CompactSketch rcskStdU = doStdUnion(tcskA, tcskB, k, null);
- final CompactSketch rcskPwU = doPwUnion(tcskA, tcskB, k);
+ CompactThetaSketch rcskStdU = doStdUnion(tcskA, tcskB, k, null);
+ final CompactThetaSketch rcskPwU = doPwUnion(tcskA, tcskB, k);
checkCornerCase(rcskPwU, rcskStdU); //heap, heap
rcskStdU = doStdUnion(tcskA, tcskB, k, wseg);
- final CompactSketch rcskStdPairU = doStdPairUnion(tcskA, tcskB, k, wseg);
+ final CompactThetaSketch rcskStdPairU = doStdPairUnion(tcskA, tcskB, k, wseg);
checkCornerCase(rcskStdPairU, rcskStdU); //direct, direct
- wseg = MemorySegment.ofArray(new byte[SetOperation.getMaxIntersectionBytes(k)]);
+ wseg = MemorySegment.ofArray(new byte[ThetaSetOperation.getMaxIntersectionBytes(k)]);
- CompactSketch rcskStdI = doStdIntersection(tcskA, tcskB, null);
- final CompactSketch rcskPwI = doPwIntersection(tcskA, tcskB);
+ CompactThetaSketch rcskStdI = doStdIntersection(tcskA, tcskB, null);
+ final CompactThetaSketch rcskPwI = doPwIntersection(tcskA, tcskB);
checkCornerCase(rcskPwI, rcskStdI); //empty, empty
rcskStdI = doStdIntersection(tcskA, tcskB, wseg);
- final CompactSketch rcskStdPairI = doStdPairIntersection(tcskA, tcskB, wseg);
+ final CompactThetaSketch rcskStdPairI = doStdPairIntersection(tcskA, tcskB, wseg);
checkCornerCase(rcskStdPairI, rcskStdI); //empty, empty //direct, direct???
- wseg = MemorySegment.ofArray(new byte[SetOperation.getMaxAnotBResultBytes(k)]);
+ wseg = MemorySegment.ofArray(new byte[ThetaSetOperation.getMaxAnotBResultBytes(k)]);
- CompactSketch rcskStdAnotB = doStdAnotB(tcskA, tcskB, null);
- final CompactSketch rcskPwAnotB = doPwAnotB(tcskA, tcskB);
+ CompactThetaSketch rcskStdAnotB = doStdAnotB(tcskA, tcskB, null);
+ final CompactThetaSketch rcskPwAnotB = doPwAnotB(tcskA, tcskB);
checkCornerCase(rcskPwAnotB, rcskStdAnotB); //heap, heap
rcskStdAnotB = doStdAnotB(tcskA, tcskB, wseg);
- final CompactSketch rcskStdStatefulAnotB = doStdStatefulAnotB(tcskA, tcskB, wseg);
+ final CompactThetaSketch rcskStdStatefulAnotB = doStdStatefulAnotB(tcskA, tcskB, wseg);
checkCornerCase(rcskStdStatefulAnotB, rcskStdAnotB); //direct, heap
}
private static void cornerCaseChecks(final State stateA, final State stateB, final int k) {
println("StateA: " + stateA + ", StateB: " + stateB);
- final CompactSketch tcskA = generate(stateA, k);
- final CompactSketch tcskB = generate(stateB, k);
+ final CompactThetaSketch tcskA = generate(stateA, k);
+ final CompactThetaSketch tcskB = generate(stateB, k);
- final CompactSketch rcskStdU = doStdUnion(tcskA, tcskB, k, null);
- final CompactSketch rcskPwU = doPwUnion(tcskA, tcskB, k);
+ final CompactThetaSketch rcskStdU = doStdUnion(tcskA, tcskB, k, null);
+ final CompactThetaSketch rcskPwU = doPwUnion(tcskA, tcskB, k);
checkCornerCase(rcskPwU, rcskStdU);
- final CompactSketch rcskStdPairU = doStdPairUnion(tcskA, tcskB, k, null);
+ final CompactThetaSketch rcskStdPairU = doStdPairUnion(tcskA, tcskB, k, null);
checkCornerCase(rcskStdPairU, rcskStdU);
- final CompactSketch rcskStdI = doStdIntersection(tcskA, tcskB, null);
- final CompactSketch rcskPwI = doPwIntersection(tcskA, tcskB);
+ final CompactThetaSketch rcskStdI = doStdIntersection(tcskA, tcskB, null);
+ final CompactThetaSketch rcskPwI = doPwIntersection(tcskA, tcskB);
checkCornerCase(rcskPwI, rcskStdI);
- final CompactSketch rcskStdPairI = doStdPairIntersection(tcskA, tcskB, null);
+ final CompactThetaSketch rcskStdPairI = doStdPairIntersection(tcskA, tcskB, null);
checkCornerCase(rcskStdPairI, rcskStdI);
- final CompactSketch rcskStdAnotB = doStdAnotB(tcskA, tcskB, null);
- final CompactSketch rcskPwAnotB = doPwAnotB(tcskA, tcskB);
+ final CompactThetaSketch rcskStdAnotB = doStdAnotB(tcskA, tcskB, null);
+ final CompactThetaSketch rcskPwAnotB = doPwAnotB(tcskA, tcskB);
checkCornerCase(rcskPwAnotB, rcskStdAnotB);
- final CompactSketch rcskStdStatefulAnotB = doStdStatefulAnotB(tcskA, tcskB, null);
+ final CompactThetaSketch rcskStdStatefulAnotB = doStdStatefulAnotB(tcskA, tcskB, null);
checkCornerCase(rcskStdStatefulAnotB, rcskStdAnotB);
}
- private static CompactSketch doStdUnion(final ThetaSketch tskA, final ThetaSketch tskB, final int k, final MemorySegment wseg) {
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ private static CompactThetaSketch doStdUnion(final ThetaSketch tskA, final ThetaSketch tskB, final int k, final MemorySegment wseg) {
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
union.union(tskA);
union.union(tskB);
return union.getResult(true, wseg);
}
- private static CompactSketch doStdPairUnion(final ThetaSketch tskA, final ThetaSketch tskB, final int k, final MemorySegment wseg) {
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ private static CompactThetaSketch doStdPairUnion(final ThetaSketch tskA, final ThetaSketch tskB, final int k, final MemorySegment wseg) {
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
return union.union(tskA, tskB, true, wseg);
}
- private static CompactSketch doStdIntersection(final ThetaSketch tskA, final ThetaSketch tskB, final MemorySegment wseg) {
- final Intersection inter = SetOperation.builder().buildIntersection();
+ private static CompactThetaSketch doStdIntersection(final ThetaSketch tskA, final ThetaSketch tskB, final MemorySegment wseg) {
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
inter.intersect(tskA);
inter.intersect(tskB);
return inter.getResult(true, wseg);
}
- private static CompactSketch doStdPairIntersection(final ThetaSketch tskA, final ThetaSketch tskB, final MemorySegment wseg) {
- final Intersection inter = SetOperation.builder().buildIntersection();
+ private static CompactThetaSketch doStdPairIntersection(final ThetaSketch tskA, final ThetaSketch tskB, final MemorySegment wseg) {
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
return inter.intersect(tskA, tskB, true, wseg);
}
- private static CompactSketch doStdAnotB(final ThetaSketch tskA, final ThetaSketch tskB, final MemorySegment wseg) {
- final AnotB anotb = SetOperation.builder().buildANotB();
+ private static CompactThetaSketch doStdAnotB(final ThetaSketch tskA, final ThetaSketch tskB, final MemorySegment wseg) {
+ final ThetaAnotB anotb = ThetaSetOperation.builder().buildANotB();
return anotb.aNotB(tskA, tskB, true, wseg);
}
- private static CompactSketch doStdStatefulAnotB(final ThetaSketch tskA, final ThetaSketch tskB, final MemorySegment wseg) {
- final AnotB anotb = SetOperation.builder().buildANotB();
+ private static CompactThetaSketch doStdStatefulAnotB(final ThetaSketch tskA, final ThetaSketch tskB, final MemorySegment wseg) {
+ final ThetaAnotB anotb = ThetaSetOperation.builder().buildANotB();
anotb.setA(tskA);
anotb.notB(tskB);
anotb.getResult(false);
return anotb.getResult(true, wseg, true);
}
- private static CompactSketch doPwUnion(final ThetaSketch tskA, final ThetaSketch tskB, final int k) {
- CompactSketch tcskA, tcskB;
+ private static CompactThetaSketch doPwUnion(final ThetaSketch tskA, final ThetaSketch tskB, final int k) {
+ CompactThetaSketch tcskA, tcskB;
if (tskA == null) { tcskA = null; }
- else { tcskA = (tskA instanceof CompactSketch) ? (CompactSketch) tskA : tskA.compact(); }
+ else { tcskA = (tskA instanceof CompactThetaSketch) ? (CompactThetaSketch) tskA : tskA.compact(); }
if (tskB == null) { tcskB = null; }
- else { tcskB = (tskB instanceof CompactSketch) ? (CompactSketch) tskB : tskB.compact(); }
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ else { tcskB = (tskB instanceof CompactThetaSketch) ? (CompactThetaSketch) tskB : tskB.compact(); }
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
return union.union(tcskA, tcskB);
}
- private static CompactSketch doPwIntersection(final ThetaSketch tskA, final ThetaSketch tskB) {
- final Intersection inter = SetOperation.builder().buildIntersection();
+ private static CompactThetaSketch doPwIntersection(final ThetaSketch tskA, final ThetaSketch tskB) {
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
return inter.intersect(tskA, tskB);
}
- private static CompactSketch doPwAnotB(final ThetaSketch tskA, final ThetaSketch tskB) {
- final AnotB aNotB = SetOperation.builder().buildANotB();
+ private static CompactThetaSketch doPwAnotB(final ThetaSketch tskA, final ThetaSketch tskB) {
+ final ThetaAnotB aNotB = ThetaSetOperation.builder().buildANotB();
return aNotB.aNotB(tskA, tskB);
}
@@ -248,11 +241,11 @@ private static void checkCornerCase(final ThetaSketch rskA, final ThetaSketch rs
@Test
public void checkUnionNotOrdered() {
final int k = 64;
- final CompactSketch skNull = generate(NULL, k);
- final CompactSketch skEmpty = generate(EMPTY, k);
- final CompactSketch skHeap = generate(EST_HEAP, k);
- final CompactSketch skHeapUO = generate(EST_SEGMENT_UNORDERED, k);
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ final CompactThetaSketch skNull = generate(NULL, k);
+ final CompactThetaSketch skEmpty = generate(EMPTY, k);
+ final CompactThetaSketch skHeap = generate(EST_HEAP, k);
+ final CompactThetaSketch skHeapUO = generate(EST_SEGMENT_UNORDERED, k);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
union.union(skNull, skHeapUO);
union.union(skEmpty, skHeapUO);
union.union(skHeapUO, skNull);
@@ -264,22 +257,22 @@ public void checkUnionNotOrdered() {
@Test
public void checkSeedHash() {
final int k = 64;
- final UpdateSketch tmp1 = UpdateSketch.builder().setNominalEntries(k).setSeed(123).build();
+ final UpdatableThetaSketch tmp1 = UpdatableThetaSketch.builder().setNominalEntries(k).setSeed(123).build();
tmp1.update(1);
tmp1.update(3);
- final CompactSketch skSmallSeed2A = tmp1.compact(true, null);
+ final CompactThetaSketch skSmallSeed2A = tmp1.compact(true, null);
- final UpdateSketch tmp2 = UpdateSketch.builder().setNominalEntries(k).setSeed(123).build();
+ final UpdatableThetaSketch tmp2 = UpdatableThetaSketch.builder().setNominalEntries(k).setSeed(123).build();
tmp2.update(1);
tmp2.update(2);
- final CompactSketch skSmallSeed2B = tmp2.compact(true, null);
+ final CompactThetaSketch skSmallSeed2B = tmp2.compact(true, null);
- final CompactSketch skExact = generate(EXACT, k);
- final CompactSketch skHeap = generate(EST_HEAP, 2 * k);
+ final CompactThetaSketch skExact = generate(EXACT, k);
+ final CompactThetaSketch skHeap = generate(EST_HEAP, 2 * k);
- final Intersection inter = SetOperation.builder().buildIntersection();
- final AnotB aNotB = SetOperation.builder().buildANotB();
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
+ final ThetaAnotB aNotB = ThetaSetOperation.builder().buildANotB();
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
//Intersect
try {
@@ -315,7 +308,7 @@ public void checkSeedHash() {
aNotB.aNotB(skHeap, skSmallSeed2B);
Assert.fail();
} catch (final Exception e) { } //pass
- //Union
+ //ThetaUnion
try {
union.union(skExact, skSmallSeed2A);
Assert.fail();
@@ -337,12 +330,12 @@ public void checkSeedHash() {
@Test
public void checkPwUnionReduceToK() {
final int k = 16;
- final CompactSketch skNull = generate(NULL, k);
- final CompactSketch skEmpty = generate(EMPTY, k);
- final CompactSketch skHeap1 = generate(EST_HEAP, k);
- final CompactSketch skHeap2 = generate(EST_HEAP, k);
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
- CompactSketch csk;
+ final CompactThetaSketch skNull = generate(NULL, k);
+ final CompactThetaSketch skEmpty = generate(EMPTY, k);
+ final CompactThetaSketch skHeap1 = generate(EST_HEAP, k);
+ final CompactThetaSketch skHeap2 = generate(EST_HEAP, k);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
+ CompactThetaSketch csk;
csk = union.union(skNull, skHeap1);
Assert.assertEquals(csk.getRetainedEntries(true), k);
csk = union.union(skEmpty, skHeap1);
@@ -370,7 +363,7 @@ static void println(final String s) {
@Test
public void checkGenerator() {
final int k = 16;
- CompactSketch csk;
+ CompactThetaSketch csk;
csk = generate(State.NULL, 0);
assertNull(csk);
@@ -441,9 +434,9 @@ public void checkGenerator() {
enum State {NULL, EMPTY, SINGLE, EXACT, EST_HEAP, THLT1_CNT0_FALSE, THEQ1_CNT0_TRUE, EST_SEGMENT_UNORDERED}
- private static CompactSketch generate(final State state, final int k) {
- UpdateSketch sk = null;
- CompactSketch csk = null;
+ private static CompactThetaSketch generate(final State state, final int k) {
+ UpdatableThetaSketch sk = null;
+ CompactThetaSketch csk = null;
switch(state) {
case NULL : {
@@ -451,17 +444,17 @@ private static CompactSketch generate(final State state, final int k) {
break;
}
case EMPTY : { //results in EmptyCompactSketch
- csk = UpdateSketch.builder().setNominalEntries(k).build().compact(true, null);
+ csk = UpdatableThetaSketch.builder().setNominalEntries(k).build().compact(true, null);
break;
}
case SINGLE : { //results in SingleItemSketches most of the time
- sk = UpdateSketch.builder().setNominalEntries(k).build();
+ sk = UpdatableThetaSketch.builder().setNominalEntries(k).build();
sk.update(1);
csk = sk.compact(true, null);
break;
}
case EXACT : {
- sk = UpdateSketch.builder().setNominalEntries(k).build();
+ sk = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i = 0; i < k; i++) {
sk.update(i);
}
@@ -469,7 +462,7 @@ private static CompactSketch generate(final State state, final int k) {
break;
}
case EST_HEAP : {
- sk = UpdateSketch.builder().setNominalEntries(k).build();
+ sk = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i = 0; i < (4 * k); i++) {
sk.update(i);
}
@@ -477,20 +470,20 @@ private static CompactSketch generate(final State state, final int k) {
break;
}
case THLT1_CNT0_FALSE : {
- sk = UpdateSketch.builder().setP((float)0.5).setNominalEntries(k).build();
+ sk = UpdatableThetaSketch.builder().setP((float)0.5).setNominalEntries(k).build();
sk.update(7); //above theta
assert(sk.getRetainedEntries(true) == 0);
csk = sk.compact(true, null); //compact as {Th < 1.0, 0, F}
break;
}
case THEQ1_CNT0_TRUE : {
- sk = UpdateSketch.builder().setP((float)0.5).setNominalEntries(k).build();
+ sk = UpdatableThetaSketch.builder().setP((float)0.5).setNominalEntries(k).build();
assert(sk.getRetainedEntries(true) == 0);
csk = sk.compact(true, null); //compact as {Th < 1.0, 0, T}
break;
}
case EST_SEGMENT_UNORDERED : {
- sk = UpdateSketch.builder().setNominalEntries(k).build();
+ sk = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i = 0; i < (4 * k); i++) {
sk.update(i);
}
diff --git a/src/test/java/org/apache/datasketches/theta/SingleItemSketchTest.java b/src/test/java/org/apache/datasketches/theta/SingleItemSketchTest.java
index a0c3cd346..081d24629 100644
--- a/src/test/java/org/apache/datasketches/theta/SingleItemSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/SingleItemSketchTest.java
@@ -42,7 +42,7 @@ public class SingleItemSketchTest {
@Test
public void check1() {
- final Union union = SetOperation.builder().buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().buildUnion();
union.union(SingleItemSketch.create(1));
union.union(SingleItemSketch.create(1.0));
union.union(SingleItemSketch.create(0.0));
@@ -82,7 +82,7 @@ public void check1() {
@Test
public void check2() {
final long seed = Util.DEFAULT_UPDATE_SEED;
- final Union union = SetOperation.builder().buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().buildUnion();
union.union(SingleItemSketch.create(1, seed));
union.union(SingleItemSketch.create(1.0, seed));
union.union(SingleItemSketch.create(0.0, seed));
@@ -157,11 +157,11 @@ public void checkSerDe() {
final SingleItemSketch sis3 = SingleItemSketch.heapify(seg , defaultSeedHash);
assertEquals(sis3.getEstimate(), 1.0);
- final Union union = SetOperation.builder().buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().buildUnion();
union.union(sis);
union.union(sis2);
union.union(sis3);
- final CompactSketch csk = union.getResult();
+ final CompactThetaSketch csk = union.getResult();
assertTrue(csk instanceof SingleItemSketch);
assertEquals(union.getResult().getEstimate(), 1.0);
}
@@ -176,7 +176,7 @@ public void checkRestricted() {
@Test
public void unionWrapped() {
final ThetaSketch sketch = SingleItemSketch.create(1);
- final Union union = SetOperation.builder().buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().buildUnion();
final MemorySegment seg = MemorySegment.ofArray(sketch.toByteArray());
union.union(seg );
assertEquals(union.getResult().getEstimate(), 1, 0);
@@ -184,11 +184,11 @@ public void unionWrapped() {
@Test
public void buildAndCompact() {
- UpdateSketch sk1;
- CompactSketch csk;
+ UpdatableThetaSketch sk1;
+ CompactThetaSketch csk;
int bytes;
//On-heap
- sk1 = UpdateSketch.builder().setNominalEntries(32).build();
+ sk1 = UpdatableThetaSketch.builder().setNominalEntries(32).build();
sk1.update(1);
csk = sk1.compact(true, null);
assertTrue(csk instanceof SingleItemSketch);
@@ -198,7 +198,7 @@ public void buildAndCompact() {
//Off-heap
bytes = ThetaSketch.getMaxUpdateSketchBytes(32);
MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
- sk1= UpdateSketch.builder().setNominalEntries(32).build(wseg );
+ sk1= UpdatableThetaSketch.builder().setNominalEntries(32).build(wseg );
sk1.update(1);
csk = sk1.compact(true, null);
assertTrue(csk instanceof SingleItemSketch);
@@ -215,25 +215,25 @@ public void buildAndCompact() {
@Test
public void intersection() {
- UpdateSketch sk1, sk2;
- CompactSketch csk;
+ UpdatableThetaSketch sk1, sk2;
+ CompactThetaSketch csk;
int bytes;
- //Intersection on-heap
- sk1 = UpdateSketch.builder().setNominalEntries(32).build();
- sk2 = UpdateSketch.builder().setNominalEntries(32).build();
+ //ThetaIntersection on-heap
+ sk1 = UpdatableThetaSketch.builder().setNominalEntries(32).build();
+ sk2 = UpdatableThetaSketch.builder().setNominalEntries(32).build();
sk1.update(1);
sk1.update(2);
sk2.update(1);
- Intersection inter = SetOperation.builder().buildIntersection();
+ ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
inter.intersect(sk1);
inter.intersect(sk2);
csk = inter.getResult(true, null);
assertTrue(csk instanceof SingleItemSketch);
- //Intersection off-heap
- bytes = SetOperation.getMaxIntersectionBytes(32);
+ //ThetaIntersection off-heap
+ bytes = ThetaSetOperation.getMaxIntersectionBytes(32);
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
- inter = SetOperation.builder().buildIntersection(wseg );
+ inter = ThetaSetOperation.builder().buildIntersection(wseg );
inter.intersect(sk1);
inter.intersect(sk2);
csk = inter.getResult(true, null);
@@ -244,24 +244,24 @@ public void intersection() {
@Test
public void union() {
- UpdateSketch sk1, sk2;
- CompactSketch csk;
+ UpdatableThetaSketch sk1, sk2;
+ CompactThetaSketch csk;
int bytes;
- //Union on-heap
- sk1 = UpdateSketch.builder().setNominalEntries(32).build();
- sk2 = UpdateSketch.builder().setNominalEntries(32).build();
+ //ThetaUnion on-heap
+ sk1 = UpdatableThetaSketch.builder().setNominalEntries(32).build();
+ sk2 = UpdatableThetaSketch.builder().setNominalEntries(32).build();
sk1.update(1);
sk2.update(1);
- Union union = SetOperation.builder().buildUnion();
+ ThetaUnion union = ThetaSetOperation.builder().buildUnion();
union.union(sk1);
union.union(sk2);
csk = union.getResult(true, null);
assertTrue(csk instanceof SingleItemSketch);
- //Union off-heap
- bytes = SetOperation.getMaxUnionBytes(32);
+ //ThetaUnion off-heap
+ bytes = ThetaSetOperation.getMaxUnionBytes(32);
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
- union = SetOperation.builder().buildUnion(wseg );
+ union = ThetaSetOperation.builder().buildUnion(wseg );
union.union(sk1);
union.union(sk2);
csk = union.getResult(true, null);
@@ -272,32 +272,32 @@ public void union() {
@Test
public void aNotB() {
- UpdateSketch sk1, sk2;
- CompactSketch csk;
- //AnotB on-heap
- sk1 = UpdateSketch.builder().setNominalEntries(32).build();
- sk2 = UpdateSketch.builder().setNominalEntries(32).build();
+ UpdatableThetaSketch sk1, sk2;
+ CompactThetaSketch csk;
+ //ThetaAnotB on-heap
+ sk1 = UpdatableThetaSketch.builder().setNominalEntries(32).build();
+ sk2 = UpdatableThetaSketch.builder().setNominalEntries(32).build();
sk1.update(1);
sk2.update(2);
- final AnotB aNotB = SetOperation.builder().buildANotB();
+ final ThetaAnotB aNotB = ThetaSetOperation.builder().buildANotB();
aNotB.setA(sk1);
aNotB.notB(sk2);
csk = aNotB.getResult(true, null, true);
assertTrue(csk instanceof SingleItemSketch);
- //not AnotB off-heap form
+ //not ThetaAnotB off-heap form
}
@Test
public void checkHeapifyInstance() {
- final UpdateSketch sk1 = new UpdateSketchBuilder().build();
+ final UpdatableThetaSketch sk1 = new UpdateSketchBuilder().build();
sk1.update(1);
- final UpdateSketch sk2 = new UpdateSketchBuilder().build();
+ final UpdatableThetaSketch sk2 = new UpdateSketchBuilder().build();
sk2.update(1);
- final Intersection inter = SetOperation.builder().buildIntersection();
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
inter.intersect(sk1);
inter.intersect(sk2);
final MemorySegment wseg = MemorySegment.ofArray(new byte[16]);
- final CompactSketch csk = inter.getResult(false, wseg );
+ final CompactThetaSketch csk = inter.getResult(false, wseg );
assertTrue(csk.isOrdered());
final ThetaSketch csk2 = ThetaSketch.heapify(wseg );
assertTrue(csk2 instanceof SingleItemSketch);
@@ -307,7 +307,7 @@ public void checkHeapifyInstance() {
@Test
public void checkSingleItemBadFlags() {
final short defaultSeedHash = Util.computeSeedHash(Util.DEFAULT_UPDATE_SEED);
- final UpdateSketch sk1 = new UpdateSketchBuilder().build();
+ final UpdatableThetaSketch sk1 = new UpdateSketchBuilder().build();
sk1.update(1);
final MemorySegment wseg = MemorySegment.ofArray(new byte[16]);
sk1.compact(true, wseg );
@@ -330,13 +330,13 @@ public void checkDirectUnionSingleItem2() {
@Test
public void checkSingleItemCompact() {
- final UpdateSketch sk1 = new UpdateSketchBuilder().build();
+ final UpdatableThetaSketch sk1 = new UpdateSketchBuilder().build();
sk1.update(1);
- final CompactSketch csk = sk1.compact();
+ final CompactThetaSketch csk = sk1.compact();
assertTrue(csk instanceof SingleItemSketch);
- final CompactSketch csk2 = csk.compact();
+ final CompactThetaSketch csk2 = csk.compact();
assertEquals(csk, csk2);
- final CompactSketch csk3 = csk.compact(true, MemorySegment.ofArray(new byte[16]));
+ final CompactThetaSketch csk3 = csk.compact(true, MemorySegment.ofArray(new byte[16]));
assertTrue(csk3 instanceof DirectCompactSketch);
assertEquals(csk2.getCurrentPreambleLongs(), 1);
assertEquals(csk3.getCurrentPreambleLongs(), 1);
diff --git a/src/test/java/org/apache/datasketches/theta/SketchMiscTest.java b/src/test/java/org/apache/datasketches/theta/SketchMiscTest.java
index a920b8426..cc896e344 100644
--- a/src/test/java/org/apache/datasketches/theta/SketchMiscTest.java
+++ b/src/test/java/org/apache/datasketches/theta/SketchMiscTest.java
@@ -35,24 +35,24 @@
public class SketchMiscTest {
private static MemorySegment getCompactSketchMemorySegment(final int k, final int from, final int to) {
- final UpdateSketch sk1 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch sk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=from; i If the AlphaSketch is fed into any SetOperation, the error distribution reverts back to the
+ * If the AlphaSketch is fed into any ThetaSetOperation, the error distribution reverts back to the
* normal QuickSelect/KMV error distribution (~1/sqrt(k)). For this reason, the AlphaSketch
- * does not have a sister class for off-heap operation. The Alpha Sketch has a roughly 30% faster
+ * does not have a sister class for off-heap operation. The AlphaSketch has a roughly 30% faster
* overall update time as compared to the QuickSelect sketch family. The Alpha Sketch is created using the UpdateSketch.builder().
+ * The AlphaSketch is created using the UpdatableThetaSketchBuilder().
* See Alpha TCF and
* Theta Sketch Framework
*/
@@ -56,35 +56,35 @@ public enum Family {
* The QuickSelect Sketch family is a member of the Theta Sketch Framework of sketches and
* is the workhorse of the Theta Sketch Families and can be constructed for either on-heap or
* off-heap operation.
- * The QuickSelect Sketch is created using the UpdateSketch.builder().
+ * The QuickSelect Sketch is created using the UpdatableThetaSketchBuilder().
* See Quick Select TCF
*/
QUICKSELECT(2, "QuickSelect", 3, 3),
/**
* The Compact Sketch family is a member of the Theta Sketch Framework of sketches.
- * The are read-only and cannot be updated, but can participate in any of the Set Operations.
- * The compact sketches are never created directly with a constructor or Builder.
+ * They are read-only and cannot be updated, but can participate in any of the Set Operations.
+ * The compact sketches are never created directly with a constructor or builder.
* Instead they are created as a result of the compact()
- * method of an UpdateSketch or as a result of a getSketchSamples() of a SetOperation.
+ * method of an UpdatableThetaSketch or as a result of a getSketchSamples() of a ThetaSetOperation.
*/
COMPACT(3, "Compact", 1, 3),
/**
* The Union family is an operation for the Theta Sketch Framework of sketches.
- * The Union is constructed using the SetOperation.builder().
+ * The Union is constructed using the ThetaSetOperationBuilder().
*/
UNION(4, "Union", 4, 4),
/**
* The Intersection family is an operation for the Theta Sketch Framework of sketches.
- * The Intersection is constructed using the SetOperation.builder().
+ * The ThetaIntersection is constructed using the ThetaSetOperationBuilder().
*/
INTERSECTION(5, "Intersection", 3, 3),
/**
* The A and not B family is an operation for the Theta Sketch Framework of sketches.
- * The AnotB operation is constructed using the SetOperation.builder().
+ * The ThetaAnotB operation is constructed using the ThetaSetOperationBuilder().
*/
A_NOT_B(6, "AnotB", 3, 3),
diff --git a/src/main/java/org/apache/datasketches/fdt/FdtSketch.java b/src/main/java/org/apache/datasketches/fdt/FdtSketch.java
index 9dc6aecca..fb9f5c752 100644
--- a/src/main/java/org/apache/datasketches/fdt/FdtSketch.java
+++ b/src/main/java/org/apache/datasketches/fdt/FdtSketch.java
@@ -24,7 +24,7 @@
import org.apache.datasketches.common.SketchesArgumentException;
import org.apache.datasketches.thetacommon.ThetaUtil;
-import org.apache.datasketches.tuple.strings.ArrayOfStringsSketch;
+import org.apache.datasketches.tuple.strings.ArrayOfStringsTupleSketch;
/**
* A Frequent Distinct Tuples sketch.
@@ -46,7 +46,7 @@
*
* @author Lee Rhodes
*/
-public final class FdtSketch extends ArrayOfStringsSketch {
+public final class FdtSketch extends ArrayOfStringsTupleSketch {
/**
* Create new instance of Frequent Distinct Tuples sketch with the given
diff --git a/src/main/java/org/apache/datasketches/theta/ThetaSketch.java b/src/main/java/org/apache/datasketches/theta/ThetaSketch.java
index 7ce965084..1b82ec76b 100644
--- a/src/main/java/org/apache/datasketches/theta/ThetaSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/ThetaSketch.java
@@ -45,7 +45,7 @@
/**
* The top-level class for all theta sketches. This class is never constructed directly.
- * Use the UpdatableThetaSketch.builder() methods to create UpdatableThetaSketches.
+ * Use the UpdatableThetaSketchBuilder() methods to create UpdatableThetaSketches.
*
* @author Lee Rhodes
*/
diff --git a/src/main/java/org/apache/datasketches/theta/UpdatableThetaSketch.java b/src/main/java/org/apache/datasketches/theta/UpdatableThetaSketch.java
index a3f511f33..8b75c7883 100644
--- a/src/main/java/org/apache/datasketches/theta/UpdatableThetaSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/UpdatableThetaSketch.java
@@ -212,8 +212,8 @@ public boolean isSameResource(final MemorySegment that) {
* Returns a new builder
* @return a new builder
*/
- public static final UpdateSketchBuilder builder() {
- return new UpdateSketchBuilder();
+ public static final UpdatableThetaSketchBuilder builder() {
+ return new UpdatableThetaSketchBuilder();
}
/**
diff --git a/src/main/java/org/apache/datasketches/theta/UpdateSketchBuilder.java b/src/main/java/org/apache/datasketches/theta/UpdatableThetaSketchBuilder.java
similarity index 94%
rename from src/main/java/org/apache/datasketches/theta/UpdateSketchBuilder.java
rename to src/main/java/org/apache/datasketches/theta/UpdatableThetaSketchBuilder.java
index e607e6d9d..1493c1209 100644
--- a/src/main/java/org/apache/datasketches/theta/UpdateSketchBuilder.java
+++ b/src/main/java/org/apache/datasketches/theta/UpdatableThetaSketchBuilder.java
@@ -39,7 +39,7 @@
*
* @author Lee Rhodes
*/
-public final class UpdateSketchBuilder {
+public final class UpdatableThetaSketchBuilder {
private int bLgNomLongs;
private long bSeed;
private ResizeFactor bRF;
@@ -75,7 +75,7 @@ public final class UpdateSketchBuilder {
* Note: only retained hash values are compared, and the Tuple summary values are not accounted for in the
* similarity measure. Note: For very large pairs of sketches, where the configured nominal entries of the sketches
* are 2^25 or 2^26, this method may produce unpredictable results.
*
- * @param sketchA The first argument, a Tuple sketch with summary type S
- * @param sketchB The second argument, a Tuple sketch with summary type S
+ * @param sketchA The first argument, a TupleSketch with summary type S
+ * @param sketchB The second argument, a TupleSketch with summary type S
* @param summarySetOps instance of SummarySetOperations used to unify or intersect summaries.
* @param Note: For very large pairs of sketches, where the configured nominal entries of the sketches
* are 2^25 or 2^26, this method may produce unpredictable results.
*
- * @param sketchA The first argument, a Tuple sketch with summary type S
- * @param sketchB The second argument, a Theta sketch
- * @param summary the given proxy summary for the theta sketch, which doesn't have one.
+ * @param sketchA The first argument, a TupleSketch with summary type S
+ * @param sketchB The second argument, a ThetaSketch
+ * @param summary the given proxy summary for the ThetaSketch, which doesn't have one.
* This may not be null.
* @param summarySetOps instance of SummarySetOperations used to unify or intersect summaries.
* @param The stateful operation is as follows: The stateful operation is as in the following example: The stateless operation is as follows: The stateless operation is as in the following example: Calling the setA operation a second time essentially clears the internal state and loads
@@ -67,7 +69,7 @@
*
* @author Lee Rhodes
*/
-public final class AnotB An input argument of null will throw an exception. An input argument of null or empty is ignored. An input argument of null or empty is ignored. Use {@link #getResult(boolean)} to obtain the result. This a stateless operation and has no impact on the internal state of this operator.
- * Thus, this is not an accumulating update and is independent of the {@link #setA(Sketch)},
- * {@link #notB(Sketch)}, {@link #notB(org.apache.datasketches.theta.ThetaSketch)}, and
+ * Thus, this is not an accumulating update and is independent of the {@link #setA(TupleSketch)},
+ * {@link #notB(TupleSketch)}, {@link #notB(ThetaSketch)}, and
* {@link #getResult(boolean)} methods. If either argument is null an exception is thrown. double getLowerBoundForBoverA(
- final Sketch sketchA,
- final Sketch sketchB) {
+ final TupleSketch sketchA,
+ final TupleSketch sketchB) {
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
checkThetas(thetaLongA, thetaLongB);
@@ -84,7 +84,7 @@ public static double getLowerBoundForBoverA(
* @return the approximate lower bound for B over A
*/
public static double getLowerBoundForBoverA(
- final Sketch sketchA,
+ final TupleSketch sketchA,
final org.apache.datasketches.theta.ThetaSketch sketchB) {
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
@@ -108,8 +108,8 @@ public static double getLowerBoundForBoverA(
* @return the approximate upper bound for B over A
*/
public static double getUpperBoundForBoverA(
- final Sketch sketchA,
- final Sketch sketchB) {
+ final TupleSketch sketchA,
+ final TupleSketch sketchB) {
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
checkThetas(thetaLongA, thetaLongB);
@@ -132,7 +132,7 @@ public static double getUpperBoundForBoverA(
* @return the approximate upper bound for B over A
*/
public static double getUpperBoundForBoverA(
- final Sketch sketchA,
+ final TupleSketch sketchA,
final org.apache.datasketches.theta.ThetaSketch sketchB) {
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
@@ -156,8 +156,8 @@ public static double getUpperBoundForBoverA(
* @return the estimate for B over A
*/
public static double getEstimateOfBoverA(
- final Sketch sketchA,
- final Sketch sketchB) {
+ final TupleSketch sketchA,
+ final TupleSketch sketchB) {
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
checkThetas(thetaLongA, thetaLongB);
@@ -180,7 +180,7 @@ public static double getEstimateOfBoverA(
* @return the estimate for B over A
*/
public static double getEstimateOfBoverA(
- final Sketch sketchA,
+ final TupleSketch sketchA,
final org.apache.datasketches.theta.ThetaSketch sketchB) {
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
diff --git a/src/main/java/org/apache/datasketches/tuple/CompactSketch.java b/src/main/java/org/apache/datasketches/tuple/CompactTupleSketch.java
similarity index 89%
rename from src/main/java/org/apache/datasketches/tuple/CompactSketch.java
rename to src/main/java/org/apache/datasketches/tuple/CompactTupleSketch.java
index b05fd9c15..030eae7e5 100644
--- a/src/main/java/org/apache/datasketches/tuple/CompactSketch.java
+++ b/src/main/java/org/apache/datasketches/tuple/CompactTupleSketch.java
@@ -32,16 +32,16 @@
import org.apache.datasketches.common.SketchesArgumentException;
/**
- * CompactSketches are never created directly. They are created as a result of
- * the compact() method of an UpdatableSketch or as a result of the getResult()
- * method of a set operation like Union, Intersection or AnotB. CompactSketch
- * consists of a compact list (i.e. no intervening spaces) of hash values,
+ * CompactTupleSketches are never created directly. They are created as a result of
+ * the compact() method of an UpdatableTupleSketch or as a result of the getResult()
+ * method of a set operation like TupleUnion, TupleIntersection or TupleAnotB.
+ * CompactTupleSketch consists of a compact list (i.e. no intervening spaces) of hash values,
* corresponding list of Summaries, and a value for theta. The lists may or may
- * not be ordered. CompactSketch is read-only.
+ * not be ordered. CompactTupleSketch is read-only.
*
* @param type of Summary
*/
-public final class CompactSketch extends Sketch {
+public final class CompactTupleSketch extends TupleSketch {
private static final byte serialVersionWithSummaryClassNameUID = 1;
private static final byte serialVersionUIDLegacy = 2;
private static final byte serialVersionUID = 3;
@@ -54,13 +54,13 @@ private enum FlagsLegacy { IS_BIG_ENDIAN, IS_EMPTY, HAS_ENTRIES, IS_THETA_INCLUD
private enum Flags { IS_RESERVED, IS_READ_ONLY, IS_EMPTY, IS_COMPACT, IS_ORDERED }
/**
- * Create a CompactSketch from correct components
+ * Create a CompactTupleSketch from correct components
* @param hashArr compacted hash array
* @param summaryArr compacted summary array
* @param thetaLong long value of theta
* @param empty empty flag
*/
- CompactSketch(final long[] hashArr, final S[] summaryArr, final long thetaLong, final boolean empty) {
+ CompactTupleSketch(final long[] hashArr, final S[] summaryArr, final long thetaLong, final boolean empty) {
super(thetaLong, empty, null);
super.thetaLong_ = thetaLong;
super.empty_ = empty;
@@ -69,12 +69,12 @@ private enum Flags { IS_RESERVED, IS_READ_ONLY, IS_EMPTY, IS_COMPACT, IS_ORDERED
}
/**
- * This is to create an instance of a CompactSketch given a serialized form
+ * This is to create an instance of a CompactTupleSketch given a serialized form
*
- * @param seg MemorySegment object with serialized CompactSketch
+ * @param seg MemorySegment object with serialized CompactTupleSketch
* @param deserializer the SummaryDeserializer
*/
- CompactSketch(final MemorySegment seg, final SummaryDeserializer deserializer) {
+ CompactTupleSketch(final MemorySegment seg, final SummaryDeserializer deserializer) {
super(Long.MAX_VALUE, true, null);
int offset = 0;
final byte preambleLongs = seg.get(JAVA_BYTE, offset++);
@@ -86,7 +86,7 @@ private enum Flags { IS_RESERVED, IS_READ_ONLY, IS_EMPTY, IS_COMPACT, IS_ORDERED
"Unsupported serial version. Expected: " + serialVersionUID + " or lower, actual: " + version);
}
SerializerDeserializer
- .validateType(seg.get(JAVA_BYTE, offset++), SerializerDeserializer.SketchType.CompactSketch);
+ .validateType(seg.get(JAVA_BYTE, offset++), SerializerDeserializer.SketchType.CompactTupleSketch);
if (version <= serialVersionUIDLegacy) { // legacy serial format
final byte flags = seg.get(JAVA_BYTE, offset++);
empty_ = (flags & (1 << FlagsLegacy.IS_EMPTY.ordinal())) > 0;
@@ -166,7 +166,7 @@ private int readSummary(final MemorySegment seg, final int offset, final int i,
}
@Override
- public CompactSketch compact() {
+ public CompactTupleSketch compact() {
return this;
}
@@ -214,7 +214,7 @@ public byte[] toByteArray() {
bytes[offset++] = (byte) preambleLongs;
bytes[offset++] = serialVersionUID;
bytes[offset++] = (byte) Family.TUPLE.getID();
- bytes[offset++] = (byte) SerializerDeserializer.SketchType.CompactSketch.ordinal();
+ bytes[offset++] = (byte) SerializerDeserializer.SketchType.CompactTupleSketch.ordinal();
offset++; // unused
bytes[offset++] = (byte) (
(1 << Flags.IS_COMPACT.ordinal())
diff --git a/src/main/java/org/apache/datasketches/tuple/Filter.java b/src/main/java/org/apache/datasketches/tuple/Filter.java
index 2ed156b84..8706043c1 100644
--- a/src/main/java/org/apache/datasketches/tuple/Filter.java
+++ b/src/main/java/org/apache/datasketches/tuple/Filter.java
@@ -24,7 +24,7 @@
import java.util.function.Predicate;
/**
- * Class for filtering entries from a {@link Sketch} given a {@link Summary}
+ * Class for filtering entries from a {@link TupleSketch} given a {@link Summary}
*
* @param {
HashTables() { }
//must have valid entries
- void fromSketch(final Sketch sketch) {
+ void fromSketch(final TupleSketch sketch) {
numKeys = sketch.getRetainedEntries();
lgTableSize = getLgTableSize(numKeys);
@@ -58,12 +60,12 @@ void fromSketch(final Sketch sketch) {
}
//must have valid entries
- void fromSketch(final org.apache.datasketches.theta.ThetaSketch sketch, final S summary) {
+ void fromSketch(final ThetaSketch sketch, final S summary) {
numKeys = sketch.getRetainedEntries(true);
lgTableSize = getLgTableSize(numKeys);
hashTable = new long[1 << lgTableSize];
- final org.apache.datasketches.theta.HashIterator it = sketch.iterator();
+ final HashIterator it = sketch.iterator();
while (it.next()) {
final long hash = it.get();
final int index = hashInsertOnly(hashTable, lgTableSize, hash);
@@ -92,9 +94,9 @@ private void fromArrays(final long[] hashArr, final S[] summaryArr, final int co
}
}
- //For Tuple Sketches
+ //For TupleSketches
HashTables getIntersectHashTables(
- final Sketch nextTupleSketch,
+ final TupleSketch nextTupleSketch,
final long thetaLong,
final SummarySetOperations summarySetOps) {
@@ -121,9 +123,9 @@ HashTables getIntersectHashTables(
return resultHT;
}
- //For Theta Sketches
+ //For ThetaSketches
HashTables getIntersectHashTables(
- final org.apache.datasketches.theta.ThetaSketch nextThetaSketch,
+ final ThetaSketch nextThetaSketch,
final long thetaLong,
final SummarySetOperations summarySetOps,
final S summary) {
@@ -135,7 +137,7 @@ HashTables getIntersectHashTables(
final long[] matchHashArr = new long[maxMatchSize];
final S[] matchSummariesArr = (S[]) Array.newInstance(summaryType, maxMatchSize);
int matchCount = 0;
- final org.apache.datasketches.theta.HashIterator it = nextThetaSketch.iterator();
+ final HashIterator it = nextThetaSketch.iterator();
//scan B & search A(hashTable) for match
while (it.next()) {
diff --git a/src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java b/src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java
index 2a57a16a5..3df418737 100644
--- a/src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java
+++ b/src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java
@@ -27,10 +27,11 @@
import static org.apache.datasketches.thetacommon.BoundsOnRatiosInTupleSketchedSets.getUpperBoundForBoverA;
import org.apache.datasketches.common.SketchesArgumentException;
+import org.apache.datasketches.theta.ThetaSketch;
import org.apache.datasketches.thetacommon.ThetaUtil;
/**
- * Jaccard similarity of two Tuple Sketches, or alternatively, of a Tuple and Theta Sketch.
+ * Jaccard similarity of two TupleSketches, or alternatively, of a TupleSketch and a ThetaSketch.
*
* Summary
* @return a double array {LowerBound, Estimate, UpperBound} of the Jaccard index.
* The Upper and Lower bounds are for a confidence interval of 95.4% or +/- 2 standard deviations.
*/
public static double[] jaccard(
- final Sketch sketchA,
- final Sketch sketchB,
+ final TupleSketch sketchA,
+ final TupleSketch sketchB,
final SummarySetOperations summarySetOps) {
//Corner case checks
if (sketchA == null || sketchB == null) { return ZEROS.clone(); }
@@ -71,15 +72,15 @@ public static double[] jaccard(
final int countA = sketchA.getRetainedEntries();
final int countB = sketchB.getRetainedEntries();
- //Create the Union
+ //Create the TupleUnion
final int minK = 1 << ThetaUtil.MIN_LG_NOM_LONGS;
final int maxK = 1 << ThetaUtil.MAX_LG_NOM_LONGS;
final int newK = max(min(ceilingPowerOf2(countA + countB), maxK), minK);
- final Union union = new Union<>(newK, summarySetOps);
+ final TupleUnion union = new TupleUnion<>(newK, summarySetOps);
union.union(sketchA);
union.union(sketchB);
- final Sketch unionAB = union.getResult();
+ final TupleSketch unionAB = union.getResult();
final long thetaLongUAB = unionAB.getThetaLong();
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
@@ -91,12 +92,12 @@ public static double[] jaccard(
return ONES.clone();
}
- //Create the Intersection
- final Intersection inter = new Intersection<>(summarySetOps);
+ //Create the TupleIntersection
+ final TupleIntersection inter = new TupleIntersection<>(summarySetOps);
inter.intersect(sketchA);
inter.intersect(sketchB);
inter.intersect(unionAB); //ensures that intersection is a subset of the union
- final Sketch interABU = inter.getResult();
+ final TupleSketch interABU = inter.getResult();
final double lb = getLowerBoundForBoverA(unionAB, interABU);
final double est = getEstimateOfBoverA(unionAB, interABU);
@@ -114,9 +115,9 @@ public static double[] jaccard(
* Summary
@@ -124,8 +125,8 @@ public static double[] jaccard(
* The Upper and Lower bounds are for a confidence interval of 95.4% or +/- 2 standard deviations.
*/
public static double[] jaccard(
- final Sketch sketchA,
- final org.apache.datasketches.theta.ThetaSketch sketchB,
+ final TupleSketch sketchA,
+ final ThetaSketch sketchB,
final S summary, final SummarySetOperations summarySetOps) {
// Null case checks
if (summary == null) {
@@ -139,15 +140,15 @@ public static double[] jaccard(
final int countA = sketchA.getRetainedEntries();
final int countB = sketchB.getRetainedEntries(true);
- //Create the Union
+ //Create the Tuple/Theta Union
final int minK = 1 << ThetaUtil.MIN_LG_NOM_LONGS;
final int maxK = 1 << ThetaUtil.MAX_LG_NOM_LONGS;
final int newK = max(min(ceilingPowerOf2(countA + countB), maxK), minK);
- final Union union = new Union<>(newK, summarySetOps);
+ final TupleUnion union = new TupleUnion<>(newK, summarySetOps);
union.union(sketchA);
union.union(sketchB, summary);
- final Sketch unionAB = union.getResult();
+ final TupleSketch unionAB = union.getResult();
final long thetaLongUAB = unionAB.getThetaLong();
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
@@ -159,12 +160,12 @@ public static double[] jaccard(
return ONES.clone();
}
- //Create the Intersection
- final Intersection inter = new Intersection<>(summarySetOps);
+ //Create the Tuple/Theta Intersection
+ final TupleIntersection inter = new TupleIntersection<>(summarySetOps);
inter.intersect(sketchA);
inter.intersect(sketchB, summary);
inter.intersect(unionAB); //ensures that intersection is a subset of the union
- final Sketch interABU = inter.getResult();
+ final TupleSketch interABU = inter.getResult();
final double lb = getLowerBoundForBoverA(unionAB, interABU);
final double est = getEstimateOfBoverA(unionAB, interABU);
@@ -175,16 +176,16 @@ public static double[] jaccard(
/**
* Returns true if the two given sketches have exactly the same hash values and the same
* theta values. Thus, they are equivalent.
- * @param sketchA The first argument, a Tuple sketch with summary type S
- * @param sketchB The second argument, a Tuple sketch with summary type S
+ * @param sketchA The first argument, a TupleSketch with summary type S
+ * @param sketchB The second argument, a TupleSketch with summary type S
* @param summarySetOps instance of SummarySetOperations used to unify or intersect summaries.
* @param Summary
* @return true if the two given sketches have exactly the same hash values and the same
* theta values.
*/
public static boolean exactlyEqual(
- final Sketch sketchA,
- final Sketch sketchB,
+ final TupleSketch sketchA,
+ final TupleSketch sketchB,
final SummarySetOperations summarySetOps) {
//Corner case checks
if (sketchA == null || sketchB == null) { return false; }
@@ -195,11 +196,11 @@ public static boolean exactlyEqual(
final int countA = sketchA.getRetainedEntries();
final int countB = sketchB.getRetainedEntries();
- //Create the Union
- final Union union = new Union<>(ceilingPowerOf2(countA + countB), summarySetOps);
+ //Create the TupleUnion
+ final TupleUnion union = new TupleUnion<>(ceilingPowerOf2(countA + countB), summarySetOps);
union.union(sketchA);
union.union(sketchB);
- final Sketch unionAB = union.getResult();
+ final TupleSketch unionAB = union.getResult();
final long thetaLongUAB = unionAB.getThetaLong();
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
@@ -216,9 +217,9 @@ public static boolean exactlyEqual(
/**
* Returns true if the two given sketches have exactly the same hash values and the same
* theta values. Thus, they are equivalent.
- * @param sketchA The first argument, a Tuple sketch with summary type S
- * @param sketchB The second argument, a Theta sketch
- * @param summary the given proxy summary for the theta sketch, which doesn't have one.
+ * @param sketchA The first argument, a TupleSketch with summary type S
+ * @param sketchB The second argument, a ThetaSketch
+ * @param summary the given proxy summary for the ThetaSketch, which doesn't have one.
* This may not be null.
* @param summarySetOps instance of SummarySetOperations used to unify or intersect summaries.
* @param Summary
@@ -226,8 +227,8 @@ public static boolean exactlyEqual(
* theta values.
*/
public static boolean exactlyEqual(
- final Sketch sketchA,
- final org.apache.datasketches.theta.ThetaSketch sketchB,
+ final TupleSketch sketchA,
+ final ThetaSketch sketchB,
final S summary, final SummarySetOperations summarySetOps) {
// Null case checks
if (summary == null) {
@@ -241,11 +242,11 @@ public static boolean exactlyEqual(
final int countA = sketchA.getRetainedEntries();
final int countB = sketchB.getRetainedEntries(true);
- //Create the Union
- final Union union = new Union<>(ceilingPowerOf2(countA + countB), summarySetOps);
+ //Create the TupleUnion
+ final TupleUnion union = new TupleUnion<>(ceilingPowerOf2(countA + countB), summarySetOps);
union.union(sketchA);
union.union(sketchB, summary);
- final Sketch unionAB = union.getResult();
+ final TupleSketch unionAB = union.getResult();
final long thetaLongUAB = unionAB.getThetaLong();
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
@@ -260,14 +261,14 @@ public static boolean exactlyEqual(
}
/**
- * Tests similarity of a measured Sketch against an expected Sketch.
+ * Tests similarity of a measured TupleSketch against an expected TupleSketch.
* Computes the lower bound of the Jaccard index JLB of the measured and
* expected sketches.
* if JLB ≥ threshold, then the sketches are considered to be
* similar with a confidence of 97.7%.
*
- * @param measured a Tuple sketch with summary type S to be tested
- * @param expected the reference Tuple sketch with summary type S that is considered to be correct.
+ * @param measured a TupleSketch with summary type S to be tested
+ * @param expected the reference TupleSketch with summary type S that is considered to be correct.
* @param summarySetOps instance of SummarySetOperations used to unify or intersect summaries.
* @param threshold a real value between zero and one.
* @param Summary
@@ -275,7 +276,7 @@ public static boolean exactlyEqual(
* with at least 97.7% confidence.
*/
public static boolean similarityTest(
- final Sketch measured, final Sketch expected,
+ final TupleSketch measured, final TupleSketch expected,
final SummarySetOperations summarySetOps,
final double threshold) {
//index 0: the lower bound
@@ -286,15 +287,15 @@ public static boolean similarityTest(
}
/**
- * Tests similarity of a measured Sketch against an expected Sketch.
+ * Tests similarity of a measured TupleSketch against an expected ThetaSketch.
* Computes the lower bound of the Jaccard index JLB of the measured and
* expected sketches.
* if JLB ≥ threshold, then the sketches are considered to be
* similar with a confidence of 97.7%.
*
- * @param measured a Tuple sketch with summary type S to be tested
- * @param expected the reference Theta sketch that is considered to be correct.
- * @param summary the given proxy summary for the theta sketch, which doesn't have one.
+ * @param measured a TupleSketch with summary type S to be tested
+ * @param expected the reference ThetaSketch that is considered to be correct.
+ * @param summary the given proxy summary for the ThetaSketch, which doesn't have one.
* This may not be null.
* @param summarySetOps instance of SummarySetOperations used to unify or intersect summaries.
* @param threshold a real value between zero and one.
@@ -303,7 +304,7 @@ public static boolean similarityTest(
* with at least 97.7% confidence.
*/
public static boolean similarityTest(
- final Sketch measured, final org.apache.datasketches.theta.ThetaSketch expected,
+ final TupleSketch measured, final ThetaSketch expected,
final S summary, final SummarySetOperations summarySetOps,
final double threshold) {
//index 0: the lower bound
@@ -314,14 +315,14 @@ public static boolean similarityTest(
}
/**
- * Tests dissimilarity of a measured Sketch against an expected Sketch.
+ * Tests dissimilarity of a measured TupleSketch against an expected TupleSketch.
* Computes the upper bound of the Jaccard index JUB of the measured and
* expected sketches.
* if JUB ≤ threshold, then the sketches are considered to be
* dissimilar with a confidence of 97.7%.
*
- * @param measured a Tuple sketch with summary type S to be tested
- * @param expected the reference Theta sketch that is considered to be correct.
+ * @param measured a TupleSketch with summary type S to be tested
+ * @param expected the reference TupleSketch that is considered to be correct.
* @param summarySetOps instance of SummarySetOperations used to unify or intersect summaries.
* @param threshold a real value between zero and one.
* @param Summary
@@ -329,7 +330,7 @@ public static boolean similarityTest(
* with at least 97.7% confidence.
*/
public static boolean dissimilarityTest(
- final Sketch measured, final Sketch expected,
+ final TupleSketch measured, final TupleSketch expected,
final SummarySetOperations summarySetOps,
final double threshold) {
//index 0: the lower bound
@@ -340,15 +341,15 @@ public static boolean dissimilarityTest(
}
/**
- * Tests dissimilarity of a measured Sketch against an expected Sketch.
+ * Tests dissimilarity of a measured TupleSketch against an expected ThetaSketch.
* Computes the upper bound of the Jaccard index JUB of the measured and
* expected sketches.
* if JUB ≤ threshold, then the sketches are considered to be
* dissimilar with a confidence of 97.7%.
*
- * @param measured a Tuple sketch with summary type S to be tested
- * @param expected the reference Theta sketch that is considered to be correct.
- * @param summary the given proxy summary for the theta sketch, which doesn't have one.
+ * @param measured a TupleSketch with summary type S to be tested
+ * @param expected the reference ThetaSketch that is considered to be correct.
+ * @param summary the given proxy summary for the ThetaSketch, which doesn't have one.
* This may not be null.
* @param summarySetOps instance of SummarySetOperations used to unify or intersect summaries.
* @param threshold a real value between zero and one.
@@ -357,7 +358,7 @@ public static boolean dissimilarityTest(
* with at least 97.7% confidence.
*/
public static boolean dissimilarityTest(
- final Sketch measured, final org.apache.datasketches.theta.ThetaSketch expected,
+ final TupleSketch measured, final ThetaSketch expected,
final S summary, final SummarySetOperations summarySetOps,
final double threshold) {
//index 0: the lower bound
diff --git a/src/main/java/org/apache/datasketches/tuple/QuickSelectSketch.java b/src/main/java/org/apache/datasketches/tuple/QuickSelectSketch.java
index 92355a77b..64548d6c1 100644
--- a/src/main/java/org/apache/datasketches/tuple/QuickSelectSketch.java
+++ b/src/main/java/org/apache/datasketches/tuple/QuickSelectSketch.java
@@ -45,7 +45,7 @@
*
* @param type of Summary
*/
-class QuickSelectSketch extends Sketch {
+class QuickSelectSketch extends TupleSketch {
private static final byte serialVersionUID = 2;
private enum Flags { IS_RESERVED, IS_IN_SAMPLING_MODE, IS_EMPTY, HAS_ENTRIES, IS_THETA_INCLUDED }
@@ -174,9 +174,9 @@ private QuickSelectSketch(
* @param seg MemorySegment object with serialized QuickSelectSketch
* @param deserializer the SummaryDeserializer
* @param summaryFactory the SummaryFactory
- * @deprecated As of 3.0.0, heapifying an UpdatableSketch is deprecated.
+ * @deprecated As of 3.0.0, heapifying an UpdatableTupleSketch is deprecated.
* This capability will be removed in a future release.
- * Heapifying a CompactSketch is not deprecated.
+ * Heapifying a CompactTupleSketch is not deprecated.
*/
@Deprecated
QuickSelectSketch(
@@ -377,10 +377,10 @@ public void reset() {
*/
@Override
@SuppressWarnings("unchecked")
- public CompactSketch compact() {
+ public CompactTupleSketch compact() {
if (getRetainedEntries() == 0) {
- if (empty_) { return new CompactSketch<>(null, null, Long.MAX_VALUE, true); }
- return new CompactSketch<>(null, null, thetaLong_, false);
+ if (empty_) { return new CompactTupleSketch<>(null, null, Long.MAX_VALUE, true); }
+ return new CompactTupleSketch<>(null, null, thetaLong_, false);
}
final long[] hashArr = new long[getRetainedEntries()];
final S[] summaryArr = Util.newSummaryArray(summaryTable_, getRetainedEntries());
@@ -392,7 +392,7 @@ public CompactSketch compact() {
i++;
}
}
- return new CompactSketch<>(hashArr, summaryArr, thetaLong_, empty_);
+ return new CompactTupleSketch<>(hashArr, summaryArr, thetaLong_, empty_);
}
// Layout of first 8 bytes:
@@ -401,11 +401,11 @@ public CompactSketch compact() {
// || 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
// 0 || RF | lgArr | lgNom | Flags | SkType | FamID | SerVer | Preamble_Longs |
/**
- * This serializes an UpdatableSketch (QuickSelectSketch).
- * @return serialized representation of an UpdatableSketch (QuickSelectSketch).
- * @deprecated As of 3.0.0, serializing an UpdatableSketch is deprecated.
+ * This serializes an UpdatableTupleSketch (QuickSelectSketch).
+ * @return serialized representation of an UpdatableTupleSketch (QuickSelectSketch).
+ * @deprecated As of 3.0.0, serializing an UpdatableTupleSketch is deprecated.
* This capability will be removed in a future release.
- * Serializing a CompactSketch is not deprecated.
+ * Serializing a CompactTupleSketch is not deprecated.
*/
@Deprecated
@Override
diff --git a/src/main/java/org/apache/datasketches/tuple/SerializerDeserializer.java b/src/main/java/org/apache/datasketches/tuple/SerializerDeserializer.java
index 2ca7c29df..367ef9971 100644
--- a/src/main/java/org/apache/datasketches/tuple/SerializerDeserializer.java
+++ b/src/main/java/org/apache/datasketches/tuple/SerializerDeserializer.java
@@ -37,8 +37,8 @@ public final class SerializerDeserializer {
public static enum SketchType {
/** QuickSelectSketch */
QuickSelectSketch,
- /** CompactSketch */
- CompactSketch,
+ /** CompactTupleSketch */
+ CompactTupleSketch,
/** ArrayOfDoublesQuickSelectSketch */
ArrayOfDoublesQuickSelectSketch,
/** ArrayOfDoublesCompactSketch */
diff --git a/src/main/java/org/apache/datasketches/tuple/Sketches.java b/src/main/java/org/apache/datasketches/tuple/Sketches.java
deleted file mode 100644
index 6eef7f88d..000000000
--- a/src/main/java/org/apache/datasketches/tuple/Sketches.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.datasketches.tuple;
-
-import java.lang.foreign.MemorySegment;
-
-/**
- * Convenient static methods to instantiate generic tuple sketches.
- */
-@SuppressWarnings("deprecation")
-public final class Sketches {
-
- /**
- * Creates an empty sketch.
- * @param Type of Summary
- * @return an empty instance of Sketch
- */
- public static Sketch createEmptySketch() {
- return new CompactSketch<>(null, null, Long.MAX_VALUE, true);
- }
-
- /**
- * Instantiate a Sketch from a given MemorySegment.
- * @param Type of Summary
- * @param seg MemorySegment object representing a Sketch
- * @param deserializer instance of SummaryDeserializer
- * @return Sketch created from its MemorySegment representation
- */
- public static Sketch heapifySketch(
- final MemorySegment seg,
- final SummaryDeserializer deserializer) {
- final SerializerDeserializer.SketchType sketchType = SerializerDeserializer.getSketchType(seg);
- if (sketchType == SerializerDeserializer.SketchType.QuickSelectSketch) {
- return new QuickSelectSketch<>(seg, deserializer, null);
- }
- return new CompactSketch<>(seg, deserializer);
- }
-
- /**
- * Instantiate UpdatableSketch from a given MemorySegment
- * @param Type of update value
- * @param Type of Summary
- * @param seg MemorySegment object representing a Sketch
- * @param deserializer instance of SummaryDeserializer
- * @param summaryFactory instance of SummaryFactory
- * @return Sketch created from its MemorySegment representation
- */
- public static > UpdatableSketch heapifyUpdatableSketch(
- final MemorySegment seg,
- final SummaryDeserializer deserializer,
- final SummaryFactory summaryFactory) {
- return new UpdatableSketch<>(seg, deserializer, summaryFactory);
- }
-
-}
diff --git a/src/main/java/org/apache/datasketches/tuple/AnotB.java b/src/main/java/org/apache/datasketches/tuple/TupleAnotB.java
similarity index 81%
rename from src/main/java/org/apache/datasketches/tuple/AnotB.java
rename to src/main/java/org/apache/datasketches/tuple/TupleAnotB.java
index 25b7340fb..7676211b8 100644
--- a/src/main/java/org/apache/datasketches/tuple/AnotB.java
+++ b/src/main/java/org/apache/datasketches/tuple/TupleAnotB.java
@@ -30,32 +30,34 @@
import org.apache.datasketches.common.SketchesArgumentException;
import org.apache.datasketches.common.SketchesStateException;
import org.apache.datasketches.common.SuppressFBWarnings;
+import org.apache.datasketches.theta.CompactThetaSketch;
+import org.apache.datasketches.theta.ThetaSketch;
import org.apache.datasketches.thetacommon.SetOperationCornerCases;
-import org.apache.datasketches.thetacommon.ThetaUtil;
import org.apache.datasketches.thetacommon.SetOperationCornerCases.AnotbAction;
import org.apache.datasketches.thetacommon.SetOperationCornerCases.CornerCase;
+import org.apache.datasketches.thetacommon.ThetaUtil;
/**
- * Computes a set difference, A-AND-NOT-B, of two generic tuple sketches.
+ * Computes a set difference, A-AND-NOT-B, of two generic TupleSketches.
* This class includes both stateful and stateless operations.
*
- *
*
- *
- * AnotB anotb = new AnotB();
+ * TupleAnotB anotb = new TupleAnotB();
*
- * anotb.setA(Sketch skA); //The first argument.
- * anotb.notB(Sketch skB); //The second (subtraction) argument.
- * anotb.notB(Sketch skC); // ...any number of additional subtractions...
+ * anotb.setA(TupleSketch skA); //The first argument.
+ * anotb.notB(TupleSketch skB); //The second (subtraction) argument.
+ * anotb.notB(TupleSketch skC); // ...any number of additional subtractions...
* anotb.getResult(false); //Get an interim result.
- * anotb.notB(Sketch skD); //Additional subtractions.
- * anotb.getResult(true); //Final result and resets the AnotB operator.
+ * anotb.notB(TupleSketch skD); //Additional subtractions.
+ * anotb.getResult(true); //Final result and resets the TupleAnotB operator.
*
*
*
- * AnotB anotb = new AnotB();
+ * TupleAnotB anotb = new TupleAnotB();
*
- * CompactSketch csk = anotb.aNotB(Sketch skA, Sketch skB);
+ * CompactTupleSketch csk = anotb.aNotB(TupleSketch skA, TupleSketch skB);
* {
+public final class TupleAnotB {
private boolean empty_ = true;
private long thetaLong_ = Long.MAX_VALUE;
private long[] hashArr_ = null; //always in compact form, not necessarily sorted
@@ -78,7 +80,7 @@ public final class AnotB {
static {
try {
- GET_CACHE = org.apache.datasketches.theta.ThetaSketch.class.getDeclaredMethod("getCache");
+ GET_CACHE = ThetaSketch.class.getDeclaredMethod("getCache");
GET_CACHE.setAccessible(true);
} catch (final Exception e) {
throw new SketchesStateException("Could not reflect getCache(): " + e);
@@ -86,9 +88,9 @@ public final class AnotB {
}
/**
- * This is part of a multistep, stateful AnotB operation and sets the given Tuple sketch as the
+ * This is part of a multistep, stateful TupleAnotB operation and sets the given TupleSketch as the
* first argument A of A-AND-NOT-B. This overwrites the internal state of this
- * AnotB operator with the contents of the given sketch.
+ * TupleAnotB operator with the contents of the given sketch.
* This sets the stage for multiple following notB steps.
*
* {
*
* @param skA The incoming sketch for the first argument, A.
*/
- public void setA(final Sketch skA) {
+ public void setA(final TupleSketch skA) {
if (skA == null) {
reset();
throw new SketchesArgumentException("The input argument A may not be null");
@@ -125,9 +127,9 @@ public void setA(final Sketch skA) {
}
/**
- * This is part of a multistep, stateful AnotB operation and sets the given Tuple sketch as the
+ * This is part of a multistep, stateful TupleAnotB operation and sets the given TupleSketch as the
* second (or n+1th) argument B of A-AND-NOT-B.
- * Performs an AND NOT operation with the existing internal state of this AnotB operator.
+ * Performs an AND NOT operation with the existing internal state of this TupleAnotB operator.
*
* skA) {
*
* @param skB The incoming Tuple sketch for the second (or following) argument B.
*/
- public void notB(final Sketch skB) {
+ public void notB(final TupleSketch skB) {
if (skB == null) { return; } //ignore
final long thetaLongB = skB.getThetaLong();
@@ -195,11 +197,11 @@ public void notB(final Sketch skB) {
}
/**
- * This is part of a multistep, stateful AnotB operation and sets the given Theta sketch as the
+ * This is part of a multistep, stateful TupleAnotB operation and sets the given ThetaSketch as the
* second (or n+1th) argument B of A-AND-NOT-B.
- * Performs an AND NOT operation with the existing internal state of this AnotB operator.
+ * Performs an AND NOT operation with the existing internal state of this TupleAnotB operator.
* Calls to this method can be intermingled with calls to
- * {@link #notB(org.apache.datasketches.theta.ThetaSketch)}.
+ * {@link #notB(ThetaSketch)}.
*
* skB) {
*
* getResult(final boolean reset) {
- final CompactSketch result;
+ public CompactTupleSketch getResult(final boolean reset) {
+ final CompactTupleSketch result;
if (curCount_ == 0) {
- result = new CompactSketch<>(null, null, thetaLong_, thetaLong_ == Long.MAX_VALUE);
+ result = new CompactTupleSketch<>(null, null, thetaLong_, thetaLong_ == Long.MAX_VALUE);
} else {
- result = new CompactSketch<>(hashArr_, Util.copySummaryArray(summaryArr_), thetaLong_, false);
+ result = new CompactTupleSketch<>(hashArr_, Util.copySummaryArray(summaryArr_), thetaLong_, false);
}
if (reset) { reset(); }
return result;
}
/**
- * Returns the A-and-not-B set operation on the two given Tuple sketches.
+ * Returns the A-and-not-B set operation on the two given TupleSketches.
*
* getResult(final boolean reset) {
* no following possible viable arguments for the second argument.
* Since it is very likely that a null is a programming error, we throw an exception.
This a stateless operation and has no impact on the internal state of this operator. - * Thus, this is not an accumulating update and is independent of the {@link #setA(Sketch)}, - * {@link #notB(Sketch)}, {@link #notB(org.apache.datasketches.theta.ThetaSketch)}, and + * Thus, this is not an accumulating update and is independent of the {@link #setA(TupleSketch)}, + * {@link #notB(TupleSketch)}, {@link #notB(ThetaSketch)}, and * {@link #getResult(boolean)} methods.
* *If either argument is null an exception is thrown.
@@ -397,16 +399,16 @@ public staticIf this sketch is already in compact form this operation returns this.
*
- * @return this sketch as a CompactSketch on the Java heap.
+ * @return this sketch as a CompactTupleSketch on the Java heap.
*/
- public abstract CompactSketch compact();
+ public abstract CompactTupleSketch compact();
/**
* Estimates the cardinality of the set (number of unique values presented to the sketch)
@@ -152,7 +157,7 @@ public boolean isEstimationMode() {
/**
* Gets the number of hash values less than the given theta expressed as a long.
- * @param thetaLong the given theta as a long between zero and Long.MAX_VALUE.
+ * @param thetaLong the given theta as a long in the range (zero, Long.MAX_VALUE].
* @return the number of hash values less than the given thetaLong.
*/
public abstract int getCountLessThanThetaLong(final long thetaLong);
@@ -174,12 +179,12 @@ public double getTheta() {
}
/**
- * This is to serialize a sketch instance to a byte array.
+ * Serialize this sketch to a byte array.
*
- *
As of 3.0.0, serializing an UpdatableSketch is deprecated. + *
As of 3.0.0, serializing an UpdatableTupleSketch is deprecated. * This capability will be removed in a future release. - * Serializing a CompactSketch is not deprecated.
- * @return serialized representation of the sketch + * Serializing a CompactTupleSketch is not deprecated. + * @return serialized representation of this sketch. */ public abstract byte[] toByteArray(); @@ -209,9 +214,9 @@ public String toString() { sb.append(" EstMode? : ").append(isEstimationMode()).append(LS); sb.append(" Empty? : ").append(isEmpty()).append(LS); sb.append(" Retained Entries : ").append(this.getRetainedEntries()).append(LS); - if (this instanceof UpdatableSketch) { + if (this instanceof UpdatableTupleSketch) { @SuppressWarnings("rawtypes") - final UpdatableSketch updatable = (UpdatableSketch) this; + final UpdatableTupleSketch updatable = (UpdatableTupleSketch) this; sb.append(" Nominal Entries (k) : ").append(updatable.getNominalEntries()).append(LS); sb.append(" Current Capacity : ").append(updatable.getCurrentCapacity()).append(LS); sb.append(" Resize Factor : ").append(updatable.getResizeFactor().getValue()).append(LS); @@ -221,4 +226,46 @@ public String toString() { return sb.toString(); } + /** + * Instantiate an UpdatableTupleSketch from a given MemorySegment on the heap, + * @param Type of update value + * @paramThis class includes a stateless operation as follows:
* *
- * CompactSketch csk = anotb.aNotB(ArrayOfDoublesSketch skA, ArrayOfDoublesSketch skB);
+ * CompactTupleSketch csk = anotb.aNotB(ArrayOfDoublesSketch skA, ArrayOfDoublesSketch skB);
*
*
* @author Lee Rhodes
diff --git a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesCompactSketch.java b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesCompactSketch.java
index 5ffac576a..1cf3ac040 100644
--- a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesCompactSketch.java
+++ b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesCompactSketch.java
@@ -22,10 +22,10 @@
/**
* Top level compact tuple sketch of type ArrayOfDoubles. Compact sketches are never created
* directly. They are created as a result of the compact() method on a QuickSelectSketch
- * or the getResult() method of a set operation like Union, Intersection or AnotB.
- * Compact sketch consists of a compact list (i.e. no intervening spaces) of hash values,
- * corresponding list of double values, and a value for theta. The lists may or may
- * not be ordered. A compact sketch is read-only.
+ * or the getResult() method of a set operation like TupleUnion, TupleIntersection or TupleAnotB.
+ * A CompactTupleSketch consists of a compact list (i.e. no intervening spaces) of hash values,
+ * a corresponding list of double values, and a value for theta. The lists may or may
+ * not be ordered. It is read-only.
*/
public abstract class ArrayOfDoublesCompactSketch extends ArrayOfDoublesSketch {
diff --git a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesIntersection.java b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesIntersection.java
index 7c474ee45..91d51b483 100644
--- a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesIntersection.java
+++ b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesIntersection.java
@@ -58,17 +58,17 @@ public abstract class ArrayOfDoublesIntersection {
}
/**
- * Performs a stateful intersection of the internal set with the given tupleSketch.
- * The given tupleSketch and the internal state must have the same numValues.
+ * Performs a stateful intersection of the internal set with the given TupleSketch.
+ * The given TupleSketch and the internal state must have the same numValues.
* @param tupleSketch Input sketch to intersect with the internal set.
* @param combiner Method of combining two arrays of double values
*/
public void intersect(final ArrayOfDoublesSketch tupleSketch, final ArrayOfDoublesCombiner combiner) {
- if (tupleSketch == null) { throw new SketchesArgumentException("Sketch must not be null"); }
+ if (tupleSketch == null) { throw new SketchesArgumentException("TupleSketch must not be null"); }
Util.checkSeedHashes(seedHash_, tupleSketch.getSeedHash());
if (tupleSketch.numValues_ != numValues_) {
throw new SketchesArgumentException(
- "Input tupleSketch cannot have different numValues from the internal numValues.");
+ "Input TupleSketch cannot have different numValues from the internal numValues.");
}
final boolean isFirstCall = firstCall_;
diff --git a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesSketch.java b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesSketch.java
index b86f5f624..6fb1aacaa 100644
--- a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesSketch.java
+++ b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesSketch.java
@@ -95,7 +95,7 @@ public static ArrayOfDoublesSketch heapify(final MemorySegment seg, final long s
/**
* Wrap the given MemorySegment as an ArrayOfDoublesSketch.
- * If the given source MemorySegment is read-only, the returned Union object will also be read-only.
+ * If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only.
* @param seg the given MemorySegment
* @return an ArrayOfDoublesSketch
*/
@@ -105,7 +105,7 @@ public static ArrayOfDoublesSketch wrap(final MemorySegment seg) {
/**
* Wrap the given MemorySegment and seed as a ArrayOfDoublesSketch.
- * If the given source MemorySegment is read-only, the returned Union object will also be read-only.
+ * If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only.
* @param seg the given MemorySegment
* @param seed the given seed
* @return an ArrayOfDoublesSketch
@@ -289,4 +289,126 @@ public String toString() {
return sb.toString();
}
+ // Convenient static methods to instantiate tuple sketches of type ArrayOfDoubles.
+
+ /**
+ * Wrap the given MemorySegment and seed as an ArrayOfDoublesUnion
+ * If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only.
+ * @param srcSeg the given source MemorySegment
+ * @param seed the given seed
+ * @return an ArrayOfDoublesUnion
+ */
+ public static ArrayOfDoublesUnion wrapUnion(final MemorySegment srcSeg, final long seed) {
+ return ArrayOfDoublesUnion.wrap(srcSeg, seed);
+ }
+
+ /**
+ * Wrap the given MemorySegment as an ArrayOfDoublesUnion
+ * If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only.
+ * @param srcSeg the given source MemorySegment
+ * @return an ArrayOfDoublesUnion
+ */
+ public static ArrayOfDoublesUnion wrapUnion(final MemorySegment srcSeg) {
+ return ArrayOfDoublesSketch.wrapUnion(srcSeg, Util.DEFAULT_UPDATE_SEED);
+ }
+
+ /**
+ * Heapify the given MemorySegment and seed as an ArrayOfDoublesUnion
+ * @param srcSeg the given source MemorySegment
+ * @param seed the given seed
+ * @return an ArrayOfDoublesUnion
+ */
+ public static ArrayOfDoublesUnion heapifyUnion(final MemorySegment srcSeg, final long seed) {
+ return ArrayOfDoublesUnion.heapify(srcSeg, seed);
+ }
+
+ /**
+ * Heapify the given MemorySegment as an ArrayOfDoublesUnion
+ * @param srcSeg the given source MemorySegment
+ * @return an ArrayOfDoublesUnion
+ */
+ public static ArrayOfDoublesUnion heapifyUnion(final MemorySegment srcSeg) {
+ return ArrayOfDoublesSketch.heapifyUnion(srcSeg, Util.DEFAULT_UPDATE_SEED);
+ }
+
+ /**
+ * Wrap the given MemorySegment and seed as a ArrayOfDoublesUpdatableSketch.
+ * If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only.
+ * @param srcSeg the given source MemorySegment
+ * @param seed the given seed
+ * @return an ArrayOfDoublesUpdatableSketch
+ */
+ public static ArrayOfDoublesUpdatableSketch wrapUpdatableSketch(final MemorySegment srcSeg, final long seed) {
+ return ArrayOfDoublesUpdatableSketch.wrap(srcSeg, seed);
+ }
+
+ /**
+ * Wrap the given MemorySegment as an ArrayOfDoublesUpdatableSketch.
+ * If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only.
+ * @param srcSeg the given source MemorySegment
+ * @return an ArrayOfDoublesUpdatableSketch
+ */
+ public static ArrayOfDoublesUpdatableSketch wrapUpdatableSketch(final MemorySegment srcSeg) {
+ return ArrayOfDoublesSketch.wrapUpdatableSketch(srcSeg, Util.DEFAULT_UPDATE_SEED);
+ }
+
+ /**
+ * Wrap the given MemorySegment and seed as a ArrayOfDoublesSketch.
+ * If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only.
+ * @param srcSeg the given source MemorySegment
+ * @param seed the given seed
+ * @return an ArrayOfDoublesSketch
+ */
+ public static ArrayOfDoublesSketch wrapSketch(final MemorySegment srcSeg, final long seed) {
+ return wrap(srcSeg, seed);
+ }
+
+ /**
+ * Wrap the given MemorySegment as an ArrayOfDoublesSketch.
+ * If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only.
+ * @param srcSeg the given source MemorySegment
+ * @return an ArrayOfDoublesSketch
+ */
+ public static ArrayOfDoublesSketch wrapSketch(final MemorySegment srcSeg) {
+ return ArrayOfDoublesSketch.wrapSketch(srcSeg, Util.DEFAULT_UPDATE_SEED);
+ }
+
+ /**
+ * Heapify the given MemorySegment and seed as a ArrayOfDoublesUpdatableSketch
+ * @param srcSeg the given source MemorySegment
+ * @param seed the given seed
+ * @return an ArrayOfDoublesUpdatableSketch
+ */
+ public static ArrayOfDoublesUpdatableSketch heapifyUpdatableSketch(final MemorySegment srcSeg, final long seed) {
+ return ArrayOfDoublesUpdatableSketch.heapify(srcSeg, seed);
+ }
+
+ /**
+ * Heapify the given MemorySegment as an ArrayOfDoublesUpdatableSketch
+ * @param srcSeg the given source MemorySegment
+ * @return an ArrayOfDoublesUpdatableSketch
+ */
+ public static ArrayOfDoublesUpdatableSketch heapifyUpdatableSketch(final MemorySegment srcSeg) {
+ return ArrayOfDoublesSketch.heapifyUpdatableSketch(srcSeg, Util.DEFAULT_UPDATE_SEED);
+ }
+
+ /**
+ * Heapify the given MemorySegment and seed as a ArrayOfDoublesSketch
+ * @param srcSeg the given source MemorySegment
+ * @param seed the given seed
+ * @return an ArrayOfDoublesSketch
+ */
+ public static ArrayOfDoublesSketch heapifySketch(final MemorySegment srcSeg, final long seed) {
+ return heapify(srcSeg, seed);
+ }
+
+ /**
+ * Heapify the given MemorySegment as an ArrayOfDoublesSketch
+ * @param srcSeg the given source MemorySegment
+ * @return an ArrayOfDoublesSketch
+ */
+ public static ArrayOfDoublesSketch heapifySketch(final MemorySegment srcSeg) {
+ return ArrayOfDoublesSketch.heapifySketch(srcSeg, Util.DEFAULT_UPDATE_SEED);
+ }
+
}
diff --git a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesSketches.java b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesSketches.java
deleted file mode 100644
index 53a145beb..000000000
--- a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesSketches.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.datasketches.tuple.arrayofdoubles;
-
-import java.lang.foreign.MemorySegment;
-
-import org.apache.datasketches.common.Util;
-
-/**
- * Convenient static methods to instantiate tuple sketches of type ArrayOfDoubles.
- */
-public final class ArrayOfDoublesSketches {
-
- /**
- * Heapify the given MemorySegment as an ArrayOfDoublesSketch
- * @param srcSeg the given source MemorySegment
- * @return an ArrayOfDoublesSketch
- */
- public static ArrayOfDoublesSketch heapifySketch(final MemorySegment srcSeg) {
- return heapifySketch(srcSeg, Util.DEFAULT_UPDATE_SEED);
- }
-
- /**
- * Heapify the given MemorySegment and seed as a ArrayOfDoublesSketch
- * @param srcSeg the given source MemorySegment
- * @param seed the given seed
- * @return an ArrayOfDoublesSketch
- */
- public static ArrayOfDoublesSketch heapifySketch(final MemorySegment srcSeg, final long seed) {
- return ArrayOfDoublesSketch.heapify(srcSeg, seed);
- }
-
- /**
- * Heapify the given MemorySegment as an ArrayOfDoublesUpdatableSketch
- * @param srcSeg the given source MemorySegment
- * @return an ArrayOfDoublesUpdatableSketch
- */
- public static ArrayOfDoublesUpdatableSketch heapifyUpdatableSketch(final MemorySegment srcSeg) {
- return heapifyUpdatableSketch(srcSeg, Util.DEFAULT_UPDATE_SEED);
- }
-
- /**
- * Heapify the given MemorySegment and seed as a ArrayOfDoublesUpdatableSketch
- * @param srcSeg the given source MemorySegment
- * @param seed the given seed
- * @return an ArrayOfDoublesUpdatableSketch
- */
- public static ArrayOfDoublesUpdatableSketch heapifyUpdatableSketch(final MemorySegment srcSeg, final long seed) {
- return ArrayOfDoublesUpdatableSketch.heapify(srcSeg, seed);
- }
-
- /**
- * Wrap the given MemorySegment as an ArrayOfDoublesSketch.
- * If the given source MemorySegment is read-only, the returned Union object will also be read-only.
- * @param srcSeg the given source MemorySegment
- * @return an ArrayOfDoublesSketch
- */
- public static ArrayOfDoublesSketch wrapSketch(final MemorySegment srcSeg) {
- return wrapSketch(srcSeg, Util.DEFAULT_UPDATE_SEED);
- }
-
- /**
- * Wrap the given MemorySegment and seed as a ArrayOfDoublesSketch.
- * If the given source MemorySegment is read-only, the returned Union object will also be read-only.
- * @param srcSeg the given source MemorySegment
- * @param seed the given seed
- * @return an ArrayOfDoublesSketch
- */
- public static ArrayOfDoublesSketch wrapSketch(final MemorySegment srcSeg, final long seed) {
- return ArrayOfDoublesSketch.wrap(srcSeg, seed);
- }
-
- /**
- * Wrap the given MemorySegment as an ArrayOfDoublesUpdatableSketch.
- * If the given source MemorySegment is read-only, the returned Union object will also be read-only.
- * @param srcSeg the given source MemorySegment
- * @return an ArrayOfDoublesUpdatableSketch
- */
- public static ArrayOfDoublesUpdatableSketch wrapUpdatableSketch(final MemorySegment srcSeg) {
- return wrapUpdatableSketch(srcSeg, Util.DEFAULT_UPDATE_SEED);
- }
-
- /**
- * Wrap the given MemorySegment and seed as a ArrayOfDoublesUpdatableSketch.
- * If the given source MemorySegment is read-only, the returned Union object will also be read-only.
- * @param srcSeg the given source MemorySegment
- * @param seed the given seed
- * @return an ArrayOfDoublesUpdatableSketch
- */
- public static ArrayOfDoublesUpdatableSketch wrapUpdatableSketch(final MemorySegment srcSeg, final long seed) {
- return ArrayOfDoublesUpdatableSketch.wrap(srcSeg, seed);
- }
-
- /**
- * Heapify the given MemorySegment as an ArrayOfDoublesUnion
- * @param srcSeg the given source MemorySegment
- * @return an ArrayOfDoublesUnion
- */
- public static ArrayOfDoublesUnion heapifyUnion(final MemorySegment srcSeg) {
- return heapifyUnion(srcSeg, Util.DEFAULT_UPDATE_SEED);
- }
-
- /**
- * Heapify the given MemorySegment and seed as an ArrayOfDoublesUnion
- * @param srcSeg the given source MemorySegment
- * @param seed the given seed
- * @return an ArrayOfDoublesUnion
- */
- public static ArrayOfDoublesUnion heapifyUnion(final MemorySegment srcSeg, final long seed) {
- return ArrayOfDoublesUnion.heapify(srcSeg, seed);
- }
-
- /**
- * Wrap the given MemorySegment as an ArrayOfDoublesUnion
- * If the given source MemorySegment is read-only, the returned Union object will also be read-only.
- * @param srcSeg the given source MemorySegment
- * @return an ArrayOfDoublesUnion
- */
- public static ArrayOfDoublesUnion wrapUnion(final MemorySegment srcSeg) {
- return wrapUnion(srcSeg, Util.DEFAULT_UPDATE_SEED);
- }
-
- /**
- * Wrap the given MemorySegment and seed as an ArrayOfDoublesUnion
- * If the given source MemorySegment is read-only, the returned Union object will also be read-only.
- * @param srcSeg the given source MemorySegment
- * @param seed the given seed
- * @return an ArrayOfDoublesUnion
- */
- public static ArrayOfDoublesUnion wrapUnion(final MemorySegment srcSeg, final long seed) {
- return ArrayOfDoublesUnion.wrap(srcSeg, seed);
- }
-
-}
diff --git a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesUnion.java b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesUnion.java
index 58a907702..2d11551ee 100644
--- a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesUnion.java
+++ b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesUnion.java
@@ -19,9 +19,9 @@
package org.apache.datasketches.tuple.arrayofdoubles;
+import static java.lang.Math.min;
import static java.lang.foreign.ValueLayout.JAVA_BYTE;
import static java.lang.foreign.ValueLayout.JAVA_LONG_UNALIGNED;
-import static java.lang.Math.min;
import java.lang.foreign.MemorySegment;
@@ -51,7 +51,7 @@ public abstract class ArrayOfDoublesUnion {
long unionThetaLong_;
/**
- * Constructs this Union initializing it with the given sketch, which can be on-heap or off-heap.
+ * Constructs this TupleUnion initializing it with the given sketch, which can be on-heap or off-heap.
* @param sketch the given sketch.
*/
ArrayOfDoublesUnion(final ArrayOfDoublesQuickSelectSketch sketch) {
@@ -80,7 +80,7 @@ public static ArrayOfDoublesUnion heapify(final MemorySegment srcSeg, final long
/**
* Wrap the given MemorySegment as an ArrayOfDoublesUnion.
- * If the given source MemorySegment is read-only, the returned Union object will also be read-only.
+ * If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only.
* @param srcSeg the given source MemorySegment
* @return an ArrayOfDoublesUnion
*/
@@ -90,7 +90,7 @@ public static ArrayOfDoublesUnion wrap(final MemorySegment srcSeg) {
/**
* Wrap the given MemorySegment and seed as an ArrayOfDoublesUnion.
- * If the given source MemorySegment is read-only, the returned Union object will also be read-only.
+ * If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only.
* @param srcSeg the given source MemorySegment
* @param seed the given seed
* @return an ArrayOfDoublesUnion
@@ -101,7 +101,7 @@ public static ArrayOfDoublesUnion wrap(final MemorySegment srcSeg, final long se
/**
* Updates the union by adding a set of entries from a given sketch, which can be on-heap or off-heap.
- * Both the given tupleSketch and the internal state of the Union must have the same numValues.
+ * Both the given tupleSketch and the internal state of the TupleUnion must have the same numValues.
*
* Nulls and empty sketches are ignored.
* @@ -171,7 +171,7 @@ public void reset() { // || 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | // 0 || Seed Hash=0 | #Dbls=0|Flags=0 | SkType | FamID | SerVer | Preamble_Longs | // || 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | - // 1 ||---------------------------Union Theta Long-----------------------------------------| + // 1 ||---------------------------TupleUnion Theta Long------------------------------------| /** * Returns a byte array representation of this object * @return a byte array representation of this object diff --git a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesUpdatableSketch.java b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesUpdatableSketch.java index dfeffcc4f..591c67f1f 100644 --- a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesUpdatableSketch.java +++ b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesUpdatableSketch.java @@ -19,8 +19,8 @@ package org.apache.datasketches.tuple.arrayofdoubles; -import static org.apache.datasketches.common.Util.computeSeedHash; import static org.apache.datasketches.common.Util.DEFAULT_UPDATE_SEED; +import static org.apache.datasketches.common.Util.computeSeedHash; import java.lang.foreign.MemorySegment; import java.nio.ByteBuffer; @@ -62,7 +62,7 @@ public static ArrayOfDoublesUpdatableSketch heapify(final MemorySegment seg, fin /** * Wrap the given MemorySegment as an ArrayOfDoublesUpdatableSketch. - * If the given source MemorySegment is read-only, the returned Union object will also be read-only. + * If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only. * @param seg the given MemorySegment * @return an ArrayOfDoublesUpdatableSketch */ @@ -72,7 +72,7 @@ public static ArrayOfDoublesUpdatableSketch wrap(final MemorySegment seg) { /** * Wrap the given MemorySegment and seed as a ArrayOfDoublesUpdatableSketch. - * If the given source MemorySegment is read-only, the returned Union object will also be read-only. + * If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only. * @param seg the given MemorySegment * @param seed the given seed * @return an ArrayOfDoublesUpdatableSketch diff --git a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesUpdatableSketchBuilder.java b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesUpdatableSketchBuilder.java index 185186975..c15bb6d3e 100644 --- a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesUpdatableSketchBuilder.java +++ b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesUpdatableSketchBuilder.java @@ -68,7 +68,7 @@ public ArrayOfDoublesUpdatableSketchBuilder setNominalEntries(final int nomEntri * Value of X1 means that the maximum capacity is allocated from the start. * Default resize factor is X8. * @param resizeFactor value of X1, X2, X4 or X8 - * @return this UpdatableSketchBuilder + * @return this UpdatableTupleSketchBuilder */ public ArrayOfDoublesUpdatableSketchBuilder setResizeFactor(final ResizeFactor resizeFactor) { resizeFactor_ = resizeFactor; diff --git a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/DirectArrayOfDoublesCompactSketch.java b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/DirectArrayOfDoublesCompactSketch.java index 44bb4360f..76883224e 100644 --- a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/DirectArrayOfDoublesCompactSketch.java +++ b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/DirectArrayOfDoublesCompactSketch.java @@ -33,7 +33,7 @@ import org.apache.datasketches.tuple.SerializerDeserializer; /** - * Direct Compact Sketch of type ArrayOfDoubles. + * Direct CompactTupleSketch of type ArrayOfDoubles. * *This implementation uses data in a given MemorySegment that is owned and managed by the caller. * This MemorySegment can be off-heap, which if managed properly will greatly reduce the need for diff --git a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/DirectArrayOfDoublesIntersection.java b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/DirectArrayOfDoublesIntersection.java index 1aa34dbba..74fd2abec 100644 --- a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/DirectArrayOfDoublesIntersection.java +++ b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/DirectArrayOfDoublesIntersection.java @@ -22,7 +22,7 @@ import java.lang.foreign.MemorySegment; /** - * Direct Intersection operation for tuple sketches of type ArrayOfDoubles. + * Direct TupleIntersection operation for tuple sketches of type ArrayOfDoubles. * *
This implementation uses data in a given MemorySegment that is owned and managed by the caller. * This MemorySegment can be off-heap, which if managed properly will greatly reduce the need for diff --git a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/DirectArrayOfDoublesUnion.java b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/DirectArrayOfDoublesUnion.java index 0c7242088..5e00b9910 100644 --- a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/DirectArrayOfDoublesUnion.java +++ b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/DirectArrayOfDoublesUnion.java @@ -29,7 +29,7 @@ import org.apache.datasketches.tuple.SerializerDeserializer; /** - * Direct Union operation for tuple sketches of type ArrayOfDoubles. + * Direct TupleUnion operation for tuple sketches of type ArrayOfDoubles. * *
This implementation uses data in a given MemorySegment that is owned and managed by the caller.
* This MemorySegment can be off-heap, which if managed properly will greatly reduce the need for
diff --git a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/HeapArrayOfDoublesCompactSketch.java b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/HeapArrayOfDoublesCompactSketch.java
index f0de95ef4..8672014d4 100644
--- a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/HeapArrayOfDoublesCompactSketch.java
+++ b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/HeapArrayOfDoublesCompactSketch.java
@@ -34,7 +34,7 @@
import org.apache.datasketches.tuple.SerializerDeserializer;
/**
- * The on-heap implementation of tuple Compact Sketch of type ArrayOfDoubles.
+ * The on-heap implementation of CompactTupleSketch of type ArrayOfDoubles.
*/
final class HeapArrayOfDoublesCompactSketch extends ArrayOfDoublesCompactSketch {
diff --git a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/HeapArrayOfDoublesQuickSelectSketch.java b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/HeapArrayOfDoublesQuickSelectSketch.java
index 9891c9809..370d6cb44 100644
--- a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/HeapArrayOfDoublesQuickSelectSketch.java
+++ b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/HeapArrayOfDoublesQuickSelectSketch.java
@@ -210,7 +210,7 @@ int getSerializedSizeBytes() {
}
// X/Y: X = Byte index for just AoDQuickSelectSketch
- // Y = Byte index when combined with Union Preamble
+ // Y = Byte index when combined with TupleUnion Preamble
// Long || Start Byte Adr:
// Adr:
// First 16 bytes are preamble from AoDUnion
diff --git a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/HeapArrayOfDoublesUnion.java b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/HeapArrayOfDoublesUnion.java
index 7a9b7fd75..b3f93c60e 100644
--- a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/HeapArrayOfDoublesUnion.java
+++ b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/HeapArrayOfDoublesUnion.java
@@ -28,7 +28,7 @@
import org.apache.datasketches.tuple.SerializerDeserializer;
/**
- * The on-heap implementation of the Union set operation for tuple sketches of type
+ * The on-heap implementation of the TupleUnion set operation for tuple sketches of type
* ArrayOfDoubles.
*/
final class HeapArrayOfDoublesUnion extends ArrayOfDoublesUnion {
diff --git a/src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSketch.java b/src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsTupleSketch.java
similarity index 77%
rename from src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSketch.java
rename to src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsTupleSketch.java
index 66ba4f96e..6260f0df2 100644
--- a/src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSketch.java
+++ b/src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsTupleSketch.java
@@ -24,19 +24,19 @@
import java.lang.foreign.MemorySegment;
import org.apache.datasketches.common.ResizeFactor;
-import org.apache.datasketches.tuple.UpdatableSketch;
+import org.apache.datasketches.tuple.UpdatableTupleSketch;
/**
- * Extends UpdatableSketch<String[], ArrayOfStringsSummary>
+ * Extends UpdatableTupleSketch<String[], ArrayOfStringsSummary>
* @author Lee Rhodes
*/
-public class ArrayOfStringsSketch extends UpdatableSketch