You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by le...@apache.org on 2025/10/10 00:33:02 UTC
(datasketches-java) branch cleanup_names_phase_4 updated: Forgot to stage the previous commit. All the classes affected by the name changes for Theta.
This is an automated email from the ASF dual-hosted git repository.
leerho pushed a commit to branch cleanup_names_phase_4
in repository https://gitbox.apache.org/repos/asf/datasketches-java.git
The following commit(s) were added to refs/heads/cleanup_names_phase_4 by this push:
new 36e2e0865 Forgot to stage the previous commit. All the classes affected by the name changes for Theta.
36e2e0865 is described below
commit 36e2e0865a1cc437af275fe4240d51d80822ed0f
Author: Lee Rhodes <le...@gmail.com>
AuthorDate: Thu Oct 9 17:32:49 2025 -0700
Forgot to stage the previous commit. All the classes affected by the
name changes for Theta.
---
.../datasketches/theta/CompactOperations.java | 32 +--
.../datasketches/theta/CompactThetaSketch.java | 66 +++---
.../ConcurrentBackgroundThetaPropagation.java | 2 +-
.../theta/ConcurrentDirectQuickSelectSketch.java | 8 +-
.../theta/ConcurrentHeapQuickSelectSketch.java | 10 +-
.../theta/ConcurrentHeapThetaBuffer.java | 12 +-
.../theta/ConcurrentSharedThetaSketch.java | 10 +-
.../theta/DirectCompactCompressedSketch.java | 10 +-
.../datasketches/theta/DirectCompactSketch.java | 10 +-
.../theta/DirectQuickSelectSketch.java | 18 +-
.../theta/DirectQuickSelectSketchR.java | 30 +--
.../datasketches/theta/EmptyCompactSketch.java | 10 +-
.../apache/datasketches/theta/HeapAlphaSketch.java | 26 +--
.../datasketches/theta/HeapCompactSketch.java | 10 +-
.../datasketches/theta/HeapQuickSelectSketch.java | 14 +-
.../datasketches/theta/HeapUpdateSketch.java | 10 +-
.../datasketches/theta/JaccardSimilarity.java | 22 +-
.../apache/datasketches/theta/PreambleUtil.java | 28 +--
.../datasketches/theta/SingleItemSketch.java | 48 ++--
.../org/apache/datasketches/theta/ThetaAnotB.java | 60 ++---
.../apache/datasketches/theta/ThetaAnotBimpl.java | 22 +-
.../datasketches/theta/ThetaIntersection.java | 46 ++--
.../datasketches/theta/ThetaIntersectionImpl.java | 62 ++---
.../datasketches/theta/ThetaSetOperation.java | 72 +++---
.../theta/ThetaSetOperationBuilder.java | 104 ++++-----
.../org/apache/datasketches/theta/ThetaSketch.java | 112 ++++-----
.../org/apache/datasketches/theta/ThetaUnion.java | 82 ++++---
.../apache/datasketches/theta/ThetaUnionImpl.java | 82 +++----
.../datasketches/theta/UpdatableThetaSketch.java | 40 ++--
.../datasketches/theta/UpdateReturnState.java | 8 +-
.../datasketches/theta/UpdateSketchBuilder.java | 76 +++----
.../theta/WrappedCompactCompressedSketch.java | 8 +-
.../datasketches/theta/WrappedCompactSketch.java | 12 +-
.../apache/datasketches/theta/package-info.java | 8 +-
.../java/org/apache/datasketches/tuple/AnotB.java | 2 +-
.../java/org/apache/datasketches/tuple/Union.java | 18 +-
.../apache/datasketches/theta/AnotBimplTest.java | 74 +++---
.../datasketches/theta/CompactSketchTest.java | 136 +++++------
.../ConcurrentDirectQuickSelectSketchTest.java | 106 ++++-----
.../theta/ConcurrentHeapQuickSelectSketchTest.java | 92 ++++----
.../theta/CornerCaseThetaSetOperationsTest.java | 124 +++++-----
.../datasketches/theta/DirectIntersectionTest.java | 249 ++++++++++-----------
.../theta/DirectQuickSelectSketchTest.java | 100 ++++-----
.../apache/datasketches/theta/DirectUnionTest.java | 220 +++++++++---------
.../org/apache/datasketches/theta/EmptyTest.java | 46 ++--
.../apache/datasketches/theta/ExamplesTest.java | 41 ++--
.../datasketches/theta/HeapAlphaSketchTest.java | 78 +++----
.../datasketches/theta/HeapIntersectionTest.java | 180 +++++++--------
.../theta/HeapQuickSelectSketchTest.java | 70 +++---
.../apache/datasketches/theta/HeapUnionTest.java | 182 +++++++--------
.../datasketches/theta/HeapifyWrapSerVer3Test.java | 72 +++---
.../apache/datasketches/theta/IteratorTest.java | 14 +-
.../datasketches/theta/JaccardSimilarityTest.java | 26 +--
.../theta/PairwiseSetOperationsTest.java | 169 +++++++-------
.../datasketches/theta/PreambleUtilTest.java | 12 +-
.../theta/ReadOnlyMemorySegmentTest.java | 42 ++--
.../datasketches/theta/SetOperationTest.java | 112 ++++-----
.../datasketches/theta/SetOpsCornerCasesTest.java | 187 ++++++++--------
.../datasketches/theta/SingleItemSketchTest.java | 86 +++----
.../apache/datasketches/theta/SketchMiscTest.java | 40 ++--
.../org/apache/datasketches/theta/SketchTest.java | 46 ++--
.../theta/ThetaSketchCrossLanguageTest.java | 22 +-
.../apache/datasketches/theta/UnionImplTest.java | 78 +++----
.../datasketches/theta/UpdateSketchTest.java | 26 +--
.../BoundsOnRatiosInThetaSketchedSetsTest.java | 20 +-
.../BoundsOnRatiosInTupleSketchedSetsTest.java | 8 +-
.../datasketches/tuple/JaccardSimilarityTest.java | 16 +-
.../datasketches/tuple/TupleExamples2Test.java | 12 +-
.../datasketches/tuple/TupleExamplesTest.java | 8 +-
.../tuple/adouble/AdoubleAnotBTest.java | 16 +-
.../tuple/adouble/AdoubleIntersectionTest.java | 18 +-
.../tuple/adouble/AdoubleUnionTest.java | 4 +-
.../CornerCaseTupleSetOperationsTest.java | 40 ++--
73 files changed, 1965 insertions(+), 1997 deletions(-)
diff --git a/src/main/java/org/apache/datasketches/theta/CompactOperations.java b/src/main/java/org/apache/datasketches/theta/CompactOperations.java
index 9fb917b24..fe7b6b60c 100644
--- a/src/main/java/org/apache/datasketches/theta/CompactOperations.java
+++ b/src/main/java/org/apache/datasketches/theta/CompactOperations.java
@@ -60,7 +60,7 @@ final class CompactOperations {
private CompactOperations() {}
- static CompactSketch componentsToCompact( //No error checking
+ static CompactThetaSketch componentsToCompact( //No error checking
final long thetaLong,
final int curCount,
final short seedHash,
@@ -108,15 +108,15 @@ final class CompactOperations {
}
/**
- * Heapify or convert a source Theta Sketch MemorySegment image into a heap or target MemorySegment CompactSketch.
+ * Heapify or convert a source ThetaSketch MemorySegment image into a heap or target MemorySegment CompactThetaSketch.
* This assumes hashSeed is OK; serVer = 3.
* @param srcSeg the given input source MemorySegment image. Can be Read Only.
- * @param dstOrdered the desired ordering of the resulting CompactSketch
- * @param dstWSeg Used for the target CompactSketch if it is MemorySegment-based. Must be Writable.
- * @return a CompactSketch of the correct form.
+ * @param dstOrdered the desired ordering of the resulting CompactThetaSketch
+ * @param dstWSeg Used for the target CompactThetaSketch if it is MemorySegment-based. Must be Writable.
+ * @return a CompactThetaSketch of the correct form.
*/
@SuppressWarnings("unused")
- static CompactSketch segmentToCompact(
+ static CompactThetaSketch segmentToCompact(
final MemorySegment srcSeg,
final boolean dstOrdered,
final MemorySegment dstWSeg)
@@ -233,7 +233,7 @@ final class CompactOperations {
}
final byte famID = (byte) Family.COMPACT.getID();
- //It is important to make sure that all byte fields are initialized, even those that are not used by the CompactSketch.
+ //It is important to make sure that all byte fields are initialized, even those that are not used by the CompactThetaSketch.
// Otherwise, uninitialized fields could could cause other problems downstream.
// As written below, all fields are initialized.
@@ -242,7 +242,7 @@ final class CompactOperations {
insertSerVer(dstWSeg, SER_VER);
insertFamilyID(dstWSeg, famID);
//The following initializes the lgNomLongs and lgArrLongs to 0.
- //They are not used in CompactSketches.
+ //They are not used in CompactThetaSketches.
dstWSeg.set(JAVA_SHORT_UNALIGNED, LG_NOM_LONGS_BYTE, (short)0);
insertFlags(dstWSeg, flags);
insertSeedHash(dstWSeg, seedHash);
@@ -305,15 +305,15 @@ final class CompactOperations {
* Num Theta CurCount Empty State Name, Comments
* 0 1.0 0 T OK EMPTY: The Normal Empty State
* 1 1.0 0 F Internal This can occur internally as the result of an intersection of two exact,
- * disjoint sets, or AnotB of two exact, identical sets. There is no probability
+ * disjoint sets, or ThetaAnotB of two exact, identical sets. There is no probability
* distribution, so this is converted internally to EMPTY {1.0, 0, T}.
- * This is handled in SetOperation.createCompactSketch().
+ * This is handled in ThetaSetOperation.createCompactThetaSketch().
* 2 1.0 !0 T Error Empty=T and curCount !0 should never coexist.
* This is checked in all compacting operations.
* 3 1.0 !0 F OK EXACT: This corresponds to a sketch in exact mode
- * 4 <1.0 0 T Internal This can be an initial UpdateSketch state if p < 1.0,
+ * 4 <1.0 0 T Internal This can be an initial UpdatableThetaSketch state if p < 1.0,
* so change theta to 1.0. Return {Th = 1.0, 0, T}.
- * This is handled in UpdateSketch.compact() and toByteArray().
+ * This is handled in UpdatableThetaSketch.compact() and toByteArray().
* 5 <1.0 0 F OK This can result from set operations
* 6 <1.0 !0 T Error Empty=T and curCount !0 should never coexist.
* This is checked in all compacting operations.
@@ -324,11 +324,11 @@ final class CompactOperations {
*/
/**
- * This corrects a temporary anomalous condition where compact() or toByteArray() is called on an UpdateSketch
+ * This corrects a temporary anomalous condition where compact() or toByteArray() is called on an UpdatableThetaSketch
* that was initialized with p < 1.0 and update() was never called. In this case Theta < 1.0,
* curCount = 0, and empty = true. The correction is to change Theta to 1.0, which makes the
* returning sketch empty. This should only be used in the compaction or serialization of an
- * UpdateSketch.
+ * UpdatableThetaSketch.
* @param empty the given empty state
* @param curCount the given curCount
* @param thetaLong the given thetaLong
@@ -355,7 +355,7 @@ final class CompactOperations {
/**
* This compute number of preamble longs for a compact sketch based on <i>empty</i>,
* <i>curCount</i> and <i>thetaLong</i>.
- * This also accommodates for EmptyCompactSketch and SingleItemSketch.
+ * This also accommodates for EmptyCompactThetaSketch and SingleItemThetaSketch.
* @param empty The given empty state
* @param curCount The given current count (retained entries)
* @param thetaLong the current thetaLong
@@ -367,7 +367,7 @@ final class CompactOperations {
}
/**
- * This checks for the singleItem Compact Sketch.
+ * This checks for the singleItem CompactThetaSketch.
* @param empty the given empty state
* @param curCount the given curCount
* @param thetaLong the given thetaLong
diff --git a/src/main/java/org/apache/datasketches/theta/CompactThetaSketch.java b/src/main/java/org/apache/datasketches/theta/CompactThetaSketch.java
index d560a8729..9dedaac46 100644
--- a/src/main/java/org/apache/datasketches/theta/CompactThetaSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/CompactThetaSketch.java
@@ -46,49 +46,49 @@ import org.apache.datasketches.common.SketchesArgumentException;
import org.apache.datasketches.common.Util;
/**
- * The parent class of all the CompactSketches. CompactSketches are never created directly.
- * They are created as a result of the compact() method of an UpdateSketch, a result of a
- * getResult() of a SetOperation, or from a heapify method.
+ * The parent class of all the CompactThetaSketches. CompactThetaSketches are never created directly.
+ * They are created as a result of the compact() method of an UpdatableThetaSketch, a result of a
+ * getResult() of a ThetaSetOperation, or from a heapify method.
*
- * <p>A CompactSketch is the simplest form of a Theta Sketch. It consists of a compact list
+ * <p>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.</p>
+ * bytes of preamble. An empty CompactThetaSketch consumes only 8 bytes.</p>
*
* @author Lee Rhodes
*/
-public abstract class CompactSketch extends ThetaSketch {
+public abstract class CompactThetaSketch extends ThetaSketch {
/**
- * 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.
*
* <p>The resulting sketch will not retain any link to the source MemorySegment and all of its data will be
- * copied to the heap CompactSketch.</p>
+ * copied to the heap CompactThetaSketch.</p>
*
* <p>The {@link Util#DEFAULT_UPDATE_SEED DEFAULT_UPDATE_SEED} is assumed.</p>
*
- * @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.
*
* <p>The resulting sketch will not retain any link to the source MemorySegment and all of its data will be
- * copied to the heap CompactSketch.</p>
+ * copied to the heap CompactThetaSketch.</p>
*
* <p>This method checks if the given expectedSeed was used to create the source MemorySegment image.</p>
*
- * @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.
* <a href="{@docRoot}/resources/dictionary.html#seed">See Update Hash Seed</a>.
- * @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 abstract class CompactSketch extends ThetaSketch {
}
/**
- * 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 abstract class CompactSketch extends ThetaSketch {
*
* <p>The {@link Util#DEFAULT_UPDATE_SEED DEFAULT_UPDATE_SEED} is assumed.</p>
*
- * @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 abstract class CompactSketch extends ThetaSketch {
*
* <p>This method checks if the given expectedSeed was used to create the source MemorySegment image.</p>
*
- * @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.
* <a href="{@docRoot}/resources/dictionary.html#seed">See Update Hash Seed</a>.
- * @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 abstract class CompactSketch extends ThetaSketch {
*
* <p>This method checks if the DEFAULT_UPDATE_SEED was used to create the source byte array image.</p>
*
- * @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 abstract class CompactSketch extends ThetaSketch {
*
* <p>This method checks if the given expectedSeed was used to create the source byte array image.</p>
*
- * @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.
* <a href="{@docRoot}/resources/dictionary.html#seed">See Update Hash Seed</a>.
- * @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 abstract class CompactSketch extends ThetaSketch {
"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 @@ public abstract class CompactSketch extends ThetaSketch {
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 @@ final class ConcurrentDirectQuickSelectSketch extends DirectQuickSelectSketch
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.ResizeFactor;
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 @@ final class ConcurrentHeapQuickSelectSketch extends HeapQuickSelectSketch
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 @@ import org.apache.datasketches.thetacommon.HashOperations;
* Propagation is done either synchronously by the updating thread, or asynchronously by a
* background propagation thread.
*
- * <p>This is a buffer, not a sketch, and it extends the <i>HeapQuickSelectSketch</i>
+ * <p>This is a buffer, not a sketch, and it extends the <i>HeapQuickSelectThetaSketch</i>
* in order to leverage some of the sketch machinery to make its work simple. However, if this
* buffer receives a query, like <i>getEstimate()</i>, the correct answer does not come from the super
- * <i>HeapQuickSelectSketch</i>, which knows nothing about the concurrency relationship to the
+ * <i>HeapQuickSelectThetaSketch</i>, 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 @@ final class ConcurrentHeapThetaBuffer extends HeapQuickSelectSketch {
//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 @@ final class ConcurrentHeapThetaBuffer extends HeapQuickSelectSketch {
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 @@ final class ConcurrentHeapThetaBuffer extends HeapQuickSelectSketch {
throw new UnsupportedOperationException("Local theta buffer need not be serialized");
}
- //Public UpdateSketch overrides
+ //Public UpdatableThetaSketch overrides
@Override
public void reset() {
@@ -187,7 +187,7 @@ final class ConcurrentHeapThetaBuffer extends HeapQuickSelectSketch {
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 @@ interface ConcurrentSharedThetaSketch extends MemorySegmentStatus {
//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 @@ interface ConcurrentSharedThetaSketch extends MemorySegmentStatus {
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 @@ final class DirectCompactCompressedSketch extends DirectCompactSketch {
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 @@ final class DirectCompactCompressedSketch extends DirectCompactSketch {
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 @@ import org.apache.datasketches.common.Util;
*
* @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 @@ class DirectCompactSketch extends CompactSketch {
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 @@ class DirectCompactSketch extends CompactSketch {
}
@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.HashOperations;
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)
*
* <p>This implementation uses data in a given MemorySegment that is owned and managed by the caller.
@@ -110,8 +110,8 @@ class DirectQuickSelectSketch extends DirectQuickSelectSketchR {
* @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 @@ class DirectQuickSelectSketch extends DirectQuickSelectSketchR {
* @param seed <a href="{@docRoot}/resources/dictionary.html#seed">See Update Hash Seed</a>
* @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 @@ class DirectQuickSelectSketch extends DirectQuickSelectSketchR {
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 @@ class DirectQuickSelectSketch extends DirectQuickSelectSketchR {
* @param seed <a href="{@docRoot}/resources/dictionary.html#seed">See Update Hash Seed</a>
* @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 @@ class DirectQuickSelectSketch extends DirectQuickSelectSketchR {
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.PREAMBLE_LONGS_BYTE;
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.ResizeFactor;
import org.apache.datasketches.common.SketchesReadOnlyException;
/**
- * The read-only Theta Sketch.
+ * The read-only ThetaSketch in a MemorySegment.
*
* <p>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 @@ import org.apache.datasketches.common.SketchesReadOnlyException;
* @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.
*
- * <p>When this class is constructed with the writable constructor, called by the writable child DirectQuickSelectSketch,
+ * <p>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.</p>
*
* <p>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 @@ class DirectQuickSelectSketchR extends UpdateSketch {
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 @@ class DirectQuickSelectSketchR extends UpdateSketch {
return new DirectQuickSelectSketchR(seed, srcSeg);
}
- //Sketch
+ //ThetaSketch
@Override
public int getCurrentBytes() {
@@ -146,7 +146,7 @@ class DirectQuickSelectSketchR extends UpdateSketch {
}
@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 @@ class DirectQuickSelectSketchR extends UpdateSketch {
return byteArray;
}
- //UpdateSketch
+ //UpdatableThetaSketch
@Override
public final int getLgNomLongs() {
@@ -211,7 +211,7 @@ class DirectQuickSelectSketchR extends UpdateSketch {
}
@Override
- public UpdateSketch rebuild() {
+ public UpdatableThetaSketch rebuild() {
throw new SketchesReadOnlyException();
}
@@ -253,7 +253,7 @@ class DirectQuickSelectSketchR extends UpdateSketch {
@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 java.lang.foreign.MemorySegment;
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 @@ final class EmptyCompactSketch extends CompactSketch {
// 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 @@ final class EmptyCompactSketch extends CompactSketch {
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 @@ final class EmptyCompactSketch extends CompactSketch {
}
/**
- * 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 @@ import org.apache.datasketches.thetacommon.ThetaUtil;
/**
* This sketch uses the
- * <a href="{@docRoot}/resources/dictionary.html#thetaSketch">Theta Sketch Framework</a>
+ * <a href="{@docRoot}/resources/dictionary.html#thetaSketch">ThetaSketch Framework</a>
* and the
* <a href="{@docRoot}/resources/dictionary.html#alphaTCF">Alpha TCF</a> algorithm
* with a single cache.
@@ -164,7 +164,7 @@ final class HeapAlphaSketch extends HeapUpdateSketch {
return has;
}
- //Sketch
+ //ThetaSketch
@Override
public Family getFamily() {
@@ -208,7 +208,7 @@ final class HeapAlphaSketch extends HeapUpdateSketch {
}
@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 @@ final class HeapAlphaSketch extends HeapUpdateSketch {
}
/*
- * Alpha Sketch Preamble Layout ( same as Theta UpdateSketch )
+ * AlphaSketch Preamble Layout ( same as UpdatableThetaSketch )
* <pre>
* Long || Start Byte Adr:
* Adr:
@@ -261,10 +261,10 @@ final class HeapAlphaSketch extends HeapUpdateSketch {
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 @@ final class HeapAlphaSketch extends HeapUpdateSketch {
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 @@ final class HeapAlphaSketch extends HeapUpdateSketch {
* 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
* </pre>
* @param k alias for nominal entries.
* @param p <a href="{@docRoot}/resources/dictionary.html#p">See Sampling Probability, <i>p</i></a>.
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 static org.apache.datasketches.theta.PreambleUtil.SINGLEITEM_FLAG_MASK;
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 @@ final class HeapCompactSketch extends CompactSketch {
}
@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 @@ class HeapQuickSelectSketch extends HeapUpdateSketch {
* @param seed <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a>
* @param p <a href="{@docRoot}/resources/dictionary.html#p">See Sampling Probability, <i>p</i></a>
* @param rf <a href="{@docRoot}/resources/dictionary.html#resizeFactor">See Resize Factor</a>
- * @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 @@ class HeapQuickSelectSketch extends HeapUpdateSketch {
}
/**
- * 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 <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a>
@@ -136,7 +136,7 @@ class HeapQuickSelectSketch extends HeapUpdateSketch {
return hqss;
}
- //Sketch
+ //ThetaSketch
@Override
public double getEstimate() {
@@ -149,7 +149,7 @@ class HeapQuickSelectSketch extends HeapUpdateSketch {
}
@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 @@ class HeapQuickSelectSketch extends HeapUpdateSketch {
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.common.Util;
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 @@ abstract class HeapUpdateSketch extends UpdateSketch {
return preLongs + dataLongs << 3;
}
- //UpdateSketch
+ //UpdatableThetaSketch
@Override
public final int getLgNomLongs() {
@@ -92,7 +92,7 @@ abstract class HeapUpdateSketch extends UpdateSketch {
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 static org.apache.datasketches.thetacommon.BoundsOnRatiosInThetaSketchedS
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 final class JaccardSimilarity {
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 final class JaccardSimilarity {
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 final class JaccardSimilarity {
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 final class JaccardSimilarity {
}
/**
- * 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 <i>J<sub>LB</sub></i> of the measured and
* expected sketches.
* if <i>J<sub>LB</sub> ≥ threshold</i>, then the sketches are considered to be
@@ -157,7 +157,7 @@ public final class JaccardSimilarity {
}
/**
- * 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 <i>J<sub>UB</sub></i> of the measured and
* expected sketches.
* if <i>J<sub>UB</sub> ≤ threshold</i>, 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 @@ import org.apache.datasketches.common.Util;
* fields.
*
* <p>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.</p>
*
@@ -50,7 +50,7 @@ import org.apache.datasketches.common.Util;
* multi-byte integers (<i>int</i> and <i>long</i>) are stored in native byte order. The
* <i>byte</i> values are treated as unsigned.</p>
*
- * <p>An empty CompactSketch only requires 8 bytes.
+ * <p>An empty CompactThetaSketch only requires 8 bytes.
* Flags: notSI, Ordered*, Compact, Empty*, ReadOnly, LE.
* (*) Earlier versions did not set these.</p>
*
@@ -61,7 +61,7 @@ import org.apache.datasketches.common.Util;
* 0 || Seed Hash | Flags | | | FamID | SerVer | PreLongs = 1 |
* </pre>
*
- * <p>A SingleItemSketch (extends CompactSketch) requires an 8 byte preamble plus a single
+ * <p>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.</p>
*
@@ -75,7 +75,7 @@ import org.apache.datasketches.common.Util;
* 1 ||---------------------------Single long hash----------------------------------------|
* </pre>
*
- * <p>An exact (non-estimating) CompactSketch requires 16 bytes of preamble plus a compact array of
+ * <p>An exact (non-estimating) CompactThetaSketch requires 16 bytes of preamble plus a compact array of
* longs.</p>
*
* <pre>
@@ -91,7 +91,7 @@ import org.apache.datasketches.common.Util;
* 2 ||----------------------Start of Compact Long Array----------------------------------|
* </pre>
*
- * <p>An estimating CompactSketch requires 24 bytes of preamble plus a compact array of longs.</p>
+ * <p>An estimating CompactThetaSketch requires 24 bytes of preamble plus a compact array of longs.</p>
*
* <pre>
* Long || Start Byte Adr:
@@ -109,7 +109,7 @@ import org.apache.datasketches.common.Util;
* 3 ||----------------------Start of Compact Long Array----------------------------------|
* </pre>
*
- * <p>The compressed CompactSketch has 8 bytes of preamble in exact mode because Theta can
+ * <p>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.</p>
@@ -139,10 +139,10 @@ import org.apache.datasketches.common.Util;
* 3 ||--------Delta encoded compressed byte array starts at bytes 17-20------------------|
* </pre>
*
- * <p>The UpdateSketch and AlphaSketch require 24 bytes of preamble followed by a non-compact
+ * <p>The UpdatableThetaSketch and AlphaSketch require 24 bytes of preamble followed by a non-compact
* array of longs representing a hash table.</p>
*
- * <p>The following table applies to both the Theta UpdateSketch and the Alpha Sketch</p>
+ * <p>The following table applies to both the Theta UpdatableThetaSketch and the AlphaSketch</p>
* <pre>
* Long || Start Byte Adr:
* Adr:
@@ -159,7 +159,7 @@ import org.apache.datasketches.common.Util;
* 3 ||----------------------Start of Hash Table of longs---------------------------------|
* </pre>
*
- * <p>Union objects require 32 bytes of preamble plus a non-compact array of longs representing a
+ * <p>ThetaUnion objects require 32 bytes of preamble plus a non-compact array of longs representing a
* hash table.</p>
*
* <pre>
@@ -201,7 +201,7 @@ final class 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 @@ final class PreambleUtil {
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 @@ final class PreambleUtil {
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.SketchesArgumentException;
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 @@ final class SingleItemSketch extends CompactSketch {
}
/**
- * 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 @@ final class SingleItemSketch extends CompactSketch {
}
@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 @@ final class SingleItemSketch extends CompactSketch {
* 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 @@ final class SingleItemSketch extends CompactSketch {
* 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 @@ final class SingleItemSketch extends CompactSketch {
* </p>
*
* @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 @@ final class SingleItemSketch extends CompactSketch {
* 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 @@ final class SingleItemSketch extends CompactSketch {
* method but will be a little faster as it avoids the complexity of the UTF8 encoding.</p>
*
* @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 @@ final class SingleItemSketch extends CompactSketch {
* 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 @@ final class SingleItemSketch extends CompactSketch {
* 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 @@ final class SingleItemSketch extends CompactSketch {
*
* @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 @@ final class SingleItemSketch extends CompactSketch {
*
* @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 @@ final class SingleItemSketch extends CompactSketch {
*
* @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 @@ final class SingleItemSketch extends CompactSketch {
*
* @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 @@ final class SingleItemSketch extends CompactSketch {
*
* @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 @@ final class SingleItemSketch extends CompactSketch {
*
* @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 @@ final class SingleItemSketch extends CompactSketch {
*
* @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 @@ final class SingleItemSketch extends CompactSketch {
}
@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 @@ final class SingleItemSketch extends CompactSketch {
// 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 java.lang.foreign.MemorySegment;
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.
*
* <p>The stateful operation is as follows:</p>
* <pre><code>
- * 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.
* </code></pre>
*
* <p>The stateless operation is as follows:</p>
* <pre><code>
- * AnotB anotb = SetOperationBuilder.buildAnotB();
+ * ThetaAnotB anotb = ThetaSetOperationBuilder.buildAnotB();
*
- * CompactSketch csk = anotb.aNotB(Sketch skA, Sketch skB);
+ * CompactThetaSketch csk = anotb.aNotB(ThetaSketch skA, ThetaSketch skB);
* </code></pre>
*
* <p>Calling the <i>setA</i> operation a second time essentially clears the internal state and loads
- * the new sketch.</p>
+ * the new ThetaSketch.</p>
*
* <p>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 @@ import org.apache.datasketches.common.Family;
*
* @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 abstract class AnotB extends SetOperation {
}
/**
- * 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 <i>A</i> of <i>A-AND-NOT-B</i>. 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 <i>notB</i> steps.
*
* <p>An input argument of null will throw an exception.</p>
@@ -95,9 +95,9 @@ public abstract class AnotB extends SetOperation {
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 <i>n+1</i>th) argument <i>B</i> of <i>A-AND-NOT-B</i>.
- * Performs an <i>AND NOT</i> operation with the existing internal state of this AnotB operator.
+ * Performs an <i>AND NOT</i> operation with the existing internal state of this ThetaAnotB operator.
*
* <p>An input argument of null or empty is ignored.</p>
*
@@ -109,28 +109,28 @@ public abstract class AnotB extends SetOperation {
*
* <p>Use {@link #getResult(boolean)} to obtain the result.</p>
*
- * @param skB The incoming Theta sketch for the second (or following) argument <i>B</i>.
+ * @param skB The incoming ThetaSketch for the second (or following) argument <i>B</i>.
*/
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 <i>true</i>, clears this operator to the empty state after this result is
* returned. Set this to <i>false</i> 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 <i>true</i>, the result will be an ordered {@link CompactSketch}.
+ * @param dstOrdered If <i>true</i>, the result will be an ordered {@link CompactThetaSketch}.
* <a href="{@docRoot}/resources/dictionary.html#dstOrdered">See Destination Ordered</a>.
*
* @param dstSeg if not <i>null</i> the given MemorySegment will be the target location of the result.
@@ -138,13 +138,13 @@ public abstract class AnotB extends SetOperation {
* @param reset If <i>true</i>, clears this operator to the empty state after this result is
* returned. Set this to <i>false</i> 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.
*
* <p>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 abstract class AnotB extends SetOperation {
*
* @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.
*
* <p>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 abstract class AnotB extends SetOperation {
* @param dstOrdered
* <a href="{@docRoot}/resources/dictionary.html#dstOrdered">See Destination Ordered</a>.
* @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 @@ import org.apache.datasketches.thetacommon.ThetaUtil;
* @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 <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a>
*/
- 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 @@ final class AnotBimpl extends AnotB {
}
@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 @@ final class AnotBimpl extends AnotB {
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 @@ final class AnotBimpl extends AnotB {
// 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 @@ import org.apache.datasketches.common.Util;
*
* @author Lee Rhodes
*/
-public abstract class Intersection extends SetOperation {
+public abstract class ThetaIntersection extends ThetaSetOperation {
@Override
public Family getFamily() {
@@ -41,22 +41,22 @@ public abstract class Intersection extends SetOperation {
}
/**
- * 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.
*
* <p>Note that presenting an intersection with an empty sketch sets the internal
@@ -71,10 +71,10 @@ public abstract class Intersection extends SetOperation {
*
* @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 abstract class Intersection extends SetOperation {
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 abstract class Intersection extends SetOperation {
/**
* 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
* <a href="{@docRoot}/resources/dictionary.html#dstOrdered">See Destination Ordered</a>.
* @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 <a href="{@docRoot}/resources/dictionary.html#defaultUpdateSeed">Default Update Seed</a>.
* 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 <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a>
- * @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.common.Util;
import org.apache.datasketches.thetacommon.ThetaUtil;
/**
- * Intersection operation for Theta Sketches.
+ * The intersection operation for ThetaSketches.
*
* <p>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 @@ import org.apache.datasketches.thetacommon.ThetaUtil;
* @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 @@ final class IntersectionImpl extends Intersection {
}
/**
- * 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 <a href="{@docRoot}/resources/dictionary.html#seed">See Seed</a>
* @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 <a href="{@docRoot}/resources/dictionary.html#seed">See Seed</a>
* @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 @@ final class IntersectionImpl extends Intersection {
//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 @@ final class IntersectionImpl extends Intersection {
* @param seed <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a>
* @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 @@ final class IntersectionImpl extends Intersection {
}
/**
- * 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 <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a>
* @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 @@ final class IntersectionImpl extends Intersection {
}
@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 @@ final class IntersectionImpl extends Intersection {
@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 @@ final class IntersectionImpl extends Intersection {
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 @@ final class IntersectionImpl extends Intersection {
} 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 @@ final class IntersectionImpl extends Intersection {
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 @@ final class IntersectionImpl extends Intersection {
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 @@ final class IntersectionImpl extends Intersection {
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 @@ import org.apache.datasketches.common.Util;
*
* @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
* <a href="{@docRoot}/resources/dictionary.html#defaultUpdateSeed">Default Update Seed</a>.
- * The resulting SetOperation will not retain any link to the source MemorySegment.
+ * The resulting ThetaSetOperation will not retain any link to the source MemorySegment.
*
* <p>Note: Only certain set operators during stateful operations can be serialized and thus
* heapified.</p>
*
- * @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.
*
* <p>Note: Only certain set operators during stateful operations can be serialized and thus
* heapified.</p>
*
- * @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.
* <a href="{@docRoot}/resources/dictionary.html#seed">See Update Hash Seed</a>.
- * @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 <a href="{@docRoot}/resources/dictionary.html#defaultUpdateSeed">Default Update Seed</a>.
* If the given source MemorySegment is read-only, the returned object will also be read-only.
*
* <p>Note: Only certain set operators during stateful operations can be serialized and thus wrapped.</p>
*
- * @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.
*
* <p>Note: Only certain set operators during stateful operations can be serialized and thus wrapped.</p>
*
- * @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.
* <a href="{@docRoot}/resources/dictionary.html#seed">See Update Hash Seed</a>.
- * @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 abstract class SetOperation implements MemorySegmentStatus {
}
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 <a href="{@docRoot}/resources/dictionary.html#nomEntries">Nominal Entries</a>
* 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 abstract class SetOperation implements MemorySegmentStatus {
}
/**
- * 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 <a href="{@docRoot}/resources/dictionary.html#nomEntries">Nominal Entries</a>
* This will become the ceiling power of 2 if it is not.
@@ -170,8 +170,8 @@ public abstract class SetOperation implements MemorySegmentStatus {
}
/**
- * 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 abstract class SetOperation implements MemorySegmentStatus {
}
/**
- * 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.common.Util;
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
* <ul>
* <li>Max Nominal Entries (max K):
* {@value org.apache.datasketches.thetacommon.ThetaUtil#DEFAULT_NOMINAL_ENTRIES}</li>
@@ -53,7 +53,7 @@ public final class SetOperationBuilder {
* <li>MemorySegment: null</li>
* </ul>
*/
- public SetOperationBuilder() {
+ public ThetaSetOperationBuilder() {
bLgNomLongs = Integer.numberOfTrailingZeros(ThetaUtil.DEFAULT_NOMINAL_ENTRIES);
bSeed = Util.DEFAULT_UPDATE_SEED;
bP = (float) 1.0;
@@ -66,9 +66,9 @@ public final class SetOperationBuilder {
* The minimum value is 16 and the maximum value is 67,108,864, which is 2^26.
* @param nomEntries <a href="{@docRoot}/resources/dictionary.html#nomEntries">Nominal Entries</a>
* This will become the ceiling power of 2 if it is not a power of 2.
- * @return this SetOperationBuilder
+ * @return this ThetaSetOperationBuilder
*/
- public SetOperationBuilder setNominalEntries(final int nomEntries) {
+ public ThetaSetOperationBuilder setNominalEntries(final int nomEntries) {
bLgNomLongs = Integer.numberOfTrailingZeros(ceilingPowerOf2(nomEntries));
if ((bLgNomLongs > ThetaUtil.MAX_LG_NOM_LONGS) || (bLgNomLongs < ThetaUtil.MIN_LG_NOM_LONGS)) {
throw new SketchesArgumentException("Nominal Entries must be >= 16 and <= 67108864: "
@@ -84,9 +84,9 @@ public final class SetOperationBuilder {
* thoroughly characterized for performance.
*
* @param lgNomEntries the log_base2 Nominal Entries.
- * @return this SetOperationBuilder
+ * @return this ThetaSetOperationBuilder
*/
- public SetOperationBuilder setLogNominalEntries(final int lgNomEntries) {
+ public ThetaSetOperationBuilder setLogNominalEntries(final int lgNomEntries) {
bLgNomLongs = ThetaUtil.checkNomLongs(1 << lgNomEntries);
return this;
}
@@ -102,9 +102,9 @@ public final class SetOperationBuilder {
/**
* Sets the long seed value that is require by the hashing function.
* @param seed <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a>
- * @return this SetOperationBuilder
+ * @return this ThetaSetOperationBuilder
*/
- public SetOperationBuilder setSeed(final long seed) {
+ public ThetaSetOperationBuilder setSeed(final long seed) {
bSeed = seed;
return this;
}
@@ -119,12 +119,12 @@ public final class SetOperationBuilder {
/**
* Sets the upfront uniform sampling probability, <i>p</i>. Although this functionality is
- * implemented for Unions only, it rarely makes sense to use it. The proper use of upfront
+ * implemented for ThetaUnions only, it rarely makes sense to use it. The proper use of upfront
* sampling is when building the sketches.
* @param p <a href="{@docRoot}/resources/dictionary.html#p">See Sampling Probability, <i>p</i></a>
- * @return this SetOperationBuilder
+ * @return this ThetaSetOperationBuilder
*/
- public SetOperationBuilder setP(final float p) {
+ public ThetaSetOperationBuilder setP(final float p) {
if ((p <= 0.0) || (p > 1.0)) {
throw new SketchesArgumentException("p must be > 0 and <= 1.0: " + p);
}
@@ -143,9 +143,9 @@ public final class SetOperationBuilder {
/**
* Sets the cache Resize Factor
* @param rf <a href="{@docRoot}/resources/dictionary.html#resizeFactor">See Resize Factor</a>
- * @return this SetOperationBuilder
+ * @return this ThetaSetOperationBuilder
*/
- public SetOperationBuilder setResizeFactor(final ResizeFactor rf) {
+ public ThetaSetOperationBuilder setResizeFactor(final ResizeFactor rf) {
bRF = rf;
return this;
}
@@ -159,106 +159,106 @@ public final class SetOperationBuilder {
}
/**
- * Returns a SetOperation with the current configuration of this Builder and the given Family.
- * @param family the chosen SetOperation family
- * @return a SetOperation
+ * Returns a ThetaSetOperation with the current configuration of this Builder and the given Family.
+ * @param family the chosen ThetaSetOperation family
+ * @return a ThetaSetOperation
*/
- public SetOperation build(final Family family) {
+ public ThetaSetOperation build(final Family family) {
return build(family, null);
}
/**
- * Returns a SetOperation with the current configuration of this Builder, the given Family
- * and the given destination MemorySegment. Note that the destination MemorySegment cannot be used with AnotB.
- * @param family the chosen SetOperation family
+ * Returns a ThetaSetOperation with the current configuration of this Builder, the given Family
+ * and the given destination MemorySegment. Note that the destination MemorySegment cannot be used with ThetaAnotB.
+ * @param family the chosen ThetaSetOperation family
* @param dstSeg The destination MemorySegment.
- * @return a SetOperation
+ * @return a ThetaSetOperation
*/
- public SetOperation build(final Family family, final MemorySegment dstSeg) {
- SetOperation setOp = null;
+ public ThetaSetOperation build(final Family family, final MemorySegment dstSeg) {
+ ThetaSetOperation setOp = null;
switch (family) {
case UNION: {
if (dstSeg == null) {
- setOp = UnionImpl.initNewHeapInstance(bLgNomLongs, bSeed, bP, bRF);
+ setOp = ThetaUnionImpl.initNewHeapInstance(bLgNomLongs, bSeed, bP, bRF);
}
else {
- setOp = UnionImpl.initNewDirectInstance(bLgNomLongs, bSeed, bP, bRF, dstSeg);
+ setOp = ThetaUnionImpl.initNewDirectInstance(bLgNomLongs, bSeed, bP, bRF, dstSeg);
}
break;
}
case INTERSECTION: {
if (dstSeg == null) {
- setOp = IntersectionImpl.initNewHeapInstance(bSeed);
+ setOp = ThetaIntersectionImpl.initNewHeapInstance(bSeed);
}
else {
- setOp = IntersectionImpl.initNewDirectInstance(bSeed, dstSeg);
+ setOp = ThetaIntersectionImpl.initNewDirectInstance(bSeed, dstSeg);
}
break;
}
case A_NOT_B: {
if (dstSeg == null) {
- setOp = new AnotBimpl(bSeed);
+ setOp = new ThetaAnotBimpl(bSeed);
}
else {
throw new SketchesArgumentException(
- "AnotB can not be persisted.");
+ "ThetaAnotB can not be persisted.");
}
break;
}
default:
throw new SketchesArgumentException(
- "Given Family cannot be built as a SetOperation: " + family.toString());
+ "Given Family cannot be built as a ThetaSetOperation: " + family.toString());
}
return setOp;
}
/**
- * Convenience method, returns a configured SetOperation Union with
+ * Convenience method, returns a configured ThetaSetOperation ThetaUnion with
* <a href="{@docRoot}/resources/dictionary.html#defaultNomEntries">Default Nominal Entries</a>
- * @return a Union object
+ * @return a ThetaUnion object
*/
- public Union buildUnion() {
- return (Union) build(Family.UNION);
+ public ThetaUnion buildUnion() {
+ return (ThetaUnion) build(Family.UNION);
}
/**
- * Convenience method, returns a configured SetOperation Union with
+ * Convenience method, returns a configured ThetaSetOperation ThetaUnion with
* <a href="{@docRoot}/resources/dictionary.html#defaultNomEntries">Default Nominal Entries</a>
* and the given destination MemorySegment.
* @param dstSeg The destination MemorySegment.
- * @return a Union object
+ * @return a ThetaUnion object
*/
- public Union buildUnion(final MemorySegment dstSeg) {
- return (Union) build(Family.UNION, dstSeg);
+ public ThetaUnion buildUnion(final MemorySegment dstSeg) {
+ return (ThetaUnion) build(Family.UNION, dstSeg);
}
/**
- * Convenience method, returns a configured SetOperation Intersection with
+ * Convenience method, returns a configured ThetaIntersection with
* <a href="{@docRoot}/resources/dictionary.html#defaultNomEntries">Default Nominal Entries</a>
- * @return an Intersection object
+ * @return a ThetaIntersection object
*/
- public Intersection buildIntersection() {
- return (Intersection) build(Family.INTERSECTION);
+ public ThetaIntersection buildIntersection() {
+ return (ThetaIntersection) build(Family.INTERSECTION);
}
/**
- * Convenience method, returns a configured SetOperation Intersection with
+ * Convenience method, returns a configured ThetaIntersection with
* <a href="{@docRoot}/resources/dictionary.html#defaultNomEntries">Default Nominal Entries</a>
* and the given destination MemorySegment.
* @param dstSeg The destination MemorySegment.
- * @return an Intersection object
+ * @return a ThetaIntersection object
*/
- public Intersection buildIntersection(final MemorySegment dstSeg) {
- return (Intersection) build(Family.INTERSECTION, dstSeg);
+ public ThetaIntersection buildIntersection(final MemorySegment dstSeg) {
+ return (ThetaIntersection) build(Family.INTERSECTION, dstSeg);
}
/**
- * Convenience method, returns a configured SetOperation ANotB with
+ * Convenience method, returns a configured ThetaSetOperation ANotB with
* <a href="{@docRoot}/resources/dictionary.html#defaultUpdateSeed">Default Update Seed</a>
- * @return an ANotB object
+ * @return a ThetaANotB object
*/
- public AnotB buildANotB() {
- return (AnotB) build(Family.A_NOT_B);
+ public ThetaAnotB buildANotB() {
+ return (ThetaAnotB) build(Family.A_NOT_B);
}
@Override
diff --git a/src/main/java/org/apache/datasketches/theta/ThetaSketch.java b/src/main/java/org/apache/datasketches/theta/ThetaSketch.java
index d3a1c2bfd..7ce965084 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 @@ import org.apache.datasketches.thetacommon.ThetaUtil;
/**
* The top-level class for all theta sketches. This class is never constructed directly.
- * Use the UpdateSketch.builder() methods to create UpdateSketches.
+ * Use the UpdatableThetaSketch.builder() methods to create UpdatableThetaSketches.
*
* @author Lee Rhodes
*/
@@ -56,41 +56,41 @@ public abstract class ThetaSketch implements MemorySegmentStatus {
//public static factory constructor-type methods
/**
- * 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.
*
* <p>The resulting sketch will not retain any link to the source MemorySegment.</p>
*
- * <p>For Update Sketches this method checks if the
+ * <p>For UpdatableThetaSketches this method checks if the
* <a href="{@docRoot}/resources/dictionary.html#defaultUpdateSeed">Default Update Seed</a></p>
* 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.
*
* <p>The resulting sketch will not retain any link to the source MemorySegment.</p>
*
- * <p>For Update Sketches this method checks if the expectedSeed
+ * <p>For UpdatableThetaSketches this method checks if the expectedSeed
* was used to create the source MemorySegment image.</p>
*
- * @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.
* <a href="{@docRoot}/resources/dictionary.html#seed">See Update Hash Seed</a>.
* 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 abstract class ThetaSketch implements MemorySegmentStatus {
* <a href="{@docRoot}/resources/dictionary.html#defaultUpdateSeed">Default Update Seed</a>
* was used to create the source MemorySegment image.</p>
*
- * @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 abstract class ThetaSketch implements MemorySegmentStatus {
* <p>This method checks if the given expectedSeed
* was used to create the source MemorySegment image.</p>
*
- * @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.
* <a href="{@docRoot}/resources/dictionary.html#seed">See Update Hash Seed</a>.
- * @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 abstract class ThetaSketch implements MemorySegmentStatus {
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.
*
* <p>If <i>this.isCompact() == true</i> this method returns <i>this</i>,
* otherwise, this method is equivalent to
* {@link #compact(boolean, MemorySegment) compact(true, null)}.
*
- * <p>A CompactSketch is always immutable.</p>
+ * <p>A CompactThetaSketch is always immutable.</p>
*
- * @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 <i>CompactSketch</i>.
+ * Convert this sketch to a <i>CompactThetaSketch</i>.
*
- * <p>If this sketch is a type of <i>UpdateSketch</i>, the compacting process converts the hash table
- * of the <i>UpdateSketch</i> to a simple list of the valid hash values.
+ * <p>If this sketch is a type of <i>UpdatableThetaSketch</i>, the compacting process converts the hash table
+ * of the <i>UpdatableThetaketch</i> 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 <i>CompactSketch</i> depends on a number of factors,
+ * The number of valid values remaining in the <i>CompactThetaSketch</i> depends on a number of factors,
* but may be larger or smaller than <i>Nominal Entries</i> (or <i>k</i>).
* It will never exceed 2<i>k</i>.
* If it is critical to always limit the size to no more than <i>k</i>,
- * then <i>rebuild()</i> should be called on the <i>UpdateSketch</i> prior to calling this method.</p>
+ * then <i>rebuild()</i> should be called on the <i>UpdatableThetaSketch</i> prior to calling this method.</p>
*
- * <p>A <i>CompactSketch</i> is always immutable.</p>
+ * <p>A <i>CompactThetaSketch</i> is always immutable.</p>
*
- * <p>A new <i>CompactSketch</i> object is created:</p>
+ * <p>A new <i>CompactThetaSketch</i> object is created:</p>
* <ul><li>if <i>dstSeg!= null</i></li>
* <li>if <i>dstSeg == null</i> and <i>this.hasMemorySegment() == true</i></li>
* <li>if <i>dstSeg == null</i> and <i>this</i> has more than 1 item and <i>this.isOrdered() == false</i>
@@ -196,12 +196,12 @@ public abstract class ThetaSketch implements MemorySegmentStatus {
* @param dstSeg
* <a href="{@docRoot}/resources/dictionary.html#dstSeg">See Destination MemorySegment</a>.
*
- * @return this sketch as a <i>CompactSketch</i>.
+ * @return this sketch as a <i>CompactThetaSketch</i>.
*/
- public abstract CompactSketch compact(final boolean dstOrdered, final MemorySegment dstSeg);
+ public abstract CompactThetaSketch compact(final boolean dstOrdered, final MemorySegment dstSeg);
/**
- * Returns the number of storage bytes required for this Sketch if its current state were
+ * Returns the number of storage bytes required for this ThetaSketch if its current state were
* compacted. It this sketch is already in the compact form this is equivalent to
* calling {@link #getCurrentBytes()}.
* @return number of compact bytes
@@ -239,7 +239,7 @@ public abstract class ThetaSketch implements MemorySegmentStatus {
checkSegPreambleCap(srcSeg);
final int familyId = extractFamilyID(srcSeg);
if (!isValidSketchID(familyId)) {
- throw new SketchesArgumentException("Source MemorySegment not a valid Sketch Family: "
+ throw new SketchesArgumentException("Source MemorySegment is not a valid ThetaSketch Family: "
+ Family.idToFamily(familyId).toString());
}
return ThetaSketch.estimate(extractThetaLong(srcSeg), getRetainedEntries(srcSeg));
@@ -266,10 +266,10 @@ public abstract class ThetaSketch implements MemorySegmentStatus {
}
/**
- * Returns the maximum number of storage bytes required for a CompactSketch with the given
+ * Returns the maximum number of storage bytes required for a CompactThetaSketch with the given
* number of actual entries.
* @param numberOfEntries the actual number of retained entries stored in the sketch.
- * @return the maximum number of storage bytes required for a CompactSketch with the given number
+ * @return the maximum number of storage bytes required for a CompactThetaSketch with the given number
* of retained entries.
*/
public static int getMaxCompactSketchBytes(final int numberOfEntries) {
@@ -279,10 +279,10 @@ public abstract class ThetaSketch implements MemorySegmentStatus {
}
/**
- * Returns the maximum number of storage bytes required for a CompactSketch given the configured
+ * Returns the maximum number of storage bytes required for a CompactThetaSketch given the configured
* log_base2 of the number of nominal entries, which is a power of 2.
* @param lgNomEntries <a href="{@docRoot}/resources/dictionary.html#nomEntries">Nominal Entries</a>
- * @return the maximum number of storage bytes required for a CompactSketch with the given
+ * @return the maximum number of storage bytes required for a CompactThetaSketch with the given
* lgNomEntries.
*/
public static int getCompactSketchMaxBytes(final int lgNomEntries) {
@@ -291,11 +291,11 @@ public abstract class ThetaSketch implements MemorySegmentStatus {
}
/**
- * Returns the maximum number of storage bytes required for an UpdateSketch with the given
+ * Returns the maximum number of storage bytes required for an UpdatableThetaSketch with the given
* number of nominal entries (power of 2).
* @param nomEntries <a href="{@docRoot}/resources/dictionary.html#nomEntries">Nominal Entries</a>
* This will become the ceiling power of 2 if it is not.
- * @return the maximum number of storage bytes required for a UpdateSketch with the given
+ * @return the maximum number of storage bytes required for a UpdatableThetaSketch with the given
* nomEntries
*/
public static int getMaxUpdateSketchBytes(final int nomEntries) {
@@ -304,10 +304,10 @@ public abstract class ThetaSketch implements MemorySegmentStatus {
}
/**
- * Returns the maximum number of storage bytes required for an UpdateSketch with the given
+ * Returns the maximum number of storage bytes required for an UpdatableThetaSketch with the given
* log_base2 of the nominal entries.
* @param lgNomEntries log_base2 of <a href="{@docRoot}/resources/dictionary.html#nomEntries">Nominal Entries</a>
- * @return the maximum number of storage bytes required for a UpdateSketch with the given lgNomEntries
+ * @return the maximum number of storage bytes required for a UpdatableThetaSketch with the given lgNomEntries
*/
public static int getUpdateSketchMaxBytes(final int lgNomEntries) {
return (16 << lgNomEntries) + (Family.QUICKSELECT.getMaxPreLongs() << 3);
@@ -315,7 +315,7 @@ public abstract class ThetaSketch implements MemorySegmentStatus {
/**
* Returns the number of valid entries that have been retained by the sketch.
- * For the Alpha Sketch this returns only valid entries.
+ * For the AlphaSketch this returns only valid entries.
* @return the number of valid retained entries.
*/
public int getRetainedEntries() {
@@ -324,7 +324,7 @@ public abstract class ThetaSketch implements MemorySegmentStatus {
/**
* Returns the number of entries that have been retained by the sketch.
- * @param valid This parameter is only relevant for the Alpha Sketch.
+ * @param valid This parameter is only relevant for the AlphaSketch.
* if true, returns the number of valid entries, which are less than theta and used
* for estimation. Otherwise, return the number of all entries, valid or not, that are currently in the
* internal sketch cache.
@@ -334,7 +334,7 @@ public abstract class ThetaSketch implements MemorySegmentStatus {
/**
* Returns the number of valid entries that have been retained by the sketch from the given MemorySegment
- * @param srcSeg the given MemorySegment that has an image of a Sketch
+ * @param srcSeg the given MemorySegment that has an image of a ThetaSketch
* @return the number of valid retained entries
*/
public static int getRetainedEntries(final MemorySegment srcSeg) {
@@ -425,7 +425,7 @@ public abstract class ThetaSketch implements MemorySegmentStatus {
/**
* Returns a human readable summary of the sketch. This method is equivalent to the parameterized
* call:<br>
- * <i>Sketch.toString(sketch, true, false, 8, true);</i>
+ * <i>ThetaSketch.toString(ThetaSketch, true, false, 8, true);</i>
* @return summary
*/
@Override
@@ -455,13 +455,13 @@ public abstract class ThetaSketch implements MemorySegmentStatus {
int arrLongs = 0;
float p = 0;
int rf = 0;
- final boolean updateSketch = this instanceof UpdateSketch;
+ final boolean updateSketch = this instanceof UpdatableThetaSketch;
final long thetaLong = getThetaLong();
final int curCount = this.getRetainedEntries(true);
if (updateSketch) {
- final UpdateSketch uis = (UpdateSketch)this;
+ final UpdatableThetaSketch uis = (UpdatableThetaSketch)this;
nomLongs = 1 << uis.getLgNomLongs();
arrLongs = 1 << uis.getLgArrLongs();
p = uis.getP();
@@ -528,18 +528,18 @@ public abstract class ThetaSketch implements MemorySegmentStatus {
}
/**
- * Returns a human readable string of the preamble of a byte array image of a Theta Sketch.
+ * Returns a human readable string of the preamble of a byte array image of a ThetaSketch.
* @param byteArr the given byte array
- * @return a human readable string of the preamble of a byte array image of a Theta Sketch.
+ * @return a human readable string of the preamble of a byte array image of a ThetaSketch.
*/
public static String toString(final byte[] byteArr) {
return PreambleUtil.preambleToString(byteArr);
}
/**
- * Returns a human readable string of the preamble of a MemorySegment image of a Theta Sketch.
+ * Returns a human readable string of the preamble of a MemorySegment image of a ThetaSketch.
* @param seg the given MemorySegment object
- * @return a human readable string of the preamble of a MemorySegment image of a Theta Sketch.
+ * @return a human readable string of the preamble of a MemorySegment image of a ThetaSketch.
*/
public static String toString(final MemorySegment seg) {
return PreambleUtil.preambleToString(seg);
@@ -623,7 +623,7 @@ public abstract class ThetaSketch implements MemorySegmentStatus {
}
/**
- * Gets the approximate lower error bound from a valid MemorySegment image of a Sketch
+ * Gets the approximate lower error bound from a valid MemorySegment image of a ThetaSketch
* given the specified number of Standard Deviations.
* This will return getEstimate() if isEmpty() is true.
*
@@ -642,7 +642,7 @@ public abstract class ThetaSketch implements MemorySegmentStatus {
}
/**
- * Gets the approximate upper error bound from a valid MemorySegment image of a Sketch
+ * Gets the approximate upper error bound from a valid MemorySegment image of a ThetaSketch
* given the specified number of Standard Deviations.
* This will return getEstimate() if isEmpty() is true.
*
@@ -662,11 +662,11 @@ public abstract class ThetaSketch implements MemorySegmentStatus {
}
/**
- * Instantiates a Heap Update Sketch from MemorySegment.
+ * Instantiates a Heap UpdatableThetaSketch from MemorySegment.
* @param srcSeg the source MemorySegment
* @param expectedSeed the seed used to validate the given MemorySegment image.
* <a href="{@docRoot}/resources/dictionary.html#seed">See Update Hash Seed</a>.
- * @return a Sketch
+ * @return a ThetaSketch
*/
private static final ThetaSketch heapifyUpdateSketchFromMemorySegment(final MemorySegment srcSeg, final long expectedSeed) {
final Family family = idToFamily(extractFamilyID(srcSeg));
@@ -684,7 +684,7 @@ public abstract class ThetaSketch implements MemorySegmentStatus {
return HeapQuickSelectSketch.heapifyInstance(srcSeg, expectedSeed);
}
throw new SketchesArgumentException(
- "Sketch cannot heapify family: " + family + " as a Sketch");
+ "Cannot heapify family: " + family + " as a ThetaSketch");
}
}
diff --git a/src/main/java/org/apache/datasketches/theta/ThetaUnion.java b/src/main/java/org/apache/datasketches/theta/ThetaUnion.java
index 25b00a7f7..72da65053 100644
--- a/src/main/java/org/apache/datasketches/theta/ThetaUnion.java
+++ b/src/main/java/org/apache/datasketches/theta/ThetaUnion.java
@@ -35,62 +35,62 @@ import org.apache.datasketches.common.Util;
*
* @author Lee Rhodes
*/
-public abstract class Union extends SetOperation {
+public abstract class ThetaUnion extends ThetaSetOperation {
/**
- * Wrap a Union object around a Union MemorySegment object containing data.
+ * Wrap a ThetaUnion object around a ThetaUnion MemorySegment object containing data.
* This method assumes the <a href="{@docRoot}/resources/dictionary.html#defaultUpdateSeed">Default Update Seed</a>.
* This does NO validity checking of the given MemorySegment.
- * 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 ThetaUnion object will also be read-only.
* @param srcSeg The source MemorySegment object.
* @return this class
*/
- public static Union fastWrap(final MemorySegment srcSeg) {
+ public static ThetaUnion fastWrap(final MemorySegment srcSeg) {
return fastWrap(srcSeg, Util.DEFAULT_UPDATE_SEED);
}
/**
- * Wrap a Union object around a Union MemorySegment object containing data.
+ * Wrap a ThetaUnion object around a ThetaUnion MemorySegment object containing data.
* This does NO validity checking of the given MemorySegment.
- * 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 ThetaUnion object will also be read-only.
* @param srcSeg The source MemorySegment object.
* @param expectedSeed the seed used to validate the given MemorySegment image.
* <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a>
* @return this class
*/
- public static Union fastWrap(final MemorySegment srcSeg, final long expectedSeed) {
+ public static ThetaUnion fastWrap(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 UnionImpl.fastWrapInstance(srcSeg, expectedSeed);
+ return ThetaUnionImpl.fastWrapInstance(srcSeg, expectedSeed);
}
/**
- * Wrap a Union object around a Union MemorySegment object containing data.
+ * Wrap a ThetaUnion object around a ThetaUnion MemorySegment object containing data.
* This method assumes the <a href="{@docRoot}/resources/dictionary.html#defaultUpdateSeed">Default Update Seed</a>.
- * 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 ThetaUnion object will also be read-only.
* @param srcSeg The source MemorySegment object.
* @return this class
*/
- public static Union wrap(final MemorySegment srcSeg) {
+ public static ThetaUnion wrap(final MemorySegment srcSeg) {
return wrap(srcSeg, Util.DEFAULT_UPDATE_SEED);
}
/**
- * Wrap a Union object around a Union MemorySegment object containing data.
- * If the given source MemorySegment is read-only, the returned Union object will also be read-only.
+ * Wrap a ThetaUnion object around a ThetaUnion MemorySegment object containing data.
+ * If the given source MemorySegment is read-only, the returned ThetaUnion object will also be read-only.
* @param srcSeg The source MemorySegment object.
* @param expectedSeed the seed used to validate the given MemorySegment image.
* <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a>
* @return this class
*/
- public static Union wrap(final MemorySegment srcSeg, final long expectedSeed) {
+ public static ThetaUnion 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 UnionImpl.wrapInstance(srcSeg, expectedSeed);
+ return ThetaUnionImpl.wrapInstance(srcSeg, expectedSeed);
}
/**
@@ -112,15 +112,15 @@ public abstract class Union extends SetOperation {
public abstract int getMaxUnionBytes();
/**
- * 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 the union.
* Therefore, it is OK to continue updating the union after this operation.
- * @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 abstract CompactSketch getResult();
+ public abstract CompactThetaSketch getResult();
/**
- * Gets the result of this operation as a CompactSketch of the chosen form.
+ * Gets the result of this operation as a CompactThetaSketch of the chosen form.
* This does not disturb the underlying data structure of the union.
* Therefore, it is OK to continue updating the union after this operation.
*
@@ -129,18 +129,18 @@ public abstract class Union extends SetOperation {
*
* @param dstSeg destination MemorySegment
*
- * @return the result of this operation as a CompactSketch of the chosen form
+ * @return the result of this operation as a CompactThetaSketch of the chosen form
*/
- public abstract CompactSketch getResult(boolean dstOrdered, MemorySegment dstSeg);
+ public abstract CompactThetaSketch getResult(boolean dstOrdered, MemorySegment dstSeg);
/**
- * Resets this Union. The seed remains intact, everything else reverts back to its virgin state.
+ * Resets this ThetaUnion. The seed remains intact, everything else reverts back to its virgin state.
*/
public abstract void reset();
/**
- * Returns a byte array image of this Union object
- * @return a byte array image of this Union object
+ * Returns a byte array image of this ThetaUnion object
+ * @return a byte array image of this ThetaUnion object
*/
public abstract byte[] toByteArray();
@@ -152,30 +152,29 @@ public abstract class Union extends SetOperation {
*
* @param sketchA The first argument
* @param sketchB The second argument
- * @return the result ordered CompactSketch on the heap.
+ * @return the result ordered CompactThetaSketch on the heap.
*/
- public CompactSketch union(final ThetaSketch sketchA, final ThetaSketch sketchB) {
+ public CompactThetaSketch union(final ThetaSketch sketchA, final ThetaSketch sketchB) {
return union(sketchA, sketchB, true, null);
}
/**
* This implements a stateless, pair-wise union operation. The returned sketch will be cut back to
- * k if required, similar to the regular Union operation.
+ * k if required, similar to the regular ThetaUnion operation.
*
* <p>Nulls and empty sketches are ignored.</p>
*
* @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 <i>this</i> 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 <i>this</i> ThetaUnion and the given on-heap sketch of the Theta Family.
*
* <p>This method can be repeatedly called.
*
@@ -186,9 +185,8 @@ public abstract class Union extends SetOperation {
public abstract void union(ThetaSketch sketchIn);
/**
- * Perform a Union operation with <i>this</i> 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 <i>this</i> ThetaUnion and the given MemorySegment image of any sketch of the
+ * Theta Family.
*
* <p>This method can be repeatedly called.
*
@@ -225,7 +223,7 @@ public abstract class Union extends SetOperation {
* method and will generally be a little slower depending on the complexity of the UTF8 encoding.
* </p>
*
- * <p>Note: this is not a Sketch Union operation. This treats the given string as a data item.</p>
+ * <p>Note: this is not a union operation. This treats the given string as a data item.</p>
*
* @param datum The given String.
*/
@@ -235,7 +233,7 @@ public abstract class Union extends SetOperation {
* Update <i>this</i> union with the given byte array item.
* If the byte array is null or empty no update attempt is made and the method returns.
*
- * <p>Note: this is not a Sketch Union operation. This treats the given byte array as a data
+ * <p>Note: this is not a union operation. This treats the given byte array as a data
* item.</p>
*
* @param data The given byte array.
@@ -246,7 +244,7 @@ public abstract class Union extends SetOperation {
* Update <i>this</i> union with the given ByteBuffer item.
* If the ByteBuffer is null or empty no update attempt is made and the method returns.
*
- * <p>Note: this is not a Sketch Union operation. This treats the given ByteBuffer as a data
+ * <p>Note: this is not a union operation. This treats the given ByteBuffer as a data
* item.</p>
*
* @param data The given ByteBuffer.
@@ -257,7 +255,7 @@ public abstract class Union extends SetOperation {
* Update <i>this</i> union with the given integer array item.
* If the integer array is null or empty no update attempt is made and the method returns.
*
- * <p>Note: this is not a Sketch Union operation. This treats the given integer array as a data
+ * <p>Note: this is not a union operation. This treats the given integer array as a data
* item.</p>
*
* @param data The given int array.
@@ -271,7 +269,7 @@ public abstract class Union extends SetOperation {
* <p>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.</p>
*
- * <p>Note: this is not a Sketch Union operation. This treats the given char array as a data
+ * <p>Note: this is not a union operation. This treats the given char array as a data
* item.</p>
*
* @param data The given char array.
@@ -282,7 +280,7 @@ public abstract class Union extends SetOperation {
* Update <i>this</i> union with the given long array item.
* If the long array is null or empty no update attempt is made and the method returns.
*
- * <p>Note: this is not a Sketch Union operation. This treats the given char array as a data
+ * <p>Note: this is not a union operation. This treats the given char array as a data
* item.</p>
*
* @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.common.Util;
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 <a href="{@docRoot}/resources/dictionary.html#lgNomLogs">See lgNomLongs</a>
* @param seed <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a>
@@ -77,22 +77,22 @@ final class UnionImpl extends Union {
* @param rf <a href="{@docRoot}/resources/dictionary.html#resizeFactor">See Resize Factor</a>
* @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 <a href="{@docRoot}/resources/dictionary.html#lgNomLogs">See lgNomLongs</a>.
* @param seed <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a>
@@ -101,71 +101,71 @@ final class UnionImpl extends Union {
* @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.
* <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a>
* @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.
* <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a>
* @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.
* <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a>
* @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 @@ final class UnionImpl extends Union {
}
@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 @@ final class UnionImpl extends Union {
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 @@ final class UnionImpl extends Union {
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 @@ final class UnionImpl extends Union {
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.common.Util;
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 {
* <a href="{@docRoot}/resources/dictionary.html#defaultUpdateSeed">Default Update Seed</a>.
* @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 abstract class UpdateSketch extends ThetaSketch {
* @param expectedSeed the seed used to validate the given MemorySegment image.
* <a href="{@docRoot}/resources/dictionary.html#seed">See Update Hash Seed</a>.
* 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 abstract class UpdateSketch extends ThetaSketch {
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.
* <a href="{@docRoot}/resources/dictionary.html#seed">See Update Hash Seed</a>.
- * @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 abstract class UpdateSketch extends ThetaSketch {
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 abstract class UpdateSketch extends ThetaSketch {
return this instanceof final DirectQuickSelectSketchR dqssr && dqssr.isSameResource(that);
}
- //UpdateSketch interface
+ //UpdatableThetaSketch interface
/**
* Returns a new builder
@@ -245,7 +245,7 @@ public abstract class UpdateSketch extends ThetaSketch {
* 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.common.Util;
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
* <ul>
* <li>Nominal Entries: {@value org.apache.datasketches.thetacommon.ThetaUtil#DEFAULT_NOMINAL_ENTRIES}</li>
* <li>Seed: {@value org.apache.datasketches.common.Util#DEFAULT_UPDATE_SEED}</li>
@@ -100,7 +100,7 @@ public final class UpdateSketchBuilder {
*
* @param nomEntries <a href="{@docRoot}/resources/dictionary.html#nomEntries">Nominal Entries</a>
* This will become the ceiling power of 2 if the given value is not.
- * @return this UpdateSketchBuilder
+ * @return this UpdatableThetaSketchBuilder
*/
public UpdateSketchBuilder setNominalEntries(final int nomEntries) {
bLgNomLongs = ThetaUtil.checkNomLongs(nomEntries);
@@ -115,7 +115,7 @@ public final class UpdateSketchBuilder {
* thoroughly characterized for performance.
*
* @param lgNomEntries the Log Nominal Entries. Also for the concurrent shared sketch
- * @return this UpdateSketchBuilder
+ * @return this UpdatableThetaSketchBuilder
*/
public UpdateSketchBuilder setLogNominalEntries(final int lgNomEntries) {
bLgNomLongs = ThetaUtil.checkNomLongs(1 << lgNomEntries);
@@ -130,7 +130,7 @@ public final class UpdateSketchBuilder {
* thoroughly characterized for performance.
*
* @param lgK the Log Nominal Entries. Also for the concurrent shared sketch.
- * @return this UpdateSketchBuilder
+ * @return this UpdatableThetaSketchBuilder
*/
public UpdateSketchBuilder setLgK(final int lgK) {
bLgNomLongs = ThetaUtil.checkNomLongs(1 << lgK);
@@ -153,7 +153,7 @@ public final class UpdateSketchBuilder {
*
* @param nomEntries <a href="{@docRoot}/resources/dictionary.html#nomEntries">Nominal Entries</a>
* This will become the ceiling power of 2 if it is not.
- * @return this UpdateSketchBuilder
+ * @return this UpdatableThetaSketchBuilder
*/
public UpdateSketchBuilder setConCurNominalEntries(final int nomEntries) {
bConCurLgNomLongs = Integer.numberOfTrailingZeros(ceilingPowerOf2(nomEntries));
@@ -171,7 +171,7 @@ public final class UpdateSketchBuilder {
* value have not been thoroughly tested or characterized for performance.
*
* @param lgNomEntries the Log Nominal Entries for a concurrent local sketch
- * @return this UpdateSketchBuilder
+ * @return this UpdatableThetaSketchBuilder
*/
public UpdateSketchBuilder setConCurLogNominalEntries(final int lgNomEntries) {
bConCurLgNomLongs = lgNomEntries;
@@ -193,7 +193,7 @@ public final class UpdateSketchBuilder {
/**
* Sets the local long seed value that is required by the hashing function.
* @param seed <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a>
- * @return this UpdateSketchBuilder
+ * @return this UpdatableThetaSketchBuilder
*/
public UpdateSketchBuilder setSeed(final long seed) {
bSeed = seed;
@@ -211,7 +211,7 @@ public final class UpdateSketchBuilder {
/**
* Sets the local upfront uniform pre-sampling probability, <i>p</i>
* @param p <a href="{@docRoot}/resources/dictionary.html#p">See Sampling Probability, <i>p</i></a>
- * @return this UpdateSketchBuilder
+ * @return this UpdatableThetaSketchBuilder
*/
public UpdateSketchBuilder setP(final float p) {
if (p <= 0.0 || p > 1.0) {
@@ -232,7 +232,7 @@ public final class UpdateSketchBuilder {
/**
* Sets the local cache Resize Factor.
* @param rf <a href="{@docRoot}/resources/dictionary.html#resizeFactor">See Resize Factor</a>
- * @return this UpdateSketchBuilder
+ * @return this UpdatableThetaSketchBuilder
*/
public UpdateSketchBuilder setResizeFactor(final ResizeFactor rf) {
bRF = rf;
@@ -250,7 +250,7 @@ public final class UpdateSketchBuilder {
/**
* Set the local Family. Choose either Family.ALPHA or Family.QUICKSELECT.
* @param family the family for this builder
- * @return this UpdateSketchBuilder
+ * @return this UpdatableThetaSketchBuilder
*/
public UpdateSketchBuilder setFamily(final Family family) {
bFam = family;
@@ -268,7 +268,7 @@ public final class UpdateSketchBuilder {
/**
* Sets the local MemorySegmentRequest
* @param mSegReq the given MemorySegmentRequest
- * @return this UpdateSketchBuilder
+ * @return this UpdatableThetaSketchBuilder
*/
public UpdateSketchBuilder setMemorySegmentRequest(final MemorySegmentRequest mSegReq) {
bMemorySegmentRequest = mSegReq;
@@ -305,7 +305,7 @@ public final class UpdateSketchBuilder {
* Sets the local Propagate Ordered Compact flag to the given value. Used with concurrent sketches.
*
* @param prop the given value
- * @return this UpdateSketchBuilder
+ * @return this UpdatableThetaSketchBuilder
*/
public UpdateSketchBuilder setPropagateOrderedCompact(final boolean prop) {
bPropagateOrderedCompact = prop;
@@ -356,23 +356,23 @@ public final class UpdateSketchBuilder {
// BUILD FUNCTIONS
/**
- * Returns an UpdateSketch with the current configuration of this Builder.
- * @return an UpdateSketch
+ * Returns an UpdatableThetaSketch with the current configuration of this Builder.
+ * @return an UpdatableThetaSketch
*/
- public UpdateSketch build() {
+ public UpdatableThetaSketch build() {
return build(null);
}
/**
- * Returns an UpdateSketch with the current configuration of this Builder
+ * Returns an UpdatableThetaSketch with the current configuration of this Builder
* with the specified backing destination MemorySegment store.
* Note: this can only be used with the QUICKSELECT Family of sketches
* and cannot be used with the Alpha Family of sketches.
* @param dstSeg The destination MemorySegment.
- * @return an UpdateSketch
+ * @return an UpdatableThetaSketch
*/
- public UpdateSketch build(final MemorySegment dstSeg) {
- UpdateSketch sketch = null;
+ public UpdatableThetaSketch build(final MemorySegment dstSeg) {
+ UpdatableThetaSketch sketch = null;
final boolean unionGadget = false;
switch (bFam) {
case ALPHA: {
@@ -395,14 +395,14 @@ public final class UpdateSketchBuilder {
}
default: {
throw new SketchesArgumentException(
- "Given Family cannot be built as a Theta Sketch: " + bFam.toString());
+ "Given Family cannot be built as an UpdatableThetaSketch: " + bFam.toString());
}
}
return sketch;
}
/**
- * Returns an on-heap concurrent shared UpdateSketch with the current configuration of the
+ * Returns an on-heap concurrent shared UpdatableThetaSketch with the current configuration of the
* Builder.
*
* <p>The parameters unique to the shared concurrent sketch are:
@@ -411,21 +411,21 @@ public final class UpdateSketchBuilder {
* <li>Maximum Concurrency Error</li>
* </ul>
*
- * <p>Key parameters that are in common with other <i>Theta</i> sketches:
+ * <p>Key parameters that are in common with other <i>ThetaSketches</i>:
* <ul>
* <li>Nominal Entries or Log Nominal Entries (for the shared concurrent sketch)</li>
* </ul>
*
- * @return an on-heap concurrent UpdateSketch with the current configuration of the Builder.
+ * @return an on-heap concurrent UpdatableThetaSketch with the current configuration of the Builder.
*/
- public UpdateSketch buildShared() {
+ public UpdatableThetaSketch buildShared() {
return buildShared(null);
}
/**
- * Returns a concurrent shared UpdateSketch with the current
+ * Returns a concurrent shared UpdatableThetaSketch with the current
* configuration of the Builder and the given destination MemorySegment. If the destination
- * MemorySegment is null, this defaults to an on-heap concurrent shared UpdateSketch.
+ * MemorySegment is null, this defaults to an on-heap concurrent shared UpdatableThetaSketch.
*
* <p>The parameters unique to the shared concurrent sketch are:
* <ul>
@@ -440,12 +440,12 @@ public final class UpdateSketchBuilder {
* </ul>
*
* @param dstSeg the given MemorySegment for Direct, otherwise <i>null</i>.
- * @return a concurrent UpdateSketch with the current configuration of the Builder
+ * @return a concurrent UpdatableThetaSketch with the current configuration of the Builder
* and the given destination MemorySegment.
*/
@SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD",
justification = "Harmless in Builder, fix later")
- public UpdateSketch buildShared(final MemorySegment dstSeg) {
+ public UpdatableThetaSketch buildShared(final MemorySegment dstSeg) {
ConcurrentPropagationService.NUM_POOL_THREADS = bNumPoolThreads;
if (dstSeg == null) {
return new ConcurrentHeapQuickSelectSketch(bLgNomLongs, bSeed, bMaxConcurrencyError);
@@ -455,10 +455,10 @@ public final class UpdateSketchBuilder {
}
/**
- * Returns a direct (potentially off-heap) concurrent shared UpdateSketch with the current
+ * Returns a direct (potentially off-heap) concurrent shared UpdatableThetaSketch with the current
* configuration of the Builder, the data from the given sketch, and the given destination
* MemorySegment. If the destination MemorySegment is null, this defaults to an on-heap
- * concurrent shared UpdateSketch.
+ * concurrent shared UpdatableThetaSketch.
*
* <p>The parameters unique to the shared concurrent sketch are:
* <ul>
@@ -472,15 +472,15 @@ public final class UpdateSketchBuilder {
* <li>Destination MemorySegment (if not null, returned sketch is Direct. Default is null.)</li>
* </ul>
*
- * @param sketch a given UpdateSketch from which the data is used to initialize the returned
+ * @param sketch a given UpdatableThetaSketch from which the data is used to initialize the returned
* shared sketch.
* @param dstSeg the given MemorySegment for Direct, otherwise <i>null</i>.
- * @return a concurrent UpdateSketch with the current configuration of the Builder
+ * @return a concurrent UpdatableThetaSketch with the current configuration of the Builder
* and the given destination MemorySegment.
*/
@SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD",
justification = "Harmless in Builder, fix later")
- public UpdateSketch buildSharedFromSketch(final UpdateSketch sketch, final MemorySegment dstSeg) {
+ public UpdatableThetaSketch buildSharedFromSketch(final UpdatableThetaSketch sketch, final MemorySegment dstSeg) {
ConcurrentPropagationService.NUM_POOL_THREADS = bNumPoolThreads;
if (dstSeg == null) {
return new ConcurrentHeapQuickSelectSketch(sketch, bSeed, bMaxConcurrencyError);
@@ -490,8 +490,8 @@ public final class UpdateSketchBuilder {
}
/**
- * Returns a local, on-heap, concurrent UpdateSketch to be used as a per-thread local buffer
- * along with the given concurrent shared UpdateSketch and the current configuration of this
+ * Returns a local, on-heap, concurrent UpdatableThetaSketch to be used as a per-thread local buffer
+ * along with the given concurrent shared UpdatableThetaSketch and the current configuration of this
* Builder.
*
* <p>The parameters unique to the local concurrent sketch are:
@@ -501,9 +501,9 @@ public final class UpdateSketchBuilder {
* </ul>
*
* @param shared the concurrent shared sketch to be accessed via the concurrent local sketch.
- * @return an UpdateSketch to be used as a per-thread local buffer.
+ * @return an UpdatableThetaSketch to be used as a per-thread local buffer.
*/
- public UpdateSketch buildLocal(final UpdateSketch shared) {
+ public UpdatableThetaSketch buildLocal(final UpdatableThetaSketch shared) {
if (shared == null || !(shared instanceof ConcurrentSharedThetaSketch)) {
throw new SketchesStateException("The concurrent shared sketch must be built first.");
}
diff --git a/src/main/java/org/apache/datasketches/theta/WrappedCompactCompressedSketch.java b/src/main/java/org/apache/datasketches/theta/WrappedCompactCompressedSketch.java
index 584338469..d709188ed 100644
--- a/src/main/java/org/apache/datasketches/theta/WrappedCompactCompressedSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/WrappedCompactCompressedSketch.java
@@ -44,8 +44,8 @@ final class WrappedCompactCompressedSketch extends WrappedCompactSketch {
}
/**
- * Wraps the given bytes, which must be a SerVer 4 compressed CompactSketch image.
- * @param bytes representation of serialized compressed compact sketch.
+ * Wraps the given bytes, which must be a SerVer 4 compressed CompactThetaSketch image.
+ * @param bytes representation of serialized compressed CompactThetaSketch.
* @param seedHash The update seedHash.
* <a href="{@docRoot}/resources/dictionary.html#seedHash">See Seed Hash</a>.
* @return this sketch
@@ -55,7 +55,7 @@ final class WrappedCompactCompressedSketch extends WrappedCompactSketch {
return new WrappedCompactCompressedSketch(bytes);
}
- //Sketch Overrides
+ //ThetaSketch Overrides
@Override
public int getCurrentBytes() {
@@ -69,7 +69,7 @@ final class WrappedCompactCompressedSketch extends WrappedCompactSketch {
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/WrappedCompactSketch.java b/src/main/java/org/apache/datasketches/theta/WrappedCompactSketch.java
index 1f3f3ab9e..2a33a386a 100644
--- a/src/main/java/org/apache/datasketches/theta/WrappedCompactSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/WrappedCompactSketch.java
@@ -42,7 +42,7 @@ import org.apache.datasketches.common.Util;
*
* <p>This sketch can only be associated with a Serialization Version 3 binary image format.</p>
*/
-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.
* <a href="{@docRoot}/resources/dictionary.html#seedHash">See Seed Hash</a>.
* @return this sketch
@@ -65,10 +65,10 @@ class WrappedCompactSketch extends CompactSketch {
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 @@ class WrappedCompactSketch extends CompactSketch {
}
@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
- * <a href="{@docRoot}/resources/dictionary.html#thetaSketch">Theta Sketch Framework</a>.
+ * The /theta/ package contains the basic sketch classes that are members of the
+ * <a href="{@docRoot}/resources/dictionary.html#thetaSketch">ThetaSketch Framework</a>.
*
- * <p>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.</p>
+ * <p>There is a separate /tuple/ package for many of the sketches that are derived from the
+ * same algorithms defined in the ThetaSketch Framework paper.</p>
*/
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 @@ public final class AnotB<S extends Summary> {
try { hashCacheB = (long[])GET_CACHE.invoke(skB);
} catch (final Exception e) { throw new SketchesStateException("Reflection Exception " + e); }
- if (skB instanceof org.apache.datasketches.theta.CompactSketch) {
+ if (skB instanceof org.apache.datasketches.theta.CompactThetaSketch) {
final int countB = skB.getRetainedEntries(true);
hashTableB = convertToHashTable(hashCacheB, countB, minThetaLong, ThetaUtil.REBUILD_THRESHOLD);
} else {
diff --git a/src/main/java/org/apache/datasketches/tuple/Union.java b/src/main/java/org/apache/datasketches/tuple/Union.java
index 9c663f88a..593c944cb 100644
--- a/src/main/java/org/apache/datasketches/tuple/Union.java
+++ b/src/main/java/org/apache/datasketches/tuple/Union.java
@@ -26,8 +26,8 @@ import org.apache.datasketches.common.SketchesArgumentException;
import org.apache.datasketches.thetacommon.ThetaUtil;
/**
- * Compute the union of two or more generic tuple sketches or generic tuple sketches combined with
- * theta sketches. A new instance represents an empty set.
+ * Compute the union of two or more generic tuple sketches or generic TupleSketches combined with
+ * ThetaSketches. A new instance represents an empty set.
* @param <S> Type of Summary
*/
public class Union<S extends Summary> {
@@ -77,14 +77,14 @@ public class Union<S extends Summary> {
}
/**
- * Perform a stateless, pair-wise union operation between a tupleSketch and a thetaSketch.
+ * Perform a stateless, pair-wise union operation between a tupleSketch and a ThetaSketch.
* The returned sketch will be cut back to the smaller of the two k values if required.
*
* <p>Nulls and empty sketches are ignored.</p>
*
* @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 class Union<S extends Summary> {
}
/**
- * Performs a stateful union of the internal set with the given tupleSketch.
+ * Performs a stateful union of the internal set with the given TupleSketch.
* @param tupleSketch input tuple sketch to merge with the internal set.
* Nulls and empty sketches are ignored.
*/
@@ -114,10 +114,10 @@ public class Union<S extends Summary> {
}
/**
- * Performs a stateful union of the internal set with the given thetaSketch by combining entries
- * using the hashes from the theta sketch and summary values from the given summary.
- * @param thetaSketch the given theta sketch input. If null or empty, it is ignored.
- * @param summary the given proxy summary for the theta sketch, which doesn't have one. This may
+ * Performs a stateful union of the internal set with the given ThetaSketch by combining entries
+ * using the hashes from the ThetaSketch and summary values from the given summary.
+ * @param thetaSketch the given ThetaSketch input. If null or empty, it is ignored.
+ * @param summary the given proxy summary for the ThetaSketch, which doesn't have one. This may
* not be null.
*/
public void union(final org.apache.datasketches.theta.ThetaSketch thetaSketch, final S summary) {
diff --git a/src/test/java/org/apache/datasketches/theta/AnotBimplTest.java b/src/test/java/org/apache/datasketches/theta/AnotBimplTest.java
index 6960fbc32..414308280 100644
--- a/src/test/java/org/apache/datasketches/theta/AnotBimplTest.java
+++ b/src/test/java/org/apache/datasketches/theta/AnotBimplTest.java
@@ -40,8 +40,8 @@ public class AnotBimplTest {
public void checkExactAnotB_AvalidNoOverlap() {
final int k = 512;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<k/2; i++) {
usk1.update(i);
@@ -50,7 +50,7 @@ public class AnotBimplTest {
usk2.update(i);
}
- final AnotB aNb = SetOperation.builder().buildANotB();
+ final ThetaAnotB aNb = ThetaSetOperation.builder().buildANotB();
assertTrue(aNb.isEmpty()); //only applies to stateful
assertTrue(aNb.getCache().length == 0); //only applies to stateful
assertEquals(aNb.getThetaLong(), Long.MAX_VALUE); //only applies to stateful
@@ -60,7 +60,7 @@ public class AnotBimplTest {
aNb.notB(usk2);
assertEquals(aNb.getRetainedEntries(), k/2);
- CompactSketch rsk1;
+ CompactThetaSketch rsk1;
rsk1 = aNb.getResult(false, null, true); //not ordered, reset
assertEquals(rsk1.getEstimate(), k/2.0);
@@ -87,30 +87,30 @@ public class AnotBimplTest {
@Test
public void checkCombinations() {
final int k = 512;
- final UpdateSketch aNull = null;
- final UpdateSketch bNull = null;
- final UpdateSketch aEmpty = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch bEmpty = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch aNull = null;
+ final UpdatableThetaSketch bNull = null;
+ final UpdatableThetaSketch aEmpty = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch bEmpty = UpdatableThetaSketch.builder().setNominalEntries(k).build();
- final UpdateSketch aHT = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch aHT = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<k; i++) {
aHT.update(i);
}
- final CompactSketch aC = aHT.compact(false, null);
- final CompactSketch aO = aHT.compact(true, null);
+ final CompactThetaSketch aC = aHT.compact(false, null);
+ final CompactThetaSketch aO = aHT.compact(true, null);
- final UpdateSketch bHT = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch bHT = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=k/2; i<k+k/2; i++) {
bHT.update(i); //overlap is k/2
}
- final CompactSketch bC = bHT.compact(false, null);
- final CompactSketch bO = bHT.compact(true, null);
+ final CompactThetaSketch bC = bHT.compact(false, null);
+ final CompactThetaSketch bO = bHT.compact(true, null);
- CompactSketch result;
- AnotB aNb;
+ CompactThetaSketch result;
+ ThetaAnotB aNb;
final boolean ordered = true;
- aNb = SetOperation.builder().buildANotB();
+ aNb = ThetaSetOperation.builder().buildANotB();
try { aNb.setA(aNull); fail();} catch (final SketchesArgumentException e) {}
@@ -206,23 +206,23 @@ public class AnotBimplTest {
final int k = 1024;
final boolean ordered = true;
- final UpdateSketch aU = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch aU = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<k; i++) { aU.update(i); } //All 1024
- final UpdateSketch bU = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch bU = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<k/2; i++) { bU.update(i); } //first 512
- final UpdateSketch cU = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch cU = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=k/2; i<3*k/4; i++) { cU.update(i); } //third 256
final int segBytes = ThetaSketch.getMaxUpdateSketchBytes(k);
- CompactSketch result1, result2, result3;
+ CompactThetaSketch result1, result2, result3;
final MemorySegment wseg1 = MemorySegment.ofArray(new byte[segBytes]);
final MemorySegment wseg2 = MemorySegment.ofArray(new byte[segBytes]);
final MemorySegment wseg3 = MemorySegment.ofArray(new byte[segBytes]);
- final AnotB aNb = SetOperation.builder().buildANotB();
+ final ThetaAnotB aNb = ThetaSetOperation.builder().buildANotB();
//Note: stateful and stateless operations can be interleaved, they are independent.
@@ -250,20 +250,20 @@ public class AnotBimplTest {
final int k = 1024;
final boolean ordered = true;
- final UpdateSketch a = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch a = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<k; i++) { a.update(i); } //All 1024
- final UpdateSketch b = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch b = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<k/2; i++) { b.update(i); } //first 512
- final UpdateSketch c = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch c = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=k/2; i<3*k/4; i++) { c.update(i); } //third 256
final int segBytes = ThetaSketch.getMaxCompactSketchBytes(a.getRetainedEntries(true));
final MemorySegment seg = MemorySegment.ofArray(new byte[segBytes]);
- CompactSketch result1, result2;
- final AnotB aNb = SetOperation.builder().buildANotB();
+ CompactThetaSketch result1, result2;
+ final ThetaAnotB aNb = ThetaSetOperation.builder().buildANotB();
//Note: stateful and stateless operations can be interleaved, they are independent.
@@ -289,32 +289,32 @@ public class AnotBimplTest {
@Test
public void checkAnotBsimple() {
- final UpdateSketch skA = UpdateSketch.builder().build();
- final UpdateSketch skB =UpdateSketch.builder().build();
- final AnotB aNotB = SetOperation.builder().buildANotB();
- final CompactSketch csk = aNotB.aNotB(skA, skB);
+ final UpdatableThetaSketch skA = UpdatableThetaSketch.builder().build();
+ final UpdatableThetaSketch skB =UpdatableThetaSketch.builder().build();
+ final ThetaAnotB aNotB = ThetaSetOperation.builder().buildANotB();
+ final CompactThetaSketch csk = aNotB.aNotB(skA, skB);
assertEquals(csk.getCurrentBytes(), 8);
}
@Test
public void checkGetResult() {
- final UpdateSketch skA = UpdateSketch.builder().build();
- final UpdateSketch skB = UpdateSketch.builder().build();
- final AnotB aNotB = SetOperation.builder().buildANotB();
- final CompactSketch csk = aNotB.aNotB(skA, skB);
+ final UpdatableThetaSketch skA = UpdatableThetaSketch.builder().build();
+ final UpdatableThetaSketch skB = UpdatableThetaSketch.builder().build();
+ final ThetaAnotB aNotB = ThetaSetOperation.builder().buildANotB();
+ final CompactThetaSketch csk = aNotB.aNotB(skA, skB);
assertEquals(csk.getCurrentBytes(), 8);
}
@Test
public void checkGetFamily() {
//cheap trick
- final AnotBimpl anotb = new AnotBimpl(Util.DEFAULT_UPDATE_SEED);
+ final ThetaAnotBimpl anotb = new ThetaAnotBimpl(Util.DEFAULT_UPDATE_SEED);
assertEquals(anotb.getFamily(), Family.A_NOT_B);
}
@Test
public void checkGetMaxBytes() {
- final int bytes = SetOperation.getMaxAnotBResultBytes(10);
+ final int bytes = ThetaSetOperation.getMaxAnotBResultBytes(10);
assertEquals(bytes, 16 * 15 + 24);
}
diff --git a/src/test/java/org/apache/datasketches/theta/CompactSketchTest.java b/src/test/java/org/apache/datasketches/theta/CompactSketchTest.java
index 4b2feb1bc..23a3d5e0d 100644
--- a/src/test/java/org/apache/datasketches/theta/CompactSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/CompactSketchTest.java
@@ -53,24 +53,24 @@ public class CompactSketchTest {
//test combinations of compact ordered/not ordered and heap/direct
public void checkHeapifyWrap(final int k, final int u, final boolean ordered) {
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u; i++) { //populate update sketch
usk.update(i);
}
/****ON HEAP MemorySegment -- HEAPIFY****/
- CompactSketch refSk = usk.compact(ordered, null);
+ CompactThetaSketch refSk = usk.compact(ordered, null);
final byte[] barr = refSk.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(barr);
- CompactSketch testSk = (CompactSketch) ThetaSketch.heapify(srcSeg);
+ CompactThetaSketch testSk = (CompactThetaSketch) ThetaSketch.heapify(srcSeg);
checkByRange(refSk, testSk, u, ordered);
/**Via byte[]**/
final byte[] byteArray = refSk.toByteArray();
final MemorySegment heapROSeg = MemorySegment.ofArray(byteArray).asReadOnly();
- testSk = (CompactSketch)ThetaSketch.heapify(heapROSeg);
+ testSk = (CompactThetaSketch)ThetaSketch.heapify(heapROSeg);
checkByRange(refSk, testSk, u, ordered);
@@ -81,14 +81,14 @@ public class CompactSketchTest {
try (Arena arena = Arena.ofConfined()) {
final MemorySegment directSeg = arena.allocate(bytes);
- /**Via CompactSketch.compact**/
+ /**Via CompactThetaSketch.compact**/
refSk = usk.compact(ordered, directSeg);
- testSk = (CompactSketch)ThetaSketch.wrap(directSeg);
+ testSk = (CompactThetaSketch)ThetaSketch.wrap(directSeg);
checkByRange(refSk, testSk, u, ordered);
- /**Via CompactSketch.compact**/
- testSk = (CompactSketch)ThetaSketch.wrap(directSeg);
+ /**Via CompactThetaSketch.compact**/
+ testSk = (CompactThetaSketch)ThetaSketch.wrap(directSeg);
checkByRange(refSk, testSk, u, ordered);
} catch (final Exception e) {
throw new RuntimeException(e);
@@ -174,7 +174,7 @@ public class CompactSketchTest {
@Test
public void checkDirectSingleItemSketch() {
- final UpdateSketch sk = UpdateSketch.builder().build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().build();
sk.update(1);
final int bytes = sk.getCompactBytes();
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
@@ -188,7 +188,7 @@ public class CompactSketchTest {
final int k = 512;
final int u = k;
final boolean ordered = false;
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u; i++) {
usk.update(i);
}
@@ -204,7 +204,7 @@ public class CompactSketchTest {
final int k = 512;
final int u = k;
final boolean ordered = true;
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u; i++) {
usk.update(i);
}
@@ -218,7 +218,7 @@ public class CompactSketchTest {
@Test
public void checkCompactCachePart() {
//phony values except for curCount = 0.
- final long[] result = IntersectionImpl.compactCachePart(null, 4, 0, 0L, false);
+ final long[] result = ThetaIntersectionImpl.compactCachePart(null, 4, 0, 0L, false);
assertEquals(result.length, 0);
}
@@ -238,35 +238,35 @@ public class CompactSketchTest {
* Empty, segment-based Compact sketches are always ordered
*/
public void checkEmptyMemorySegmentCompactSketch() {
- final UpdateSketch sk = UpdateSketch.builder().build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().build();
final MemorySegment wseg1 = MemorySegment.ofArray(new byte[16]);
- final CompactSketch csk1 = sk.compact(false, wseg1); //the first parameter is ignored when empty
+ final CompactThetaSketch csk1 = sk.compact(false, wseg1); //the first parameter is ignored when empty
final State state1 = new State("DirectCompactSketch", 0, 8, COMPACT, EMPTY, !DIRECT, SEGMENT, ORDERED, !ESTIMATION);
state1.check(csk1);
final MemorySegment wseg2 = MemorySegment.ofArray(new byte[16]);
- final CompactSketch csk2 = sk.compact(false, wseg2);
+ final CompactThetaSketch csk2 = sk.compact(false, wseg2);
state1.check(csk2);
assertNotEquals(csk1, csk2); //different object because MemorySegment is valid
assertFalse(csk1 == csk2);
final MemorySegment wseg3 = MemorySegment.ofArray(new byte[16]);
- final CompactSketch csk3 = csk1.compact(false, wseg3);
+ final CompactThetaSketch csk3 = csk1.compact(false, wseg3);
state1.check(csk3);
assertNotEquals(csk1, csk3); //different object because MemorySegment is valid
assertFalse(csk1 == csk3);
- final CompactSketch csk4 = csk1.compact(false, null);
+ final CompactThetaSketch csk4 = csk1.compact(false, null);
final State state4 = new State("EmptyCompactSketch", 0, 8, COMPACT, EMPTY, !DIRECT, !SEGMENT, ORDERED, !ESTIMATION);
state4.check(csk4);
assertNotEquals(csk1, csk4); //different object because on heap
assertFalse(csk1 == csk4);
- final CompactSketch cskc = csk1.compact();
+ final CompactThetaSketch cskc = csk1.compact();
state1.check(cskc);
assertEquals(csk1, cskc); //the same object
@@ -278,29 +278,29 @@ public class CompactSketchTest {
* Single-Item, segment-based Compact sketches are always ordered:
*/
public void checkSingleItemMemorySegmentCompactSketch() {
- final UpdateSketch sk = UpdateSketch.builder().build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().build();
sk.update(1);
final MemorySegment wseg1 = MemorySegment.ofArray(new byte[16]);
- final CompactSketch csk1 = sk.compact(false, wseg1); //the first parameter is ignored when single item
+ final CompactThetaSketch csk1 = sk.compact(false, wseg1); //the first parameter is ignored when single item
final State state1 = new State("DirectCompactSketch", 1, 16, COMPACT, !EMPTY, !DIRECT, SEGMENT, ORDERED, !ESTIMATION);
state1.check(csk1);
final MemorySegment wseg2 = MemorySegment.ofArray(new byte[16]);
- final CompactSketch csk2 = sk.compact(false, wseg2); //the first parameter is ignored when single item
+ final CompactThetaSketch csk2 = sk.compact(false, wseg2); //the first parameter is ignored when single item
state1.check(csk2);
assertNotEquals(csk1, csk2); //different object because segment is valid
assertFalse(csk1 == csk2);
final MemorySegment wseg3 = MemorySegment.ofArray(new byte[16]);
- final CompactSketch csk3 = csk1.compact(false, wseg3);
+ final CompactThetaSketch csk3 = csk1.compact(false, wseg3);
state1.check(csk3);
assertNotEquals(csk1, csk3); //different object because segment is valid
assertFalse(csk1 == csk3);
- final CompactSketch cskc = csk1.compact();
+ final CompactThetaSketch cskc = csk1.compact();
state1.check(cskc);
assertEquals(csk1, cskc); //the same object
@@ -309,19 +309,19 @@ public class CompactSketchTest {
@Test
public void checkMultipleItemMemorySegmentCompactSketch() {
- final UpdateSketch sk = UpdateSketch.builder().build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().build();
//This sequence is naturally out-of-order by the hash values.
sk.update(1);
sk.update(2);
sk.update(3);
final MemorySegment wseg1 = MemorySegment.ofArray(new byte[50]);
- final CompactSketch csk1 = sk.compact(true, wseg1);
+ final CompactThetaSketch csk1 = sk.compact(true, wseg1);
final State state1 = new State("DirectCompactSketch", 3, 40, COMPACT, !EMPTY, !DIRECT, SEGMENT, ORDERED, !ESTIMATION);
state1.check(csk1);
final MemorySegment wseg2 = MemorySegment.ofArray(new byte[50]);
- final CompactSketch csk2 = sk.compact(false, wseg2);
+ final CompactThetaSketch csk2 = sk.compact(false, wseg2);
final State state2 = new State("DirectCompactSketch", 3, 40, COMPACT, !EMPTY, !DIRECT, SEGMENT, !ORDERED, !ESTIMATION);
state2.check(csk2);
@@ -329,13 +329,13 @@ public class CompactSketchTest {
assertFalse(csk1 == csk2);
final MemorySegment wseg3 = MemorySegment.ofArray(new byte[50]);
- final CompactSketch csk3 = csk1.compact(false, wseg3);
+ final CompactThetaSketch csk3 = csk1.compact(false, wseg3);
state2.check(csk3);
assertNotEquals(csk1, csk3); //different object because segment is valid
assertFalse(csk1 == csk3);
- final CompactSketch cskc = csk1.compact();
+ final CompactThetaSketch cskc = csk1.compact();
state1.check(cskc);
assertEquals(csk1, cskc); //the same object
@@ -348,25 +348,25 @@ public class CompactSketchTest {
* All empty, heap-based, compact sketches point to the same static, final constant of 8 bytes.
*/
public void checkEmptyHeapCompactSketch() {
- final UpdateSketch sk = UpdateSketch.builder().build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().build();
- final CompactSketch csk1 = sk.compact(false, null); //the first parameter is ignored when empty
+ final CompactThetaSketch csk1 = sk.compact(false, null); //the first parameter is ignored when empty
final State state1 = new State("EmptyCompactSketch", 0, 8, COMPACT, EMPTY, !DIRECT, !SEGMENT, ORDERED, !ESTIMATION);
state1.check(csk1);
- final CompactSketch csk2 = sk.compact(false, null); //the first parameter is ignored when empty
+ final CompactThetaSketch csk2 = sk.compact(false, null); //the first parameter is ignored when empty
state1.check(csk1);
assertEquals(csk1, csk2);
assertTrue(csk1 == csk2);
- final CompactSketch csk3 = csk1.compact(false, null);
+ final CompactThetaSketch csk3 = csk1.compact(false, null);
state1.check(csk3);
assertEquals(csk1, csk3); //The same object
assertTrue(csk1 == csk3);
- final CompactSketch cskc = csk1.compact();
+ final CompactThetaSketch cskc = csk1.compact();
state1.check(cskc);
assertEquals(csk1, cskc); //The same object
@@ -378,26 +378,26 @@ public class CompactSketchTest {
* Single-Item, heap-based Compact sketches are always ordered.
*/
public void checkSingleItemHeapCompactSketch() {
- final UpdateSketch sk = UpdateSketch.builder().build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().build();
sk.update(1);
- final CompactSketch csk1 = sk.compact(false, null); //the first parameter is ignored when single item
+ final CompactThetaSketch csk1 = sk.compact(false, null); //the first parameter is ignored when single item
final State state1 = new State("SingleItemSketch", 1, 16, COMPACT, !EMPTY, !DIRECT, !SEGMENT, ORDERED, !ESTIMATION);
state1.check(csk1);
- final CompactSketch csk2 = sk.compact(false, null); //the first parameter is ignored when single item
+ final CompactThetaSketch csk2 = sk.compact(false, null); //the first parameter is ignored when single item
state1.check(csk2);
assertNotEquals(csk1, csk2); //calling the compact(boolean, null) method creates a new object
assertFalse(csk1 == csk2);
- final CompactSketch csk3 = csk1.compact(false, null);
+ final CompactThetaSketch csk3 = csk1.compact(false, null);
state1.check(csk3);
assertEquals(csk1, csk3); //The same object
assertTrue(csk1 == csk3);
- final CompactSketch cskc = csk1.compact(); //this, however just returns the same object.
+ final CompactThetaSketch cskc = csk1.compact(); //this, however just returns the same object.
state1.check(csk1);
assertEquals(csk1, cskc); //the same object
@@ -406,24 +406,24 @@ public class CompactSketchTest {
@Test
public void checkMultipleItemHeapCompactSketch() {
- final UpdateSketch sk = UpdateSketch.builder().build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().build();
//This sequence is naturally out-of-order by the hash values.
sk.update(1);
sk.update(2);
sk.update(3);
- final CompactSketch csk1 = sk.compact(true, null); //creates a new object
+ final CompactThetaSketch csk1 = sk.compact(true, null); //creates a new object
final State state1 = new State("HeapCompactSketch", 3, 40, COMPACT, !EMPTY, !DIRECT, !SEGMENT, ORDERED, !ESTIMATION);
state1.check(csk1);
- final CompactSketch csk2 = sk.compact(false, null); //creates a new object, unordered
+ final CompactThetaSketch csk2 = sk.compact(false, null); //creates a new object, unordered
final State state2 = new State("HeapCompactSketch", 3, 40, COMPACT, !EMPTY, !DIRECT, !SEGMENT, !ORDERED, !ESTIMATION);
state2.check(csk2);
assertNotEquals(csk1, csk2); //order is different and different objects
assertFalse(csk1 == csk2);
- final CompactSketch csk3 = csk1.compact(true, null);
+ final CompactThetaSketch csk3 = csk1.compact(true, null);
state1.check(csk3);
assertEquals(csk1, csk3); //the same object because wseg = null and csk1.ordered = dstOrdered
@@ -432,7 +432,7 @@ public class CompactSketchTest {
assertNotEquals(csk2, csk3); //different object because wseg = null and csk2.ordered = false && dstOrdered = true
assertFalse(csk2 == csk3);
- final CompactSketch cskc = csk1.compact();
+ final CompactThetaSketch cskc = csk1.compact();
state1.check(cskc);
assertEquals(csk1, cskc); //the same object
@@ -441,7 +441,7 @@ public class CompactSketchTest {
@Test
public void checkHeapifySingleItemSketch() {
- final UpdateSketch sk = UpdateSketch.builder().build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().build();
sk.update(1);
final int bytes = ThetaSketch.getMaxCompactSketchBytes(2); //1 more than needed
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
@@ -452,9 +452,9 @@ public class CompactSketchTest {
@Test
public void checkHeapifyEmptySketch() {
- final UpdateSketch sk = UpdateSketch.builder().build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().build();
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
+ final CompactThetaSketch csk = sk.compact(false, wseg); //ignores order because it is empty
assertTrue(csk instanceof DirectCompactSketch);
final ThetaSketch csk2 = ThetaSketch.heapify(wseg);
assertTrue(csk2 instanceof EmptyCompactSketch);
@@ -462,20 +462,20 @@ public class CompactSketchTest {
@Test
public void checkGetCache() {
- final UpdateSketch sk = UpdateSketch.builder().setP((float).5).build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().setP((float).5).build();
sk.update(7);
final int bytes = sk.getCompactBytes();
- final CompactSketch csk = sk.compact(true, MemorySegment.ofArray(new byte[bytes]));
+ final CompactThetaSketch csk = sk.compact(true, MemorySegment.ofArray(new byte[bytes]));
final long[] cache = csk.getCache();
assertTrue(cache.length == 0);
}
@Test
public void checkHeapCompactSketchCompact() {
- final UpdateSketch sk = UpdateSketch.builder().build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().build();
sk.update(1);
sk.update(2);
- final CompactSketch csk = sk.compact();
+ final CompactThetaSketch csk = sk.compact();
assertTrue(csk.isOrdered());
assertEquals(csk.getCurrentPreambleLongs(), 2);
}
@@ -489,12 +489,12 @@ public class CompactSketchTest {
@Test
public void checkDirectCompactSketchCompact() {
MemorySegment wseg1, wseg2;
- CompactSketch csk1, csk2;
+ CompactThetaSketch csk1, csk2;
int bytes;
final int lgK = 6;
//empty
- final UpdateSketch sk = UpdateSketch.builder().setLogNominalEntries(lgK).build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().setLogNominalEntries(lgK).build();
bytes = sk.getCompactBytes(); //empty, 8 bytes
wseg1 = MemorySegment.ofArray(new byte[bytes]);
wseg2 = MemorySegment.ofArray(new byte[bytes]);
@@ -554,13 +554,13 @@ public class CompactSketchTest {
@Test
public void serializeDeserializeHeapV4() {
- final UpdateSketch sk = UpdateSketch.builder().build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().build();
for (int i = 0; i < 10000; i++) {
sk.update(i);
}
- final CompactSketch cs1 = sk.compact();
+ final CompactThetaSketch cs1 = sk.compact();
final byte[] bytes = cs1.toByteArrayCompressed();
- final CompactSketch cs2 = CompactSketch.heapify(MemorySegment.ofArray(bytes));
+ final CompactThetaSketch cs2 = CompactThetaSketch.heapify(MemorySegment.ofArray(bytes));
assertEquals(cs1.getRetainedEntries(), cs2.getRetainedEntries());
final HashIterator it1 = cs1.iterator();
final HashIterator it2 = cs2.iterator();
@@ -571,13 +571,13 @@ public class CompactSketchTest {
@Test
public void serializeDeserializeDirectV4_segment() {
- final UpdateSketch sk = UpdateSketch.builder().build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().build();
for (int i = 0; i < 10000; i++) {
sk.update(i);
}
- final CompactSketch cs1 = sk.compact(true, MemorySegment.ofArray(new byte[sk.getCompactBytes()]));
+ final CompactThetaSketch cs1 = sk.compact(true, MemorySegment.ofArray(new byte[sk.getCompactBytes()]));
final byte[] bytes = cs1.toByteArrayCompressed();
- final CompactSketch cs2 = CompactSketch.wrap(MemorySegment.ofArray(bytes));
+ final CompactThetaSketch cs2 = CompactThetaSketch.wrap(MemorySegment.ofArray(bytes));
assertEquals(cs1.getRetainedEntries(), cs2.getRetainedEntries());
final HashIterator it1 = cs1.iterator();
final HashIterator it2 = cs2.iterator();
@@ -588,13 +588,13 @@ public class CompactSketchTest {
@Test
public void serializeDeserializeDirectV4_bytes() {
- final UpdateSketch sk = UpdateSketch.builder().build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().build();
for (int i = 0; i < 10000; i++) {
sk.update(i);
}
- final CompactSketch cs1 = sk.compact(true, MemorySegment.ofArray(new byte[sk.getCompactBytes()]));
+ final CompactThetaSketch cs1 = sk.compact(true, MemorySegment.ofArray(new byte[sk.getCompactBytes()]));
final byte[] bytes = cs1.toByteArrayCompressed();
- final CompactSketch cs2 = CompactSketch.wrap(bytes);
+ final CompactThetaSketch cs2 = CompactThetaSketch.wrap(bytes);
assertEquals(cs1.getRetainedEntries(), cs2.getRetainedEntries());
final HashIterator it1 = cs1.iterator();
final HashIterator it2 = cs2.iterator();
@@ -606,13 +606,13 @@ public class CompactSketchTest {
@Test
public void serializeWrapBytesV3() {
- final UpdateSketch sk = UpdateSketch.builder().build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().build();
for (int i = 0; i < 10000; i++) {
sk.update(i);
}
- final CompactSketch cs1 = sk.compact();
+ final CompactThetaSketch cs1 = sk.compact();
final byte[] bytes = cs1.toByteArray();
- final CompactSketch cs2 = new WrappedCompactSketch(bytes);
+ final CompactThetaSketch cs2 = new WrappedCompactSketch(bytes);
assertEquals(cs1.getRetainedEntries(), cs2.getRetainedEntries());
final HashIterator it1 = cs1.iterator();
final HashIterator it2 = cs2.iterator();
@@ -624,13 +624,13 @@ public class CompactSketchTest {
@Test
public void serializeWrapBytesV4() {
- final UpdateSketch sk = UpdateSketch.builder().build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().build();
for (int i = 0; i < 10000; i++) {
sk.update(i);
}
- final CompactSketch cs1 = sk.compact();
+ final CompactThetaSketch cs1 = sk.compact();
final byte[] bytes = cs1.toByteArrayCompressed();
- final CompactSketch cs2 = new WrappedCompactCompressedSketch(bytes);
+ final CompactThetaSketch cs2 = new WrappedCompactCompressedSketch(bytes);
assertEquals(cs1.getRetainedEntries(), cs2.getRetainedEntries());
final HashIterator it1 = cs1.iterator();
final HashIterator it2 = cs2.iterator();
@@ -664,7 +664,7 @@ public class CompactSketchTest {
this.estimation = estimation;
}
- void check(final CompactSketch csk) {
+ void check(final CompactThetaSketch csk) {
assertEquals(csk.getClass().getSimpleName(), classType, "ClassType");
assertEquals(csk.getRetainedEntries(true), count, "curCount");
assertEquals(csk.getCurrentBytes(), bytes, "Bytes" );
diff --git a/src/test/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketchTest.java b/src/test/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketchTest.java
index f12d5809e..5163aaa97 100644
--- a/src/test/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketchTest.java
@@ -60,8 +60,8 @@ public class ConcurrentDirectQuickSelectSketchTest {
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
- final UpdateSketch shared = sl.shared; //off-heap
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared; //off-heap
+ final UpdatableThetaSketch local = sl.local;
for (int i=0; i<u; i++) { local.update(i); }
waitForBgPropagationToComplete(shared);
@@ -70,7 +70,7 @@ public class ConcurrentDirectQuickSelectSketchTest {
assertEquals(local.getClass().getSimpleName(), "ConcurrentHeapThetaBuffer");
//This sharedHeap is not linked to the concurrent local buffer
- final UpdateSketch sharedHeap = UpdateSketch.heapify(sl.wseg);
+ final UpdatableThetaSketch sharedHeap = UpdatableThetaSketch.heapify(sl.wseg);
assertEquals(sharedHeap.getClass().getSimpleName(), "HeapQuickSelectSketch");
checkMemorySegmentDirectProxyMethods(local, shared);
@@ -93,8 +93,8 @@ public class ConcurrentDirectQuickSelectSketchTest {
final int k = 1 << lgK;
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
- UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
for (int i=0; i< k; i++) { local.update(i); }
waitForBgPropagationToComplete(shared);
@@ -106,8 +106,8 @@ public class ConcurrentDirectQuickSelectSketchTest {
//reconstruct to Native/Direct
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);
+ shared = sl.bldr.buildSharedFromSketch((UpdatableThetaSketch)recoveredShared, wseg);
+ final UpdatableThetaSketch local2 = sl.bldr.buildLocal(shared);
assertEquals(local2.getEstimate(), k, 0.0);
assertEquals(local2.getLowerBound(2), k, 0.0);
@@ -130,8 +130,8 @@ public class ConcurrentDirectQuickSelectSketchTest {
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
- UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
for (int i=0; i<u; i++) { local.update(i); }
waitForBgPropagationToComplete(shared);
@@ -148,8 +148,8 @@ public class ConcurrentDirectQuickSelectSketchTest {
//reconstruct to Native/Direct
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);
+ shared = sl.bldr.buildSharedFromSketch((UpdatableThetaSketch)recoveredShared, wseg);
+ final UpdatableThetaSketch local2 = sl.bldr.buildLocal(shared);
assertEquals(local2.getEstimate(), uskEst);
assertEquals(local2.getLowerBound(2), uskLB);
@@ -168,8 +168,8 @@ public class ConcurrentDirectQuickSelectSketchTest {
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
for (int i=0; i<u; i++) { local.update(i); }
waitForBgPropagationToComplete(shared);
@@ -196,8 +196,8 @@ public class ConcurrentDirectQuickSelectSketchTest {
//boolean estimating = (u > k);
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
assertEquals(local.getClass().getSimpleName(), "ConcurrentHeapThetaBuffer");
assertFalse(local.isOffHeap());
@@ -214,7 +214,7 @@ public class ConcurrentDirectQuickSelectSketchTest {
final double localUB = local.getUpperBound(2);
assertTrue(local.isEstimationMode());
- CompactSketch csk;
+ CompactThetaSketch csk;
csk = shared.compact(false, null);
assertEquals(csk.getEstimate(), localEst);
@@ -261,8 +261,8 @@ public class ConcurrentDirectQuickSelectSketchTest {
final int lgK = 9;
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
//empty
local.toString(false, true, 0, false); //exercise toString
@@ -277,14 +277,14 @@ public class ConcurrentDirectQuickSelectSketchTest {
final byte[] segArr2 = new byte[bytes];
final MemorySegment seg2 = MemorySegment.ofArray(segArr2);
- final CompactSketch csk2 = shared.compact(false, seg2);
+ final CompactThetaSketch csk2 = shared.compact(false, seg2);
assertEquals(csk2.getEstimate(), localEst);
assertEquals(csk2.getLowerBound(2), localLB);
assertEquals(csk2.getUpperBound(2), localUB);
assertTrue(csk2.isEmpty());
assertFalse(csk2.isEstimationMode());
assertTrue(csk2.isOrdered());
- final CompactSketch csk3 = shared.compact(true, seg2);
+ final CompactThetaSketch csk3 = shared.compact(true, seg2);
csk3.toString(false, true, 0, false);
csk3.toString();
assertEquals(csk3.getEstimate(), localEst);
@@ -301,8 +301,8 @@ public class ConcurrentDirectQuickSelectSketchTest {
final int k = 1 << lgK;
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
assertTrue(local.isEmpty());
final int u = 3*k;
@@ -318,8 +318,8 @@ public class ConcurrentDirectQuickSelectSketchTest {
final int k = 1 << lgK;
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
//Exact mode
for (int i = 0; i < k; i++ ) { local.update(i); }
@@ -353,8 +353,8 @@ public class ConcurrentDirectQuickSelectSketchTest {
final int u = 2*k;
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
for (int i = 0; i < u; i++ ) { local.update(i); }
waitForBgPropagationToComplete(shared);
@@ -373,8 +373,8 @@ public class ConcurrentDirectQuickSelectSketchTest {
final int u = 4*k;
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
assertTrue(local.isEmpty());
@@ -399,8 +399,8 @@ public class ConcurrentDirectQuickSelectSketchTest {
final int k = 1 << lgK;
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
assertTrue(local.isEmpty());
@@ -427,8 +427,8 @@ public class ConcurrentDirectQuickSelectSketchTest {
final int u = k;
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
assertTrue(local.isEmpty());
for (int i = 0; i< u; i++) { local.update(i); }
@@ -444,8 +444,8 @@ public class ConcurrentDirectQuickSelectSketchTest {
final int k = 1 << lgK;
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
assertTrue(local.isEmpty());
final int u = 3*k;
@@ -463,8 +463,8 @@ public class ConcurrentDirectQuickSelectSketchTest {
final int k = 1 << lgK;
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
assertTrue(local.isEmpty());
final int u = 3*k;
@@ -481,8 +481,8 @@ public class ConcurrentDirectQuickSelectSketchTest {
final int k = 1 << lgK;
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
- UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
assertTrue(local.isEmpty());
final int u = 3*k;
@@ -500,13 +500,13 @@ public class ConcurrentDirectQuickSelectSketchTest {
serArr = shared.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(serArr);
- final UpdateSketch recoveredShared = UpdateSketch.wrap(seg);
+ final UpdatableThetaSketch recoveredShared = UpdatableThetaSketch.wrap(seg);
//reconstruct to Native/Direct
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);
+ final UpdatableThetaSketch local2 = sl.bldr.buildLocal(shared);
est2 = local2.getEstimate();
assertEquals(est2, est1, 0.0);
@@ -515,9 +515,9 @@ public class ConcurrentDirectQuickSelectSketchTest {
@Test
public void checkNullMemorySegment() {
final UpdateSketchBuilder bldr = new UpdateSketchBuilder();
- final UpdateSketch sk = bldr.build();
+ final UpdatableThetaSketch sk = bldr.build();
for (int i = 0; i < 1000; i++) { sk.update(i); }
- final UpdateSketch shared = bldr.buildSharedFromSketch(sk, null);
+ final UpdatableThetaSketch shared = bldr.buildSharedFromSketch(sk, null);
assertEquals(shared.getRetainedEntries(true), 1000);
assertFalse(shared.hasMemorySegment());
}
@@ -529,7 +529,7 @@ public class ConcurrentDirectQuickSelectSketchTest {
final int u = 1 << 20;
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, SEED, useSeg, true, 8); //seg is 8X larger than needed
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch local = sl.local;
for (int i = 0; i < u; i++) { local.update(i); }
}
@@ -558,7 +558,7 @@ public class ConcurrentDirectQuickSelectSketchTest {
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
- ThetaSketch.heapify(sl.wseg); //catch in Sketch.constructHeapSketch
+ ThetaSketch.heapify(sl.wseg); //catch in ThetaSketch.constructHeapSketch
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -577,8 +577,8 @@ public class ConcurrentDirectQuickSelectSketchTest {
final int u = 10*k;
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
assertTrue(local.isEmpty());
final ConcurrentHeapThetaBuffer sk1 = (ConcurrentHeapThetaBuffer)local; //for internal checks
@@ -615,8 +615,8 @@ public class ConcurrentDirectQuickSelectSketchTest {
final int k = 1 << lgK;
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
assertTrue(local.isEmpty());
for (int i = 0; i< k; i++) { local.update(i); }
@@ -636,9 +636,9 @@ public class ConcurrentDirectQuickSelectSketchTest {
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
- sl.wseg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Sketch ID byte
+ sl.wseg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the FamilyID byte
//try to wrap the corrupted seg
- ThetaSketch.wrap(sl.wseg); //catch in Sketch.constructDirectSketch
+ ThetaSketch.wrap(sl.wseg); //catch in ThetaSketch.constructDirectSketch
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -647,7 +647,7 @@ public class ConcurrentDirectQuickSelectSketchTest {
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
- sl.wseg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Sketch ID byte
+ sl.wseg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the FamilyID byte
//try to wrap the corrupted seg
DirectQuickSelectSketch.writableWrap(sl.wseg, null, Util.DEFAULT_UPDATE_SEED);
}
@@ -659,7 +659,7 @@ public class ConcurrentDirectQuickSelectSketchTest {
final long seed2 = Util.DEFAULT_UPDATE_SEED;
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, seed1, useSeg, true, 1);
- final UpdateSketch shared = sl.shared;
+ final UpdatableThetaSketch shared = sl.shared;
final MemorySegment srcSeg = MemorySegment.ofArray(shared.toByteArray()).asReadOnly();
ThetaSketch.heapify(srcSeg, seed2);
@@ -680,7 +680,7 @@ public class ConcurrentDirectQuickSelectSketchTest {
final int lgK = 4;
final boolean useSeg = true;
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
- final UpdateSketch shared = sl.shared;
+ final UpdatableThetaSketch shared = sl.shared;
shared.hashUpdate(1);
}
diff --git a/src/test/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketchTest.java b/src/test/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketchTest.java
index e3f4e8823..393f79adb 100644
--- a/src/test/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketchTest.java
@@ -48,8 +48,8 @@ public class ConcurrentHeapQuickSelectSketchTest {
final int k = 1 << lgK;
final int u = k;
final SharedLocal sl = new SharedLocal(lgK);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
assertTrue(local.isEmpty());
@@ -77,8 +77,8 @@ public class ConcurrentHeapQuickSelectSketchTest {
final int k = 1 << lgK;
final int u = 200*k;
final SharedLocal sl = new SharedLocal(lgK, 4, false, false);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
assertEquals((sl.bldr.getConCurLgNominalEntries()), 4);
assertTrue(local.isEmpty());
@@ -98,8 +98,8 @@ public class ConcurrentHeapQuickSelectSketchTest {
final int u = k;
final SharedLocal sl = new SharedLocal(lgK);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
assertTrue(local.isEmpty());
assertTrue(shared instanceof ConcurrentHeapQuickSelectSketch);
for (int i = 0; i< u; i++) {
@@ -112,7 +112,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
assertEquals(shared.getRetainedEntries(false), u);
final byte[] byteArray = shared.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
- seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Sketch ID byte
+ seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the FamilyID byte
//try to heapify the corrupted seg
ThetaSketch.heapify(seg, sl.seed);
@@ -152,8 +152,8 @@ public class ConcurrentHeapQuickSelectSketchTest {
final int k = 1 << lgK;
final int u = k;
final SharedLocal sl = new SharedLocal(lgK);
- UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
for (int i=0; i<u; i++) {
local.update(i);
@@ -162,13 +162,13 @@ public class ConcurrentHeapQuickSelectSketchTest {
final byte[] serArr = shared.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(serArr).asReadOnly();
- final ThetaSketch recoveredShared = UpdateSketch.heapify(srcSeg);
+ final ThetaSketch recoveredShared = UpdatableThetaSketch.heapify(srcSeg);
//reconstruct to Native/Direct
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);
+ shared = sl.bldr.buildSharedFromSketch((UpdatableThetaSketch)recoveredShared, wseg);
+ final UpdatableThetaSketch local2 = sl.bldr.buildLocal(shared);
assertEquals(local2.getEstimate(), u, 0.0);
assertEquals(local2.getLowerBound(2), u, 0.0);
@@ -186,8 +186,8 @@ public class ConcurrentHeapQuickSelectSketchTest {
final int u = 2*k;
final SharedLocal sl = new SharedLocal(lgK);
- final UpdateSketch local = sl.local;
- UpdateSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
+ UpdatableThetaSketch shared = sl.shared;
for (int i=0; i<u; i++) {
local.update(i);
@@ -201,12 +201,12 @@ public class ConcurrentHeapQuickSelectSketchTest {
final byte[] serArr = shared.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(serArr).asReadOnly();
- final UpdateSketch recoveredShared = UpdateSketch.heapify(srcSeg, sl.seed);
+ final UpdatableThetaSketch recoveredShared = UpdatableThetaSketch.heapify(srcSeg, sl.seed);
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);
+ final UpdatableThetaSketch local2 = sl.bldr.buildLocal(shared);
assertEquals(local2.getEstimate(), localEst);
assertEquals(local2.getLowerBound(2), localLB);
assertEquals(local2.getUpperBound(2), localUB);
@@ -222,8 +222,8 @@ public class ConcurrentHeapQuickSelectSketchTest {
final int u = 2*k; //thus estimating
final SharedLocal sl = new SharedLocal(lgK);
- final UpdateSketch local = sl.local;
- UpdateSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
+ UpdatableThetaSketch shared = sl.shared;
for (int i=0; i<u; i++) {
local.update(i);
@@ -240,12 +240,12 @@ public class ConcurrentHeapQuickSelectSketchTest {
final byte[] serArr = shared.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(serArr).asReadOnly();
- final UpdateSketch recoveredShared = UpdateSketch.heapify(srcSeg, Util.DEFAULT_UPDATE_SEED);
+ final UpdatableThetaSketch recoveredShared = UpdatableThetaSketch.heapify(srcSeg, Util.DEFAULT_UPDATE_SEED);
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);
+ final UpdatableThetaSketch local2 = sl.bldr.buildLocal(shared);
assertEquals(local2.getEstimate(), localEst);
assertEquals(local2.getLowerBound(2), localLB);
@@ -263,8 +263,8 @@ public class ConcurrentHeapQuickSelectSketchTest {
final int maxBytes = (k << 4) + (Family.QUICKSELECT.getMinPreLongs() << 3);
final SharedLocal sl = new SharedLocal(lgK);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
assertEquals(local.getClass().getSimpleName(), "ConcurrentHeapThetaBuffer");
assertFalse(local.isOffHeap());
@@ -286,7 +286,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
assertEquals(sharedBytes, maxBytes);
assertTrue(local.isEstimationMode());
- CompactSketch comp1, comp2, comp3, comp4;
+ CompactThetaSketch comp1, comp2, comp3, comp4;
comp1 = shared.compact(false, null);
@@ -338,8 +338,8 @@ public class ConcurrentHeapQuickSelectSketchTest {
public void checkHQStoCompactEmptyForms() {
final int lgK = 9;
final SharedLocal sl = new SharedLocal(lgK);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
println("lgArr: "+ local.getLgArrLongs());
//empty
@@ -358,7 +358,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
final byte[] arr2 = new byte[compBytes];
final MemorySegment seg2 = MemorySegment.ofArray(arr2);
- final CompactSketch csk2 = shared.compact(false, seg2);
+ final CompactThetaSketch csk2 = shared.compact(false, seg2);
assertEquals(csk2.getEstimate(), localEst);
assertEquals(csk2.getLowerBound(2), localLB);
assertEquals(csk2.getUpperBound(2), localUB);
@@ -366,7 +366,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
assertEquals(csk2.isEstimationMode(), estimating);
assertTrue(csk2.isOrdered());
- final CompactSketch csk3 = shared.compact(true, seg2);
+ final CompactThetaSketch csk3 = shared.compact(true, seg2);
csk3.toString(false, true, 0, false);
csk3.toString();
assertEquals(csk3.getEstimate(), localEst);
@@ -382,8 +382,8 @@ public class ConcurrentHeapQuickSelectSketchTest {
final int lgK = 12;
final int u = 1 << lgK;
final SharedLocal sl = new SharedLocal(lgK);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
assertTrue(local.isEmpty());
@@ -401,8 +401,8 @@ public class ConcurrentHeapQuickSelectSketchTest {
final int lgK = 12;
final int k = 1 << lgK;
final SharedLocal sl = new SharedLocal(lgK);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
assertTrue(local.isEmpty());
@@ -421,8 +421,8 @@ public class ConcurrentHeapQuickSelectSketchTest {
final int lgK = 9;
final int k = 1 << lgK;
final SharedLocal sl = new SharedLocal(lgK);
- final UpdateSketch local = sl.local;
- final UpdateSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
//Exact mode
//int limit = (int)ConcurrentSharedThetaSketch.computeExactLimit(lim, 0); //? ask Eshcar
@@ -456,8 +456,8 @@ public class ConcurrentHeapQuickSelectSketchTest {
final int k = 1 << lgK;
final SharedLocal sl = new SharedLocal(lgK);
//must build shared first
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
assertTrue(local.isEmpty());
final int t = ((ConcurrentHeapThetaBuffer)local).getHashTableThreshold();
@@ -498,7 +498,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
public void checkNegativeHashes() {
final int lgK = 9;
final SharedLocal sl = new SharedLocal(lgK);
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch local = sl.local;
local.hashUpdate(-1L);
}
@@ -507,8 +507,8 @@ public class ConcurrentHeapQuickSelectSketchTest {
final int lgK = 9;
final int k = 1 << lgK;
final SharedLocal sl = new SharedLocal(lgK);
- final UpdateSketch shared = sl.shared;
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
assertTrue(local.isEmpty());
final int u = 3*k;
@@ -532,8 +532,8 @@ public class ConcurrentHeapQuickSelectSketchTest {
public void checkDQStoCompactEmptyForms() {
final int lgK = 9;
final SharedLocal sl = new SharedLocal(lgK);
- final UpdateSketch local = sl.local;
- final UpdateSketch shared = sl.shared;
+ final UpdatableThetaSketch local = sl.local;
+ final UpdatableThetaSketch shared = sl.shared;
//empty
local.toString(false, true, 0, false); //exercise toString
@@ -548,7 +548,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
final byte[] segArr2 = new byte[bytes];
final MemorySegment seg2 = MemorySegment.ofArray(segArr2);
- final CompactSketch csk2 = shared.compact(false, seg2);
+ final CompactThetaSketch csk2 = shared.compact(false, seg2);
assertEquals(csk2.getEstimate(), localEst);
assertEquals(csk2.getLowerBound(2), localLB);
assertEquals(csk2.getUpperBound(2), uskUB);
@@ -556,7 +556,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
assertFalse(csk2.isEstimationMode());
assertTrue(csk2.isOrdered());
- final CompactSketch csk3 = shared.compact(true, seg2);
+ final CompactThetaSketch csk3 = shared.compact(true, seg2);
csk3.toString(false, true, 0, false);
csk3.toString();
assertEquals(csk3.getEstimate(), localEst);
@@ -597,7 +597,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
@Test
public void checkFamily() {
final SharedLocal sl = new SharedLocal();
- final UpdateSketch local = sl.local;
+ final UpdatableThetaSketch local = sl.local;
assertEquals(local.getFamily(), Family.QUICKSELECT);
}
@@ -676,9 +676,9 @@ public class ConcurrentHeapQuickSelectSketchTest {
static class SharedLocal {
static final long DefaultSeed = Util.DEFAULT_UPDATE_SEED;
- final UpdateSketch shared;
+ final UpdatableThetaSketch shared;
final ConcurrentSharedThetaSketch sharedIf;
- final UpdateSketch local;
+ final UpdatableThetaSketch local;
final int sharedLgK;
final int localLgK;
final long seed;
@@ -729,7 +729,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
}
}
- static void waitForBgPropagationToComplete(final UpdateSketch shared) {
+ static void waitForBgPropagationToComplete(final UpdatableThetaSketch shared) {
try {
Thread.sleep(10);
} catch (final InterruptedException e) {
diff --git a/src/test/java/org/apache/datasketches/theta/CornerCaseThetaSetOperationsTest.java b/src/test/java/org/apache/datasketches/theta/CornerCaseThetaSetOperationsTest.java
index 25ddc54ed..dd26d8f98 100644
--- a/src/test/java/org/apache/datasketches/theta/CornerCaseThetaSetOperationsTest.java
+++ b/src/test/java/org/apache/datasketches/theta/CornerCaseThetaSetOperationsTest.java
@@ -19,14 +19,6 @@
package org.apache.datasketches.theta;
-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.SetOperationBuilder;
-import org.apache.datasketches.theta.Union;
-import org.apache.datasketches.theta.UpdateSketch;
-import org.apache.datasketches.theta.UpdateSketchBuilder;
import org.testng.annotations.Test;
//import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
//import static org.apache.datasketches.hash.MurmurHash3.hash;
@@ -64,8 +56,8 @@ public class CornerCaseThetaSetOperationsTest {
@Test
public void emptyEmpty() {
- UpdateSketch thetaA = getSketch(SkType.EMPTY, 0, 0);
- UpdateSketch thetaB = getSketch(SkType.EMPTY, 0, 0);
+ UpdatableThetaSketch thetaA = getSketch(SkType.EMPTY, 0, 0);
+ UpdatableThetaSketch thetaB = getSketch(SkType.EMPTY, 0, 0);
final double expectedIntersectTheta = 1.0;
final int expectedIntersectCount = 0;
final boolean expectedIntersectEmpty = true;
@@ -84,8 +76,8 @@ public class CornerCaseThetaSetOperationsTest {
@Test
public void emptyExact() {
- UpdateSketch thetaA = getSketch(SkType.EMPTY, 0, 0);
- UpdateSketch thetaB = getSketch(SkType.EXACT, 0, GT_MIDP_V);
+ UpdatableThetaSketch thetaA = getSketch(SkType.EMPTY, 0, 0);
+ UpdatableThetaSketch thetaB = getSketch(SkType.EXACT, 0, GT_MIDP_V);
final double expectedIntersectTheta = 1.0;
final int expectedIntersectCount = 0;
final boolean expectedIntersectEmpty = true;
@@ -104,8 +96,8 @@ public class CornerCaseThetaSetOperationsTest {
@Test
public void emptyDegenerate() {
- UpdateSketch thetaA = getSketch(SkType.EMPTY, 0, 0);
- UpdateSketch thetaB = getSketch(SkType.DEGENERATE, LOWP, GT_LOWP_V);
+ UpdatableThetaSketch thetaA = getSketch(SkType.EMPTY, 0, 0);
+ UpdatableThetaSketch thetaB = getSketch(SkType.DEGENERATE, LOWP, GT_LOWP_V);
final double expectedIntersectTheta = 1.0;
final int expectedIntersectCount = 0;
final boolean expectedIntersectEmpty = true;
@@ -124,8 +116,8 @@ public class CornerCaseThetaSetOperationsTest {
@Test
public void emptyEstimation() {
- UpdateSketch thetaA = getSketch(SkType.EMPTY, 0, 0);
- UpdateSketch thetaB = getSketch(SkType.ESTIMATION, LOWP, LT_LOWP_V);
+ UpdatableThetaSketch thetaA = getSketch(SkType.EMPTY, 0, 0);
+ UpdatableThetaSketch thetaB = getSketch(SkType.ESTIMATION, LOWP, LT_LOWP_V);
final double expectedIntersectTheta = 1.0;
final int expectedIntersectCount = 0;
final boolean expectedIntersectEmpty = true;
@@ -146,8 +138,8 @@ public class CornerCaseThetaSetOperationsTest {
@Test
public void exactEmpty() {
- UpdateSketch thetaA = getSketch(SkType.EXACT, 0, GT_MIDP_V);
- UpdateSketch thetaB = getSketch(SkType.EMPTY, 0, 0);
+ UpdatableThetaSketch thetaA = getSketch(SkType.EXACT, 0, GT_MIDP_V);
+ UpdatableThetaSketch thetaB = getSketch(SkType.EMPTY, 0, 0);
final double expectedIntersectTheta = 1.0;
final int expectedIntersectCount = 0;
final boolean expectedIntersectEmpty = true;
@@ -166,8 +158,8 @@ public class CornerCaseThetaSetOperationsTest {
@Test
public void exactExact() {
- UpdateSketch thetaA = getSketch(SkType.EXACT, 0, GT_MIDP_V);
- UpdateSketch thetaB = getSketch(SkType.EXACT, 0, GT_MIDP_V);
+ UpdatableThetaSketch thetaA = getSketch(SkType.EXACT, 0, GT_MIDP_V);
+ UpdatableThetaSketch thetaB = getSketch(SkType.EXACT, 0, GT_MIDP_V);
final double expectedIntersectTheta = 1.0;
final int expectedIntersectCount = 1;
final boolean expectedIntersectEmpty = false;
@@ -186,8 +178,8 @@ public class CornerCaseThetaSetOperationsTest {
@Test
public void exactDegenerate() {
- UpdateSketch thetaA = getSketch(SkType.EXACT, 0, LT_LOWP_V);
- UpdateSketch thetaB = getSketch(SkType.DEGENERATE, LOWP, GT_LOWP_V); //entries = 0
+ UpdatableThetaSketch thetaA = getSketch(SkType.EXACT, 0, LT_LOWP_V);
+ UpdatableThetaSketch thetaB = getSketch(SkType.DEGENERATE, LOWP, GT_LOWP_V); //entries = 0
final double expectedIntersectTheta = LOWP_THETA;
final int expectedIntersectCount = 0;
final boolean expectedIntersectEmpty = false;
@@ -206,8 +198,8 @@ public class CornerCaseThetaSetOperationsTest {
@Test
public void exactEstimation() {
- UpdateSketch thetaA = getSketch(SkType.EXACT, 0, LT_LOWP_V);
- UpdateSketch thetaB = getSketch(SkType.ESTIMATION, LOWP, LT_LOWP_V);
+ UpdatableThetaSketch thetaA = getSketch(SkType.EXACT, 0, LT_LOWP_V);
+ UpdatableThetaSketch thetaB = getSketch(SkType.ESTIMATION, LOWP, LT_LOWP_V);
final double expectedIntersectTheta = LOWP_THETA;
final int expectedIntersectCount = 1;
final boolean expectedIntersectEmpty = false;
@@ -228,8 +220,8 @@ public class CornerCaseThetaSetOperationsTest {
@Test
public void estimationEmpty() {
- UpdateSketch thetaA = getSketch(SkType.ESTIMATION, LOWP, LT_LOWP_V);
- UpdateSketch thetaB = getSketch(SkType.EMPTY, 0, 0);
+ UpdatableThetaSketch thetaA = getSketch(SkType.ESTIMATION, LOWP, LT_LOWP_V);
+ UpdatableThetaSketch thetaB = getSketch(SkType.EMPTY, 0, 0);
final double expectedIntersectTheta = 1.0;
final int expectedIntersectCount = 0;
final boolean expectedIntersectEmpty = true;
@@ -248,8 +240,8 @@ public class CornerCaseThetaSetOperationsTest {
@Test
public void estimationExact() {
- UpdateSketch thetaA = getSketch(SkType.ESTIMATION, LOWP, LT_LOWP_V);
- UpdateSketch thetaB = getSketch(SkType.EXACT, 0, LT_LOWP_V);
+ UpdatableThetaSketch thetaA = getSketch(SkType.ESTIMATION, LOWP, LT_LOWP_V);
+ UpdatableThetaSketch thetaB = getSketch(SkType.EXACT, 0, LT_LOWP_V);
final double expectedIntersectTheta = LOWP_THETA;
final int expectedIntersectCount = 1;
final boolean expectedIntersectEmpty = false;
@@ -268,8 +260,8 @@ public class CornerCaseThetaSetOperationsTest {
@Test
public void estimationDegenerate() {
- UpdateSketch thetaA = getSketch(SkType.ESTIMATION, MIDP, LT_LOWP_V);
- UpdateSketch thetaB = getSketch(SkType.DEGENERATE, LOWP, GT_LOWP_V);
+ UpdatableThetaSketch thetaA = getSketch(SkType.ESTIMATION, MIDP, LT_LOWP_V);
+ UpdatableThetaSketch thetaB = getSketch(SkType.DEGENERATE, LOWP, GT_LOWP_V);
final double expectedIntersectTheta = LOWP_THETA;
final int expectedIntersectCount = 0;
final boolean expectedIntersectEmpty = false;
@@ -288,8 +280,8 @@ public class CornerCaseThetaSetOperationsTest {
@Test
public void estimationEstimation() {
- UpdateSketch thetaA = getSketch(SkType.ESTIMATION, MIDP, LT_LOWP_V);
- UpdateSketch thetaB = getSketch(SkType.ESTIMATION, LOWP, LT_LOWP_V);
+ UpdatableThetaSketch thetaA = getSketch(SkType.ESTIMATION, MIDP, LT_LOWP_V);
+ UpdatableThetaSketch thetaB = getSketch(SkType.ESTIMATION, LOWP, LT_LOWP_V);
final double expectedIntersectTheta = LOWP_THETA;
final int expectedIntersectCount = 1;
final boolean expectedIntersectEmpty = false;
@@ -310,8 +302,8 @@ public class CornerCaseThetaSetOperationsTest {
@Test
public void degenerateEmpty() {
- UpdateSketch thetaA = getSketch(SkType.DEGENERATE, LOWP, GT_LOWP_V); //entries = 0
- UpdateSketch thetaB = getSketch(SkType.EMPTY, 0, 0);
+ UpdatableThetaSketch thetaA = getSketch(SkType.DEGENERATE, LOWP, GT_LOWP_V); //entries = 0
+ UpdatableThetaSketch thetaB = getSketch(SkType.EMPTY, 0, 0);
final double expectedIntersectTheta = 1.0;
final int expectedIntersectCount = 0;
final boolean expectedIntersectEmpty = true;
@@ -330,8 +322,8 @@ public class CornerCaseThetaSetOperationsTest {
@Test
public void degenerateExact() {
- UpdateSketch thetaA = getSketch(SkType.DEGENERATE, LOWP, GT_LOWP_V); //entries = 0
- UpdateSketch thetaB = getSketch(SkType.EXACT, 0, LT_LOWP_V);
+ UpdatableThetaSketch thetaA = getSketch(SkType.DEGENERATE, LOWP, GT_LOWP_V); //entries = 0
+ UpdatableThetaSketch thetaB = getSketch(SkType.EXACT, 0, LT_LOWP_V);
final double expectedIntersectTheta = LOWP_THETA;
final int expectedIntersectCount = 0;
final boolean expectedIntersectEmpty = false;
@@ -350,8 +342,8 @@ public class CornerCaseThetaSetOperationsTest {
@Test
public void degenerateDegenerate() {
- UpdateSketch thetaA = getSketch(SkType.DEGENERATE, MIDP, GT_MIDP_V); //entries = 0
- UpdateSketch thetaB = getSketch(SkType.DEGENERATE, LOWP, GT_LOWP_V);
+ UpdatableThetaSketch thetaA = getSketch(SkType.DEGENERATE, MIDP, GT_MIDP_V); //entries = 0
+ UpdatableThetaSketch thetaB = getSketch(SkType.DEGENERATE, LOWP, GT_LOWP_V);
final double expectedIntersectTheta = LOWP_THETA;
final int expectedIntersectCount = 0;
final boolean expectedIntersectEmpty = false;
@@ -370,8 +362,8 @@ public class CornerCaseThetaSetOperationsTest {
@Test
public void degenerateEstimation() {
- UpdateSketch thetaA = getSketch(SkType.DEGENERATE, MIDP, GT_MIDP_V); //entries = 0
- UpdateSketch thetaB = getSketch(SkType.ESTIMATION, LOWP, LT_LOWP_V);
+ UpdatableThetaSketch thetaA = getSketch(SkType.DEGENERATE, MIDP, GT_MIDP_V); //entries = 0
+ UpdatableThetaSketch thetaB = getSketch(SkType.ESTIMATION, LOWP, LT_LOWP_V);
final double expectedIntersectTheta = LOWP_THETA;
final int expectedIntersectCount = 0;
final boolean expectedIntersectEmpty = false;
@@ -392,8 +384,8 @@ public class CornerCaseThetaSetOperationsTest {
//=================================
private static void checks(
- UpdateSketch thetaA,
- UpdateSketch thetaB,
+ UpdatableThetaSketch thetaA,
+ UpdatableThetaSketch thetaB,
double expectedIntersectTheta,
int expectedIntersectCount,
boolean expectedIntersectEmpty,
@@ -403,56 +395,56 @@ public class CornerCaseThetaSetOperationsTest {
double expectedUnionTheta,
int expectedUnionCount,
boolean expectedUnionEmpty) {
- CompactSketch csk;
- Intersection inter = SetOperation.builder().buildIntersection();
- AnotB anotb = SetOperation.builder().buildANotB();
- Union union = new SetOperationBuilder().buildUnion();
+ CompactThetaSketch csk;
+ ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
+ ThetaAnotB anotb = ThetaSetOperation.builder().buildANotB();
+ ThetaUnion union = new ThetaSetOperationBuilder().buildUnion();
- //Intersection Stateless Theta, Theta Updatable
+ //ThetaIntersection Stateless Theta, Theta Updatable
csk = inter.intersect(thetaA, thetaB);
- checkResult("Intersect Stateless Theta, Theta", csk, expectedIntersectTheta, expectedIntersectCount,
+ checkResult("ThetaIntersect Stateless Theta, Theta", csk, expectedIntersectTheta, expectedIntersectCount,
expectedIntersectEmpty);
- //Intersection Stateless Theta, Theta Compact
+ //ThetaIntersection Stateless Theta, Theta Compact
csk = inter.intersect(thetaA.compact(), thetaB.compact());
- checkResult("Intersect Stateless Theta, Theta", csk, expectedIntersectTheta, expectedIntersectCount,
+ checkResult("ThetaIntersect Stateless Theta, Theta", csk, expectedIntersectTheta, expectedIntersectCount,
expectedIntersectEmpty);
- //AnotB Stateless Theta, Theta Updatable
+ //ThetaAnotB Stateless Theta, Theta Updatable
csk = anotb.aNotB(thetaA, thetaB);
- checkResult("AnotB Stateless Theta, Theta", csk, expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty);
- //AnotB Stateless Theta, Theta Compact
+ checkResult("ThetaAnotB Stateless Theta, Theta", csk, expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty);
+ //ThetaAnotB Stateless Theta, Theta Compact
csk = anotb.aNotB(thetaA.compact(), thetaB.compact());
- checkResult("AnotB Stateless Theta, Theta", csk, expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty);
+ checkResult("ThetaAnotB Stateless Theta, Theta", csk, expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty);
- //AnotB Stateful Theta, Theta Updatable
+ //ThetaAnotB Stateful Theta, Theta Updatable
anotb.setA(thetaA);
anotb.notB(thetaB);
csk = anotb.getResult(true);
- checkResult("AnotB Stateful Theta, Theta", csk, expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty);
- //AnotB Stateful Theta, Theta Compact
+ checkResult("ThetaAnotB Stateful Theta, Theta", csk, expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty);
+ //ThetaAnotB Stateful Theta, Theta Compact
anotb.setA(thetaA.compact());
anotb.notB(thetaB.compact());
csk = anotb.getResult(true);
- checkResult("AnotB Stateful Theta, Theta", csk, expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty);
+ checkResult("ThetaAnotB Stateful Theta, Theta", csk, expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty);
- //Union Stateful Theta, Theta Updatable
+ //ThetaUnion Stateful Theta, Theta Updatable
union.union(thetaA);
union.union(thetaB);
csk = union.getResult();
union.reset();
- checkResult("Union Stateless Theta, Theta", csk, expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
- //Union Stateful Theta, Theta Compact
+ checkResult("ThetaUnion Stateless Theta, Theta", csk, expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
+ //ThetaUnion Stateful Theta, Theta Compact
union.union(thetaA.compact());
union.union(thetaB.compact());
csk = union.getResult();
union.reset();
- checkResult("Union Stateless Theta, Theta", csk, expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
+ checkResult("ThetaUnion Stateless Theta, Theta", csk, expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
}
private static void checkResult(
String comment,
- CompactSketch csk,
+ CompactThetaSketch csk,
double expectedTheta,
int expectedEntries,
boolean expectedEmpty) {
@@ -473,10 +465,10 @@ public class CornerCaseThetaSetOperationsTest {
}
}
- private static UpdateSketch getSketch(SkType skType, float p, long value) {
- UpdateSketchBuilder bldr = UpdateSketch.builder();
+ private static UpdatableThetaSketch getSketch(SkType skType, float p, long value) {
+ UpdateSketchBuilder bldr = UpdatableThetaSketch.builder();
bldr.setLogNominalEntries(4);
- UpdateSketch sk;
+ UpdatableThetaSketch sk;
switch(skType) {
case EMPTY: { // { 1.0, 0, T} p and value are not used
sk = bldr.build();
diff --git a/src/test/java/org/apache/datasketches/theta/DirectIntersectionTest.java b/src/test/java/org/apache/datasketches/theta/DirectIntersectionTest.java
index 59b6396b7..d1f923089 100644
--- a/src/test/java/org/apache/datasketches/theta/DirectIntersectionTest.java
+++ b/src/test/java/org/apache/datasketches/theta/DirectIntersectionTest.java
@@ -23,8 +23,8 @@ import static java.lang.foreign.ValueLayout.JAVA_BYTE;
import static java.lang.foreign.ValueLayout.JAVA_INT_UNALIGNED;
import static org.apache.datasketches.theta.PreambleUtil.PREAMBLE_LONGS_BYTE;
import static org.apache.datasketches.theta.PreambleUtil.SER_VER_BYTE;
-import static org.apache.datasketches.theta.SetOperation.CONST_PREAMBLE_LONGS;
-import static org.apache.datasketches.theta.SetOperation.getMaxIntersectionBytes;
+import static org.apache.datasketches.theta.ThetaSetOperation.CONST_PREAMBLE_LONGS;
+import static org.apache.datasketches.theta.ThetaSetOperation.getMaxIntersectionBytes;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
@@ -49,10 +49,10 @@ public class DirectIntersectionTest {
public void checkExactIntersectionNoOverlap() {
final int lgK = 9;
final int k = 1<<lgK;
- Intersection inter;
+ ThetaIntersection inter;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<k/2; i++) {
usk1.update(i);
@@ -65,7 +65,7 @@ public class DirectIntersectionTest {
final byte[] segArr = new byte[segBytes];
final MemorySegment iSeg = MemorySegment.ofArray(segArr);
- inter = SetOperation.builder().buildIntersection(iSeg);
+ inter = ThetaSetOperation.builder().buildIntersection(iSeg);
inter.intersect(usk1);
inter.intersect(usk2);
@@ -73,7 +73,7 @@ public class DirectIntersectionTest {
final long[] cache = inter.getCache(); //only applies to stateful
assertEquals(cache.length, 32);
- CompactSketch rsk1;
+ CompactThetaSketch rsk1;
final boolean ordered = true;
assertTrue(inter.hasResult());
@@ -98,10 +98,10 @@ public class DirectIntersectionTest {
public void checkExactIntersectionFullOverlap() {
final int lgK = 9;
final int k = 1<<lgK;
- Intersection inter;
+ ThetaIntersection inter;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<k; i++) {
usk1.update(i);
@@ -114,11 +114,11 @@ public class DirectIntersectionTest {
final byte[] segArr = new byte[segBytes];
final MemorySegment iSeg = MemorySegment.ofArray(segArr);
- inter = SetOperation.builder().buildIntersection(iSeg);
+ inter = ThetaSetOperation.builder().buildIntersection(iSeg);
inter.intersect(usk1);
inter.intersect(usk2);
- CompactSketch rsk1;
+ CompactThetaSketch rsk1;
final boolean ordered = true;
rsk1 = inter.getResult(!ordered, null);
@@ -144,8 +144,8 @@ public class DirectIntersectionTest {
final int k = 1<<lgK;
final int u = 4*k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u; i++) {
usk1.update(i);
@@ -158,15 +158,15 @@ public class DirectIntersectionTest {
final byte[] segArr = new byte[segBytes];
final MemorySegment iSeg = MemorySegment.ofArray(segArr);
- final CompactSketch csk1 = usk1.compact(true, null);
- final CompactSketch csk2 = usk2.compact(true, null);
+ final CompactThetaSketch csk1 = usk1.compact(true, null);
+ final CompactThetaSketch csk2 = usk2.compact(true, null);
- final Intersection inter =
- SetOperation.builder().buildIntersection(iSeg);
+ final ThetaIntersection inter =
+ ThetaSetOperation.builder().buildIntersection(iSeg);
inter.intersect(csk1);
inter.intersect(csk2);
- final CompactSketch rsk1 = inter.getResult(true, null);
+ final CompactThetaSketch rsk1 = inter.getResult(true, null);
println(""+rsk1.getEstimate());
}
@@ -175,13 +175,13 @@ public class DirectIntersectionTest {
public void checkNoCall() {
final int lgK = 9;
final int k = 1<<lgK;
- Intersection inter;
+ ThetaIntersection inter;
final int segBytes = getMaxIntersectionBytes(k);
final byte[] segArr = new byte[segBytes];
final MemorySegment iSeg = MemorySegment.ofArray(segArr);
- inter = SetOperation.builder().buildIntersection(iSeg);
+ inter = ThetaSetOperation.builder().buildIntersection(iSeg);
assertFalse(inter.hasResult());
inter.getResult(false, null);
}
@@ -193,8 +193,8 @@ public class DirectIntersectionTest {
final int segBytes = getMaxIntersectionBytes(k);
final byte[] segArr = new byte[segBytes];
final MemorySegment iSeg = MemorySegment.ofArray(segArr);
- final Intersection inter = SetOperation.builder().buildIntersection(iSeg);
- final UpdateSketch sk = null;
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection(iSeg);
+ final UpdatableThetaSketch sk = null;
try { inter.intersect(sk); fail(); }
catch (final SketchesArgumentException e) { }
@@ -207,9 +207,9 @@ public class DirectIntersectionTest {
public void check1stCall() {
final int lgK = 9;
final int k = 1<<lgK;
- Intersection inter;
- UpdateSketch sk;
- CompactSketch rsk1;
+ ThetaIntersection inter;
+ UpdatableThetaSketch sk;
+ CompactThetaSketch rsk1;
double est;
final int segBytes = getMaxIntersectionBytes(k);
@@ -217,8 +217,8 @@ public class DirectIntersectionTest {
final MemorySegment iSeg = MemorySegment.ofArray(segArr);
//1st call = empty
- sk = UpdateSketch.builder().setNominalEntries(k).build(); //empty
- inter = SetOperation.builder().buildIntersection(iSeg);
+ sk = UpdatableThetaSketch.builder().setNominalEntries(k).build(); //empty
+ inter = ThetaSetOperation.builder().buildIntersection(iSeg);
inter.intersect(sk);
rsk1 = inter.getResult(false, null);
est = rsk1.getEstimate();
@@ -226,9 +226,9 @@ public class DirectIntersectionTest {
println("Est: "+est); // = 0
//1st call = valid and not empty
- sk = UpdateSketch.builder().setNominalEntries(k).build();
+ sk = UpdatableThetaSketch.builder().setNominalEntries(k).build();
sk.update(1);
- inter = SetOperation.builder().buildIntersection(iSeg);
+ inter = ThetaSetOperation.builder().buildIntersection(iSeg);
inter.intersect(sk);
rsk1 = inter.getResult(false, null);
est = rsk1.getEstimate();
@@ -240,9 +240,9 @@ public class DirectIntersectionTest {
public void check2ndCallAfterEmpty() {
final int lgK = 9;
final int k = 1<<lgK;
- Intersection inter;
- UpdateSketch sk1, sk2;
- CompactSketch comp1;
+ ThetaIntersection inter;
+ UpdatableThetaSketch sk1, sk2;
+ CompactThetaSketch comp1;
double est;
final int segBytes = getMaxIntersectionBytes(k);
@@ -250,11 +250,11 @@ public class DirectIntersectionTest {
final MemorySegment iSeg = MemorySegment.ofArray(segArr);
//1st call = empty
- sk1 = UpdateSketch.builder().build(); //empty
- inter = SetOperation.builder().buildIntersection(iSeg);
+ sk1 = UpdatableThetaSketch.builder().build(); //empty
+ inter = ThetaSetOperation.builder().buildIntersection(iSeg);
inter.intersect(sk1);
//2nd call = empty
- sk2 = UpdateSketch.builder().build(); //empty
+ sk2 = UpdatableThetaSketch.builder().build(); //empty
inter.intersect(sk2);
comp1 = inter.getResult(false, null);
est = comp1.getEstimate();
@@ -262,11 +262,11 @@ public class DirectIntersectionTest {
println("Est: "+est);
//1st call = empty
- sk1 = UpdateSketch.builder().build(); //empty
- inter = SetOperation.builder().buildIntersection(iSeg);
+ sk1 = UpdatableThetaSketch.builder().build(); //empty
+ inter = ThetaSetOperation.builder().buildIntersection(iSeg);
inter.intersect(sk1);
//2nd call = valid and not empty
- sk2 = UpdateSketch.builder().build();
+ sk2 = UpdatableThetaSketch.builder().build();
sk2.update(1);
inter.intersect(sk2);
comp1 = inter.getResult(false, null);
@@ -279,9 +279,9 @@ public class DirectIntersectionTest {
public void check2ndCallAfterValid() {
final int lgK = 9;
final int k = 1<<lgK;
- Intersection inter;
- UpdateSketch sk1, sk2;
- CompactSketch comp1;
+ ThetaIntersection inter;
+ UpdatableThetaSketch sk1, sk2;
+ CompactThetaSketch comp1;
double est;
final int segBytes = getMaxIntersectionBytes(k);
@@ -289,12 +289,12 @@ public class DirectIntersectionTest {
final MemorySegment iSeg = MemorySegment.ofArray(segArr);
//1st call = valid
- sk1 = UpdateSketch.builder().build();
+ sk1 = UpdatableThetaSketch.builder().build();
sk1.update(1);
- inter = SetOperation.builder().buildIntersection(iSeg);
+ inter = ThetaSetOperation.builder().buildIntersection(iSeg);
inter.intersect(sk1);
//2nd call = empty
- sk2 = UpdateSketch.builder().build(); //empty
+ sk2 = UpdatableThetaSketch.builder().build(); //empty
inter.intersect(sk2);
comp1 = inter.getResult(false, null);
est = comp1.getEstimate();
@@ -302,12 +302,12 @@ public class DirectIntersectionTest {
println("Est: "+est);
//1st call = valid
- sk1 = UpdateSketch.builder().build();
+ sk1 = UpdatableThetaSketch.builder().build();
sk1.update(1);
- inter = SetOperation.builder().buildIntersection(iSeg);
+ inter = ThetaSetOperation.builder().buildIntersection(iSeg);
inter.intersect(sk1);
//2nd call = valid intersecting
- sk2 = UpdateSketch.builder().build(); //empty
+ sk2 = UpdatableThetaSketch.builder().build(); //empty
sk2.update(1);
inter.intersect(sk2);
comp1 = inter.getResult(false, null);
@@ -316,12 +316,12 @@ public class DirectIntersectionTest {
println("Est: "+est);
//1st call = valid
- sk1 = UpdateSketch.builder().build();
+ sk1 = UpdatableThetaSketch.builder().build();
sk1.update(1);
- inter = SetOperation.builder().buildIntersection(iSeg);
+ inter = ThetaSetOperation.builder().buildIntersection(iSeg);
inter.intersect(sk1);
//2nd call = valid not intersecting
- sk2 = UpdateSketch.builder().build(); //empty
+ sk2 = UpdatableThetaSketch.builder().build(); //empty
sk2.update(2);
inter.intersect(sk2);
comp1 = inter.getResult(false, null);
@@ -334,9 +334,9 @@ public class DirectIntersectionTest {
public void checkEstimatingIntersect() {
final int lgK = 9;
final int k = 1<<lgK;
- Intersection inter;
- UpdateSketch sk1, sk2;
- CompactSketch comp1;
+ ThetaIntersection inter;
+ UpdatableThetaSketch sk1, sk2;
+ CompactThetaSketch comp1;
double est;
final int segBytes = getMaxIntersectionBytes(k);
@@ -344,18 +344,18 @@ public class DirectIntersectionTest {
final MemorySegment iSeg = MemorySegment.ofArray(segArr);
//1st call = valid
- sk1 = UpdateSketch.builder().setNominalEntries(k).build();
+ sk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<2*k; i++)
{
sk1.update(i); //est mode
}
println("sk1: "+sk1.getEstimate());
- inter = SetOperation.builder().buildIntersection(iSeg);
+ inter = ThetaSetOperation.builder().buildIntersection(iSeg);
inter.intersect(sk1);
//2nd call = valid intersecting
- sk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ sk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<2*k; i++)
{
sk2.update(i); //est mode
@@ -374,10 +374,10 @@ public class DirectIntersectionTest {
public void checkOverflow() {
final int lgK = 9; //512
final int k = 1<<lgK;
- Intersection inter;
- UpdateSketch sk1;
- final UpdateSketch sk2;
- final CompactSketch comp1;
+ ThetaIntersection inter;
+ UpdatableThetaSketch sk1;
+ final UpdatableThetaSketch sk2;
+ final CompactThetaSketch comp1;
final double est;
final int reqBytes = getMaxIntersectionBytes(k);
@@ -385,7 +385,7 @@ public class DirectIntersectionTest {
final MemorySegment iSeg = MemorySegment.ofArray(segArr);
//1st call = valid
- sk1 = UpdateSketch.builder().setNominalEntries(2 * k).build(); // bigger sketch
+ sk1 = UpdatableThetaSketch.builder().setNominalEntries(2 * k).build(); // bigger sketch
for (int i=0; i<4*k; i++)
{
sk1.update(i); //force est mode
@@ -393,7 +393,7 @@ public class DirectIntersectionTest {
println("sk1est: "+sk1.getEstimate());
println("sk1cnt: "+sk1.getRetainedEntries(true));
- inter = SetOperation.builder().buildIntersection(iSeg);
+ inter = ThetaSetOperation.builder().buildIntersection(iSeg);
inter.intersect(sk1);
}
@@ -401,9 +401,9 @@ public class DirectIntersectionTest {
public void checkHeapify() {
final int lgK = 9;
final int k = 1<<lgK;
- Intersection inter;
- UpdateSketch sk1, sk2;
- CompactSketch comp1, comp2;
+ ThetaIntersection inter;
+ UpdatableThetaSketch sk1, sk2;
+ CompactThetaSketch comp1, comp2;
double est, est2;
final int segBytes = getMaxIntersectionBytes(k);
@@ -411,18 +411,18 @@ public class DirectIntersectionTest {
final MemorySegment iSeg = MemorySegment.ofArray(segArr);
//1st call = valid
- sk1 = UpdateSketch.builder().setNominalEntries(k).build();
+ sk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<2*k; i++)
{
sk1.update(i); //est mode
}
println("sk1: "+sk1.getEstimate());
- inter = SetOperation.builder().buildIntersection(iSeg);
+ inter = ThetaSetOperation.builder().buildIntersection(iSeg);
inter.intersect(sk1);
//2nd call = valid intersecting
- sk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ sk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<2*k; i++)
{
sk2.update(i); //est mode
@@ -437,7 +437,7 @@ public class DirectIntersectionTest {
final byte[] byteArray = inter.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
- final Intersection inter2 = (Intersection) SetOperation.heapify(seg);
+ final ThetaIntersection inter2 = (ThetaIntersection) ThetaSetOperation.heapify(seg);
comp2 = inter2.getResult(false, null);
est2 = comp2.getEstimate();
println("Est2: "+est2);
@@ -448,7 +448,7 @@ public class DirectIntersectionTest {
*/
@Test
public void checkPreject() {
- final UpdateSketch sk = UpdateSketch.builder().setP((float) .5).build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().setP((float) .5).build();
sk.update(7);
assertEquals(sk.getRetainedEntries(), 0);
}
@@ -457,14 +457,14 @@ public class DirectIntersectionTest {
public void checkWrapVirginEmpty() {
final int lgK = 5;
final int k = 1 << lgK;
- Intersection inter1, inter2;
- UpdateSketch sk1;
+ ThetaIntersection inter1, inter2;
+ UpdatableThetaSketch sk1;
final int segBytes = getMaxIntersectionBytes(k);
MemorySegment iSeg = MemorySegment.ofArray(new byte[segBytes]);
- inter1 = SetOperation.builder().buildIntersection(iSeg); //virgin off-heap
- inter2 = Intersection.wrap(iSeg); //virgin off-heap, identical to inter1
+ inter1 = ThetaSetOperation.builder().buildIntersection(iSeg); //virgin off-heap
+ inter2 = ThetaIntersection.wrap(iSeg); //virgin off-heap, identical to inter1
//both in virgin state, empty = false
//note: both inter1 and inter2 are tied to the same MemorySegment,
// so an intersect to one also affects the other. Don't do what I do!
@@ -472,7 +472,7 @@ public class DirectIntersectionTest {
assertFalse(inter2.hasResult());
//This constructs a sketch with 0 entries and theta < 1.0
- sk1 = UpdateSketch.builder().setP((float) .5).setNominalEntries(k).build();
+ sk1 = UpdatableThetaSketch.builder().setP((float) .5).setNominalEntries(k).build();
sk1.update(7); //will be rejected by P, see proof above.
//A virgin intersection (empty = false) intersected with a not-empty zero cache sketch
@@ -486,11 +486,11 @@ public class DirectIntersectionTest {
//test the path via toByteArray, now in a different state
iSeg = MemorySegment.ofArray(inter1.toByteArray());
- inter2 = Intersection.wrap(iSeg);
+ inter2 = ThetaIntersection.wrap(iSeg);
assertTrue(inter2.hasResult()); //still true
//test the compaction path
- final CompactSketch comp = inter2.getResult(true, null);
+ final CompactThetaSketch comp = inter2.getResult(true, null);
assertEquals(comp.getRetainedEntries(false), 0);
assertFalse(comp.isEmpty());
}
@@ -499,29 +499,29 @@ public class DirectIntersectionTest {
public void checkWrapNullEmpty2() {
final int lgK = 5;
final int k = 1<<lgK;
- Intersection inter1, inter2;
- UpdateSketch sk1;
+ ThetaIntersection inter1, inter2;
+ UpdatableThetaSketch sk1;
final int segBytes = getMaxIntersectionBytes(k);
final byte[] segArr = new byte[segBytes];
final MemorySegment iSeg = MemorySegment.ofArray(segArr);
- inter1 = SetOperation.builder().buildIntersection(iSeg); //virgin
- inter2 = Intersection.wrap(iSeg);
+ inter1 = ThetaSetOperation.builder().buildIntersection(iSeg); //virgin
+ inter2 = ThetaIntersection.wrap(iSeg);
//both in virgin state, empty = false
assertFalse(inter1.hasResult());
assertFalse(inter2.hasResult());
- sk1 = UpdateSketch.builder().setP((float) .005).setFamily(Family.QUICKSELECT).setNominalEntries(k).build();
+ sk1 = UpdatableThetaSketch.builder().setP((float) .005).setFamily(Family.QUICKSELECT).setNominalEntries(k).build();
sk1.update(1); //very unlikely to go into cache due to p.
//A virgin intersection (empty = false) intersected with a not-empty zero cache sketch
//remains empty = false.
inter1.intersect(sk1);
- inter2 = Intersection.wrap(iSeg);
+ inter2 = ThetaIntersection.wrap(iSeg);
assertTrue(inter1.hasResult());
assertTrue(inter2.hasResult());
- final CompactSketch comp = inter2.getResult(true, null);
+ final CompactThetaSketch comp = inter2.getResult(true, null);
assertEquals(comp.getRetainedEntries(false), 0);
assertFalse(comp.isEmpty());
}
@@ -534,7 +534,7 @@ public class DirectIntersectionTest {
final byte[] segArr = new byte[segBytes];
final MemorySegment iSeg = MemorySegment.ofArray(segArr);
- SetOperation.builder().buildIntersection(iSeg);
+ ThetaSetOperation.builder().buildIntersection(iSeg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -547,15 +547,15 @@ public class DirectIntersectionTest {
final byte[] segArr = new byte[segBytes];
final MemorySegment iSeg = MemorySegment.ofArray(segArr);
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u; i++) {
usk1.update(i);
}
- final CompactSketch csk1 = usk1.compact(true, null);
+ final CompactThetaSketch csk1 = usk1.compact(true, null);
- final Intersection inter = SetOperation.builder().buildIntersection(iSeg);
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection(iSeg);
inter.intersect(csk1);
}
@@ -567,50 +567,49 @@ public class DirectIntersectionTest {
final byte[] segArr = new byte[segBytes];
final MemorySegment iSeg = MemorySegment.ofArray(segArr);
- final Intersection inter1 = SetOperation.builder().buildIntersection(iSeg); //virgin
+ final ThetaIntersection inter1 = ThetaSetOperation.builder().buildIntersection(iSeg); //virgin
final byte[] byteArray = inter1.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
//corrupt:
seg.set(JAVA_BYTE, PREAMBLE_LONGS_BYTE, (byte) 2);//RF not used = 0
- Intersection.wrap(seg);
+ ThetaIntersection.wrap(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkBadSerVer() {
final int k = 32;
- Intersection inter1;
+ ThetaIntersection inter1;
final int segBytes = getMaxIntersectionBytes(k);
final byte[] segArr = new byte[segBytes];
final MemorySegment iSeg = MemorySegment.ofArray(segArr);
- inter1 = SetOperation.builder().buildIntersection(iSeg); //virgin
+ inter1 = ThetaSetOperation.builder().buildIntersection(iSeg); //virgin
final byte[] byteArray = inter1.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
//corrupt:
seg.set(JAVA_BYTE, SER_VER_BYTE, (byte) 2);
- Intersection.wrap(seg); //throws in SetOperations
+ ThetaIntersection.wrap(seg); //throws in ThetaSetOperation
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkIncorrectWrap() {
final int k = 32;
- Union union;
+ ThetaUnion union;
- union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
final byte[] byteArray = union.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
- Intersection.wrap(seg); //wrong sketch Family
- //Sketches.wrapIntersection(seg);
+ ThetaIntersection.wrap(seg); //wrong sketch Family
}
@Test
public void checkWrap() {
final int lgK = 9;
final int k = 1<<lgK;
- Intersection inter, inter2, inter3;
- UpdateSketch sk1, sk2;
- CompactSketch resultComp1, resultComp2;
+ ThetaIntersection inter, inter2, inter3;
+ UpdatableThetaSketch sk1, sk2;
+ CompactThetaSketch resultComp1, resultComp2;
double est, est2;
final int segBytes = getMaxIntersectionBytes(k);
@@ -618,28 +617,28 @@ public class DirectIntersectionTest {
final MemorySegment iSeg = MemorySegment.ofArray(segArr1);
//1st call = valid
- sk1 = UpdateSketch.builder().setNominalEntries(k).build();
+ sk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<2*k; i++)
{
sk1.update(i); //est mode
}
- final CompactSketch compSkIn1 = sk1.compact(true, null);
+ final CompactThetaSketch compSkIn1 = sk1.compact(true, null);
println("compSkIn1: "+compSkIn1.getEstimate());
- inter = SetOperation.builder().buildIntersection(iSeg);
+ inter = ThetaSetOperation.builder().buildIntersection(iSeg);
inter.intersect(compSkIn1);
final byte[] segArr2 = inter.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(segArr2);
- inter2 = Intersection.wrap(srcSeg);
+ inter2 = ThetaIntersection.wrap(srcSeg);
//2nd call = valid intersecting
- sk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ sk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<2*k; i++)
{
sk2.update(i); //est mode
}
- final CompactSketch compSkIn2 = sk2.compact(true, null);
+ final CompactThetaSketch compSkIn2 = sk2.compact(true, null);
println("sk2: "+compSkIn2.getEstimate());
inter2.intersect(compSkIn2);
@@ -650,7 +649,7 @@ public class DirectIntersectionTest {
final byte[] segArr3 = inter2.toByteArray();
final MemorySegment srcSeg2 = MemorySegment.ofArray(segArr3);
- inter3 = Intersection.wrap(srcSeg2);
+ inter3 = ThetaIntersection.wrap(srcSeg2);
resultComp2 = inter3.getResult(false, null);
est2 = resultComp2.getEstimate();
println("Est2: "+est2);
@@ -664,28 +663,28 @@ public class DirectIntersectionTest {
public void checkDefaultMinSize() {
final int k = 32;
final MemorySegment seg = MemorySegment.ofArray(new byte[k*8 + PREBYTES]);
- IntersectionImpl.initNewDirectInstance(Util.DEFAULT_UPDATE_SEED, seg);
+ ThetaIntersectionImpl.initNewDirectInstance(Util.DEFAULT_UPDATE_SEED, seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkExceptionMinSize() {
final int k = 16;
final MemorySegment seg = MemorySegment.ofArray(new byte[k*8 + PREBYTES]);
- IntersectionImpl.initNewDirectInstance(Util.DEFAULT_UPDATE_SEED, seg);
+ ThetaIntersectionImpl.initNewDirectInstance(Util.DEFAULT_UPDATE_SEED, seg);
}
@Test
public void checkGetResult() {
final int k = 1024;
- final UpdateSketch sk = UpdateSketch.builder().build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().build();
final int segBytes = getMaxIntersectionBytes(k);
final byte[] segArr = new byte[segBytes];
final MemorySegment iSeg = MemorySegment.ofArray(segArr);
- final Intersection inter = SetOperation.builder().buildIntersection(iSeg);
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection(iSeg);
inter.intersect(sk);
- final CompactSketch csk = inter.getResult();
+ final CompactThetaSketch csk = inter.getResult();
assertEquals(csk.getCompactBytes(), 8);
}
@@ -694,7 +693,7 @@ public class DirectIntersectionTest {
//cheap trick
final int k = 16;
final MemorySegment seg = MemorySegment.ofArray(new byte[k*16 + PREBYTES]);
- final IntersectionImpl impl = IntersectionImpl.initNewDirectInstance(Util.DEFAULT_UPDATE_SEED, seg);
+ final ThetaIntersectionImpl impl = ThetaIntersectionImpl.initNewDirectInstance(Util.DEFAULT_UPDATE_SEED, seg);
assertEquals(impl.getFamily(), Family.INTERSECTION);
}
@@ -702,22 +701,22 @@ public class DirectIntersectionTest {
public void checkExceptions1() {
final int k = 16;
final MemorySegment seg = MemorySegment.ofArray(new byte[k*16 + PREBYTES]);
- IntersectionImpl.initNewDirectInstance(Util.DEFAULT_UPDATE_SEED, seg);
+ ThetaIntersectionImpl.initNewDirectInstance(Util.DEFAULT_UPDATE_SEED, seg);
//corrupt SerVer
seg.set(JAVA_BYTE, PreambleUtil.SER_VER_BYTE, (byte) 2);
- IntersectionImpl.wrapInstance(seg, Util.DEFAULT_UPDATE_SEED, false);
+ ThetaIntersectionImpl.wrapInstance(seg, Util.DEFAULT_UPDATE_SEED, false);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkExceptions2() {
final int k = 16;
final MemorySegment seg = MemorySegment.ofArray(new byte[k*16 + PREBYTES]);
- IntersectionImpl.initNewDirectInstance(Util.DEFAULT_UPDATE_SEED, seg);
+ ThetaIntersectionImpl.initNewDirectInstance(Util.DEFAULT_UPDATE_SEED, seg);
//seg now has non-empty intersection
//corrupt empty and CurCount
Util.setBits(seg, PreambleUtil.FLAGS_BYTE, (byte) PreambleUtil.EMPTY_FLAG_MASK);
seg.set(JAVA_INT_UNALIGNED, PreambleUtil.RETAINED_ENTRIES_INT, 2);
- IntersectionImpl.wrapInstance(seg, Util.DEFAULT_UPDATE_SEED, false);
+ ThetaIntersectionImpl.wrapInstance(seg, Util.DEFAULT_UPDATE_SEED, false);
}
//Check Alex's bug intersecting 2 direct full sketches with only overlap of 2
@@ -726,8 +725,8 @@ public class DirectIntersectionTest {
public void checkOverlappedDirect() {
final int k = 1 << 4;
final int segBytes = 2*k*16 +PREBYTES; //plenty of room
- final UpdateSketch sk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch sk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch sk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch sk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<k; i++) {
sk1.update(i);
sk2.update(k-2 +i); //overlap by 2
@@ -736,15 +735,15 @@ public class DirectIntersectionTest {
final MemorySegment segIn2 = MemorySegment.ofArray(new byte[segBytes]);
final MemorySegment segInter = MemorySegment.ofArray(new byte[segBytes]);
final MemorySegment segComp = MemorySegment.ofArray(new byte[segBytes]);
- final CompactSketch csk1 = sk1.compact(true, segIn1);
- final CompactSketch csk2 = sk2.compact(true, segIn2);
- final Intersection inter = SetOperation.builder().buildIntersection(segInter);
+ final CompactThetaSketch csk1 = sk1.compact(true, segIn1);
+ final CompactThetaSketch csk2 = sk2.compact(true, segIn2);
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection(segInter);
inter.intersect(csk1);
inter.intersect(csk2);
- final CompactSketch cskOut = inter.getResult(true, segComp);
+ final CompactThetaSketch cskOut = inter.getResult(true, segComp);
assertEquals(cskOut.getEstimate(), 2.0, 0.0);
- final Intersection interRO = (Intersection) SetOperation.wrap(segInter.asReadOnly());
+ final ThetaIntersection interRO = (ThetaIntersection) ThetaSetOperation.wrap(segInter.asReadOnly());
try {
interRO.intersect(sk1, sk2);
fail();
diff --git a/src/test/java/org/apache/datasketches/theta/DirectQuickSelectSketchTest.java b/src/test/java/org/apache/datasketches/theta/DirectQuickSelectSketchTest.java
index 7f3f79281..65c6c0a46 100644
--- a/src/test/java/org/apache/datasketches/theta/DirectQuickSelectSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/DirectQuickSelectSketchTest.java
@@ -63,7 +63,7 @@ public class DirectQuickSelectSketchTest {
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
final DirectQuickSelectSketch sk1 = (DirectQuickSelectSketch)usk; //for internal checks
assertTrue(usk.isEmpty());
@@ -88,7 +88,7 @@ public class DirectQuickSelectSketchTest {
final int k = 8;
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
- UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
} catch (final Exception e) {
if (e instanceof SketchesArgumentException) {}
else { throw new RuntimeException(e); }
@@ -100,7 +100,7 @@ public class DirectQuickSelectSketchTest {
final int k = 16;
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k/2, arena);
- UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
} catch (final Exception e) {
if (e instanceof SketchesArgumentException) {}
else { throw new RuntimeException(e); }
@@ -112,12 +112,12 @@ public class DirectQuickSelectSketchTest {
final int k = 512;
final int bytes = (k << 4) + (Family.QUICKSELECT.getMinPreLongs() << 3);
final MemorySegment seg = MemorySegment.ofArray(new byte[bytes]);
- UpdateSketch.builder().setNominalEntries(k).build(seg);
+ UpdatableThetaSketch.builder().setNominalEntries(k).build(seg);
seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Family ID byte
//try to heapify the corrupted seg
- ThetaSketch.heapify(seg); //catch in Sketch.constructHeapSketch
+ ThetaSketch.heapify(seg); //catch in ThetaSketch.constructHeapSketch
}
@Test
@@ -126,7 +126,7 @@ public class DirectQuickSelectSketchTest {
final int u = 2*k; //thus estimating
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
- final UpdateSketch sk1 = UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch sk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
for (int i=0; i<u; i++) { sk1.update(i); }
final double sk1est = sk1.getEstimate();
@@ -141,7 +141,7 @@ public class DirectQuickSelectSketchTest {
assertTrue(sk1.hasMemorySegment());
assertEquals(sk1.getCurrentPreambleLongs(), 3);
- final UpdateSketch sk2 = UpdateSketch.heapify(wseg);
+ final UpdatableThetaSketch sk2 = UpdatableThetaSketch.heapify(wseg);
assertEquals(sk2.getEstimate(), sk1est);
assertEquals(sk2.getLowerBound(2), sk1lb);
assertEquals(sk2.getUpperBound(2), sk1ub);
@@ -168,12 +168,12 @@ public class DirectQuickSelectSketchTest {
final int maxBytes = (k << 4) + (Family.QUICKSELECT.getMinPreLongs() << 3);
final MemorySegment seg = MemorySegment.ofArray(new byte[maxBytes]);
- UpdateSketch.builder().setNominalEntries(k).build(seg);
+ UpdatableThetaSketch.builder().setNominalEntries(k).build(seg);
- seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Sketch ID byte
+ seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the FamilyID byte
//try to wrap the corrupted seg
- ThetaSketch.wrap(seg); //catch in Sketch.constructDirectSketch
+ ThetaSketch.wrap(seg); //catch in ThetaSketch.constructDirectSketch
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -182,9 +182,9 @@ public class DirectQuickSelectSketchTest {
final int maxBytes = (k << 4) + (Family.QUICKSELECT.getMinPreLongs() << 3);
final MemorySegment seg = MemorySegment.ofArray(new byte[maxBytes]);
- UpdateSketch.builder().setNominalEntries(k).build(seg);
+ UpdatableThetaSketch.builder().setNominalEntries(k).build(seg);
- seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Sketch ID byte
+ seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the FamilyID byte
//try to wrap the corrupted seg
DirectQuickSelectSketch.writableWrap(seg, null, Util.DEFAULT_UPDATE_SEED);
@@ -197,7 +197,7 @@ public class DirectQuickSelectSketchTest {
final long seed2 = Util.DEFAULT_UPDATE_SEED;
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
- final UpdateSketch usk = UpdateSketch.builder().setSeed(seed1).setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setSeed(seed1).setNominalEntries(k).build(wseg);
final byte[] byteArray = usk.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(byteArray);
ThetaSketch.heapify(srcSeg, seed2);
@@ -213,7 +213,7 @@ public class DirectQuickSelectSketchTest {
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
- UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
wseg.set(JAVA_BYTE, LG_NOM_LONGS_BYTE, (byte)2); //corrupt
ThetaSketch.heapify(wseg, Util.DEFAULT_UPDATE_SEED);
} catch (final Exception e) {
@@ -228,7 +228,7 @@ public class DirectQuickSelectSketchTest {
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
for (int i=0; i< k; i++) { usk.update(i); }
@@ -260,7 +260,7 @@ public class DirectQuickSelectSketchTest {
final int u = 2*k;
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
for (int i=0; i<u; i++) { usk.update(i); }
@@ -289,7 +289,7 @@ public class DirectQuickSelectSketchTest {
final int u = 2*k; //thus estimating
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
- final UpdateSketch sk1 = UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch sk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
for (int i=0; i<u; i++) { sk1.update(i); }
final double sk1est = sk1.getEstimate();
@@ -316,7 +316,7 @@ public class DirectQuickSelectSketchTest {
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
final DirectQuickSelectSketch sk1 = (DirectQuickSelectSketch)usk; //for internal checks
assertEquals(usk.getClass().getSimpleName(), "DirectQuickSelectSketch");
@@ -335,7 +335,7 @@ public class DirectQuickSelectSketchTest {
final double uskUB = usk.getUpperBound(2);
assertTrue(usk.isEstimationMode());
- CompactSketch csk;
+ CompactThetaSketch csk;
csk = usk.compact(false, null);
assertEquals(csk.getEstimate(), uskEst);
@@ -386,7 +386,7 @@ public class DirectQuickSelectSketchTest {
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
//empty
usk.toString(false, true, 0, false); //exercise toString
@@ -401,7 +401,7 @@ public class DirectQuickSelectSketchTest {
final byte[] segArr2 = new byte[bytes];
final MemorySegment seg2 = MemorySegment.ofArray(segArr2);
- final CompactSketch csk2 = usk.compact(false, seg2);
+ final CompactThetaSketch csk2 = usk.compact(false, seg2);
assertEquals(csk2.getEstimate(), uskEst);
assertEquals(csk2.getLowerBound(2), uskLB);
assertEquals(csk2.getUpperBound(2), uskUB);
@@ -409,7 +409,7 @@ public class DirectQuickSelectSketchTest {
assertEquals(csk2.isEstimationMode(), false);
assertEquals(csk2.getClass().getSimpleName(), "DirectCompactSketch");
- final CompactSketch csk3 = usk.compact(true, seg2);
+ final CompactThetaSketch csk3 = usk.compact(true, seg2);
csk3.toString(false, true, 0, false);
csk3.toString();
assertEquals(csk3.getEstimate(), uskEst);
@@ -432,7 +432,7 @@ public class DirectQuickSelectSketchTest {
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
final DirectQuickSelectSketch sk1 = (DirectQuickSelectSketch)usk; //for internal checks
assertTrue(usk.isEmpty());
@@ -453,7 +453,7 @@ public class DirectQuickSelectSketchTest {
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
- final UpdateSketch usk = UpdateSketch.builder().setP(p).setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setP(p).setNominalEntries(k).build(wseg);
final DirectQuickSelectSketch sk1 = (DirectQuickSelectSketch)usk; //for internal checks
for (int i = 0; i < k; i++ ) { usk.update(i); }
@@ -479,7 +479,7 @@ public class DirectQuickSelectSketchTest {
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
//Exact mode
for (int i = 0; i < k; i++ ) { usk.update(i); }
@@ -515,7 +515,7 @@ public class DirectQuickSelectSketchTest {
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
- final UpdateSketch usk = UpdateSketch.builder().setP(p).setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setP(p).setNominalEntries(k).build(wseg);
DirectQuickSelectSketch sk1 = (DirectQuickSelectSketch)usk; //for internal checks
assertTrue(usk.isEmpty());
@@ -527,7 +527,7 @@ public class DirectQuickSelectSketchTest {
p = (float)0.001;
final byte[] segArr2 = new byte[(int) wseg.byteSize()];
final MemorySegment seg2 = MemorySegment.ofArray(segArr2);
- final UpdateSketch usk2 = UpdateSketch.builder().setP(p).setNominalEntries(k).build(seg2);
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setP(p).setNominalEntries(k).build(seg2);
sk1 = (DirectQuickSelectSketch)usk2;
assertTrue(usk2.isEmpty());
@@ -555,7 +555,7 @@ public class DirectQuickSelectSketchTest {
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
for (int i = 0; i < u; i++ ) { usk.update(i); }
@@ -576,7 +576,7 @@ public class DirectQuickSelectSketchTest {
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
final DirectQuickSelectSketch sk1 = (DirectQuickSelectSketch)usk; //for internal checks
assertTrue(usk.isEmpty());
@@ -605,7 +605,7 @@ public class DirectQuickSelectSketchTest {
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
final DirectQuickSelectSketch sk1 = (DirectQuickSelectSketch)usk; //for internal checks
assertTrue(usk.isEmpty());
@@ -636,7 +636,7 @@ public class DirectQuickSelectSketchTest {
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
final DirectQuickSelectSketch sk1 = (DirectQuickSelectSketch)usk; //for internal checks
assertTrue(usk.isEmpty());
@@ -657,7 +657,7 @@ public class DirectQuickSelectSketchTest {
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
final DirectQuickSelectSketch sk1 = (DirectQuickSelectSketch)usk; //for internal checks
assertTrue(usk.isEmpty());
@@ -679,7 +679,7 @@ public class DirectQuickSelectSketchTest {
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(segCapacity, arena);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
final DirectQuickSelectSketch sk1 = (DirectQuickSelectSketch)usk; //for internal checks
assertTrue(usk.isEmpty());
@@ -700,7 +700,7 @@ public class DirectQuickSelectSketchTest {
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
assertTrue(usk.isEmpty());
for (int i = 0; i< u; i++) { usk.update(i); } //force estimation
@@ -719,7 +719,7 @@ public class DirectQuickSelectSketchTest {
final MemorySegment seg2 = MemorySegment.ofArray(serArr);
//reconstruct to Native/Direct
- final UpdateSketch usk2 = UpdateSketch.wrap(seg2);
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.wrap(seg2);
est2 = usk2.getEstimate();
count2 = usk2.getRetainedEntries(false);
@@ -733,21 +733,21 @@ public class DirectQuickSelectSketchTest {
@Test(expectedExceptions = SketchesReadOnlyException.class)
public void updateAfterReadOnlyWrap() {
- final UpdateSketch usk1 = UpdateSketch.builder().build();
- final UpdateSketch usk2 = (UpdateSketch) ThetaSketch.wrap(MemorySegment.ofArray(usk1.toByteArray()));
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().build();
+ final UpdatableThetaSketch usk2 = (UpdatableThetaSketch) ThetaSketch.wrap(MemorySegment.ofArray(usk1.toByteArray()));
usk2.update(0);
}
public void updateAfterWritableWrap() {
- final UpdateSketch usk1 = UpdateSketch.builder().build();
- final UpdateSketch usk2 = UpdateSketch.wrap(MemorySegment.ofArray(usk1.toByteArray()));
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.wrap(MemorySegment.ofArray(usk1.toByteArray()));
usk2.update(0);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkNegativeHashes() {
final int k = 512;
- final UpdateSketch qs = UpdateSketch.builder().setFamily(QUICKSELECT).setNominalEntries(k).build();
+ final UpdatableThetaSketch qs = UpdatableThetaSketch.builder().setFamily(QUICKSELECT).setNominalEntries(k).build();
qs.hashUpdate(-1L);
}
@@ -760,11 +760,11 @@ public class DirectQuickSelectSketchTest {
final byte[] arr1 = new byte[bytes];
final MemorySegment seg1 = MemorySegment.ofArray(arr1);
final ResizeFactor rf = ResizeFactor.X1; //0
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).setResizeFactor(rf).build(seg1);
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).setResizeFactor(rf).build(seg1);
for (int i=0; i<u; i++) { usk1.update(i); }
//println(PreambleUtil.toString(seg1));
@SuppressWarnings("unused")
- UpdateSketch usk2;
+ UpdatableThetaSketch usk2;
seg1.set(JAVA_BYTE, FAMILY_BYTE, (byte) 3); //corrupt Family by setting to Compact
try {
usk2 = DirectQuickSelectSketch.writableWrap(seg1, null, Util.DEFAULT_UPDATE_SEED);
@@ -827,11 +827,11 @@ public class DirectQuickSelectSketchTest {
final byte[] arr = new byte[bytes];
final MemorySegment seg = MemorySegment.ofArray(arr);
final ResizeFactor rf = ResizeFactor.X8; // 3
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).setResizeFactor(rf).build(seg);
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).setResizeFactor(rf).build(seg);
usk.update(0);
insertLgResizeFactor(seg, 0); // corrupt RF: X1
- final UpdateSketch dqss = DirectQuickSelectSketch.writableWrap(seg, null, Util.DEFAULT_UPDATE_SEED);
+ final UpdatableThetaSketch dqss = DirectQuickSelectSketch.writableWrap(seg, null, Util.DEFAULT_UPDATE_SEED);
assertEquals(dqss.getResizeFactor(), ResizeFactor.X2); // force-promote to X2
}
@@ -839,7 +839,7 @@ public class DirectQuickSelectSketchTest {
public void checkFamilyAndRF() {
final int k = 16;
final MemorySegment seg = MemorySegment.ofArray(new byte[k*16 + 24]);
- final UpdateSketch sketch = UpdateSketch.builder().setNominalEntries(k).build(seg);
+ final UpdatableThetaSketch sketch = UpdatableThetaSketch.builder().setNominalEntries(k).build(seg);
assertEquals(sketch.getFamily(), Family.QUICKSELECT);
assertEquals(sketch.getResizeFactor(), ResizeFactor.X8);
}
@@ -850,7 +850,7 @@ public class DirectQuickSelectSketchTest {
final int k = 1 << 14;
final int u = 1 << 20;
final MemorySegment seg = MemorySegment.ofArray(new byte[8*k*16 +24]);
- final UpdateSketch sketch = UpdateSketch.builder().setNominalEntries(k).build(seg);
+ final UpdatableThetaSketch sketch = UpdatableThetaSketch.builder().setNominalEntries(k).build(seg);
for (int i=0; i<u; i++) { sketch.update(i); }
}
@@ -858,7 +858,7 @@ public class DirectQuickSelectSketchTest {
public void checkBadLgNomLongs() {
final int k = 16;
final MemorySegment seg = MemorySegment.ofArray(new byte[k*16 +24]);
- UpdateSketch.builder().setNominalEntries(k).build(seg);
+ UpdatableThetaSketch.builder().setNominalEntries(k).build(seg);
seg.set(JAVA_BYTE, LG_NOM_LONGS_BYTE, (byte) 3); //Corrupt LgNomLongs byte
DirectQuickSelectSketch.writableWrap(seg, null, Util.DEFAULT_UPDATE_SEED);
}
@@ -871,7 +871,7 @@ public class DirectQuickSelectSketchTest {
MemorySegment wseg;
try (Arena arena = Arena.ofConfined()) {
wseg = arena.allocate(bytes / 2);
- final UpdateSketch sketch = UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch sketch = UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
assertTrue(sketch.isSameResource(wseg));
for (int i = 0; i < u; i++) { sketch.update(i); }
assertFalse(sketch.isSameResource(wseg));
@@ -887,12 +887,12 @@ public class DirectQuickSelectSketchTest {
MemorySegment wseg;
try (Arena arena = Arena.ofConfined()) {
wseg = arena.allocate(bytes / 2);
- final UpdateSketch sketch = UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ final UpdatableThetaSketch sketch = UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
for (int i = 0; i < u; i++) { sketch.update(i); }
final double est1 = sketch.getEstimate();
final byte[] serBytes = sketch.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(serBytes).asReadOnly();
- final UpdateSketch roSketch = (UpdateSketch) ThetaSketch.wrap(seg);
+ final UpdatableThetaSketch roSketch = (UpdatableThetaSketch) 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 c488abcb4..ec4a69200 100644
--- a/src/test/java/org/apache/datasketches/theta/DirectUnionTest.java
+++ b/src/test/java/org/apache/datasketches/theta/DirectUnionTest.java
@@ -23,7 +23,7 @@ import static java.lang.foreign.ValueLayout.JAVA_BYTE;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.datasketches.theta.HeapUnionTest.testAllCompactForms;
import static org.apache.datasketches.theta.PreambleUtil.SER_VER_BYTE;
-import static org.apache.datasketches.theta.SetOperation.getMaxUnionBytes;
+import static org.apache.datasketches.theta.ThetaSetOperation.getMaxUnionBytes;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
@@ -47,8 +47,8 @@ public class DirectUnionTest {
final int k = 1 << lgK;
final int u = k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u/2; i++) {
usk1.update(i); //256
@@ -60,10 +60,10 @@ public class DirectUnionTest {
assertEquals(u, usk1.getEstimate() + usk2.getEstimate(), 0.0); //exact, no overlap
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]);
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
- union.union(usk1); //update with heap UpdateSketch
- union.union(usk2); //update with heap UpdateSketch
+ union.union(usk1); //update with heap UpdatableThetaSketch
+ union.union(usk2); //update with heap UpdatableThetaSketch
testAllCompactForms(union, u, 0.0);
}
@@ -74,8 +74,8 @@ public class DirectUnionTest {
final int k = 1 << lgK;
final int u = 4*k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u/2; i++) {
usk1.update(i); //2*k
@@ -85,10 +85,10 @@ public class DirectUnionTest {
}
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]);
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
- union.union(usk1); //update with heap UpdateSketch
- union.union(usk2); //update with heap UpdateSketch
+ union.union(usk1); //update with heap UpdatableThetaSketch
+ union.union(usk2); //update with heap UpdatableThetaSketch
testAllCompactForms(union, u, 0.05);
}
@@ -99,8 +99,8 @@ public class DirectUnionTest {
final int k = 1 << lgK;
final int u = k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u/2; i++) {
usk1.update(i); //256
@@ -112,10 +112,10 @@ public class DirectUnionTest {
assertEquals(u, usk1.getEstimate() + usk2.getEstimate()/2, 0.0); //exact, overlapped
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]);
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
- union.union(usk1); //update with heap UpdateSketch
- union.union(usk2); //update with heap UpdateSketch
+ union.union(usk1); //update with heap UpdatableThetaSketch
+ union.union(usk2); //update with heap UpdatableThetaSketch
testAllCompactForms(union, u, 0.0);
}
@@ -126,8 +126,8 @@ public class DirectUnionTest {
final int k = 1 << lgK;
final int u = k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u/2; i++) {
usk1.update(i); //256
@@ -139,14 +139,14 @@ public class DirectUnionTest {
assertEquals(u, usk1.getEstimate() + usk2.getEstimate(), 0.0); //exact, no overlap
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]);
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
- union.union(usk1); //update with heap UpdateSketch
- union.union(usk2); //update with heap UpdateSketch
+ union.union(usk1); //update with heap UpdatableThetaSketch
+ union.union(usk2); //update with heap UpdatableThetaSketch
testAllCompactForms(union, u, 0.0);
- final Union union2 = (Union)SetOperation.heapify(MemorySegment.ofArray(union.toByteArray()));
+ final ThetaUnion union2 = (ThetaUnion)ThetaSetOperation.heapify(MemorySegment.ofArray(union.toByteArray()));
testAllCompactForms(union2, u, 0.0);
}
@@ -158,8 +158,8 @@ public class DirectUnionTest {
final int k = 1 << lgK;
final int u = k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u/2; i++) {
usk1.update(i); //256
@@ -171,14 +171,14 @@ public class DirectUnionTest {
assertEquals(u, usk1.getEstimate() + usk2.getEstimate(), 0.0); //exact, no overlap
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]);
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
- union.union(usk1); //update with heap UpdateSketch
- union.union(usk2); //update with heap UpdateSketch
+ union.union(usk1); //update with heap UpdatableThetaSketch
+ union.union(usk2); //update with heap UpdatableThetaSketch
testAllCompactForms(union, u, 0.0);
- final Union union2 = Union.wrap(MemorySegment.ofArray(union.toByteArray()));
+ final ThetaUnion union2 = ThetaUnion.wrap(MemorySegment.ofArray(union.toByteArray()));
testAllCompactForms(union2, u, 0.0);
}
@@ -189,8 +189,8 @@ public class DirectUnionTest {
final int k = 1 << lgK;
final int u = 4*k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build(); //2k estimating
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(2 * k).build(); //2k exact
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build(); //2k estimating
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(2 * k).build(); //2k exact
for (int i=0; i<u/2; i++) {
usk1.update(i); //2k
@@ -200,14 +200,14 @@ public class DirectUnionTest {
}
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]);
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
- union.union(usk1); //update with heap UpdateSketch
- union.union(usk2); //update with heap UpdateSketch, early stop not possible
+ union.union(usk1); //update with heap UpdatableThetaSketch
+ union.union(usk2); //update with heap UpdatableThetaSketch, early stop not possible
testAllCompactForms(union, u, 0.05);
- final Union union2 = Union.wrap(MemorySegment.ofArray(union.toByteArray()));
+ final ThetaUnion union2 = ThetaUnion.wrap(MemorySegment.ofArray(union.toByteArray()));
testAllCompactForms(union2, u, 0.05);
}
@@ -218,8 +218,8 @@ public class DirectUnionTest {
final int k = 1 << lgK;
final int u = 4*k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build(); //2k estimating
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build(); //2k estimating
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
for (int i=0; i<u/2; i++) {
usk1.update(i); //2k estimating
@@ -228,22 +228,22 @@ public class DirectUnionTest {
usk2.update(i); //2k no overlap, exact, will force early stop
}
- final CompactSketch cosk2 = usk2.compact(true, null);
+ final CompactThetaSketch cosk2 = usk2.compact(true, null);
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]);
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
- union.union(usk1); //update with heap UpdateSketch
+ union.union(usk1); //update with heap UpdatableThetaSketch
union.union(cosk2); //update with heap Compact, Ordered input, early stop
- UpdateSketch emptySketch = UpdateSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch emptySketch = UpdatableThetaSketch.builder().setNominalEntries(k).build();
union.union(emptySketch); //updates with empty
emptySketch = null;
union.union(emptySketch); //updates with null
testAllCompactForms(union, u, 0.05);
- final Union union2 = Union.wrap(MemorySegment.ofArray(union.toByteArray()));
+ final ThetaUnion union2 = ThetaUnion.wrap(MemorySegment.ofArray(union.toByteArray()));
testAllCompactForms(union2, u, 0.05);
@@ -257,8 +257,8 @@ public class DirectUnionTest {
final int k = 1 << lgK;
final int u = 4*k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build(); //2k estimating
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build(); //2k estimating
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
for (int i=0; i<u/2; i++) {
usk1.update(i); //2k estimating
@@ -268,22 +268,22 @@ public class DirectUnionTest {
}
final MemorySegment cskSeg2 = MemorySegment.ofArray(new byte[usk2.getCompactBytes()]);
- final CompactSketch cosk2 = usk2.compact(true, cskSeg2); //ordered, loads the cskSeg2 as ordered
+ final CompactThetaSketch cosk2 = usk2.compact(true, cskSeg2); //ordered, loads the cskSeg2 as ordered
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]); //union segment
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
- union.union(usk1); //updates with heap UpdateSketch
- union.union(cosk2); //updates with direct CompactSketch, ordered, use early stop
+ union.union(usk1); //updates with heap UpdatableThetaSketch
+ union.union(cosk2); //updates with direct CompactThetaSketch, ordered, use early stop
- UpdateSketch emptySketch = UpdateSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch emptySketch = UpdatableThetaSketch.builder().setNominalEntries(k).build();
union.union(emptySketch); //updates with empty sketch
emptySketch = null;
union.union(emptySketch); //updates with null sketch
testAllCompactForms(union, u, 0.05);
- final Union union2 = Union.wrap(MemorySegment.ofArray(union.toByteArray()));
+ final ThetaUnion union2 = ThetaUnion.wrap(MemorySegment.ofArray(union.toByteArray()));
testAllCompactForms(union2, u, 0.05);
@@ -297,8 +297,8 @@ public class DirectUnionTest {
final int k = 1 << lgK;
final int u = 4*k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build(); //2k estimating
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build(); //2k estimating
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
for (int i=0; i<u/2; i++) {
usk1.update(i); //2k estimating
@@ -311,19 +311,19 @@ public class DirectUnionTest {
usk2.compact(true, cskSeg2); //ordered, loads the cskSeg2 as ordered
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]); //union segment
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
- union.union(usk1); //updates with heap UpdateSketch
- union.union(cskSeg2); //updates with direct CompactSketch, ordered, use early stop
+ union.union(usk1); //updates with heap UpdatableThetaSketch
+ union.union(cskSeg2); //updates with direct CompactThetaSketch, ordered, use early stop
- UpdateSketch emptySketch = UpdateSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch emptySketch = UpdatableThetaSketch.builder().setNominalEntries(k).build();
union.union(emptySketch); //updates with empty sketch
emptySketch = null;
union.union(emptySketch); //updates with null sketch
testAllCompactForms(union, u, 0.05);
- final Union union2 = Union.wrap(MemorySegment.ofArray(union.toByteArray()));
+ final ThetaUnion union2 = ThetaUnion.wrap(MemorySegment.ofArray(union.toByteArray()));
testAllCompactForms(union2, u, 0.05);
@@ -337,8 +337,8 @@ public class DirectUnionTest {
final int k = 1 << lgK;
final int u = 4*k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build(); //2k estimating
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build(); //2k estimating
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
for (int i=0; i<u/2; i++) {
usk1.update(i); //2k estimating
@@ -351,19 +351,19 @@ public class DirectUnionTest {
usk2.compact(false, cskSeg2); //unordered, loads the cskSeg2 as unordered
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]); //union segment
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
- union.union(usk1); //updates with heap UpdateSketch
- union.union(cskSeg2); //updates with direct CompactSketch, ordered, use early stop
+ union.union(usk1); //updates with heap UpdatableThetaSketch
+ union.union(cskSeg2); //updates with direct CompactThetaSketch, ordered, use early stop
- UpdateSketch emptySketch = UpdateSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch emptySketch = UpdatableThetaSketch.builder().setNominalEntries(k).build();
union.union(emptySketch); //updates with empty sketch
emptySketch = null;
union.union(emptySketch); //updates with null sketch
testAllCompactForms(union, u, 0.05);
- final Union union2 = Union.wrap(MemorySegment.ofArray(union.toByteArray()));
+ final ThetaUnion union2 = ThetaUnion.wrap(MemorySegment.ofArray(union.toByteArray()));
testAllCompactForms(union2, u, 0.05);
@@ -376,10 +376,10 @@ public class DirectUnionTest {
final int lgK = 13; //8192
final int k = 1 << lgK;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk3 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk4 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk3 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk4 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
int v=0;
int u = 1000000;
@@ -402,14 +402,14 @@ public class DirectUnionTest {
v += u;
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]); //union segment
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
- union.union(usk1); //updates with heap UpdateSketch
- union.union(usk2); //updates with heap UpdateSketch
- union.union(usk3); //updates with heap UpdateSketch
- union.union(usk4); //updates with heap UpdateSketch
+ union.union(usk1); //updates with heap UpdatableThetaSketch
+ union.union(usk2); //updates with heap UpdatableThetaSketch
+ union.union(usk3); //updates with heap UpdatableThetaSketch
+ union.union(usk4); //updates with heap UpdatableThetaSketch
- final CompactSketch csk = union.getResult(true, null);
+ final CompactThetaSketch csk = union.getResult(true, null);
final double est = csk.getEstimate();
assertEquals(est, v, .01*v);
}
@@ -422,8 +422,8 @@ public class DirectUnionTest {
final int u2 = 1024; //smaller exact sketch forces early stop
final int totU = u1+u2;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u1; i++) {
usk1.update(i); //2*k
@@ -435,16 +435,16 @@ public class DirectUnionTest {
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)ThetaSketch.wrap(skSeg1);
- final CompactSketch csk2 = (CompactSketch)ThetaSketch.wrap(skSeg2);
+ final CompactThetaSketch csk1 = (CompactThetaSketch)ThetaSketch.wrap(skSeg1);
+ final CompactThetaSketch csk2 = (CompactThetaSketch)ThetaSketch.wrap(skSeg2);
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]); //union segment
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
union.union(csk1);
union.union(csk2);
- final CompactSketch cOut = union.getResult(true, null);
+ final CompactThetaSketch cOut = union.getResult(true, null);
assertEquals(cOut.getEstimate(), totU, .05*k);
}
@@ -454,16 +454,16 @@ public class DirectUnionTest {
final int k = 1 << lgK;
final int u = 2*k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u; i++)
{
usk1.update(i); //force prelongs to 3
}
- final CompactSketch usk1c = usk1.compact(true, null);
+ final CompactThetaSketch usk1c = usk1.compact(true, null);
final MemorySegment v3seg1 = MemorySegment.ofArray(usk1c.toByteArray());
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]); //union segment
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
union.union(v3seg1);
}
@@ -472,16 +472,16 @@ public class DirectUnionTest {
final int lgK = 12; //4096
final int k = 1 << lgK;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
usk1.update(1);
usk1.update(2);
- final CompactSketch usk1c = usk1.compact(true, null);
+ final CompactThetaSketch usk1c = usk1.compact(true, null);
final MemorySegment v3seg1 = MemorySegment.ofArray(usk1c.toByteArray());
//corrupt SerVer
v3seg1.set(JAVA_BYTE, SER_VER_BYTE, (byte)0);
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]); //union segment
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
union.union(v3seg1);
}
@@ -491,23 +491,23 @@ public class DirectUnionTest {
public void checkDirectWrap() {
final int nomEntries = 16;
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(nomEntries)]);
- SetOperation.builder().setNominalEntries(nomEntries).buildUnion(uSeg);
+ ThetaSetOperation.builder().setNominalEntries(nomEntries).buildUnion(uSeg);
- final UpdateSketch sk1 = UpdateSketch.builder().setNominalEntries(nomEntries).build();
+ final UpdatableThetaSketch sk1 = UpdatableThetaSketch.builder().setNominalEntries(nomEntries).build();
sk1.update("a");
sk1.update("b");
- final UpdateSketch sk2 = UpdateSketch.builder().setNominalEntries(nomEntries).build();
+ final UpdatableThetaSketch sk2 = UpdatableThetaSketch.builder().setNominalEntries(nomEntries).build();
sk2.update("c");
sk2.update("d");
- Union union = Union.wrap(uSeg);
+ ThetaUnion union = ThetaUnion.wrap(uSeg);
union.union(sk1);
- union = Union.wrap(uSeg);
+ union = ThetaUnion.wrap(uSeg);
union.union(sk2);
- final CompactSketch sketch = union.getResult(true, null);
+ final CompactThetaSketch sketch = union.getResult(true, null);
assertEquals(4.0, sketch.getEstimate(), 0.0);
}
@@ -516,10 +516,10 @@ public class DirectUnionTest {
final int k = 64;
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]); //union segment
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
final MemorySegment seg = MemorySegment.ofArray(new byte[ThetaSketch.getMaxCompactSketchBytes(0)]);
- final CompactSketch csk = union.getResult(false, seg); //DirectCompactSketch
+ final CompactThetaSketch csk = union.getResult(false, seg); //DirectCompactSketch
assertTrue(csk.isEmpty());
}
@@ -528,10 +528,10 @@ public class DirectUnionTest {
final int k = 64;
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]); //union segment
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
final MemorySegment seg = MemorySegment.ofArray(new byte[ThetaSketch.getMaxCompactSketchBytes(0)]);
- final CompactSketch csk = union.getResult(true, seg); //DirectCompactSketch
+ final CompactThetaSketch csk = union.getResult(true, seg); //DirectCompactSketch
assertTrue(csk.isEmpty());
}
@@ -540,21 +540,21 @@ public class DirectUnionTest {
final int k = 64;
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]); //union segment
- SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
+ ThetaSetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
}
@Test
public void checkGetResult() {
final int k = 1024;
- final UpdateSketch sk = UpdateSketch.builder().build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().build();
final int segBytes = getMaxUnionBytes(k);
final byte[] segArr = new byte[segBytes];
final MemorySegment iSeg = MemorySegment.ofArray(segArr);
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(iSeg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(iSeg);
union.union(sk);
- final CompactSketch csk = union.getResult();
+ final CompactThetaSketch csk = union.getResult();
assertEquals(csk.getCompactBytes(), 8);
}
@@ -562,7 +562,7 @@ public class DirectUnionTest {
public void checkPrimitiveUpdates() {
final int k = 32;
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]);
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
union.update(1L);
union.update(1.5); //#1 double
@@ -594,7 +594,7 @@ public class DirectUnionTest {
union.update(longArr); //empty long[]
final long[] longArr2 = { 6, 7, 8, 9 };
union.update(longArr2); //#6 actual long[]
- final CompactSketch comp = union.getResult();
+ final CompactThetaSketch comp = union.getResult();
final double est = comp.getEstimate();
final boolean empty = comp.isEmpty();
assertEquals(est, 8.0, 0.0);
@@ -605,7 +605,7 @@ public class DirectUnionTest {
public void checkGetFamily() {
final int k = 16;
final MemorySegment seg = MemorySegment.ofArray(new byte[k*16 +32]);
- final SetOperation setOp = new SetOperationBuilder().setNominalEntries(k).build(Family.UNION, seg);
+ final ThetaSetOperation setOp = new ThetaSetOperationBuilder().setNominalEntries(k).build(Family.UNION, seg);
assertEquals(setOp.getFamily(), Family.UNION);
}
@@ -614,7 +614,7 @@ public class DirectUnionTest {
final int k = 16;
final MemorySegment seg = MemorySegment.ofArray(new byte[k*16 +32]);
- final SetOperation setOp = new SetOperationBuilder().setNominalEntries(k).build(Family.UNION, seg);
+ final ThetaSetOperation setOp = new ThetaSetOperationBuilder().setNominalEntries(k).build(Family.UNION, seg);
println(setOp.toString());
final int familyID = PreambleUtil.extractFamilyID(seg);
final int preLongs = ThetaSketch.getPreambleLongs(seg);
@@ -628,7 +628,7 @@ public class DirectUnionTest {
public void checkSizeTooSmall() {
final int k = 16;
final MemorySegment seg = MemorySegment.ofArray(new byte[k*16 +32]); //initialized
- final SetOperation setOp = new SetOperationBuilder().setNominalEntries(k).build(Family.UNION, seg);
+ final ThetaSetOperation setOp = new ThetaSetOperationBuilder().setNominalEntries(k).build(Family.UNION, seg);
println(setOp.toString());
final MemorySegment seg2 = MemorySegment.ofArray(new byte[32]); //for just preamble
MemorySegment.copy(seg, 0, seg2, 0, 32); //too small
@@ -638,7 +638,7 @@ public class DirectUnionTest {
@Test
public void checkForDruidBug() {
final int k = 16384;
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i = 0; i < 100000; i++) {
usk.update(Integer.toString(i));
}
@@ -648,11 +648,11 @@ public class DirectUnionTest {
//create empty target union in off-heap segment
final MemorySegment seg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]);
- final Union union1 = SetOperation.builder().setNominalEntries(k).buildUnion(seg);
+ final ThetaUnion union1 = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(seg);
union1.union(s);
- final CompactSketch csk = union1.getResult();
+ final CompactThetaSketch csk = union1.getResult();
assertTrue(csk.getTheta() < 0.2);
assertEquals(csk.getRetainedEntries(true), 16384);
@@ -664,7 +664,7 @@ public class DirectUnionTest {
@Test
public void checkForDruidBug2() { //update union with just sketch segment reference
final int k = 16384;
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i = 0; i < 100000; i++) {
usk.update(Integer.toString(i));
}
@@ -674,11 +674,11 @@ public class DirectUnionTest {
//create empty target union in off-heap segment
final MemorySegment seg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]);
- final Union union1 = SetOperation.builder().setNominalEntries(k).buildUnion(seg);
+ final ThetaUnion union1 = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(seg);
union1.union(segIn);
- final CompactSketch csk = union1.getResult();
+ final CompactThetaSketch csk = union1.getResult();
assertTrue(csk.getTheta() < 0.2);
assertEquals(csk.getRetainedEntries(true), 16384);
diff --git a/src/test/java/org/apache/datasketches/theta/EmptyTest.java b/src/test/java/org/apache/datasketches/theta/EmptyTest.java
index 665330eee..fec264b26 100644
--- a/src/test/java/org/apache/datasketches/theta/EmptyTest.java
+++ b/src/test/java/org/apache/datasketches/theta/EmptyTest.java
@@ -36,9 +36,9 @@ public class EmptyTest {
@Test
public void checkEmpty() {
- final UpdateSketch sk1 = UpdateSketch.builder().build();
- final UpdateSketch sk2 = UpdateSketch.builder().build();
- final Intersection inter = SetOperation.builder().buildIntersection();
+ final UpdatableThetaSketch sk1 = UpdatableThetaSketch.builder().build();
+ final UpdatableThetaSketch sk2 = UpdatableThetaSketch.builder().build();
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
final int u = 100;
for (int i = 0; i < u; i++) { //disjoint
@@ -48,22 +48,22 @@ public class EmptyTest {
inter.intersect(sk1);
inter.intersect(sk2);
- final CompactSketch csk = inter.getResult();
+ final CompactThetaSketch csk = inter.getResult();
//The intersection of two disjoint, exact-mode sketches is empty, T == 1.0.
println(csk.toString());
assertTrue(csk.isEmpty());
- final AnotB aNotB = SetOperation.builder().buildANotB();
- final CompactSketch csk2 = aNotB.aNotB(csk, sk1);
- //The AnotB of an empty, T == 1.0 sketch with another exact-mode sketch is empty, T == 1.0
+ final ThetaAnotB aNotB = ThetaSetOperation.builder().buildANotB();
+ final CompactThetaSketch csk2 = aNotB.aNotB(csk, sk1);
+ //The ThetaAnotB of an empty, T == 1.0 sketch with another exact-mode sketch is empty, T == 1.0
assertTrue(csk2.isEmpty());
}
@Test
public void checkNotEmpty() {
- final UpdateSketch sk1 = UpdateSketch.builder().build();
- final UpdateSketch sk2 = UpdateSketch.builder().build();
- final Intersection inter = SetOperation.builder().buildIntersection();
+ final UpdatableThetaSketch sk1 = UpdatableThetaSketch.builder().build();
+ final UpdatableThetaSketch sk2 = UpdatableThetaSketch.builder().build();
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
final int u = 10000; //estimating
for (int i = 0; i < u; i++) { //disjoint
@@ -73,28 +73,28 @@ public class EmptyTest {
inter.intersect(sk1);
inter.intersect(sk2);
- final CompactSketch csk = inter.getResult();
+ final CompactThetaSketch csk = inter.getResult();
println(csk.toString());
//The intersection of two disjoint, est-mode sketches is not-empty, T < 1.0.
assertFalse(csk.isEmpty());
- AnotB aNotB = SetOperation.builder().buildANotB();
- final CompactSketch csk2 = aNotB.aNotB(csk, sk1); //empty, T < 1.0; with est-mode sketch
+ ThetaAnotB aNotB = ThetaSetOperation.builder().buildANotB();
+ final CompactThetaSketch csk2 = aNotB.aNotB(csk, sk1); //empty, T < 1.0; with est-mode sketch
println(csk2.toString());
- //The AnotB of an empty, T < 1.0 sketch with another exact-mode sketch is not-empty.
+ //The ThetaAnotB of an empty, T < 1.0 sketch with another exact-mode sketch is not-empty.
assertFalse(csk2.isEmpty());
- final UpdateSketch sk3 = UpdateSketch.builder().build();
- aNotB = SetOperation.builder().buildANotB();
- final CompactSketch csk3 = aNotB.aNotB(sk3, sk1); //empty, T == 1.0; with est-mode sketch
+ final UpdatableThetaSketch sk3 = UpdatableThetaSketch.builder().build();
+ aNotB = ThetaSetOperation.builder().buildANotB();
+ final CompactThetaSketch csk3 = aNotB.aNotB(sk3, sk1); //empty, T == 1.0; with est-mode sketch
println(csk3.toString());
- //the AnotB of an empty, T == 1.0 sketch with another est-mode sketch is empty, T < 1.0
+ //the ThetaAnotB of an empty, T == 1.0 sketch with another est-mode sketch is empty, T < 1.0
assertTrue(csk3.isEmpty());
}
@Test
public void checkPsampling() {
- final UpdateSketch sk1 = UpdateSketch.builder().setP(.5F).build();
+ final UpdatableThetaSketch sk1 = UpdatableThetaSketch.builder().setP(.5F).build();
assertTrue(sk1.isEmpty());
//An empty P-sampling sketch where T < 1.0 and has never seen data is also empty
// and will have a full preamble of 24 bytes. But when compacted, theta returns to 1.0, so
@@ -104,12 +104,12 @@ public class EmptyTest {
@Test
public void checkEmptyToCompact() {
- final UpdateSketch sk1 = UpdateSketch.builder().build();
- final CompactSketch csk = sk1.compact();
+ final UpdatableThetaSketch sk1 = UpdatableThetaSketch.builder().build();
+ final CompactThetaSketch csk = sk1.compact();
assertTrue(csk instanceof EmptyCompactSketch);
- final CompactSketch csk2 = csk.compact();
+ final CompactThetaSketch csk2 = csk.compact();
assertTrue(csk2 instanceof EmptyCompactSketch);
- final CompactSketch csk3 = csk.compact(true, MemorySegment.ofArray(new byte[8]));
+ final CompactThetaSketch csk3 = csk.compact(true, MemorySegment.ofArray(new byte[8]));
assertTrue(csk3 instanceof DirectCompactSketch);
assertEquals(csk2.getCurrentPreambleLongs(), 1);
}
diff --git a/src/test/java/org/apache/datasketches/theta/ExamplesTest.java b/src/test/java/org/apache/datasketches/theta/ExamplesTest.java
index ee740eab9..8143597a4 100644
--- a/src/test/java/org/apache/datasketches/theta/ExamplesTest.java
+++ b/src/test/java/org/apache/datasketches/theta/ExamplesTest.java
@@ -19,13 +19,6 @@
package org.apache.datasketches.theta;
-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.Union;
-import org.apache.datasketches.theta.UpdateSketch;
-import org.apache.datasketches.theta.UpdateSketchBuilder;
import org.testng.annotations.Test;
/**
@@ -38,7 +31,7 @@ public class ExamplesTest {
final int k = 4096;
final int u = 1000000;
- final UpdateSketch sketch = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch sketch = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i = 0; i < u; i++) {
sketch.update(i);
}
@@ -68,47 +61,47 @@ public class ExamplesTest {
@Test
public void theta2dot0Examples() {
//Load source sketches
- final UpdateSketchBuilder bldr = UpdateSketch.builder();
- final UpdateSketch skA = bldr.build();
- final UpdateSketch skB = bldr.build();
+ final UpdateSketchBuilder bldr = UpdatableThetaSketch.builder();
+ final UpdatableThetaSketch skA = bldr.build();
+ final UpdatableThetaSketch skB = bldr.build();
for (int i = 1; i <= 1000; i++) {
skA.update(i);
skB.update(i + 250);
}
- //Union Stateless:
- Union union = SetOperation.builder().buildUnion();
- CompactSketch csk = union.union(skA, skB);
+ //ThetaUnion Stateless:
+ ThetaUnion union = ThetaSetOperation.builder().buildUnion();
+ CompactThetaSketch csk = union.union(skA, skB);
assert csk.getEstimate() == 1250;
- //Union Stateful:
- union = SetOperation.builder().buildUnion();
+ //ThetaUnion Stateful:
+ union = ThetaSetOperation.builder().buildUnion();
union.union(skA); //first call
union.union(skB); //2nd through nth calls
//...
csk = union.getResult();
assert csk.getEstimate() == 1250;
- //Intersection Stateless:
- Intersection inter = SetOperation.builder().buildIntersection();
+ //ThetaIntersection Stateless:
+ ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
csk = inter.intersect(skA, skB);
assert csk.getEstimate() == 750;
- //Intersection Stateful:
- inter = SetOperation.builder().buildIntersection();
+ //ThetaIntersection Stateful:
+ inter = ThetaSetOperation.builder().buildIntersection();
inter.intersect(skA); //first call
inter.intersect(skB); //2nd through nth calls
//...
csk = inter.getResult();
assert csk.getEstimate() == 750;
- //AnotB Stateless:
- AnotB diff = SetOperation.builder().buildANotB();
+ //ThetaAnotB Stateless:
+ ThetaAnotB diff = ThetaSetOperation.builder().buildANotB();
csk = diff.aNotB(skA, skB);
assert csk.getEstimate() == 250;
- //AnotB Stateful:
- diff = SetOperation.builder().buildANotB();
+ //ThetaAnotB Stateful:
+ diff = ThetaSetOperation.builder().buildANotB();
diff.setA(skA); //first call
diff.notB(skB); //2nd through nth calls
//...
diff --git a/src/test/java/org/apache/datasketches/theta/HeapAlphaSketchTest.java b/src/test/java/org/apache/datasketches/theta/HeapAlphaSketchTest.java
index 38fc8f629..04fd8927c 100644
--- a/src/test/java/org/apache/datasketches/theta/HeapAlphaSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/HeapAlphaSketchTest.java
@@ -60,7 +60,7 @@ public class HeapAlphaSketchTest {
int k = 512;
int u = k;
long seed = Util.DEFAULT_UPDATE_SEED;
- UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setSeed(seed)
+ UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setSeed(seed)
.setNominalEntries(k).build();
HeapAlphaSketch sk1 = (HeapAlphaSketch)usk; //for internal checks
@@ -84,13 +84,13 @@ public class HeapAlphaSketchTest {
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkConstructorKtooSmall() {
int k = 256;
- UpdateSketch.builder().setFamily(fam_).setNominalEntries(k).build();
+ UpdatableThetaSketch.builder().setFamily(fam_).setNominalEntries(k).build();
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkAlphaIncompatibleWithSeg() {
MemorySegment seg = MemorySegment.ofArray(new byte[(512*16)+24]);
- UpdateSketch.builder().setFamily(Family.ALPHA).setNominalEntries(512).build(seg);
+ UpdatableThetaSketch.builder().setFamily(Family.ALPHA).setNominalEntries(512).build(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -98,7 +98,7 @@ public class HeapAlphaSketchTest {
int k = 512;
int u = k;
long seed = Util.DEFAULT_UPDATE_SEED;
- UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setSeed(seed)
+ UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setSeed(seed)
.setNominalEntries(k).build();
HeapAlphaSketch sk1 = (HeapAlphaSketch)usk; //for internal checks
assertTrue(usk.isEmpty());
@@ -112,7 +112,7 @@ public class HeapAlphaSketchTest {
assertEquals(sk1.getRetainedEntries(false), u);
byte[] byteArray = usk.toByteArray();
MemorySegment seg = MemorySegment.ofArray(byteArray);
- seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Sketch ID byte
+ seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the FamilyID byte
//try to heapify the corrupted seg
ThetaSketch.heapify(seg, seed);
@@ -123,7 +123,7 @@ public class HeapAlphaSketchTest {
int k = 512;
long seed1 = 1021;
long seed2 = Util.DEFAULT_UPDATE_SEED;
- UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setSeed(seed1)
+ UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setSeed(seed1)
.setNominalEntries(k).build();
byte[] byteArray = usk.toByteArray();
MemorySegment srcSeg = MemorySegment.ofArray(byteArray).asReadOnly();
@@ -135,7 +135,7 @@ public class HeapAlphaSketchTest {
int k = 512;
int u = k;
long seed = Util.DEFAULT_UPDATE_SEED;
- UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setSeed(seed)
+ UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setSeed(seed)
.setNominalEntries(k).build();
for (int i=0; i<u; i++) {
@@ -147,7 +147,7 @@ public class HeapAlphaSketchTest {
assertEquals(bytes, byteArray.length);
MemorySegment srcSeg = MemorySegment.ofArray(byteArray);
- UpdateSketch usk2 = (UpdateSketch)ThetaSketch.heapify(srcSeg, seed);
+ UpdatableThetaSketch usk2 = (UpdatableThetaSketch)ThetaSketch.heapify(srcSeg, seed);
assertEquals(usk2.getEstimate(), u, 0.0);
assertEquals(usk2.getLowerBound(2), u, 0.0);
assertEquals(usk2.getUpperBound(2), u, 0.0);
@@ -163,7 +163,7 @@ public class HeapAlphaSketchTest {
int u = 2*k;
long seed = Util.DEFAULT_UPDATE_SEED;
- UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setSeed(seed)
+ UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setSeed(seed)
.setNominalEntries(k).build();
for (int i=0; i<u; i++) {
@@ -177,7 +177,7 @@ public class HeapAlphaSketchTest {
byte[] byteArray = usk.toByteArray();
MemorySegment srcSeg = MemorySegment.ofArray(byteArray).asReadOnly();
- UpdateSketch usk2 = (UpdateSketch)ThetaSketch.heapify(srcSeg, seed);
+ UpdatableThetaSketch usk2 = (UpdatableThetaSketch)ThetaSketch.heapify(srcSeg, seed);
assertEquals(usk2.getEstimate(), uskEst);
assertEquals(usk2.getLowerBound(2), uskLB);
assertEquals(usk2.getUpperBound(2), uskUB);
@@ -193,7 +193,7 @@ public class HeapAlphaSketchTest {
long seed = Util.DEFAULT_UPDATE_SEED;
//int maxBytes = (k << 4) + (Family.ALPHA.getLowPreLongs());
- UpdateSketch sk1 = UpdateSketch.builder().setFamily(fam_).setSeed(seed)
+ UpdatableThetaSketch sk1 = UpdatableThetaSketch.builder().setFamily(fam_).setSeed(seed)
.setNominalEntries(k).build();
for (int i=0; i<u; i++) {
@@ -208,7 +208,7 @@ public class HeapAlphaSketchTest {
byte[] byteArray = sk1.toByteArray();
MemorySegment seg = MemorySegment.ofArray(byteArray).asReadOnly();
- UpdateSketch sk2 = (UpdateSketch)ThetaSketch.heapify(seg, Util.DEFAULT_UPDATE_SEED);
+ UpdatableThetaSketch sk2 = (UpdatableThetaSketch)ThetaSketch.heapify(seg, Util.DEFAULT_UPDATE_SEED);
assertEquals(sk2.getEstimate(), sk1est);
assertEquals(sk2.getLowerBound(2), sk1lb);
@@ -223,7 +223,7 @@ public class HeapAlphaSketchTest {
int k = 512;
int u = 4*k; //thus estimating
- UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setNominalEntries(k).build();
+ UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setNominalEntries(k).build();
HeapAlphaSketch sk1 = (HeapAlphaSketch)usk; //for internal checks
assertEquals(usk.getClass().getSimpleName(), "HeapAlphaSketch");
@@ -237,7 +237,7 @@ public class HeapAlphaSketchTest {
// so cannot be directly compared to the compact forms
assertTrue(usk.isEstimationMode());
- CompactSketch comp1, comp2, comp3, comp4;
+ CompactThetaSketch comp1, comp2, comp3, comp4;
comp1 = usk.compact(false, null);
@@ -299,7 +299,7 @@ public class HeapAlphaSketchTest {
public void checkAlphaToCompactEmptyForms() {
int k = 512;
- UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setNominalEntries(k).build();
+ UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setNominalEntries(k).build();
//empty
usk.toString(false, true, 0, false);
@@ -315,7 +315,7 @@ public class HeapAlphaSketchTest {
byte[] segArr2 = new byte[bytes];
MemorySegment seg2 = MemorySegment.ofArray(segArr2);
- CompactSketch csk2 = usk.compact(false, seg2);
+ CompactThetaSketch csk2 = usk.compact(false, seg2);
assertEquals(csk2.getEstimate(), uskEst);
assertEquals(csk2.getLowerBound(2), uskLB);
assertEquals(csk2.getUpperBound(2), uskUB);
@@ -323,7 +323,7 @@ public class HeapAlphaSketchTest {
assertEquals(csk2.isEstimationMode(), estimating);
assertTrue(csk2.isOrdered());
- CompactSketch csk3 = usk.compact(true, seg2);
+ CompactThetaSketch csk3 = usk.compact(true, seg2);
csk3.toString(false, true, 0, false);
csk3.toString();
assertEquals(csk3.getEstimate(), uskEst);
@@ -339,7 +339,7 @@ public class HeapAlphaSketchTest {
int k = 4096;
int u = 4096;
- UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setNominalEntries(k).build();
+ UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setNominalEntries(k).build();
HeapAlphaSketch sk1 = (HeapAlphaSketch)usk; //for internal checks
assertTrue(usk.isEmpty());
@@ -356,7 +356,7 @@ public class HeapAlphaSketchTest {
public void checkEstMode() {
int k = 4096;
int u = 2*k;
- UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setResizeFactor(ResizeFactor.X4)
+ UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setResizeFactor(ResizeFactor.X4)
.setNominalEntries(k).build();
HeapAlphaSketch sk1 = (HeapAlphaSketch)usk; //for internal checks
@@ -375,7 +375,7 @@ public class HeapAlphaSketchTest {
int u = k;
float p = (float)0.5;
- UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setP(p)
+ UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setP(p)
.setNominalEntries(k).build();
HeapAlphaSketch sk1 = (HeapAlphaSketch)usk; //for internal checks
@@ -400,7 +400,7 @@ public class HeapAlphaSketchTest {
public void checkErrorBounds() {
int k = 512;
- UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setResizeFactor(X1)
+ UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setResizeFactor(X1)
.setNominalEntries(k).build();
//Exact mode
@@ -433,7 +433,7 @@ public class HeapAlphaSketchTest {
//virgin, p = 1.0
int k = 1024;
- UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setNominalEntries(k).build();
+ UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setNominalEntries(k).build();
HeapAlphaSketch sk1 = (HeapAlphaSketch)usk; //for internal checks
assertTrue(usk.isEmpty());
@@ -442,7 +442,7 @@ public class HeapAlphaSketchTest {
assertFalse(usk.isEmpty());
//virgin, p = .001
- UpdateSketch usk2 = UpdateSketch.builder().setFamily(fam_).setP((float)0.001)
+ UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setFamily(fam_).setP((float)0.001)
.setNominalEntries(k).build();
sk1 = (HeapAlphaSketch)usk2;
assertTrue(usk2.isEmpty());
@@ -465,7 +465,7 @@ public class HeapAlphaSketchTest {
int k = 512;
int u = 2*k;
- UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setResizeFactor(X2)
+ UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setResizeFactor(X2)
.setNominalEntries(k).build();
for (int i = 0; i < u; i++ ) {
@@ -484,7 +484,7 @@ public class HeapAlphaSketchTest {
int k = 512;
int u = 4*k;
- UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setNominalEntries(k).build();
+ UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setNominalEntries(k).build();
HeapAlphaSketch sk1 = (HeapAlphaSketch)usk; //for internal checks
assertTrue(usk.isEmpty());
@@ -508,7 +508,7 @@ public class HeapAlphaSketchTest {
int k = 1024;
int u = 4*k;
- UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setResizeFactor(X8)
+ UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setResizeFactor(X8)
.setNominalEntries(k).build();
HeapAlphaSketch sk1 = (HeapAlphaSketch)usk; //for internal checks
@@ -524,7 +524,7 @@ public class HeapAlphaSketchTest {
int subMul = ThetaUtil.startingSubMultiple(11, rf.lg(), 5);
assertEquals(sk1.getLgArrLongs(), subMul);
- UpdateSketch usk2 = UpdateSketch.builder().setFamily(fam_)
+ UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setFamily(fam_)
.setResizeFactor(ResizeFactor.X1).setNominalEntries(k).build();
sk1 = (HeapAlphaSketch)usk2;
@@ -545,35 +545,35 @@ public class HeapAlphaSketchTest {
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkLBlimits0() {
int k = 512;
- ThetaSketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ ThetaSketch alpha = UpdatableThetaSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
alpha.getLowerBound(0);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkUBlimits0() {
int k = 512;
- ThetaSketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ ThetaSketch alpha = UpdatableThetaSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
alpha.getUpperBound(0);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkLBlimits4() {
int k = 512;
- ThetaSketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ ThetaSketch alpha = UpdatableThetaSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
alpha.getLowerBound(4);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkUBlimits4() {
int k = 512;
- ThetaSketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ ThetaSketch alpha = UpdatableThetaSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
alpha.getUpperBound(4);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkBadPreambleLongs() {
int k = 512;
- ThetaSketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ ThetaSketch alpha = UpdatableThetaSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
byte[] byteArray = alpha.toByteArray();
MemorySegment seg = MemorySegment.ofArray(byteArray);
//corrupt:
@@ -584,14 +584,14 @@ public class HeapAlphaSketchTest {
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkNegativeHashes() {
int k = 512;
- UpdateSketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ UpdatableThetaSketch alpha = UpdatableThetaSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
alpha.hashUpdate(-1L);
}
@Test
public void checkSegDeSerExceptions() {
int k = 1024;
- UpdateSketch sk1 = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ UpdatableThetaSketch sk1 = UpdatableThetaSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
sk1.update(1L); //forces preLongs to 3
byte[] bytearray1 = sk1.toByteArray();
MemorySegment seg = MemorySegment.ofArray(bytearray1);
@@ -630,7 +630,7 @@ public class HeapAlphaSketchTest {
// force ResizeFactor.X1, and allocated capacity too small
insertLgResizeFactor(seg, ResizeFactor.X1.lg());
- UpdateSketch usk = HeapAlphaSketch.heapifyInstance(seg, Util.DEFAULT_UPDATE_SEED);
+ UpdatableThetaSketch usk = HeapAlphaSketch.heapifyInstance(seg, Util.DEFAULT_UPDATE_SEED);
ResizeFactor rf = usk.getResizeFactor();
assertEquals(rf, ResizeFactor.X2);//ResizeFactor recovered to X2, which always works.
}
@@ -647,7 +647,7 @@ public class HeapAlphaSketchTest {
@Test
public void checkEnhancedHashInsertOnFullHashTable() {
- final HeapAlphaSketch alpha = (HeapAlphaSketch) UpdateSketch.builder()
+ final HeapAlphaSketch alpha = (HeapAlphaSketch) UpdatableThetaSketch.builder()
.setFamily(ALPHA).build();
final int n = 1 << alpha.getLgArrLongs();
@@ -666,7 +666,7 @@ public class HeapAlphaSketchTest {
@Test
public void checkFamily() {
- UpdateSketch sketch = UpdateSketch.builder().setFamily(ALPHA).build();
+ UpdatableThetaSketch sketch = UpdatableThetaSketch.builder().setFamily(ALPHA).build();
assertEquals(sketch.getFamily(), Family.ALPHA);
}
@@ -674,13 +674,13 @@ public class HeapAlphaSketchTest {
@Test(expectedExceptions = SketchesArgumentException.class)
public void corruptionLgNomLongs() {
final int k = 512;
- UpdateSketch sketch = UpdateSketch.builder().setNominalEntries(k)
+ UpdatableThetaSketch sketch = UpdatableThetaSketch.builder().setNominalEntries(k)
.setFamily(ALPHA).build();
for (int i = 0; i < k; i++) { sketch.update(i); }
byte[] byteArr = sketch.toByteArray();
MemorySegment wseg = MemorySegment.ofArray(byteArr);
wseg.set(JAVA_BYTE, LG_NOM_LONGS_BYTE, (byte) 8); //corrupt LgNomLongs
- UpdateSketch sk = UpdateSketch.heapify(wseg);
+ UpdatableThetaSketch sk = UpdatableThetaSketch.heapify(wseg);
}
@Test
diff --git a/src/test/java/org/apache/datasketches/theta/HeapIntersectionTest.java b/src/test/java/org/apache/datasketches/theta/HeapIntersectionTest.java
index 7197a87f5..f1368b543 100644
--- a/src/test/java/org/apache/datasketches/theta/HeapIntersectionTest.java
+++ b/src/test/java/org/apache/datasketches/theta/HeapIntersectionTest.java
@@ -47,8 +47,8 @@ public class HeapIntersectionTest {
final int lgK = 9;
final int k = 1<<lgK;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<k/2; i++) {
usk1.update(i);
@@ -57,12 +57,12 @@ public class HeapIntersectionTest {
usk2.update(i);
}
- final Intersection inter = SetOperation.builder().buildIntersection();
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
inter.intersect(usk1);
inter.intersect(usk2);
- CompactSketch rsk1;
+ CompactThetaSketch rsk1;
final boolean ordered = true;
assertTrue(inter.hasResult());
@@ -91,8 +91,8 @@ public class HeapIntersectionTest {
final int lgK = 9;
final int k = 1<<lgK;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<k; i++) {
usk1.update(i);
@@ -101,11 +101,11 @@ public class HeapIntersectionTest {
usk2.update(i);
}
- final Intersection inter = SetOperation.builder().buildIntersection();
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
inter.intersect(usk1);
inter.intersect(usk2);
- CompactSketch rsk1;
+ CompactThetaSketch rsk1;
final boolean ordered = true;
rsk1 = inter.getResult(!ordered, null);
@@ -131,8 +131,8 @@ public class HeapIntersectionTest {
final int k = 1<<lgK;
final int u = 4*k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u; i++) {
usk1.update(i);
@@ -142,14 +142,14 @@ public class HeapIntersectionTest {
usk2.update(i);
}
- final CompactSketch csk1 = usk1.compact(true, null);
- final CompactSketch csk2 = usk2.compact(true, null);
+ final CompactThetaSketch csk1 = usk1.compact(true, null);
+ final CompactThetaSketch csk2 = usk2.compact(true, null);
- final Intersection inter = SetOperation.builder().buildIntersection();
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
inter.intersect(csk1);
inter.intersect(csk2);
- final CompactSketch rsk1 = inter.getResult(true, null);
+ final CompactThetaSketch rsk1 = inter.getResult(true, null);
final double result = rsk1.getEstimate();
final double sd2err = 2048 * 2.0/Math.sqrt(k);
//println("2048 = " + rsk1.getEstimate() + " +/- " + sd2err);
@@ -159,15 +159,15 @@ public class HeapIntersectionTest {
//Calling getResult on a virgin Intersect is illegal
@Test(expectedExceptions = SketchesStateException.class)
public void checkNoCall() {
- final Intersection inter = SetOperation.builder().buildIntersection();
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
assertFalse(inter.hasResult());
inter.getResult(false, null);
}
@Test
public void checkIntersectionNull() {
- final Intersection inter = SetOperation.builder().buildIntersection();
- final UpdateSketch sk = null;
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
+ final UpdatableThetaSketch sk = null;
try { inter.intersect(sk); fail(); }
catch (final SketchesArgumentException e) { }
@@ -179,14 +179,14 @@ public class HeapIntersectionTest {
public void check1stCall() {
final int lgK = 9;
final int k = 1<<lgK;
- Intersection inter;
- UpdateSketch sk;
- CompactSketch rsk1;
+ ThetaIntersection inter;
+ UpdatableThetaSketch sk;
+ CompactThetaSketch rsk1;
double est;
//1st call = empty
- sk = UpdateSketch.builder().setNominalEntries(k).build(); //empty
- inter = SetOperation.builder().buildIntersection();
+ sk = UpdatableThetaSketch.builder().setNominalEntries(k).build(); //empty
+ inter = ThetaSetOperation.builder().buildIntersection();
inter.intersect(sk);
rsk1 = inter.getResult(false, null);
est = rsk1.getEstimate();
@@ -194,9 +194,9 @@ public class HeapIntersectionTest {
println("Est: "+est); // = 0
//1st call = valid and not empty
- sk = UpdateSketch.builder().setNominalEntries(k).build();
+ sk = UpdatableThetaSketch.builder().setNominalEntries(k).build();
sk.update(1);
- inter = SetOperation.builder().buildIntersection();
+ inter = ThetaSetOperation.builder().buildIntersection();
inter.intersect(sk);
rsk1 = inter.getResult(false, null);
est = rsk1.getEstimate();
@@ -206,17 +206,17 @@ public class HeapIntersectionTest {
@Test
public void check2ndCallAfterEmpty() {
- Intersection inter;
- UpdateSketch sk1, sk2;
- CompactSketch comp1;
+ ThetaIntersection inter;
+ UpdatableThetaSketch sk1, sk2;
+ CompactThetaSketch comp1;
double est;
//1st call = empty
- sk1 = UpdateSketch.builder().build(); //empty
- inter = SetOperation.builder().buildIntersection();
+ sk1 = UpdatableThetaSketch.builder().build(); //empty
+ inter = ThetaSetOperation.builder().buildIntersection();
inter.intersect(sk1);
//2nd call = empty
- sk2 = UpdateSketch.builder().build(); //empty
+ sk2 = UpdatableThetaSketch.builder().build(); //empty
inter.intersect(sk2);
comp1 = inter.getResult(false, null);
est = comp1.getEstimate();
@@ -224,11 +224,11 @@ public class HeapIntersectionTest {
println("Est: "+est);
//1st call = empty
- sk1 = UpdateSketch.builder().build(); //empty
- inter = SetOperation.builder().buildIntersection();
+ sk1 = UpdatableThetaSketch.builder().build(); //empty
+ inter = ThetaSetOperation.builder().buildIntersection();
inter.intersect(sk1);
//2nd call = valid and not empty
- sk2 = UpdateSketch.builder().build();
+ sk2 = UpdatableThetaSketch.builder().build();
sk2.update(1);
inter.intersect(sk2);
comp1 = inter.getResult(false, null);
@@ -239,18 +239,18 @@ public class HeapIntersectionTest {
@Test
public void check2ndCallAfterValid() {
- Intersection inter;
- UpdateSketch sk1, sk2;
- CompactSketch comp1;
+ ThetaIntersection inter;
+ UpdatableThetaSketch sk1, sk2;
+ CompactThetaSketch comp1;
double est;
//1st call = valid
- sk1 = UpdateSketch.builder().build();
+ sk1 = UpdatableThetaSketch.builder().build();
sk1.update(1);
- inter = SetOperation.builder().buildIntersection();
+ inter = ThetaSetOperation.builder().buildIntersection();
inter.intersect(sk1);
//2nd call = empty
- sk2 = UpdateSketch.builder().build(); //empty
+ sk2 = UpdatableThetaSketch.builder().build(); //empty
inter.intersect(sk2);
comp1 = inter.getResult(false, null);
est = comp1.getEstimate();
@@ -258,12 +258,12 @@ public class HeapIntersectionTest {
println("Est: "+est);
//1st call = valid
- sk1 = UpdateSketch.builder().build();
+ sk1 = UpdatableThetaSketch.builder().build();
sk1.update(1);
- inter = SetOperation.builder().buildIntersection();
+ inter = ThetaSetOperation.builder().buildIntersection();
inter.intersect(sk1);
//2nd call = valid intersecting
- sk2 = UpdateSketch.builder().build(); //empty
+ sk2 = UpdatableThetaSketch.builder().build(); //empty
sk2.update(1);
inter.intersect(sk2);
comp1 = inter.getResult(false, null);
@@ -272,12 +272,12 @@ public class HeapIntersectionTest {
println("Est: "+est);
//1st call = valid
- sk1 = UpdateSketch.builder().build();
+ sk1 = UpdatableThetaSketch.builder().build();
sk1.update(1);
- inter = SetOperation.builder().buildIntersection();
+ inter = ThetaSetOperation.builder().buildIntersection();
inter.intersect(sk1);
//2nd call = valid not intersecting
- sk2 = UpdateSketch.builder().build(); //empty
+ sk2 = UpdatableThetaSketch.builder().build(); //empty
sk2.update(2);
inter.intersect(sk2);
comp1 = inter.getResult(false, null);
@@ -290,24 +290,24 @@ public class HeapIntersectionTest {
public void checkEstimatingIntersect() {
final int lgK = 9;
final int k = 1<<lgK;
- Intersection inter;
- UpdateSketch sk1, sk2;
- CompactSketch comp1;
+ ThetaIntersection inter;
+ UpdatableThetaSketch sk1, sk2;
+ CompactThetaSketch comp1;
double est;
//1st call = valid
- sk1 = UpdateSketch.builder().setNominalEntries(k).build();
+ sk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<2*k; i++)
{
sk1.update(i); //est mode
}
println("sk1: "+sk1.getEstimate());
- inter = SetOperation.builder().buildIntersection();
+ inter = ThetaSetOperation.builder().buildIntersection();
inter.intersect(sk1);
//2nd call = valid intersecting
- sk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ sk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<2*k; i++)
{
sk2.update(i); //est mode
@@ -326,30 +326,30 @@ public class HeapIntersectionTest {
final int lgK = 9;
final int k = 1<<lgK;
- final UpdateSketch sk1 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch sk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i = 0; i < 2 * k; i++) {
sk1.update(i); //est mode
}
- final CompactSketch cSk1 = sk1.compact(true, null);
+ final CompactThetaSketch cSk1 = sk1.compact(true, null);
final double cSk1Est = cSk1.getEstimate();
println("cSk1Est: " + cSk1Est);
- final Intersection inter = SetOperation.builder().buildIntersection();
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
//1st call with a valid sketch
inter.intersect(cSk1);
- final UpdateSketch sk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch sk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i = 0; i < 2 * k; i++) {
sk2.update(i); //est mode
}
- final CompactSketch cSk2 = sk2.compact(true, null);
+ final CompactThetaSketch cSk2 = sk2.compact(true, null);
final double cSk2Est = cSk2.getEstimate();
println("cSk2Est: " + cSk2Est);
assertEquals(cSk2Est, cSk1Est, 0.0);
//2nd call with identical valid sketch
inter.intersect(cSk2);
- final CompactSketch interResultCSk1 = inter.getResult(false, null);
+ final CompactThetaSketch interResultCSk1 = inter.getResult(false, null);
final double inter1est = interResultCSk1.getEstimate();
assertEquals(inter1est, cSk1Est, 0.0);
println("Inter1Est: " + inter1est);
@@ -358,15 +358,15 @@ public class HeapIntersectionTest {
final byte[] byteArray = inter.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
//Heapify
- final Intersection inter2 = (Intersection) SetOperation.heapify(seg);
- final CompactSketch heapifiedSk = inter2.getResult(false, null);
+ final ThetaIntersection inter2 = (ThetaIntersection) ThetaSetOperation.heapify(seg);
+ final CompactThetaSketch heapifiedSk = inter2.getResult(false, null);
final double heapifiedEst = heapifiedSk.getEstimate();
assertEquals(heapifiedEst, cSk1Est, 0.0);
println("HeapifiedEst: "+heapifiedEst);
//Wrap
- final Intersection inter3 = Intersection.wrap(seg);
- final CompactSketch wrappedSk = inter3.getResult(false, null);
+ final ThetaIntersection inter3 = ThetaIntersection.wrap(seg);
+ final CompactThetaSketch wrappedSk = inter3.getResult(false, null);
final double wrappedEst = wrappedSk.getEstimate();
assertEquals(wrappedEst, cSk1Est, 0.0);
println("WrappedEst: "+ wrappedEst);
@@ -382,7 +382,7 @@ public class HeapIntersectionTest {
*/
@Test
public void checkPreject() {
- final UpdateSketch sk = UpdateSketch.builder().setP((float) .5).build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().setP((float) .5).build();
sk.update(7);
assertEquals(sk.getRetainedEntries(), 0);
}
@@ -391,17 +391,17 @@ public class HeapIntersectionTest {
public void checkHeapifyVirginEmpty() {
final int lgK = 5;
final int k = 1<<lgK;
- Intersection inter1, inter2;
- UpdateSketch sk1;
+ ThetaIntersection inter1, inter2;
+ UpdatableThetaSketch sk1;
- inter1 = SetOperation.builder().buildIntersection(); //virgin heap
+ inter1 = ThetaSetOperation.builder().buildIntersection(); //virgin heap
MemorySegment srcSeg = MemorySegment.ofArray(inter1.toByteArray()).asReadOnly();
- inter2 = (Intersection) SetOperation.heapify(srcSeg); //virgin heap, independent of inter1
+ inter2 = (ThetaIntersection) ThetaSetOperation.heapify(srcSeg); //virgin heap, independent of inter1
assertFalse(inter1.hasResult());
assertFalse(inter2.hasResult());
//This constructs a sketch with 0 entries and theta < 1.0
- sk1 = UpdateSketch.builder().setP((float) .5).setNominalEntries(k).build();
+ sk1 = UpdatableThetaSketch.builder().setP((float) .5).setNominalEntries(k).build();
sk1.update(7); //will be rejected by P, see proof above.
//A virgin intersection (empty = false) intersected with a not-empty zero cache sketch
@@ -414,64 +414,64 @@ public class HeapIntersectionTest {
//test the path via toByteArray, heapify, now in a different state
srcSeg = MemorySegment.ofArray(inter1.toByteArray()).asReadOnly();
- inter2 = (Intersection) SetOperation.heapify(srcSeg); //inter2 identical to inter1
+ inter2 = (ThetaIntersection) ThetaSetOperation.heapify(srcSeg); //inter2 identical to inter1
assertFalse(inter2.isEmpty());
assertTrue(inter2.hasResult());
//test the compaction path
- final CompactSketch comp = inter2.getResult(true, null);
+ final CompactThetaSketch comp = inter2.getResult(true, null);
assertEquals(comp.getRetainedEntries(false), 0);
assertFalse(comp.isEmpty());
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkBadPreambleLongs() {
- final Intersection inter1 = SetOperation.builder().buildIntersection(); //virgin
+ final ThetaIntersection inter1 = ThetaSetOperation.builder().buildIntersection(); //virgin
final byte[] byteArray = inter1.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
//corrupt:
seg.set(JAVA_BYTE, PREAMBLE_LONGS_BYTE, (byte) 2); //RF not used = 0
- SetOperation.heapify(seg);
+ ThetaSetOperation.heapify(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkBadSerVer() {
- final Intersection inter1 = SetOperation.builder().buildIntersection(); //virgin
+ final ThetaIntersection inter1 = ThetaSetOperation.builder().buildIntersection(); //virgin
final byte[] byteArray = inter1.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
//corrupt:
seg.set(JAVA_BYTE, SER_VER_BYTE, (byte) 2);
- SetOperation.heapify(seg);
+ ThetaSetOperation.heapify(seg);
}
@Test(expectedExceptions = ClassCastException.class)
public void checkFamilyID() {
final int k = 32;
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
final byte[] byteArray = union.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
@SuppressWarnings("unused")
final
- Intersection inter1 = (Intersection) SetOperation.heapify(seg); //bad cast
+ ThetaIntersection inter1 = (ThetaIntersection) ThetaSetOperation.heapify(seg); //bad cast
//println(inter1.toString());
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkBadEmptyState() {
- final Intersection inter1 = SetOperation.builder().buildIntersection(); //virgin
- final UpdateSketch sk = UpdateSketch.builder().build();
+ final ThetaIntersection inter1 = ThetaSetOperation.builder().buildIntersection(); //virgin
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().build();
inter1.intersect(sk); //initializes to a true empty intersection.
final byte[] byteArray = inter1.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
//corrupt:
seg.set(JAVA_INT_UNALIGNED, RETAINED_ENTRIES_INT, 1);
- SetOperation.heapify(seg);
+ ThetaSetOperation.heapify(seg);
}
@Test
public void checkEmpty() {
- final UpdateSketch usk = UpdateSketch.builder().build();
- final Intersection inter = SetOperation.builder().buildIntersection();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().build();
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
inter.intersect(usk);
assertTrue(inter.isEmpty());
assertEquals(inter.getRetainedEntries(), 0);
@@ -483,9 +483,9 @@ public class HeapIntersectionTest {
@Test
public void checkOne() {
- final UpdateSketch usk = UpdateSketch.builder().build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().build();
usk.update(1);
- final Intersection inter = SetOperation.builder().buildIntersection();
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
inter.intersect(usk);
assertFalse(inter.isEmpty());
assertEquals(inter.getRetainedEntries(), 1);
@@ -497,26 +497,26 @@ public class HeapIntersectionTest {
@Test
public void checkGetResult() {
- final UpdateSketch sk = UpdateSketch.builder().build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().build();
- final Intersection inter = SetOperation.builder().buildIntersection();
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
inter.intersect(sk);
- final CompactSketch csk = inter.getResult();
+ final CompactThetaSketch csk = inter.getResult();
assertEquals(csk.getCompactBytes(), 8);
}
@Test
public void checkFamily() {
- final IntersectionImpl impl = IntersectionImpl.initNewHeapInstance(Util.DEFAULT_UPDATE_SEED);
+ final ThetaIntersectionImpl impl = ThetaIntersectionImpl.initNewHeapInstance(Util.DEFAULT_UPDATE_SEED);
assertEquals(impl.getFamily(), Family.INTERSECTION);
}
@Test
public void checkPairIntersectSimple() {
- final UpdateSketch skA = UpdateSketch.builder().build();
- final UpdateSketch skB = UpdateSketch.builder().build();
- final Intersection inter = SetOperation.builder().buildIntersection();
- final CompactSketch csk = inter.intersect(skA, skB);
+ final UpdatableThetaSketch skA = UpdatableThetaSketch.builder().build();
+ final UpdatableThetaSketch skB = UpdatableThetaSketch.builder().build();
+ final ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
+ final CompactThetaSketch csk = inter.intersect(skA, skB);
assertEquals(csk.getCompactBytes(), 8);
}
diff --git a/src/test/java/org/apache/datasketches/theta/HeapQuickSelectSketchTest.java b/src/test/java/org/apache/datasketches/theta/HeapQuickSelectSketchTest.java
index dafd4e4fc..5bf75c8ae 100644
--- a/src/test/java/org/apache/datasketches/theta/HeapQuickSelectSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/HeapQuickSelectSketchTest.java
@@ -59,7 +59,7 @@ public class HeapQuickSelectSketchTest {
final int k = 512;
final int u = k;
final long seed = Util.DEFAULT_UPDATE_SEED;
- final UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setSeed(seed).setNominalEntries(k).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setSeed(seed).setNominalEntries(k).build();
final HeapQuickSelectSketch sk1 = (HeapQuickSelectSketch)usk; //for internal checks
assertTrue(usk.isEmpty());
@@ -84,7 +84,7 @@ public class HeapQuickSelectSketchTest {
final int k = 512;
final int u = k;
final long seed = Util.DEFAULT_UPDATE_SEED;
- final UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setSeed(seed).setNominalEntries(k).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setSeed(seed).setNominalEntries(k).build();
final HeapQuickSelectSketch sk1 = (HeapQuickSelectSketch)usk; //for internal checks
assertTrue(usk.isEmpty());
@@ -97,7 +97,7 @@ public class HeapQuickSelectSketchTest {
assertEquals(sk1.getRetainedEntries(false), u);
final byte[] byteArray = usk.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
- seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Sketch ID byte
+ seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the FamilyID byte
//try to heapify the corrupted seg
ThetaSketch.heapify(seg, seed);
@@ -108,7 +108,7 @@ public class HeapQuickSelectSketchTest {
final int k = 512;
final long seed1 = 1021;
final long seed2 = Util.DEFAULT_UPDATE_SEED;
- final UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setSeed(seed1).setNominalEntries(k).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setSeed(seed1).setNominalEntries(k).build();
final byte[] byteArray = usk.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(byteArray).asReadOnly();
ThetaSketch.heapify(srcSeg, seed2);
@@ -116,7 +116,7 @@ public class HeapQuickSelectSketchTest {
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkHeapifyCorruptLgNomLongs() {
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(16).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(16).build();
final MemorySegment srcSeg = MemorySegment.ofArray(usk.toByteArray());
srcSeg.set(JAVA_BYTE, LG_NOM_LONGS_BYTE, (byte)2); //corrupt
ThetaSketch.heapify(srcSeg, Util.DEFAULT_UPDATE_SEED);
@@ -127,7 +127,7 @@ public class HeapQuickSelectSketchTest {
final int k = 512;
final int u = k;
final long seed = Util.DEFAULT_UPDATE_SEED;
- final UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setSeed(seed).setNominalEntries(k).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setSeed(seed).setNominalEntries(k).build();
for (int i=0; i<u; i++) {
usk.update(i);
@@ -138,7 +138,7 @@ public class HeapQuickSelectSketchTest {
assertEquals(bytes, byteArray.length);
final MemorySegment srcSeg = MemorySegment.ofArray(byteArray).asReadOnly();
- final UpdateSketch usk2 = UpdateSketch.heapify(srcSeg, seed);
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.heapify(srcSeg, seed);
assertEquals(usk2.getEstimate(), u, 0.0);
assertEquals(usk2.getLowerBound(2), u, 0.0);
assertEquals(usk2.getUpperBound(2), u, 0.0);
@@ -155,7 +155,7 @@ public class HeapQuickSelectSketchTest {
final int u = 2*k;
final long seed = Util.DEFAULT_UPDATE_SEED;
- final UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setSeed(seed).setNominalEntries(k).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setSeed(seed).setNominalEntries(k).build();
for (int i=0; i<u; i++) {
usk.update(i);
@@ -168,7 +168,7 @@ public class HeapQuickSelectSketchTest {
final byte[] byteArray = usk.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(byteArray).asReadOnly();
- final UpdateSketch usk2 = UpdateSketch.heapify(srcSeg, seed);
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.heapify(srcSeg, seed);
assertEquals(usk2.getEstimate(), uskEst);
assertEquals(usk2.getLowerBound(2), uskLB);
assertEquals(usk2.getUpperBound(2), uskUB);
@@ -183,7 +183,7 @@ public class HeapQuickSelectSketchTest {
final int k = 512;
final int u = 2*k; //thus estimating
final long seed = Util.DEFAULT_UPDATE_SEED;
- final UpdateSketch sk1 = UpdateSketch.builder().setFamily(fam_).setSeed(seed).setNominalEntries(k).build();
+ final UpdatableThetaSketch sk1 = UpdatableThetaSketch.builder().setFamily(fam_).setSeed(seed).setNominalEntries(k).build();
for (int i=0; i<u; i++) {
sk1.update(i);
@@ -197,7 +197,7 @@ public class HeapQuickSelectSketchTest {
final byte[] byteArray = sk1.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray).asReadOnly();
- final UpdateSketch sk2 = UpdateSketch.heapify(seg, Util.DEFAULT_UPDATE_SEED);
+ final UpdatableThetaSketch sk2 = UpdatableThetaSketch.heapify(seg, Util.DEFAULT_UPDATE_SEED);
assertEquals(sk2.getEstimate(), sk1est);
assertEquals(sk2.getLowerBound(2), sk1lb);
@@ -215,7 +215,7 @@ public class HeapQuickSelectSketchTest {
//boolean compact = false;
final int maxBytes = (k << 4) + (Family.QUICKSELECT.getMinPreLongs() << 3);
- final UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setNominalEntries(k).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setNominalEntries(k).build();
final HeapQuickSelectSketch sk1 = (HeapQuickSelectSketch)usk; //for internal checks
assertEquals(usk.getClass().getSimpleName(), "HeapQuickSelectSketch");
@@ -234,12 +234,12 @@ public class HeapQuickSelectSketchTest {
final double uskEst = usk.getEstimate();
final double uskLB = usk.getLowerBound(2);
final double uskUB = usk.getUpperBound(2);
- final int uskBytes = usk.getCurrentBytes(); //size stored as UpdateSketch
- final int uskCompBytes = usk.getCompactBytes(); //size stored as CompactSketch
+ final int uskBytes = usk.getCurrentBytes(); //size stored as UpdatableThetaSketch
+ final int uskCompBytes = usk.getCompactBytes(); //size stored as CompactThetaSketch
assertEquals(uskBytes, maxBytes);
assertTrue(usk.isEstimationMode());
- CompactSketch comp1, comp2, comp3, comp4;
+ CompactThetaSketch comp1, comp2, comp3, comp4;
comp1 = usk.compact(false, null);
@@ -291,7 +291,7 @@ public class HeapQuickSelectSketchTest {
public void checkHQStoCompactEmptyForms() {
final int k = 512;
- final UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setResizeFactor(X2).setNominalEntries(k).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setResizeFactor(X2).setNominalEntries(k).build();
println("lgArr: "+ usk.getLgArrLongs());
//empty
@@ -310,7 +310,7 @@ public class HeapQuickSelectSketchTest {
final byte[] arr2 = new byte[compBytes];
final MemorySegment seg = MemorySegment.ofArray(arr2);
- final CompactSketch csk2 = usk.compact(false, seg);
+ final CompactThetaSketch csk2 = usk.compact(false, seg);
assertEquals(csk2.getEstimate(), uskEst);
assertEquals(csk2.getLowerBound(2), uskLB);
assertEquals(csk2.getUpperBound(2), uskUB);
@@ -318,7 +318,7 @@ public class HeapQuickSelectSketchTest {
assertEquals(csk2.isEstimationMode(), estimating);
assertEquals(csk2.getClass().getSimpleName(), "DirectCompactSketch");
- final CompactSketch csk3 = usk.compact(true, seg);
+ final CompactThetaSketch csk3 = usk.compact(true, seg);
println(csk3.toString(false, true, 0, false));
println(csk3.toString());
assertEquals(csk3.getEstimate(), uskEst);
@@ -334,7 +334,7 @@ public class HeapQuickSelectSketchTest {
final int k = 4096;
final int u = 4096;
- final UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setNominalEntries(k).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setNominalEntries(k).build();
final HeapQuickSelectSketch sk1 = (HeapQuickSelectSketch)usk; //for internal checks
assertTrue(usk.isEmpty());
@@ -351,7 +351,7 @@ public class HeapQuickSelectSketchTest {
public void checkEstMode() {
final int k = 4096;
final int u = 2*k;
- final UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setResizeFactor(ResizeFactor.X4).setNominalEntries(k).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setResizeFactor(ResizeFactor.X4).setNominalEntries(k).build();
final HeapQuickSelectSketch sk1 = (HeapQuickSelectSketch)usk; //for internal checks
assertTrue(usk.isEmpty());
@@ -369,7 +369,7 @@ public class HeapQuickSelectSketchTest {
final int u = k;
final float p = (float)0.5;
- final UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setP(p).setNominalEntries(k).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setP(p).setNominalEntries(k).build();
final HeapQuickSelectSketch sk1 = (HeapQuickSelectSketch)usk; //for internal checks
for (int i = 0; i < u; i++ ) {
@@ -393,7 +393,7 @@ public class HeapQuickSelectSketchTest {
public void checkErrorBounds() {
final int k = 512;
- final UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setResizeFactor(X1).setNominalEntries(k).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setResizeFactor(X1).setNominalEntries(k).build();
//Exact mode
for (int i = 0; i < k; i++ ) {
@@ -425,7 +425,7 @@ public class HeapQuickSelectSketchTest {
//virgin, p = 1.0
final int k = 1024;
- final UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setNominalEntries(k).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setNominalEntries(k).build();
HeapQuickSelectSketch sk1 = (HeapQuickSelectSketch)usk; //for internal checks
assertTrue(usk.isEmpty());
@@ -434,7 +434,7 @@ public class HeapQuickSelectSketchTest {
assertFalse(usk.isEmpty());
//virgin, p = .001
- final UpdateSketch usk2 = UpdateSketch.builder().setFamily(fam_).setP((float)0.001).setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setFamily(fam_).setP((float)0.001).setNominalEntries(k).build();
sk1 = (HeapQuickSelectSketch)usk2;
assertTrue(usk2.isEmpty());
usk2.update(1); //will be rejected
@@ -456,7 +456,7 @@ public class HeapQuickSelectSketchTest {
final int k = 512;
final int u = 2*k;
- final UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setResizeFactor(X2).setNominalEntries(k).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setResizeFactor(X2).setNominalEntries(k).build();
for (int i = 0; i < u; i++ ) {
usk.update(i);
@@ -474,7 +474,7 @@ public class HeapQuickSelectSketchTest {
final int k = 16;
final int u = 4*k;
- final UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setNominalEntries(k).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setNominalEntries(k).build();
final HeapQuickSelectSketch sk1 = (HeapQuickSelectSketch)usk; //for internal checks
assertTrue(usk.isEmpty());
@@ -500,7 +500,7 @@ public class HeapQuickSelectSketchTest {
final int k = 1024;
final int u = 4*k;
- final UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setResizeFactor(X8).setNominalEntries(k).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setFamily(fam_).setResizeFactor(X8).setNominalEntries(k).build();
HeapQuickSelectSketch sk1 = (HeapQuickSelectSketch)usk; //for internal checks
assertTrue(usk.isEmpty());
@@ -515,7 +515,7 @@ public class HeapQuickSelectSketchTest {
int subMul = ThetaUtil.startingSubMultiple(11, rf.lg(), 5); //messy
assertEquals(sk1.getLgArrLongs(), subMul);
- final UpdateSketch usk2 = UpdateSketch.builder().setFamily(fam_).setResizeFactor(ResizeFactor.X1).setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setFamily(fam_).setResizeFactor(ResizeFactor.X1).setNominalEntries(k).build();
sk1 = (HeapQuickSelectSketch)usk2;
for (int i=0; i<u; i++) {
@@ -535,14 +535,14 @@ public class HeapQuickSelectSketchTest {
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkNegativeHashes() {
final int k = 512;
- final UpdateSketch qs = UpdateSketch.builder().setFamily(QUICKSELECT).setNominalEntries(k).build();
+ final UpdatableThetaSketch qs = UpdatableThetaSketch.builder().setFamily(QUICKSELECT).setNominalEntries(k).build();
qs.hashUpdate(-1L);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkMinReqBytes() {
final int k = 16;
- final UpdateSketch s1 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch s1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i = 0; i < (4 * k); i++) { s1.update(i); }
final byte[] byteArray = s1.toByteArray();
final byte[] badBytes = Arrays.copyOfRange(byteArray, 0, 24);
@@ -553,7 +553,7 @@ public class HeapQuickSelectSketchTest {
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkThetaAndLgArrLongs() {
final int k = 16;
- final UpdateSketch s1 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch s1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i = 0; i < k; i++) { s1.update(i); }
final byte[] badArray = s1.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(badArray);
@@ -564,14 +564,14 @@ public class HeapQuickSelectSketchTest {
@Test
public void checkFamily() {
- final UpdateSketch sketch = UpdateSketch.builder().build();
+ final UpdatableThetaSketch sketch = UpdatableThetaSketch.builder().build();
assertEquals(sketch.getFamily(), Family.QUICKSELECT);
}
@Test
public void checkSegSerDeExceptions() {
final int k = 1024;
- final UpdateSketch sk1 = UpdateSketch.builder().setFamily(QUICKSELECT).setNominalEntries(k).build();
+ final UpdatableThetaSketch sk1 = UpdatableThetaSketch.builder().setFamily(QUICKSELECT).setNominalEntries(k).build();
sk1.update(1L); //forces preLongs to 3
final byte[] bytearray1 = sk1.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(bytearray1);
@@ -589,7 +589,7 @@ public class HeapQuickSelectSketchTest {
tryBadSeg(seg, FLAGS_BYTE, 2); //Corrupt READ_ONLY to true
seg.set(JAVA_LONG_UNALIGNED, 0, pre0); //restore
- tryBadSeg(seg, FAMILY_BYTE, 4); //Corrupt, Family to Union
+ tryBadSeg(seg, FAMILY_BYTE, 4); //Corrupt, Family to ThetaUnion
seg.set(JAVA_LONG_UNALIGNED, 0, pre0); //restore
final long origThetaLong = seg.get(JAVA_LONG_UNALIGNED, THETA_LONG);
@@ -613,7 +613,7 @@ public class HeapQuickSelectSketchTest {
// force ResizeFactor.X1, but allocated capacity too small
insertLgResizeFactor(seg, ResizeFactor.X1.lg());
- final UpdateSketch hqss = HeapQuickSelectSketch.heapifyInstance(seg, Util.DEFAULT_UPDATE_SEED);
+ final UpdatableThetaSketch hqss = HeapQuickSelectSketch.heapifyInstance(seg, Util.DEFAULT_UPDATE_SEED);
assertEquals(hqss.getResizeFactor(), ResizeFactor.X2); // force-promote to X2
}
diff --git a/src/test/java/org/apache/datasketches/theta/HeapUnionTest.java b/src/test/java/org/apache/datasketches/theta/HeapUnionTest.java
index bc602a6f8..f6effb255 100644
--- a/src/test/java/org/apache/datasketches/theta/HeapUnionTest.java
+++ b/src/test/java/org/apache/datasketches/theta/HeapUnionTest.java
@@ -43,8 +43,8 @@ public class HeapUnionTest {
final int k = 1 << lgK;
final int u = k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u/2; i++) {
usk1.update(i); //256
@@ -55,10 +55,10 @@ public class HeapUnionTest {
assertEquals(u, usk1.getEstimate() + usk2.getEstimate(), 0.0); //exact, no overlap
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
- union.union(usk1); //update with heap UpdateSketch
- union.union(usk2); //update with heap UpdateSketch
+ union.union(usk1); //update with heap UpdatableThetaSketch
+ union.union(usk2); //update with heap UpdatableThetaSketch
testAllCompactForms(union, u, 0.0);
}
@@ -69,8 +69,8 @@ public class HeapUnionTest {
final int k = 1 << lgK;
final int u = 4*k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u/2; i++) {
usk1.update(i); //2*k
@@ -79,10 +79,10 @@ public class HeapUnionTest {
usk2.update(i); //2*k no overlap
}
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
- union.union(usk1); //update with heap UpdateSketch
- union.union(usk2); //update with heap UpdateSketch
+ union.union(usk1); //update with heap UpdatableThetaSketch
+ union.union(usk2); //update with heap UpdatableThetaSketch
testAllCompactForms(union, u, 0.05);
}
@@ -93,8 +93,8 @@ public class HeapUnionTest {
final int k = 1 << lgK;
final int u = k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u/2; i++) {
usk1.update(i); //256
@@ -105,10 +105,10 @@ public class HeapUnionTest {
assertEquals(u, usk1.getEstimate() + usk2.getEstimate()/2, 0.0); //exact, overlapped
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
- union.union(usk1); //update with heap UpdateSketch
- union.union(usk2); //update with heap UpdateSketch
+ union.union(usk1); //update with heap UpdatableThetaSketch
+ union.union(usk2); //update with heap UpdatableThetaSketch
testAllCompactForms(union, u, 0.0);
}
@@ -119,8 +119,8 @@ public class HeapUnionTest {
final int k = 1 << lgK;
final int u = k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u/2; i++) {
usk1.update(i); //256
@@ -131,14 +131,14 @@ public class HeapUnionTest {
assertEquals(u, usk1.getEstimate() + usk2.getEstimate(), 0.0); //exact, no overlap
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
- union.union(usk1); //update with heap UpdateSketch
- union.union(usk2); //update with heap UpdateSketch
+ union.union(usk1); //update with heap UpdatableThetaSketch
+ union.union(usk2); //update with heap UpdatableThetaSketch
testAllCompactForms(union, u, 0.0);
- final Union union2 = (Union)SetOperation.heapify(MemorySegment.ofArray(union.toByteArray()));
+ final ThetaUnion union2 = (ThetaUnion)ThetaSetOperation.heapify(MemorySegment.ofArray(union.toByteArray()));
testAllCompactForms(union2, u, 0.0);
}
@@ -149,8 +149,8 @@ public class HeapUnionTest {
final int k = 1 << lgK;
final int u = 4*k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build(); //2k estimating
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(2 * k).build(); //2k exact
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build(); //2k estimating
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(2 * k).build(); //2k exact
for (int i=0; i<u/2; i++) {
usk1.update(i); //2k
@@ -159,14 +159,14 @@ public class HeapUnionTest {
usk2.update(i); //2k no overlap, exact
}
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
- union.union(usk1); //update with heap UpdateSketch
- union.union(usk2); //update with heap UpdateSketch, early stop not possible
+ union.union(usk1); //update with heap UpdatableThetaSketch
+ union.union(usk2); //update with heap UpdatableThetaSketch, early stop not possible
testAllCompactForms(union, u, 0.05);
- final Union union2 = (Union)SetOperation.heapify(MemorySegment.ofArray(union.toByteArray()));
+ final ThetaUnion union2 = (ThetaUnion)ThetaSetOperation.heapify(MemorySegment.ofArray(union.toByteArray()));
testAllCompactForms(union2, u, 0.05);
}
@@ -177,8 +177,8 @@ public class HeapUnionTest {
final int k = 1 << lgK;
final int u = 4*k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build(); //2k estimating
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build(); //2k estimating
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
for (int i=0; i<u/2; i++) {
usk1.update(i); //2k
@@ -187,21 +187,21 @@ public class HeapUnionTest {
usk2.update(i); //2k no overlap, exact, will force early stop
}
- final CompactSketch cosk2 = usk2.compact(true, null);
+ final CompactThetaSketch cosk2 = usk2.compact(true, null);
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
- union.union(usk1); //update with heap UpdateSketch
- union.union(cosk2); //update with heap Compact, Ordered input, early stop
+ union.union(usk1); //update with heap UpdatableThetaSketch
+ union.union(cosk2); //update with heap CompactThetaSketch, Ordered input, early stop
- UpdateSketch emptySketch = UpdateSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch emptySketch = UpdatableThetaSketch.builder().setNominalEntries(k).build();
union.union(emptySketch); //updates with empty
emptySketch = null;
union.union(emptySketch); //updates with null
testAllCompactForms(union, u, 0.05);
- final Union union2 = (Union)SetOperation.heapify(MemorySegment.ofArray(union.toByteArray()));
+ final ThetaUnion union2 = (ThetaUnion)ThetaSetOperation.heapify(MemorySegment.ofArray(union.toByteArray()));
testAllCompactForms(union2, u, 0.05);
@@ -215,8 +215,8 @@ public class HeapUnionTest {
final int k = 1 << lgK;
final int u = 4*k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build(); //2k estimating
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build(); //2k estimating
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
for (int i=0; i<u/2; i++) {
usk1.update(i); //2k estimating
@@ -226,21 +226,21 @@ public class HeapUnionTest {
}
final MemorySegment cskSeg2 = MemorySegment.ofArray(new byte[usk2.getCompactBytes()]);
- final CompactSketch cosk2 = usk2.compact(true, cskSeg2); //ordered, loads the cskSeg2 as ordered
+ final CompactThetaSketch cosk2 = usk2.compact(true, cskSeg2); //ordered, loads the cskSeg2 as ordered
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
- union.union(usk1); //updates with heap UpdateSketch
- union.union(cosk2); //updates with direct CompactSketch, ordered, use early stop
+ union.union(usk1); //updates with heap UpdatableThetaSketch
+ union.union(cosk2); //updates with direct CompactThetaSketch, ordered, use early stop
- UpdateSketch emptySketch = UpdateSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch emptySketch = UpdatableThetaSketch.builder().setNominalEntries(k).build();
union.union(emptySketch); //updates with empty sketch
emptySketch = null;
union.union(emptySketch); //updates with null sketch
testAllCompactForms(union, u, 0.05);
- final Union union2 = (Union)SetOperation.heapify(MemorySegment.ofArray(union.toByteArray()));
+ final ThetaUnion union2 = (ThetaUnion)ThetaSetOperation.heapify(MemorySegment.ofArray(union.toByteArray()));
testAllCompactForms(union2, u, 0.05);
@@ -254,8 +254,8 @@ public class HeapUnionTest {
final int k = 1 << lgK;
final int u = 4*k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build(); //2k estimating
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build(); //2k estimating
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
for (int i=0; i<u/2; i++) {
usk1.update(i); //2k estimating
@@ -267,19 +267,19 @@ public class HeapUnionTest {
final MemorySegment cskSeg2 = MemorySegment.ofArray(new byte[usk2.getCompactBytes()]);
usk2.compact(true, cskSeg2); //ordered, loads the cskSeg2 as ordered
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
- union.union(usk1); //updates with heap UpdateSketch
- union.union(cskSeg2); //updates with direct CompactSketch, ordered, use early stop
+ union.union(usk1); //updates with heap UpdatableThetaketch
+ union.union(cskSeg2); //updates with direct CompactThetaSketch, ordered, use early stop
- UpdateSketch emptySketch = UpdateSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch emptySketch = UpdatableThetaSketch.builder().setNominalEntries(k).build();
union.union(emptySketch); //updates with empty sketch
emptySketch = null;
union.union(emptySketch); //updates with null sketch
testAllCompactForms(union, u, 0.05);
- final Union union2 = (Union)SetOperation.heapify(MemorySegment.ofArray(union.toByteArray()));
+ final ThetaUnion union2 = (ThetaUnion)ThetaSetOperation.heapify(MemorySegment.ofArray(union.toByteArray()));
testAllCompactForms(union2, u, 0.05);
@@ -293,8 +293,8 @@ public class HeapUnionTest {
final int k = 1 << lgK;
final int u = 4*k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build(); //2k estimating
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build(); //2k estimating
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(2 * k).build(); //2k exact for early stop test
for (int i=0; i<u/2; i++) {
usk1.update(i); //2k estimating
@@ -306,19 +306,19 @@ public class HeapUnionTest {
final MemorySegment cskSeg2 = MemorySegment.ofArray(new byte[usk2.getCompactBytes()]);
usk2.compact(false, cskSeg2); //unordered, loads the cskSeg2 as unordered
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
- union.union(usk1); //updates with heap UpdateSketch
- union.union(cskSeg2); //updates with direct CompactSketch, ordered, use early stop
+ union.union(usk1); //updates with heap UpdatableThetaketch
+ union.union(cskSeg2); //updates with direct CompactThetaSketch, ordered, use early stop
- UpdateSketch emptySketch = UpdateSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch emptySketch = UpdatableThetaSketch.builder().setNominalEntries(k).build();
union.union(emptySketch); //updates with empty sketch
emptySketch = null;
union.union(emptySketch); //updates with null sketch
testAllCompactForms(union, u, 0.05);
- final Union union2 = (Union)SetOperation.heapify(MemorySegment.ofArray(union.toByteArray()));
+ final ThetaUnion union2 = (ThetaUnion)ThetaSetOperation.heapify(MemorySegment.ofArray(union.toByteArray()));
testAllCompactForms(union2, u, 0.05);
@@ -331,10 +331,10 @@ public class HeapUnionTest {
final int lgK = 13; //8192
final int k = 1 << lgK;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk3 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk4 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk3 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk4 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
int v=0;
int u = 1000000;
@@ -356,14 +356,14 @@ public class HeapUnionTest {
}
v += u;
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
- union.union(usk1); //updates with heap UpdateSketch
- union.union(usk2); //updates with heap UpdateSketch
- union.union(usk3); //updates with heap UpdateSketch
- union.union(usk4); //updates with heap UpdateSketch
+ union.union(usk1); //updates with heap UpdatableThetaketch
+ union.union(usk2); //updates with heap UpdatableThetaketch
+ union.union(usk3); //updates with heap UpdatableThetaketch
+ union.union(usk4); //updates with heap UpdatableThetaketch
- final CompactSketch csk = union.getResult(true, null);
+ final CompactThetaSketch csk = union.getResult(true, null);
final double est = csk.getEstimate();
assertEquals(est, v, .01*v);
}
@@ -376,8 +376,8 @@ public class HeapUnionTest {
final int u2 = 1024; //smaller exact sketch forces early stop
final int totU = u1+u2;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u1; i++) {
usk1.update(i); //2*k
@@ -389,15 +389,15 @@ public class HeapUnionTest {
final MemorySegment skSeg1 = MemorySegment.ofArray(usk1.compact(false, null).toByteArray());
final MemorySegment skSeg2 = MemorySegment.ofArray(usk2.compact(true, null).toByteArray());
- final CompactSketch csk1 = (CompactSketch)ThetaSketch.wrap(skSeg1);
- final CompactSketch csk2 = (CompactSketch)ThetaSketch.wrap(skSeg2);
+ final CompactThetaSketch csk1 = (CompactThetaSketch)ThetaSketch.wrap(skSeg1);
+ final CompactThetaSketch csk2 = (CompactThetaSketch)ThetaSketch.wrap(skSeg2);
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
union.union(csk1);
union.union(csk2);
- final CompactSketch cOut = union.getResult(true, null);
+ final CompactThetaSketch cOut = union.getResult(true, null);
assertEquals(cOut.getEstimate(), totU, .05*k);
}
@@ -407,15 +407,15 @@ public class HeapUnionTest {
final int k = 1 << lgK;
final int u = 2*k;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u; i++)
{
usk1.update(i); //force prelongs to 3
}
- final CompactSketch usk1c = usk1.compact(true, null);
+ final CompactThetaSketch usk1c = usk1.compact(true, null);
final MemorySegment v3seg1 = MemorySegment.ofArray(usk1c.toByteArray());
//println(PreambleUtil.toString(v3seg1));
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
union.union(v3seg1);
}
@@ -423,26 +423,26 @@ public class HeapUnionTest {
public void checkSegBadSerVer() {
final int lgK = 12; //4096
final int k = 1 << lgK;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
usk1.update(1);
usk1.update(2);
- final CompactSketch usk1c = usk1.compact(true, null);
+ final CompactThetaSketch usk1c = usk1.compact(true, null);
final MemorySegment v3seg1 = MemorySegment.ofArray(usk1c.toByteArray());
//corrupt SerVer
v3seg1.set(JAVA_BYTE, SER_VER_BYTE, (byte)0);
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
union.union(v3seg1);
}
@Test
public void checkGetResult() {
final int k = 1024;
- final UpdateSketch sk = UpdateSketch.builder().build();
+ final UpdatableThetaSketch sk = UpdatableThetaSketch.builder().build();
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
union.union(sk);
- final CompactSketch csk = union.getResult();
+ final CompactThetaSketch csk = union.getResult();
assertEquals(csk.getCompactBytes(), 8);
}
@@ -450,12 +450,12 @@ public class HeapUnionTest {
public void checkTrimToK() {
final int hiK = 1024;
final int loK = 512;
- final UpdateSketch hiSk = UpdateSketch.builder().setNominalEntries(hiK).build();
+ final UpdatableThetaSketch hiSk = UpdatableThetaSketch.builder().setNominalEntries(hiK).build();
for (int i = 0; i < 3749; i++) { hiSk.update(i); } //count = 1920
- final UpdateSketch loSk = UpdateSketch.builder().setNominalEntries(loK).build();
+ final UpdatableThetaSketch loSk = UpdatableThetaSketch.builder().setNominalEntries(loK).build();
for (int i = 0; i < 1783; i++) { loSk.update(i + 10000); } //count = 960
- final Union union = SetOperation.builder().setNominalEntries(hiK).buildUnion();
- CompactSketch csk = union.union(hiSk, loSk);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(hiK).buildUnion();
+ CompactThetaSketch csk = union.union(hiSk, loSk);
println(csk.toString());
assertEquals(csk.getRetainedEntries(), 1024);
}
@@ -463,7 +463,7 @@ public class HeapUnionTest {
@Test
public void checkPrimitiveUpdates() {
final int k = 32;
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
union.update(1L); //#1 long
union.update(1.5); //#2 double
@@ -507,7 +507,7 @@ public class HeapUnionTest {
final long[] longArr2 = { 6, 7, 8, 9 };
union.update(longArr2); //#9 actual long[]
- final CompactSketch comp = union.getResult();
+ final CompactThetaSketch comp = union.getResult();
final double est = comp.getEstimate();
final boolean empty = comp.isEmpty();
assertEquals(est, 9.0, 0.0);
@@ -515,12 +515,12 @@ public class HeapUnionTest {
}
//used by DirectUnionTest as well
- public static void testAllCompactForms(final Union union, final double expected, final double toll) {
+ public static void testAllCompactForms(final ThetaUnion union, final double expected, final double toll) {
double compEst1, compEst2;
compEst1 = union.getResult(false, null).getEstimate(); //not ordered, no seg
assertEquals(compEst1, expected, toll*expected);
- final CompactSketch comp2 = union.getResult(true, null); //ordered, no seg
+ final CompactThetaSketch comp2 = union.getResult(true, null); //ordered, no seg
compEst2 = comp2.getEstimate();
assertEquals(compEst2, compEst1, 0.0);
@@ -535,7 +535,7 @@ public class HeapUnionTest {
@Test
public void checkGetFamily() {
- final SetOperation setOp = new SetOperationBuilder().build(Family.UNION);
+ final ThetaSetOperation setOp = new ThetaSetOperationBuilder().build(Family.UNION);
assertEquals(setOp.getFamily(), Family.UNION);
}
diff --git a/src/test/java/org/apache/datasketches/theta/HeapifyWrapSerVer3Test.java b/src/test/java/org/apache/datasketches/theta/HeapifyWrapSerVer3Test.java
index 79e0252af..5b8a95f68 100644
--- a/src/test/java/org/apache/datasketches/theta/HeapifyWrapSerVer3Test.java
+++ b/src/test/java/org/apache/datasketches/theta/HeapifyWrapSerVer3Test.java
@@ -32,21 +32,21 @@ import org.testng.annotations.Test;
public class HeapifyWrapSerVer3Test {
private static final short defaultSeedHash = Util.computeSeedHash(Util.DEFAULT_UPDATE_SEED);
- //Heapify CompactSketch
+ //Heapify CompactThetaSketch
@Test
public void checkHeapifyCompactSketchAssumedDefaultSeed() {
final int k = 64;
final long seed = Util.DEFAULT_UPDATE_SEED;
final short seedHash = Util.computeSeedHash(seed);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).setSeed(seed).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).setSeed(seed).build();
for (int i = 0; i < k; i++) { usk.update(i); }
- final CompactSketch csk = usk.compact();
+ final CompactThetaSketch csk = usk.compact();
final MemorySegment cskSeg = MemorySegment.ofArray(csk.toByteArray()).asReadOnly();
- CompactSketch cskResult;
+ CompactThetaSketch cskResult;
- cskResult = CompactSketch.heapify(cskSeg);
+ cskResult = CompactThetaSketch.heapify(cskSeg);
assertEquals(cskResult.getEstimate(), usk.getEstimate());
assertEquals(cskResult.getSeedHash(), seedHash);
}
@@ -56,33 +56,33 @@ public class HeapifyWrapSerVer3Test {
final int k = 64;
final long seed = 128L;
final short seedHash = Util.computeSeedHash(seed);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).setSeed(seed).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).setSeed(seed).build();
for (int i = 0; i < k; i++) { usk.update(i); }
- final CompactSketch csk = usk.compact();
+ final CompactThetaSketch csk = usk.compact();
final MemorySegment cskSeg = MemorySegment.ofArray(csk.toByteArray()).asReadOnly();
- CompactSketch cskResult;
+ CompactThetaSketch cskResult;
- cskResult = CompactSketch.heapify(cskSeg, seed);
+ cskResult = CompactThetaSketch.heapify(cskSeg, seed);
assertEquals(cskResult.getEstimate(), usk.getEstimate());
assertEquals(cskResult.getSeedHash(), seedHash);
}
- //Heapify Sketch
+ //Heapify ThetaSketch
@Test
public void checkHeapifySketchAssumedDefaultSeed() {
final int k = 64;
final long seed = Util.DEFAULT_UPDATE_SEED;
final short seedHash = Util.computeSeedHash(seed);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).setSeed(seed).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).setSeed(seed).build();
for (int i = 0; i < k; i++) { usk.update(i); }
- final CompactSketch csk = usk.compact();
+ final CompactThetaSketch csk = usk.compact();
final MemorySegment cskSeg = MemorySegment.ofArray(csk.toByteArray()).asReadOnly();
- CompactSketch cskResult;
+ CompactThetaSketch cskResult;
- cskResult = (CompactSketch) ThetaSketch.heapify(cskSeg);
+ cskResult = (CompactThetaSketch) ThetaSketch.heapify(cskSeg);
assertEquals(cskResult.getEstimate(), usk.getEstimate());
assertEquals(cskResult.getSeedHash(), seedHash);
}
@@ -92,34 +92,34 @@ public class HeapifyWrapSerVer3Test {
final int k = 64;
final long seed = 128L;
final short seedHash = Util.computeSeedHash(seed);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).setSeed(seed).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).setSeed(seed).build();
for (int i = 0; i < k; i++) { usk.update(i); }
- final CompactSketch csk = usk.compact();
+ final CompactThetaSketch csk = usk.compact();
final MemorySegment cskSeg = MemorySegment.ofArray(csk.toByteArray()).asReadOnly();
- CompactSketch cskResult;
+ CompactThetaSketch cskResult;
- cskResult = (CompactSketch) ThetaSketch.heapify(cskSeg, seed);
+ cskResult = (CompactThetaSketch) ThetaSketch.heapify(cskSeg, seed);
assertEquals(cskResult.getEstimate(), usk.getEstimate());
assertEquals(cskResult.getSeedHash(), seedHash);
}
- //Wrap CompactSketch
+ //Wrap CompactThetaSketch
@Test
public void checkWrapCompactSketchAssumedDefaultSeed() {
final int k = 64;
final long seed = Util.DEFAULT_UPDATE_SEED;
final short seedHash = Util.computeSeedHash(seed);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).setSeed(seed).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).setSeed(seed).build();
for (int i = 0; i < k; i++) { usk.update(i); }
- CompactSketch cskResult;
+ CompactThetaSketch cskResult;
MemorySegment offHeap;
- final CompactSketch csk = usk.compact();
+ final CompactThetaSketch csk = usk.compact();
try(Arena arena = Arena.ofConfined()) {
offHeap = putOffHeap(MemorySegment.ofArray(csk.toByteArray()), arena);
- cskResult = CompactSketch.wrap(offHeap);
+ cskResult = CompactThetaSketch.wrap(offHeap);
assertEquals(cskResult.getEstimate(), usk.getEstimate());
assertEquals(cskResult.getSeedHash(), seedHash);
assertTrue(cskResult.isOffHeap());
@@ -131,38 +131,38 @@ public class HeapifyWrapSerVer3Test {
final int k = 64;
final long seed = 128L;
final short seedHash = Util.computeSeedHash(seed);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).setSeed(seed).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).setSeed(seed).build();
for (int i = 0; i < k; i++) { usk.update(i); }
- CompactSketch cskResult;
+ CompactThetaSketch cskResult;
MemorySegment offHeap;
- final CompactSketch csk = usk.compact();
+ final CompactThetaSketch csk = usk.compact();
try(Arena arena = Arena.ofConfined()) {
offHeap = putOffHeap(MemorySegment.ofArray(csk.toByteArray()), arena);
- cskResult = CompactSketch.wrap(offHeap, seed);
+ cskResult = CompactThetaSketch.wrap(offHeap, seed);
assertEquals(cskResult.getEstimate(), usk.getEstimate());
assertEquals(cskResult.getSeedHash(), seedHash);
assertTrue(cskResult.isOffHeap());
}
}
- //Wrap Sketch
+ //Wrap ThetaSketch
@Test
public void checkWrapSketchAssumedDefaultSeed() {
final int k = 64;
final long seed = Util.DEFAULT_UPDATE_SEED;
final short seedHash = Util.computeSeedHash(seed);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).setSeed(seed).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).setSeed(seed).build();
for (int i = 0; i < k; i++) { usk.update(i); }
- CompactSketch cskResult;
+ CompactThetaSketch cskResult;
MemorySegment offHeap;
- final CompactSketch csk = usk.compact();
+ final CompactThetaSketch csk = usk.compact();
//SerialVersion3 test
try(Arena arena = Arena.ofConfined()) {
offHeap = putOffHeap(MemorySegment.ofArray(csk.toByteArray()), arena);
- cskResult = (CompactSketch) ThetaSketch.wrap(offHeap);
+ cskResult = (CompactThetaSketch) ThetaSketch.wrap(offHeap);
assertEquals(cskResult.getEstimate(), usk.getEstimate());
assertEquals(cskResult.getSeedHash(), seedHash);
assertTrue(cskResult.isOffHeap());
@@ -174,16 +174,16 @@ public class HeapifyWrapSerVer3Test {
final int k = 64;
final long seed = 128L;
final short seedHash = Util.computeSeedHash(seed);
- final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).setSeed(seed).build();
+ final UpdatableThetaSketch usk = UpdatableThetaSketch.builder().setNominalEntries(k).setSeed(seed).build();
for (int i = 0; i < k; i++) { usk.update(i); }
- CompactSketch cskResult;
+ CompactThetaSketch cskResult;
MemorySegment offHeap;
- final CompactSketch csk = usk.compact();
+ final CompactThetaSketch csk = usk.compact();
//SerialVersion3 test
try(Arena arena = Arena.ofConfined()) {
offHeap = putOffHeap(MemorySegment.ofArray(csk.toByteArray()), arena);
- cskResult = (CompactSketch) ThetaSketch.wrap(offHeap, seed);
+ cskResult = (CompactThetaSketch) 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 7e3dbd159..4ce9c8f8b 100644
--- a/src/test/java/org/apache/datasketches/theta/IteratorTest.java
+++ b/src/test/java/org/apache/datasketches/theta/IteratorTest.java
@@ -24,11 +24,11 @@ import static org.testng.Assert.assertEquals;
import java.lang.foreign.MemorySegment;
import org.testng.annotations.Test;
import org.apache.datasketches.common.Family;
-import org.apache.datasketches.theta.CompactSketch;
+import org.apache.datasketches.theta.CompactThetaSketch;
import org.apache.datasketches.theta.HashIterator;
import org.apache.datasketches.theta.ThetaSketch;
-import org.apache.datasketches.theta.UpdateSketch;
+import org.apache.datasketches.theta.UpdatableThetaSketch;
/**
@@ -41,7 +41,7 @@ public class IteratorTest {
int k = 16;
int maxBytes = ThetaSketch.getMaxUpdateSketchBytes(k);
MemorySegment wseg = MemorySegment.ofArray(new byte[maxBytes]);
- UpdateSketch sk1 = UpdateSketch.builder().setNominalEntries(k).build(wseg);
+ UpdatableThetaSketch sk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build(wseg);
println(sk1.getClass().getSimpleName());
for (int i = 0; i < (k/2); i++) { sk1.update(i); }
HashIterator itr1 = sk1.iterator();
@@ -76,7 +76,7 @@ public class IteratorTest {
public void checkHeapAlphaSketch() {
int k = 512;
int u = 8;
- UpdateSketch sk1 = UpdateSketch.builder().setNominalEntries(k).setFamily(Family.ALPHA)
+ UpdatableThetaSketch sk1 = UpdatableThetaSketch.builder().setNominalEntries(k).setFamily(Family.ALPHA)
.build();
println(sk1.getClass().getSimpleName());
for (int i = 0; i < u; i++) { sk1.update(i); }
@@ -92,7 +92,7 @@ public class IteratorTest {
public void checkHeapQSSketch() {
int k = 16;
int u = 8;
- UpdateSketch sk1 = UpdateSketch.builder().setNominalEntries(k)
+ UpdatableThetaSketch sk1 = UpdatableThetaSketch.builder().setNominalEntries(k)
.build();
println(sk1.getClass().getSimpleName());
for (int i = 0; i < u; i++) { sk1.update(i); }
@@ -108,11 +108,11 @@ public class IteratorTest {
public void checkSingleItemSketch() {
int k = 16;
int u = 1;
- UpdateSketch sk1 = UpdateSketch.builder().setNominalEntries(k)
+ UpdatableThetaSketch sk1 = UpdatableThetaSketch.builder().setNominalEntries(k)
.build();
for (int i = 0; i < u; i++) { sk1.update(i); }
- CompactSketch csk = sk1.compact();
+ CompactThetaSketch csk = sk1.compact();
println(csk.getClass().getSimpleName());
HashIterator itr1 = csk.iterator();
int count = 0;
diff --git a/src/test/java/org/apache/datasketches/theta/JaccardSimilarityTest.java b/src/test/java/org/apache/datasketches/theta/JaccardSimilarityTest.java
index 63f2f9d70..d25dc37d4 100644
--- a/src/test/java/org/apache/datasketches/theta/JaccardSimilarityTest.java
+++ b/src/test/java/org/apache/datasketches/theta/JaccardSimilarityTest.java
@@ -25,7 +25,7 @@ import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import org.apache.datasketches.theta.JaccardSimilarity;
-import org.apache.datasketches.theta.UpdateSketch;
+import org.apache.datasketches.theta.UpdatableThetaSketch;
import org.testng.annotations.Test;
/**
@@ -47,8 +47,8 @@ public class JaccardSimilarityTest {
state = exactlyEqual(null, null);
assertFalse(state);
- UpdateSketch measured = UpdateSketch.builder().setNominalEntries(minK).build();
- UpdateSketch expected = UpdateSketch.builder().setNominalEntries(minK).build();
+ UpdatableThetaSketch measured = UpdatableThetaSketch.builder().setNominalEntries(minK).build();
+ UpdatableThetaSketch expected = UpdatableThetaSketch.builder().setNominalEntries(minK).build();
//check both empty
jResults = jaccard(measured, expected);
@@ -82,8 +82,8 @@ public class JaccardSimilarityTest {
double threshold = 0.9999;
println("Exact Mode, minK: " + k + "\t Th: " + threshold);
- UpdateSketch measured = UpdateSketch.builder().setNominalEntries(k).build();
- UpdateSketch expected = UpdateSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch measured = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch expected = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i = 0; i < (u-1); i++) { //one short
measured.update(i);
@@ -118,8 +118,8 @@ public class JaccardSimilarityTest {
double threshold = 0.9999;
println("Estimation Mode, minK: " + k + "\t Th: " + threshold);
- UpdateSketch measured = UpdateSketch.builder().setNominalEntries(k).build();
- UpdateSketch expected = UpdateSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch measured = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch expected = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i = 0; i < u; i++) {
measured.update(i);
@@ -162,8 +162,8 @@ public class JaccardSimilarityTest {
double threshold = 0.943;
println("Estimation Mode, minK: " + minK + "\t Th: " + threshold);
- UpdateSketch expected = UpdateSketch.builder().setNominalEntries(minK).build();
- UpdateSketch measured = UpdateSketch.builder().setNominalEntries(minK).build();
+ UpdatableThetaSketch expected = UpdatableThetaSketch.builder().setNominalEntries(minK).build();
+ UpdatableThetaSketch measured = UpdatableThetaSketch.builder().setNominalEntries(minK).build();
for (int i = 0; i < u1; i++) {
expected.update(i);
@@ -195,8 +195,8 @@ public class JaccardSimilarityTest {
double threshold = 0.061;
println("Estimation Mode, minK: " + minK + "\t Th: " + threshold);
- UpdateSketch expected = UpdateSketch.builder().setNominalEntries(minK).build();
- UpdateSketch measured = UpdateSketch.builder().setNominalEntries(minK).build();
+ UpdatableThetaSketch expected = UpdatableThetaSketch.builder().setNominalEntries(minK).build();
+ UpdatableThetaSketch measured = UpdatableThetaSketch.builder().setNominalEntries(minK).build();
for (int i = 0; i < u1; i++) {
expected.update(i);
@@ -221,8 +221,8 @@ public class JaccardSimilarityTest {
@Test
public void checkMinK() {
- UpdateSketch skA = UpdateSketch.builder().build(); //4096
- UpdateSketch skB = UpdateSketch.builder().build(); //4096
+ UpdatableThetaSketch skA = UpdatableThetaSketch.builder().build(); //4096
+ UpdatableThetaSketch skB = UpdatableThetaSketch.builder().build(); //4096
skA.update(1);
skB.update(1);
double[] result = JaccardSimilarity.jaccard(skA, skB);
diff --git a/src/test/java/org/apache/datasketches/theta/PairwiseSetOperationsTest.java b/src/test/java/org/apache/datasketches/theta/PairwiseSetOperationsTest.java
index e2682453a..06733d3fb 100644
--- a/src/test/java/org/apache/datasketches/theta/PairwiseSetOperationsTest.java
+++ b/src/test/java/org/apache/datasketches/theta/PairwiseSetOperationsTest.java
@@ -23,35 +23,28 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import org.apache.datasketches.common.SketchesArgumentException;
-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.annotations.Test;
public class PairwiseSetOperationsTest {
- // Intersection
+ // ThetaIntersection
@Test
public void checkIntersectionNoOverlap() {
int lgK = 9;
int k = 1<<lgK;
- UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<k; i++) { //<k so est is exact
usk1.update(i);
usk2.update(i + k);
}
- CompactSketch csk1 = usk1.compact(true, null);
- CompactSketch csk2 = usk2.compact(true, null);
- Intersection inter = SetOperation.builder().buildIntersection();
+ CompactThetaSketch csk1 = usk1.compact(true, null);
+ CompactThetaSketch csk2 = usk2.compact(true, null);
+ ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
ThetaSketch rsk = inter.intersect(csk1, csk2);
assertEquals(rsk.getEstimate(), 0.0);
}
@@ -61,17 +54,17 @@ public class PairwiseSetOperationsTest {
int lgK = 9;
int k = 1<<lgK;
- UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
- Intersection inter = SetOperation.builder().buildIntersection();
+ UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
for (int i=0; i<k; i++) { //<k so est is exact
usk1.update(i);
usk2.update(i);
}
- CompactSketch csk1 = usk1.compact(true, null);
- CompactSketch csk2 = usk2.compact(true, null);
+ CompactThetaSketch csk1 = usk1.compact(true, null);
+ CompactThetaSketch csk2 = usk2.compact(true, null);
ThetaSketch rsk = inter.intersect(csk1, csk2);
assertEquals(rsk.getEstimate(), k, 0.0);
@@ -85,9 +78,9 @@ public class PairwiseSetOperationsTest {
long v = 0;
int trials = 10;
- UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
- Intersection inter = SetOperation.builder().buildIntersection();
+ UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
for (int t = 0; t < trials; t++) {
for (int i=0; i<u; i++) {
@@ -96,14 +89,14 @@ public class PairwiseSetOperationsTest {
}
v += u + (u/2);
- CompactSketch csk1 = usk1.compact(true, null);
- CompactSketch csk2 = usk2.compact(true, null);
+ CompactThetaSketch csk1 = usk1.compact(true, null);
+ CompactThetaSketch csk2 = usk2.compact(true, null);
ThetaSketch rsk = inter.intersect(csk1, csk2);
double result1 = rsk.getEstimate();
inter.intersect(csk1);
inter.intersect(csk2);
- CompactSketch csk3 = inter.getResult(true, null);
+ CompactThetaSketch csk3 = inter.getResult(true, null);
double result2 = csk3.getEstimate();
assertEquals(result1, result2, 0.0);
@@ -114,24 +107,24 @@ public class PairwiseSetOperationsTest {
}
}
-// A and not B
+// Theta A and not B
@Test
public void checkAnotBNoOverlap() {
int lgK = 9;
int k = 1<<lgK;
- UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
- AnotB anotb = SetOperation.builder().buildANotB();
+ UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ ThetaAnotB anotb = ThetaSetOperation.builder().buildANotB();
for (int i=0; i<k; i++) {
usk1.update(i);
usk2.update(i + k);
}
- CompactSketch csk1 = usk1.compact(true, null);
- CompactSketch csk2 = usk2.compact(true, null);
+ CompactThetaSketch csk1 = usk1.compact(true, null);
+ CompactThetaSketch csk2 = usk2.compact(true, null);
ThetaSketch rsk = anotb.aNotB(csk1, csk2);
assertEquals(rsk.getEstimate(), k, 0.0);
@@ -142,17 +135,17 @@ public class PairwiseSetOperationsTest {
int lgK = 9;
int k = 1<<lgK;
- UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
- AnotB anotb = SetOperation.builder().buildANotB();
+ UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ ThetaAnotB anotb = ThetaSetOperation.builder().buildANotB();
for (int i=0; i<k; i++) {
usk1.update(i);
usk2.update(i);
}
- CompactSketch csk1 = usk1.compact(true, null);
- CompactSketch csk2 = usk2.compact(true, null);
+ CompactThetaSketch csk1 = usk1.compact(true, null);
+ CompactThetaSketch csk2 = usk2.compact(true, null);
ThetaSketch rsk = anotb.aNotB(csk1, csk2);
assertEquals(rsk.getEstimate(), 0.0, 0.0);
@@ -166,9 +159,9 @@ public class PairwiseSetOperationsTest {
long v = 0;
int trials = 10;
- UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
- AnotB aNotB = SetOperation.builder().buildANotB();
+ UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ ThetaAnotB aNotB = ThetaSetOperation.builder().buildANotB();
for (int t = 0; t < trials; t++) {
for (int i=0; i<u; i++) {
@@ -177,13 +170,13 @@ public class PairwiseSetOperationsTest {
}
v += u + (u/2);
- CompactSketch csk1 = usk1.compact(true, null);
- CompactSketch csk2 = usk2.compact(true, null);
+ CompactThetaSketch csk1 = usk1.compact(true, null);
+ CompactThetaSketch csk2 = usk2.compact(true, null);
ThetaSketch rsk = aNotB.aNotB(csk1, csk2);
double result1 = rsk.getEstimate();
- CompactSketch csk3 = aNotB.aNotB(csk1, csk2);
+ CompactThetaSketch csk3 = aNotB.aNotB(csk1, csk2);
double result2 = csk3.getEstimate();
assertEquals(result1, result2, 0.0);
@@ -193,24 +186,24 @@ public class PairwiseSetOperationsTest {
}
}
-//Union
+//ThetaUnion
@Test
public void checkUnionNoOverlap() {
int lgK = 9;
int k = 1<<lgK;
- UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
- Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
for (int i=0; i<k; i++) {
usk1.update(i);
usk2.update(i + k);
}
- CompactSketch csk1 = usk1.compact(true, null);
- CompactSketch csk2 = usk2.compact(true, null);
+ CompactThetaSketch csk1 = usk1.compact(true, null);
+ CompactThetaSketch csk2 = usk2.compact(true, null);
union.union(csk1);
union.union(csk2);
@@ -226,17 +219,17 @@ public class PairwiseSetOperationsTest {
int lgK = 9;
int k = 1<<lgK;
- UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
- Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
for (int i=0; i<k; i++) {
usk1.update(i);
usk2.update(i);
}
- CompactSketch csk1 = usk1.compact(true, null);
- CompactSketch csk2 = usk2.compact(true, null);
+ CompactThetaSketch csk1 = usk1.compact(true, null);
+ CompactThetaSketch csk2 = usk2.compact(true, null);
ThetaSketch rsk = union.union(csk1, csk2);
assertEquals(rsk.getEstimate(), k, 0.0);
@@ -250,9 +243,9 @@ public class PairwiseSetOperationsTest {
long v = 0;
int trials = 10;
- UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
- Union union = SetOperation.builder().setNominalEntries(2 * k).buildUnion();
+ UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(2 * k).buildUnion();
for (int t = 0; t < trials; t++) {
for (int i=0; i<u; i++) {
@@ -261,15 +254,15 @@ public class PairwiseSetOperationsTest {
}
v += u + (u/2);
- CompactSketch csk1 = usk1.compact(true, null);
- CompactSketch csk2 = usk2.compact(true, null);
+ CompactThetaSketch csk1 = usk1.compact(true, null);
+ CompactThetaSketch csk2 = usk2.compact(true, null);
ThetaSketch pwSk = union.union(csk1, csk2);
double pwEst = pwSk.getEstimate();
union.union(csk1);
union.union(csk2);
- CompactSketch stdSk = union.getResult(true, null);
+ CompactThetaSketch stdSk = union.getResult(true, null);
double stdEst = stdSk.getEstimate();
assertEquals(pwEst, stdEst, 0.0);
@@ -286,24 +279,24 @@ public class PairwiseSetOperationsTest {
int k = 1<<lgK;
int u = (3 * k);
- UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
- UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
- Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
for (int i=0; i < u; i++) {
usk1.update(i);
usk2.update(i + (2 * u));
}
- CompactSketch csk1 = usk1.compact(true, null);
- CompactSketch csk2 = usk2.compact(true, null);
+ CompactThetaSketch csk1 = usk1.compact(true, null);
+ CompactThetaSketch csk2 = usk2.compact(true, null);
ThetaSketch pwSk = union.union(csk1, csk2);
double pwEst = pwSk.getEstimate();
union.union(csk1);
union.union(csk2);
- CompactSketch stdSk = union.getResult(true, null);
+ CompactThetaSketch stdSk = union.getResult(true, null);
double stdEst = stdSk.getEstimate();
assertEquals(pwEst, stdEst, stdEst * .06);
@@ -317,12 +310,12 @@ public class PairwiseSetOperationsTest {
@Test
public void checkNullRules() {
int k = 16;
- UpdateSketch uskA = UpdateSketch.builder().setNominalEntries(k).build();
- CompactSketch cskAempty = uskA.compact();
- CompactSketch cskAnull = null;
+ UpdatableThetaSketch uskA = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ CompactThetaSketch cskAempty = uskA.compact();
+ CompactThetaSketch cskAnull = null;
- AnotB aNotB = SetOperation.builder().buildANotB();
- Intersection inter = SetOperation.builder().buildIntersection();
+ ThetaAnotB aNotB = ThetaSetOperation.builder().buildANotB();
+ ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
try {
checkIntersection(inter, cskAnull, cskAempty);
@@ -355,50 +348,50 @@ public class PairwiseSetOperationsTest {
@Test
public void checkEmptyValidRules() {
int k = 16;
- UpdateSketch uskA = UpdateSketch.builder().setNominalEntries(k).build();
- UpdateSketch uskB = UpdateSketch.builder().setNominalEntries(k).build();
- CompactSketch cskAempty = uskA.compact();
- CompactSketch cskBempty = uskB.compact();
+ UpdatableThetaSketch uskA = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ UpdatableThetaSketch uskB = UpdatableThetaSketch.builder().setNominalEntries(k).build();
+ CompactThetaSketch cskAempty = uskA.compact();
+ CompactThetaSketch cskBempty = uskB.compact();
uskA.update(1);
- CompactSketch cskA1 = uskA.compact();
+ CompactThetaSketch cskA1 = uskA.compact();
- Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
- AnotB aNotB = SetOperation.builder().buildANotB();
- Intersection inter = SetOperation.builder().buildIntersection();
+ ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion();
+ ThetaAnotB aNotB = ThetaSetOperation.builder().buildANotB();
+ ThetaIntersection inter = ThetaSetOperation.builder().buildIntersection();
checkSetOps(union, inter, aNotB, cskAempty, cskBempty); //Empty, Empty
checkSetOps(union, inter, aNotB, cskA1, cskBempty); //NotEmpty, Empty
checkSetOps(union, inter, aNotB, cskAempty, cskA1); //Empty, NotEmpty
}
- private static void checkSetOps(Union union, Intersection inter, AnotB aNotB,
- CompactSketch cskA, CompactSketch cskB) {
+ private static void checkSetOps(ThetaUnion union, ThetaIntersection inter, ThetaAnotB aNotB,
+ CompactThetaSketch cskA, CompactThetaSketch cskB) {
checkUnion(union, cskA, cskB);
checkIntersection(inter, cskA, cskB);
checkAnotB(aNotB, cskA, cskB);
}
- private static void checkUnion(Union union, CompactSketch cskA, CompactSketch cskB) {
+ private static void checkUnion(ThetaUnion union, CompactThetaSketch cskA, CompactThetaSketch cskB) {
union.union(cskA);
union.union(cskB);
- CompactSketch cskU = union.getResult();
- CompactSketch cskP = union.union(cskA, cskB);
+ CompactThetaSketch cskU = union.getResult();
+ CompactThetaSketch cskP = union.union(cskA, cskB);
assertEquals(cskU.isEmpty(), cskP.isEmpty());
union.reset();
}
- private static void checkIntersection(Intersection inter, CompactSketch cskA, CompactSketch cskB) {
+ private static void checkIntersection(ThetaIntersection inter, CompactThetaSketch cskA, CompactThetaSketch cskB) {
inter.intersect(cskA);
inter.intersect(cskB);
- CompactSketch cskI = inter.getResult();
- CompactSketch cskP = inter.intersect(cskA, cskB);
+ CompactThetaSketch cskI = inter.getResult();
+ CompactThetaSketch cskP = inter.intersect(cskA, cskB);
assertEquals(cskI.isEmpty(), cskP.isEmpty());
inter.reset();
}
- private static void checkAnotB(AnotB aNotB, CompactSketch cskA, CompactSketch cskB) {
- CompactSketch cskD = aNotB.aNotB(cskA, cskB);
- CompactSketch cskP = aNotB.aNotB(cskA, cskB);
+ private static void checkAnotB(ThetaAnotB aNotB, CompactThetaSketch cskA, CompactThetaSketch cskB) {
+ CompactThetaSketch cskD = aNotB.aNotB(cskA, cskB);
+ CompactThetaSketch cskP = aNotB.aNotB(cskA, cskB);
assertEquals(cskD.isEmpty(), cskP.isEmpty());
}
diff --git a/src/test/java/org/apache/datasketches/theta/PreambleUtilTest.java b/src/test/java/org/apache/datasketches/theta/PreambleUtilTest.java
index a17b6f64c..23b8abde0 100644
--- a/src/test/java/org/apache/datasketches/theta/PreambleUtilTest.java
+++ b/src/test/java/org/apache/datasketches/theta/PreambleUtilTest.java
@@ -46,7 +46,7 @@ import static org.apache.datasketches.theta.PreambleUtil.insertThetaLong;
import static org.apache.datasketches.theta.PreambleUtil.insertUnionThetaLong;
import static org.apache.datasketches.theta.PreambleUtil.isEmptyFlag;
import static org.apache.datasketches.theta.PreambleUtil.setEmpty;
-import static org.apache.datasketches.theta.SetOperation.getMaxUnionBytes;
+import static org.apache.datasketches.theta.ThetaSetOperation.getMaxUnionBytes;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
@@ -73,7 +73,7 @@ public class PreambleUtilTest {
final byte[] byteArray = new byte[bytes];
final MemorySegment seg = MemorySegment.ofArray(byteArray);
- final UpdateSketch quick1 = UpdateSketch.builder().setNominalEntries(k).build(seg);
+ final UpdatableThetaSketch quick1 = UpdatableThetaSketch.builder().setNominalEntries(k).build(seg);
println(ThetaSketch.toString(byteArray));
Assert.assertTrue(quick1.isEmpty());
@@ -89,7 +89,7 @@ public class PreambleUtilTest {
println(PreambleUtil.preambleToString(seg));
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]);
- final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
+ final ThetaUnion union = ThetaSetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
union.union(quick1);
println(PreambleUtil.preambleToString(uSeg));
}
@@ -98,7 +98,7 @@ public class PreambleUtilTest {
public void checkToStringWithPrelongsOf2() {
final int k = 16;
final int u = k;
- final UpdateSketch quick1 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch quick1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i = 0; i< u; i++) {
quick1.update(i);
}
@@ -133,8 +133,8 @@ public class PreambleUtilTest {
@Test
public void checkPreLongs() {
- final UpdateSketch sketch = UpdateSketch.builder().setNominalEntries(16).build();
- CompactSketch comp = sketch.compact(false, null);
+ final UpdatableThetaSketch sketch = UpdatableThetaSketch.builder().setNominalEntries(16).build();
+ CompactThetaSketch comp = sketch.compact(false, null);
byte[] byteArr = comp.toByteArray();
println(ThetaSketch.toString(byteArr)); //PreLongs = 1
diff --git a/src/test/java/org/apache/datasketches/theta/ReadOnlyMemorySegmentTest.java b/src/test/java/org/apache/datasketches/theta/ReadOnlyMemorySegmentTest.java
index d196fc95b..396d0f0cf 100644
--- a/src/test/java/org/apache/datasketches/theta/ReadOnlyMemorySegmentTest.java
+++ b/src/test/java/org/apache/datasketches/theta/ReadOnlyMemorySegmentTest.java
@@ -35,11 +35,11 @@ public class ReadOnlyMemorySegmentTest {
@Test
public void wrapAndTryUpdatingUpdateSketch() {
- final UpdateSketch updateSketch = UpdateSketch.builder().build();
+ final UpdatableThetaSketch updateSketch = UpdatableThetaSketch.builder().build();
updateSketch.update(1);
final MemorySegment seg = MemorySegment.ofBuffer(
ByteBuffer.wrap(updateSketch.toByteArray()).asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
- final UpdateSketch sketch = (UpdateSketch) ThetaSketch.wrap(seg);
+ final UpdatableThetaSketch sketch = (UpdatableThetaSketch) ThetaSketch.wrap(seg);
assertEquals(sketch.getEstimate(), 1.0);
assertTrue(seg.isReadOnly());
@@ -54,7 +54,7 @@ public class ReadOnlyMemorySegmentTest {
@Test
public void wrapCompactUnorderedSketch() {
- final UpdateSketch updateSketch = UpdateSketch.builder().build();
+ final UpdatableThetaSketch updateSketch = UpdatableThetaSketch.builder().build();
updateSketch.update(1);
final MemorySegment seg = MemorySegment.ofBuffer(
ByteBuffer.wrap(updateSketch.compact(false, null).toByteArray()).asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
@@ -65,7 +65,7 @@ public class ReadOnlyMemorySegmentTest {
@Test
public void wrapCompactOrderedSketch() {
- final UpdateSketch updateSketch = UpdateSketch.builder().build();
+ final UpdatableThetaSketch updateSketch = UpdatableThetaSketch.builder().build();
updateSketch.update(1);
final MemorySegment seg = MemorySegment.ofBuffer(ByteBuffer.wrap(updateSketch.compact().toByteArray())
.asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
@@ -76,12 +76,12 @@ public class ReadOnlyMemorySegmentTest {
@Test
public void heapifyUpdateSketch() {
- final UpdateSketch us1 = UpdateSketch.builder().build();
+ final UpdatableThetaSketch us1 = UpdatableThetaSketch.builder().build();
us1.update(1);
final MemorySegment seg = MemorySegment.ofBuffer(
ByteBuffer.wrap(us1.toByteArray()).asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
// downcasting is not recommended, for testing only
- final UpdateSketch us2 = (UpdateSketch) ThetaSketch.heapify(seg);
+ final UpdatableThetaSketch us2 = (UpdatableThetaSketch) ThetaSketch.heapify(seg);
us2.update(2);
assertEquals(us2.getEstimate(), 2.0);
assertTrue(seg.isReadOnly());
@@ -89,7 +89,7 @@ public class ReadOnlyMemorySegmentTest {
@Test
public void heapifyCompactUnorderedSketch() {
- final UpdateSketch updateSketch = UpdateSketch.builder().build();
+ final UpdatableThetaSketch updateSketch = UpdatableThetaSketch.builder().build();
updateSketch.update(1);
final MemorySegment seg = MemorySegment.ofBuffer(
ByteBuffer.wrap(updateSketch.compact(false, null).toByteArray()).asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
@@ -100,7 +100,7 @@ public class ReadOnlyMemorySegmentTest {
@Test
public void heapifyCompactOrderedSketch() {
- final UpdateSketch updateSketch = UpdateSketch.builder().build();
+ final UpdatableThetaSketch updateSketch = UpdatableThetaSketch.builder().build();
updateSketch.update(1);
final MemorySegment seg = MemorySegment.ofBuffer(
ByteBuffer.wrap(updateSketch.compact().toByteArray()).asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
@@ -111,11 +111,11 @@ public class ReadOnlyMemorySegmentTest {
@Test
public void heapifyUnion() {
- final Union u1 = SetOperation.builder().buildUnion();
+ final ThetaUnion u1 = ThetaSetOperation.builder().buildUnion();
u1.update(1);
final MemorySegment seg = MemorySegment.ofBuffer(
ByteBuffer.wrap(u1.toByteArray()).asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
- final Union u2 = (Union) SetOperation.heapify(seg);
+ final ThetaUnion u2 = (ThetaUnion) ThetaSetOperation.heapify(seg);
u2.update(2);
Assert.assertEquals(u2.getResult().getEstimate(), 2.0);
assertTrue(seg.isReadOnly());
@@ -123,13 +123,13 @@ public class ReadOnlyMemorySegmentTest {
@Test
public void wrapAndTryUpdatingUnion() {
- final Union u1 = SetOperation.builder().buildUnion();
+ final ThetaUnion u1 = ThetaSetOperation.builder().buildUnion();
u1.update(1);
final MemorySegment seg = MemorySegment.ofBuffer(
ByteBuffer.wrap(u1.toByteArray()).asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
- final Union u2 = (Union) SetOperation.wrap(seg);
- final Union u3 = Union.wrap(seg);
+ final ThetaUnion u2 = (ThetaUnion) ThetaSetOperation.wrap(seg);
+ final ThetaUnion u3 = ThetaUnion.wrap(seg);
Assert.assertEquals(u2.getResult().getEstimate(), 1.0);
Assert.assertEquals(u3.getResult().getEstimate(), 1.0);
assertTrue(seg.isReadOnly());
@@ -151,19 +151,19 @@ public class ReadOnlyMemorySegmentTest {
@Test
public void heapifyIntersection() {
- final UpdateSketch us1 = UpdateSketch.builder().build();
+ final UpdatableThetaSketch us1 = UpdatableThetaSketch.builder().build();
us1.update(1);
us1.update(2);
- final UpdateSketch us2 = UpdateSketch.builder().build();
+ final UpdatableThetaSketch us2 = UpdatableThetaSketch.builder().build();
us2.update(2);
us2.update(3);
- final Intersection i1 = SetOperation.builder().buildIntersection();
+ final ThetaIntersection i1 = ThetaSetOperation.builder().buildIntersection();
i1.intersect(us1);
i1.intersect(us2);
final MemorySegment seg = MemorySegment.ofBuffer(
ByteBuffer.wrap(i1.toByteArray()).asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
- final Intersection i2 = (Intersection) SetOperation.heapify(seg);
+ final ThetaIntersection i2 = (ThetaIntersection) ThetaSetOperation.heapify(seg);
i2.intersect(us1);
Assert.assertEquals(i2.getResult().getEstimate(), 1.0);
assertTrue(seg.isReadOnly());
@@ -171,19 +171,19 @@ public class ReadOnlyMemorySegmentTest {
@Test
public void wrapIntersection() {
- final UpdateSketch us1 = UpdateSketch.builder().build();
+ final UpdatableThetaSketch us1 = UpdatableThetaSketch.builder().build();
us1.update(1);
us1.update(2);
- final UpdateSketch us2 = UpdateSketch.builder().build();
+ final UpdatableThetaSketch us2 = UpdatableThetaSketch.builder().build();
us2.update(2);
us2.update(3);
- final Intersection i1 = SetOperation.builder().buildIntersection();
+ final ThetaIntersection i1 = ThetaSetOperation.builder().buildIntersection();
i1.intersect(us1);
i1.intersect(us2);
final MemorySegment seg = MemorySegment.ofBuffer(
ByteBuffer.wrap(i1.toByteArray()).asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
- final Intersection i2 = (Intersection) SetOperation.wrap(seg);
+ final ThetaIntersection i2 = (ThetaIntersection) ThetaSetOperation.wrap(seg);
Assert.assertEquals(i2.getResult().getEstimate(), 1.0);
boolean thrown = false;
diff --git a/src/test/java/org/apache/datasketches/theta/SetOperationTest.java b/src/test/java/org/apache/datasketches/theta/SetOperationTest.java
index e19b405c6..45481b49f 100644
--- a/src/test/java/org/apache/datasketches/theta/SetOperationTest.java
+++ b/src/test/java/org/apache/datasketches/theta/SetOperationTest.java
@@ -47,8 +47,8 @@ public class SetOperationTest {
final int k = 2048;
final long seed = 1021;
- final UpdateSketch usk1 = UpdateSketch.builder().setSeed(seed).setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setSeed(seed).setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setSeed(seed).setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setSeed(seed).setNominalEntries(k).build();
for (int i=0; i<k/2; i++) {
usk1.update(i); //256
@@ -59,21 +59,21 @@ public class SetOperationTest {
final ResizeFactor rf = X4;
//use default size
- final Union union = SetOperation.builder().setSeed(seed).setResizeFactor(rf).buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().setSeed(seed).setResizeFactor(rf).buildUnion();
union.union(usk1);
union.union(usk2);
final double exactUnionAnswer = k;
- final CompactSketch comp1 = union.getResult(false, null); //ordered: false
+ final CompactThetaSketch comp1 = union.getResult(false, null); //ordered: false
final double compEst = comp1.getEstimate();
assertEquals(compEst, exactUnionAnswer, 0.0);
}
@Test
public void checkBuilder2() {
- final SetOperationBuilder bldr = SetOperation.builder();
+ final ThetaSetOperationBuilder bldr = ThetaSetOperation.builder();
final long seed = 12345L;
bldr.setSeed(seed);
@@ -97,36 +97,36 @@ public class SetOperationTest {
@Test
public void checkBuilderNonPowerOf2() {
- SetOperation.builder().setNominalEntries(1000).buildUnion();
+ ThetaSetOperation.builder().setNominalEntries(1000).buildUnion();
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkBuilderBadFamily() {
- SetOperation.builder().build(Family.ALPHA);
+ ThetaSetOperation.builder().build(Family.ALPHA);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkBuilderIllegalPhi() {
final float p = (float)1.5;
- SetOperation.builder().setP(p).buildUnion();
+ ThetaSetOperation.builder().setP(p).buildUnion();
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkBuilderIllegalPlo() {
final float p = 0;
- SetOperation.builder().setP(p).buildUnion();
+ ThetaSetOperation.builder().setP(p).buildUnion();
}
@Test
public void checkBuilderValidP() {
final float p = (float).5;
- SetOperation.builder().setP(p).buildUnion();
+ ThetaSetOperation.builder().setP(p).buildUnion();
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkBuilderAnotB_noSeg() {
final MemorySegment seg = MemorySegment.ofArray(new byte[64]);
- SetOperation.builder().build(Family.A_NOT_B, seg);
+ ThetaSetOperation.builder().build(Family.A_NOT_B, seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -134,8 +134,8 @@ public class SetOperationTest {
final int k = 2048;
final long seed = 1021;
- final UpdateSketch usk1 = UpdateSketch.builder().setSeed(seed).setNominalEntries(k).build();
- final UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setSeed(seed).setNominalEntries(k).build();
+ final UpdatableThetaSketch usk2 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<k/2; i++) {
usk1.update(i); //256
@@ -146,7 +146,7 @@ public class SetOperationTest {
final ResizeFactor rf = X4;
- final Union union = SetOperation.builder().setSeed(seed).setResizeFactor(rf).setNominalEntries(k).buildUnion();
+ final ThetaUnion union = ThetaSetOperation.builder().setSeed(seed).setResizeFactor(rf).setNominalEntries(k).buildUnion();
union.union(usk1);
union.union(usk2); //throws seed exception here
@@ -155,61 +155,61 @@ public class SetOperationTest {
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkBuilderNomEntries() {
final int k = 1 << 27;
- final SetOperationBuilder bldr = SetOperation.builder();
+ final ThetaSetOperationBuilder bldr = ThetaSetOperation.builder();
bldr.setNominalEntries(k);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkIllegalSetOpHeapify() {
final int k = 64;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<k; i++) {
usk1.update(i); //64
}
final byte[] byteArray = usk1.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray).asReadOnly();
- SetOperation.heapify(seg);
+ ThetaSetOperation.heapify(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkIllegalSetOpWrap() {
final int k = 64;
- final UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
+ final UpdatableThetaSketch usk1 = UpdatableThetaSketch.builder().setNominalEntries(k).build();
for (int i=0; i<k; i++) {
usk1.update(i); //64
}
final byte[] byteArray = usk1.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray).asReadOnly();
- Intersection.wrap(seg);
+ ThetaIntersection.wrap(seg);
... 2143 lines suppressed ...
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org