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:31:32 UTC
(datasketches-java) 01/02: Change name of /theta/Sketch to /theta/ThetaSketch
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
commit d1e10c3d75312ff9f40ec11949aedcd01520be4d
Author: Lee Rhodes <le...@gmail.com>
AuthorDate: Mon Oct 6 17:31:28 2025 -0700
Change name of /theta/Sketch to /theta/ThetaSketch
---
.../java/org/apache/datasketches/theta/AnotB.java | 24 ++++-----
.../org/apache/datasketches/theta/AnotBimpl.java | 12 ++---
.../apache/datasketches/theta/CompactSketch.java | 6 +--
.../ConcurrentBackgroundThetaPropagation.java | 4 +-
.../theta/ConcurrentDirectQuickSelectSketch.java | 2 +-
.../theta/ConcurrentHeapQuickSelectSketch.java | 2 +-
.../theta/ConcurrentSharedThetaSketch.java | 2 +-
.../theta/DirectCompactCompressedSketch.java | 8 +--
.../datasketches/theta/DirectCompactSketch.java | 12 ++---
.../theta/DirectQuickSelectSketch.java | 2 +-
.../theta/DirectQuickSelectSketchR.java | 4 +-
.../apache/datasketches/theta/HeapAlphaSketch.java | 4 +-
.../datasketches/theta/HeapQuickSelectSketch.java | 4 +-
.../apache/datasketches/theta/Intersection.java | 10 ++--
.../datasketches/theta/IntersectionImpl.java | 10 ++--
.../datasketches/theta/JaccardSimilarity.java | 14 ++---
.../theta/MemorySegmentHashIterator.java | 2 +-
.../theta/{Sketch.java => ThetaSketch.java} | 20 ++++----
.../java/org/apache/datasketches/theta/Union.java | 6 +--
.../org/apache/datasketches/theta/UnionImpl.java | 8 +--
.../apache/datasketches/theta/UpdateSketch.java | 2 +-
.../BoundsOnRatiosInThetaSketchedSets.java | 8 +--
.../BoundsOnRatiosInTupleSketchedSets.java | 6 +--
.../java/org/apache/datasketches/tuple/AnotB.java | 16 +++---
.../org/apache/datasketches/tuple/HashTables.java | 4 +-
.../apache/datasketches/tuple/Intersection.java | 6 +--
.../datasketches/tuple/JaccardSimilarity.java | 8 +--
.../java/org/apache/datasketches/tuple/Union.java | 4 +-
.../apache/datasketches/theta/AnotBimplTest.java | 4 +-
.../datasketches/theta/CompactSketchTest.java | 24 ++++-----
.../ConcurrentDirectQuickSelectSketchTest.java | 26 +++++-----
.../theta/ConcurrentHeapQuickSelectSketchTest.java | 22 ++++----
.../theta/DirectQuickSelectSketchTest.java | 28 +++++-----
.../apache/datasketches/theta/DirectUnionTest.java | 12 ++---
.../datasketches/theta/HeapAlphaSketchTest.java | 24 ++++-----
.../theta/HeapQuickSelectSketchTest.java | 12 ++---
.../apache/datasketches/theta/HeapUnionTest.java | 4 +-
.../datasketches/theta/HeapifyWrapSerVer3Test.java | 8 +--
.../apache/datasketches/theta/IteratorTest.java | 8 +--
.../theta/PairwiseSetOperationsTest.java | 24 ++++-----
.../datasketches/theta/PreambleUtilTest.java | 14 ++---
.../theta/ReadOnlyMemorySegmentTest.java | 12 ++---
.../datasketches/theta/SetOperationTest.java | 16 +++---
.../datasketches/theta/SetOpsCornerCasesTest.java | 24 ++++-----
.../datasketches/theta/SingleItemSketchTest.java | 12 ++---
.../apache/datasketches/theta/SketchMiscTest.java | 18 +++----
.../org/apache/datasketches/theta/SketchTest.java | 60 +++++++++++-----------
.../apache/datasketches/theta/UnionImplTest.java | 6 +--
.../datasketches/theta/UpdateSketchTest.java | 4 +-
.../tuple/adouble/AdoubleAnotBTest.java | 2 +-
50 files changed, 287 insertions(+), 287 deletions(-)
diff --git a/src/main/java/org/apache/datasketches/theta/AnotB.java b/src/main/java/org/apache/datasketches/theta/AnotB.java
index cb195acd1..fc523115b 100644
--- a/src/main/java/org/apache/datasketches/theta/AnotB.java
+++ b/src/main/java/org/apache/datasketches/theta/AnotB.java
@@ -92,7 +92,7 @@ public abstract class AnotB extends SetOperation {
*
* @param skA The incoming sketch for the first argument, <i>A</i>.
*/
- public abstract void setA(Sketch skA);
+ public abstract void setA(ThetaSketch skA);
/**
* This is part of a multistep, stateful AnotB operation and sets the given Theta sketch as the
@@ -111,12 +111,12 @@ public abstract class AnotB extends SetOperation {
*
* @param skB The incoming Theta sketch for the second (or following) argument <i>B</i>.
*/
- public abstract void notB(Sketch skB);
+ public abstract void notB(ThetaSketch skB);
/**
* Gets the result of the multistep, stateful operation AnotB that have been executed with calls
- * to {@link #setA(Sketch)} and ({@link #notB(Sketch)} or
- * {@link #notB(org.apache.datasketches.theta.Sketch)}).
+ * 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.
@@ -127,8 +127,8 @@ public abstract class AnotB extends SetOperation {
/**
* Gets the result of the multistep, stateful operation AnotB that have been executed with calls
- * to {@link #setA(Sketch)} and ({@link #notB(Sketch)} or
- * {@link #notB(org.apache.datasketches.theta.Sketch)}).
+ * 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}.
* <a href="{@docRoot}/resources/dictionary.html#dstOrdered">See Destination Ordered</a>.
@@ -147,8 +147,8 @@ public abstract class AnotB extends SetOperation {
* ordered CompactSketch 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(Sketch)},
- * {@link #notB(Sketch)}, {@link #getResult(boolean)}, or
+ * Thus, this is not an accumulating update and does not interact with the {@link #setA(ThetaSketch)},
+ * {@link #notB(ThetaSketch)}, {@link #getResult(boolean)}, or
* {@link #getResult(boolean, MemorySegment, boolean)} methods.</p>
*
* <p>If either argument is null an exception is thrown.</p>
@@ -166,7 +166,7 @@ public abstract class AnotB extends SetOperation {
* @param skB The incoming sketch for the second argument. It must not be null.
* @return an ordered CompactSketch on the heap
*/
- public CompactSketch aNotB(final Sketch skA, final Sketch skB) {
+ public CompactSketch aNotB(final ThetaSketch skA, final ThetaSketch skB) {
return aNotB(skA, skB, true, null);
}
@@ -175,8 +175,8 @@ public abstract class AnotB extends SetOperation {
* CompactSketch.
*
* <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(Sketch)},
- * {@link #notB(Sketch)}, {@link #getResult(boolean)}, or
+ * Thus, this is not an accumulating update and does not interact with the {@link #setA(ThetaSketch)},
+ * {@link #notB(ThetaSketch)}, {@link #getResult(boolean)}, or
* {@link #getResult(boolean, MemorySegment, boolean)} methods.</p>
*
* <p>If either argument is null an exception is thrown.</p>
@@ -197,7 +197,7 @@ public abstract class AnotB extends SetOperation {
* @param dstSeg the destination MemorySegment
* @return the result as a CompactSketch.
*/
- public abstract CompactSketch aNotB(Sketch skA, Sketch skB, boolean dstOrdered,
+ public abstract CompactSketch aNotB(ThetaSketch skA, ThetaSketch skB, boolean dstOrdered,
MemorySegment dstSeg);
}
diff --git a/src/main/java/org/apache/datasketches/theta/AnotBimpl.java b/src/main/java/org/apache/datasketches/theta/AnotBimpl.java
index 08ec155d7..dc9ecb657 100644
--- a/src/main/java/org/apache/datasketches/theta/AnotBimpl.java
+++ b/src/main/java/org/apache/datasketches/theta/AnotBimpl.java
@@ -65,7 +65,7 @@ final class AnotBimpl extends AnotB {
}
@Override
- public void setA(final Sketch skA) {
+ public void setA(final ThetaSketch skA) {
if (skA == null) {
reset();
throw new SketchesArgumentException("The input argument <i>A</i> must not be null");
@@ -85,7 +85,7 @@ final class AnotBimpl extends AnotB {
}
@Override
- public void notB(final Sketch skB) {
+ public void notB(final ThetaSketch skB) {
if (empty_ || (skB == null) || skB.isEmpty()) { return; }
//local and skB is not empty
Util.checkSeedHashes(seedHash_, skB.getSeedHash());
@@ -113,7 +113,7 @@ final class AnotBimpl extends AnotB {
}
@Override
- public CompactSketch aNotB(final Sketch skA, final Sketch skB, final boolean dstOrdered,
+ public CompactSketch 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");
@@ -152,7 +152,7 @@ final class AnotBimpl extends AnotB {
//restricted
- private static long[] getHashArrA(final Sketch skA) { //returns a new array
+ 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
return cskA.getCache().clone();
@@ -162,7 +162,7 @@ final class AnotBimpl extends AnotB {
final long minThetaLong,
final int countA,
final long[] hashArrA,
- final Sketch skB) {
+ final ThetaSketch skB) {
// Rebuild or get hashtable of skB
final long[] hashTableB; //read only
@@ -192,7 +192,7 @@ final class AnotBimpl extends AnotB {
}
private static long[] convertToHashTable(
- final Sketch sketch,
+ final ThetaSketch sketch,
final long thetaLong,
final double rebuildThreshold) {
final int lgArrLongs = minLgHashTableSize(sketch.getRetainedEntries(true), rebuildThreshold);
diff --git a/src/main/java/org/apache/datasketches/theta/CompactSketch.java b/src/main/java/org/apache/datasketches/theta/CompactSketch.java
index aaa751af0..d560a8729 100644
--- a/src/main/java/org/apache/datasketches/theta/CompactSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/CompactSketch.java
@@ -58,7 +58,7 @@ import org.apache.datasketches.common.Util;
*
* @author Lee Rhodes
*/
-public abstract class CompactSketch extends Sketch {
+public abstract class CompactSketch extends ThetaSketch {
/**
* Heapify takes a CompactSketch image in a MemorySegment and instantiates an on-heap CompactSketch.
@@ -303,7 +303,7 @@ public abstract class CompactSketch extends Sketch {
@Override
public double getEstimate() {
- return Sketch.estimate(getThetaLong(), getRetainedEntries());
+ return ThetaSketch.estimate(getThetaLong(), getRetainedEntries());
}
/**
@@ -386,7 +386,7 @@ public abstract class CompactSketch extends Sketch {
}
private static CompactSketch heapifyV4(final MemorySegment srcSeg, final long seed) {
- final int preLongs = Sketch.getPreambleLongs(srcSeg);
+ final int preLongs = ThetaSketch.getPreambleLongs(srcSeg);
final int entryBits = extractEntryBitsV4(srcSeg);
final int numEntriesBytes = extractNumEntriesBytesV4(srcSeg);
final short seedHash = (short) extractSeedHash(srcSeg);
diff --git a/src/main/java/org/apache/datasketches/theta/ConcurrentBackgroundThetaPropagation.java b/src/main/java/org/apache/datasketches/theta/ConcurrentBackgroundThetaPropagation.java
index c3d8bfaa5..b3e863532 100644
--- a/src/main/java/org/apache/datasketches/theta/ConcurrentBackgroundThetaPropagation.java
+++ b/src/main/java/org/apache/datasketches/theta/ConcurrentBackgroundThetaPropagation.java
@@ -40,7 +40,7 @@ final class ConcurrentBackgroundThetaPropagation implements Runnable {
private final AtomicBoolean localPropagationInProgress;
// Sketch to be propagated to shared sketch. Can be null if only a single hash is propagated
- private final Sketch sketchIn;
+ private final ThetaSketch sketchIn;
// Hash of the datum to be propagated to shared sketch. Can be ConcurrentSharedThetaSketch.NOT_SINGLE_HASH
// if the data is propagated through a sketch.
@@ -52,7 +52,7 @@ final class ConcurrentBackgroundThetaPropagation implements Runnable {
private final long epoch;
ConcurrentBackgroundThetaPropagation(final ConcurrentSharedThetaSketch sharedThetaSketch,
- final AtomicBoolean localPropagationInProgress, final Sketch sketchIn, final long singleHash,
+ final AtomicBoolean localPropagationInProgress, final ThetaSketch sketchIn, final long singleHash,
final long epoch) {
this.sharedThetaSketch = sharedThetaSketch;
this.localPropagationInProgress = localPropagationInProgress;
diff --git a/src/main/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketch.java b/src/main/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketch.java
index b70fdda36..76aac8d9d 100644
--- a/src/main/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketch.java
@@ -207,7 +207,7 @@ final class ConcurrentDirectQuickSelectSketch extends DirectQuickSelectSketch
@Override
public boolean propagate(final AtomicBoolean localPropagationInProgress,
- final Sketch sketchIn, final long singleHash) {
+ final ThetaSketch sketchIn, final long singleHash) {
final long epoch = epoch_;
if (singleHash != NOT_SINGLE_HASH // namely, is a single hash and
&& getRetainedEntries(false) < exactLimit_) { // a small sketch then propagate myself (blocking)
diff --git a/src/main/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketch.java b/src/main/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketch.java
index c061bde1d..dddfd1548 100644
--- a/src/main/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketch.java
@@ -199,7 +199,7 @@ final class ConcurrentHeapQuickSelectSketch extends HeapQuickSelectSketch
@Override
public boolean propagate(final AtomicBoolean localPropagationInProgress,
- final Sketch sketchIn, final long singleHash) {
+ final ThetaSketch sketchIn, final long singleHash) {
final long epoch = epoch_;
if ((singleHash != NOT_SINGLE_HASH) //namely, is a single hash and
&& (getRetainedEntries(false) < exactLimit_)) { //a small sketch then propagate myself (blocking)
diff --git a/src/main/java/org/apache/datasketches/theta/ConcurrentSharedThetaSketch.java b/src/main/java/org/apache/datasketches/theta/ConcurrentSharedThetaSketch.java
index 3dda0c31f..cef561d58 100644
--- a/src/main/java/org/apache/datasketches/theta/ConcurrentSharedThetaSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/ConcurrentSharedThetaSketch.java
@@ -86,7 +86,7 @@ interface ConcurrentSharedThetaSketch extends MemorySegmentStatus {
* @param singleHash a single hash value
* @return true if propagation successfully started
*/
- boolean propagate(final AtomicBoolean localPropagationInProgress, final Sketch sketchIn,
+ boolean propagate(final AtomicBoolean localPropagationInProgress, final ThetaSketch sketchIn,
final long singleHash);
/**
diff --git a/src/main/java/org/apache/datasketches/theta/DirectCompactCompressedSketch.java b/src/main/java/org/apache/datasketches/theta/DirectCompactCompressedSketch.java
index 4a3b80839..f0b850eb7 100644
--- a/src/main/java/org/apache/datasketches/theta/DirectCompactCompressedSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/DirectCompactCompressedSketch.java
@@ -74,7 +74,7 @@ final class DirectCompactCompressedSketch extends DirectCompactSketch {
@Override
public int getCurrentBytes() {
- final int preLongs = Sketch.getPreambleLongs(seg_);
+ final int preLongs = ThetaSketch.getPreambleLongs(seg_);
final int entryBits = extractEntryBitsV4(seg_);
final int numEntriesBytes = extractNumEntriesBytesV4(seg_);
return preLongs * Long.BYTES + numEntriesBytes + wholeBytesToHoldBits(getRetainedEntries() * entryBits);
@@ -88,7 +88,7 @@ final class DirectCompactCompressedSketch extends DirectCompactSketch {
// 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
- final int preLongs = Sketch.getPreambleLongs(seg_); // if > 1 then the second long has theta
+ final int preLongs = ThetaSketch.getPreambleLongs(seg_); // if > 1 then the second long has theta
final int numEntriesBytes = extractNumEntriesBytesV4(seg_);
int offsetBytes = preLongs > 1 ? START_PACKED_DATA_ESTIMATION_MODE : START_PACKED_DATA_EXACT_MODE;
int numEntries = 0;
@@ -100,7 +100,7 @@ final class DirectCompactCompressedSketch extends DirectCompactSketch {
@Override
public long getThetaLong() {
- final int preLongs = Sketch.getPreambleLongs(seg_);
+ final int preLongs = ThetaSketch.getPreambleLongs(seg_);
return (preLongs > 1) ? extractThetaLongV4(seg_) : Long.MAX_VALUE;
}
@@ -118,7 +118,7 @@ final class DirectCompactCompressedSketch extends DirectCompactSketch {
public HashIterator iterator() {
return new MemorySegmentCompactCompressedHashIterator(
seg_,
- (Sketch.getPreambleLongs(seg_) > 1 ? START_PACKED_DATA_ESTIMATION_MODE : START_PACKED_DATA_EXACT_MODE)
+ (ThetaSketch.getPreambleLongs(seg_) > 1 ? START_PACKED_DATA_ESTIMATION_MODE : START_PACKED_DATA_EXACT_MODE)
+ extractNumEntriesBytesV4(seg_),
extractEntryBitsV4(seg_),
getRetainedEntries()
diff --git a/src/main/java/org/apache/datasketches/theta/DirectCompactSketch.java b/src/main/java/org/apache/datasketches/theta/DirectCompactSketch.java
index f393dc5b8..b5794aeb6 100644
--- a/src/main/java/org/apache/datasketches/theta/DirectCompactSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/DirectCompactSketch.java
@@ -81,7 +81,7 @@ class DirectCompactSketch extends CompactSketch {
@Override
public int getCurrentBytes() {
if (checkForSingleItem(seg_)) { return 16; }
- final int preLongs = Sketch.getPreambleLongs(seg_);
+ final int preLongs = ThetaSketch.getPreambleLongs(seg_);
final int curCount = (preLongs == 1) ? 0 : extractCurCount(seg_);
return (preLongs + curCount) << 3;
}
@@ -89,13 +89,13 @@ class DirectCompactSketch extends CompactSketch {
@Override
public int getRetainedEntries(final boolean valid) { //valid is only relevant for the Alpha Sketch
if (checkForSingleItem(seg_)) { return 1; }
- final int preLongs = Sketch.getPreambleLongs(seg_);
+ final int preLongs = ThetaSketch.getPreambleLongs(seg_);
return (preLongs == 1) ? 0 : extractCurCount(seg_);
}
@Override
public long getThetaLong() {
- final int preLongs = Sketch.getPreambleLongs(seg_);
+ final int preLongs = ThetaSketch.getPreambleLongs(seg_);
return (preLongs > 2) ? extractThetaLong(seg_) : Long.MAX_VALUE;
}
@@ -147,7 +147,7 @@ class DirectCompactSketch extends CompactSketch {
@Override
long[] getCache() {
if (checkForSingleItem(seg_)) { return new long[] { seg_.get(JAVA_LONG_UNALIGNED, 8) }; }
- final int preLongs = Sketch.getPreambleLongs(seg_);
+ final int preLongs = ThetaSketch.getPreambleLongs(seg_);
final int curCount = (preLongs == 1) ? 0 : extractCurCount(seg_);
if (curCount > 0) {
final long[] cache = new long[curCount];
@@ -159,12 +159,12 @@ class DirectCompactSketch extends CompactSketch {
@Override
int getCompactPreambleLongs() {
- return Sketch.getPreambleLongs(seg_);
+ return ThetaSketch.getPreambleLongs(seg_);
}
@Override
int getCurrentPreambleLongs() {
- return Sketch.getPreambleLongs(seg_);
+ return ThetaSketch.getPreambleLongs(seg_);
}
@Override
diff --git a/src/main/java/org/apache/datasketches/theta/DirectQuickSelectSketch.java b/src/main/java/org/apache/datasketches/theta/DirectQuickSelectSketch.java
index 723b6cc75..d1cbb740f 100644
--- a/src/main/java/org/apache/datasketches/theta/DirectQuickSelectSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/DirectQuickSelectSketch.java
@@ -175,7 +175,7 @@ class DirectQuickSelectSketch extends DirectQuickSelectSketchR {
final MemorySegment srcSeg,
final MemorySegmentRequest mSegReq,
final long seed) {
- final int preambleLongs = Sketch.getPreambleLongs(srcSeg); //byte 0
+ final int preambleLongs = ThetaSketch.getPreambleLongs(srcSeg); //byte 0
final int lgNomLongs = extractLgNomLongs(srcSeg); //byte 3
final int lgArrLongs = extractLgArrLongs(srcSeg); //byte 4
diff --git a/src/main/java/org/apache/datasketches/theta/DirectQuickSelectSketchR.java b/src/main/java/org/apache/datasketches/theta/DirectQuickSelectSketchR.java
index f78fbced4..7b07d660f 100644
--- a/src/main/java/org/apache/datasketches/theta/DirectQuickSelectSketchR.java
+++ b/src/main/java/org/apache/datasketches/theta/DirectQuickSelectSketchR.java
@@ -136,7 +136,7 @@ class DirectQuickSelectSketchR extends UpdateSketch {
public double getEstimate() {
final int curCount = extractCurCount(wseg_);
final long thetaLong = extractThetaLong(wseg_);
- return Sketch.estimate(thetaLong, curCount);
+ return ThetaSketch.estimate(thetaLong, curCount);
}
@Override
@@ -238,7 +238,7 @@ class DirectQuickSelectSketchR extends UpdateSketch {
@Override
int getCurrentPreambleLongs() {
- return Sketch.getPreambleLongs(wseg_);
+ return ThetaSketch.getPreambleLongs(wseg_);
}
@Override
diff --git a/src/main/java/org/apache/datasketches/theta/HeapAlphaSketch.java b/src/main/java/org/apache/datasketches/theta/HeapAlphaSketch.java
index 5a5c16f00..846fb02b6 100644
--- a/src/main/java/org/apache/datasketches/theta/HeapAlphaSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/HeapAlphaSketch.java
@@ -134,7 +134,7 @@ final class HeapAlphaSketch extends HeapUpdateSketch {
static HeapAlphaSketch heapifyInstance(final MemorySegment srcSeg, final long expectedSeed) {
Objects.requireNonNull(srcSeg, "Source MemorySegment must not be null");
checkBounds(0, 24, srcSeg.byteSize());
- final int preambleLongs = Sketch.getPreambleLongs(srcSeg); //byte 0
+ final int preambleLongs = ThetaSketch.getPreambleLongs(srcSeg); //byte 0
final int lgNomLongs = extractLgNomLongs(srcSeg); //byte 3
final int lgArrLongs = extractLgArrLongs(srcSeg); //byte 4
@@ -179,7 +179,7 @@ final class HeapAlphaSketch extends HeapUpdateSketch {
@Override
public double getEstimate() {
return (thetaLong_ > split1_)
- ? Sketch.estimate(thetaLong_, curCount_)
+ ? ThetaSketch.estimate(thetaLong_, curCount_)
: (1 << lgNomLongs_) * (LONG_MAX_VALUE_AS_DOUBLE / thetaLong_);
}
diff --git a/src/main/java/org/apache/datasketches/theta/HeapQuickSelectSketch.java b/src/main/java/org/apache/datasketches/theta/HeapQuickSelectSketch.java
index c23deebf1..89f4f21f5 100644
--- a/src/main/java/org/apache/datasketches/theta/HeapQuickSelectSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/HeapQuickSelectSketch.java
@@ -107,7 +107,7 @@ class HeapQuickSelectSketch extends HeapUpdateSketch {
* @return instance of this sketch
*/
static HeapQuickSelectSketch heapifyInstance(final MemorySegment srcSeg, final long seed) {
- final int preambleLongs = Sketch.getPreambleLongs(srcSeg); //byte 0
+ final int preambleLongs = ThetaSketch.getPreambleLongs(srcSeg); //byte 0
final int lgNomLongs = extractLgNomLongs(srcSeg); //byte 3
final int lgArrLongs = extractLgArrLongs(srcSeg); //byte 4
@@ -140,7 +140,7 @@ class HeapQuickSelectSketch extends HeapUpdateSketch {
@Override
public double getEstimate() {
- return Sketch.estimate(thetaLong_, curCount_);
+ return ThetaSketch.estimate(thetaLong_, curCount_);
}
@Override
diff --git a/src/main/java/org/apache/datasketches/theta/Intersection.java b/src/main/java/org/apache/datasketches/theta/Intersection.java
index 134c49ff6..4482df91c 100644
--- a/src/main/java/org/apache/datasketches/theta/Intersection.java
+++ b/src/main/java/org/apache/datasketches/theta/Intersection.java
@@ -43,7 +43,7 @@ public abstract class Intersection extends SetOperation {
/**
* Gets the result of this operation as an ordered CompactSketch on the Java heap.
* This does not disturb the underlying data structure of this intersection.
- * The {@link #intersect(Sketch)} method must have been called at least once, otherwise an
+ * 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
* Universal Set, which has an infinite number of values.
* @return the result of this operation as an ordered CompactSketch on the Java heap
@@ -55,7 +55,7 @@ public abstract class Intersection extends SetOperation {
/**
* Gets the result of this operation as a CompactSketch in the given dstSeg.
* This does not disturb the underlying data structure of this intersection.
- * The {@link #intersect(Sketch)} method must have been called at least once, otherwise an
+ * 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
* Universal Set, which has an infinite number of values.
*
@@ -102,7 +102,7 @@ public abstract class Intersection extends SetOperation {
* Theta will become the minimum of thetas seen so far.
* @param sketchIn the given sketch
*/
- public abstract void intersect(Sketch sketchIn);
+ public abstract void intersect(ThetaSketch sketchIn);
/**
* Perform intersect set operation on the two given sketch arguments and return the result as an
@@ -111,7 +111,7 @@ public abstract class Intersection extends SetOperation {
* @param b The second sketch argument
* @return an ordered CompactSketch on the heap
*/
- public CompactSketch intersect(final Sketch a, final Sketch b) {
+ public CompactSketch intersect(final ThetaSketch a, final ThetaSketch b) {
return intersect(a, b, true, null);
}
@@ -125,7 +125,7 @@ public abstract class Intersection extends SetOperation {
* @param dstSeg the destination MemorySegment.
* @return the result as a CompactSketch.
*/
- public abstract CompactSketch intersect(Sketch a, Sketch b, boolean dstOrdered,
+ public abstract CompactSketch intersect(ThetaSketch a, ThetaSketch b, boolean dstOrdered,
MemorySegment dstSeg);
/**
diff --git a/src/main/java/org/apache/datasketches/theta/IntersectionImpl.java b/src/main/java/org/apache/datasketches/theta/IntersectionImpl.java
index 6819524b1..54a513831 100644
--- a/src/main/java/org/apache/datasketches/theta/IntersectionImpl.java
+++ b/src/main/java/org/apache/datasketches/theta/IntersectionImpl.java
@@ -220,7 +220,7 @@ final class IntersectionImpl extends Intersection {
}
@Override
- public CompactSketch intersect(final Sketch a, final Sketch b, final boolean dstOrdered, final MemorySegment dstSeg) {
+ public CompactSketch intersect(final ThetaSketch a, final ThetaSketch b, final boolean dstOrdered, final MemorySegment dstSeg) {
if ((wseg_ != null) && readOnly_) { throw new SketchesReadOnlyException(); }
hardReset();
intersect(a);
@@ -231,7 +231,7 @@ final class IntersectionImpl extends Intersection {
}
@Override
- public void intersect(final Sketch sketchIn) {
+ public void intersect(final ThetaSketch sketchIn) {
if (sketchIn == null) {
throw new SketchesArgumentException("Intersection argument must not be null.");
}
@@ -439,7 +439,7 @@ final class IntersectionImpl extends Intersection {
return thetaLong_;
}
- private void performIntersect(final Sketch sketchIn) {
+ private void performIntersect(final ThetaSketch sketchIn) {
// curCount and input data are nonzero, match against HT
assert (curCount_ > 0) && !empty_;
final long[] hashTable;
@@ -507,7 +507,7 @@ final class IntersectionImpl extends Intersection {
assert tmpCnt == count : "Intersection Count Check: got: " + tmpCnt + ", expected: " + count;
}
- private void moveDataToTgt(final Sketch sketch) {
+ private void moveDataToTgt(final ThetaSketch sketch) {
final int count = sketch.getRetainedEntries();
int tmpCnt = 0;
if (wseg_ != null) { //Off Heap puts directly into mem
@@ -620,7 +620,7 @@ final class IntersectionImpl extends Intersection {
//Get Preamble
//Note: Intersection does not use lgNomLongs (or k), per se.
//seedHash loaded and checked in private constructor
- final int preLongs = Sketch.getPreambleLongs(srcSeg);
+ final int preLongs = ThetaSketch.getPreambleLongs(srcSeg);
final int serVer = extractSerVer(srcSeg);
final int famID = extractFamilyID(srcSeg);
final boolean empty = (extractFlags(srcSeg) & EMPTY_FLAG_MASK) > 0;
diff --git a/src/main/java/org/apache/datasketches/theta/JaccardSimilarity.java b/src/main/java/org/apache/datasketches/theta/JaccardSimilarity.java
index a058f649a..0a71d6fbc 100644
--- a/src/main/java/org/apache/datasketches/theta/JaccardSimilarity.java
+++ b/src/main/java/org/apache/datasketches/theta/JaccardSimilarity.java
@@ -54,7 +54,7 @@ public final class JaccardSimilarity {
* @return a double array {LowerBound, Estimate, UpperBound} of the Jaccard index.
* The Upper and Lower bounds are for a confidence interval of 95.4% or +/- 2 standard deviations.
*/
- public static double[] jaccard(final Sketch sketchA, final Sketch sketchB) {
+ public static double[] jaccard(final ThetaSketch sketchA, final ThetaSketch sketchB) {
//Corner case checks
if (sketchA == null || sketchB == null) { return ZEROS.clone(); }
if (sketchA == sketchB) { return ONES.clone(); }
@@ -72,7 +72,7 @@ public final class JaccardSimilarity {
SetOperation.builder().setNominalEntries(newK).buildUnion();
union.union(sketchA);
union.union(sketchB);
- final Sketch unionAB = union.getResult(false, null);
+ final ThetaSketch unionAB = union.getResult(false, null);
final long thetaLongUAB = unionAB.getThetaLong();
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
@@ -89,7 +89,7 @@ public final class JaccardSimilarity {
inter.intersect(sketchA);
inter.intersect(sketchB);
inter.intersect(unionAB); //ensures that intersection is a subset of the union
- final Sketch interABU = inter.getResult(false, null);
+ final ThetaSketch interABU = inter.getResult(false, null);
final double lb = getLowerBoundForBoverA(unionAB, interABU);
final double est = getEstimateOfBoverA(unionAB, interABU);
@@ -105,7 +105,7 @@ public final class JaccardSimilarity {
* @return true if the two given sketches have exactly the same hash values and the same
* theta values.
*/
- public static boolean exactlyEqual(final Sketch sketchA, final Sketch sketchB) {
+ public static boolean exactlyEqual(final ThetaSketch sketchA, final ThetaSketch sketchB) {
//Corner case checks
if (sketchA == null || sketchB == null) { return false; }
if (sketchA == sketchB) { return true; }
@@ -120,7 +120,7 @@ public final class JaccardSimilarity {
SetOperation.builder().setNominalEntries(ceilingPowerOf2(countA + countB)).buildUnion();
union.union(sketchA);
union.union(sketchB);
- final Sketch unionAB = union.getResult();
+ final ThetaSketch unionAB = union.getResult();
final long thetaLongUAB = unionAB.getThetaLong();
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
@@ -147,7 +147,7 @@ public final class JaccardSimilarity {
* @return if true, the similarity of the two sketches is greater than the given threshold
* with at least 97.7% confidence.
*/
- public static boolean similarityTest(final Sketch measured, final Sketch expected,
+ public static boolean similarityTest(final ThetaSketch measured, final ThetaSketch expected,
final double threshold) {
//index 0: the lower bound
//index 1: the mean estimate
@@ -169,7 +169,7 @@ public final class JaccardSimilarity {
* @return if true, the dissimilarity of the two sketches is greater than the given threshold
* with at least 97.7% confidence.
*/
- public static boolean dissimilarityTest(final Sketch measured, final Sketch expected,
+ public static boolean dissimilarityTest(final ThetaSketch measured, final ThetaSketch expected,
final double threshold) {
//index 0: the lower bound
//index 1: the mean estimate
diff --git a/src/main/java/org/apache/datasketches/theta/MemorySegmentHashIterator.java b/src/main/java/org/apache/datasketches/theta/MemorySegmentHashIterator.java
index 53344c8d6..89d6b19f2 100644
--- a/src/main/java/org/apache/datasketches/theta/MemorySegmentHashIterator.java
+++ b/src/main/java/org/apache/datasketches/theta/MemorySegmentHashIterator.java
@@ -38,7 +38,7 @@ final class MemorySegmentHashIterator implements HashIterator {
this.seg = srcSeg;
this.arrLongs = arrLongs;
this.thetaLong = thetaLong;
- offsetBytes = Sketch.getPreambleLongs(srcSeg) << 3;
+ offsetBytes = ThetaSketch.getPreambleLongs(srcSeg) << 3;
index = -1;
hash = 0;
}
diff --git a/src/main/java/org/apache/datasketches/theta/Sketch.java b/src/main/java/org/apache/datasketches/theta/ThetaSketch.java
similarity index 96%
rename from src/main/java/org/apache/datasketches/theta/Sketch.java
rename to src/main/java/org/apache/datasketches/theta/ThetaSketch.java
index d14519062..d3a1c2bfd 100644
--- a/src/main/java/org/apache/datasketches/theta/Sketch.java
+++ b/src/main/java/org/apache/datasketches/theta/ThetaSketch.java
@@ -49,9 +49,9 @@ import org.apache.datasketches.thetacommon.ThetaUtil;
*
* @author Lee Rhodes
*/
-public abstract class Sketch implements MemorySegmentStatus {
+public abstract class ThetaSketch implements MemorySegmentStatus {
- Sketch() {}
+ ThetaSketch() {}
//public static factory constructor-type methods
@@ -68,7 +68,7 @@ public abstract class Sketch implements MemorySegmentStatus {
*
* @return a Sketch on the heap.
*/
- public static Sketch heapify(final MemorySegment srcSeg) {
+ public static ThetaSketch heapify(final MemorySegment srcSeg) {
return heapify(srcSeg, Util.DEFAULT_UPDATE_SEED);
}
@@ -86,7 +86,7 @@ public abstract class Sketch implements MemorySegmentStatus {
* Compact sketches store a 16-bit hash of the seed, but not the seed itself.
* @return a Sketch on the heap.
*/
- public static Sketch heapify(final MemorySegment srcSeg, final long expectedSeed) {
+ public static ThetaSketch heapify(final MemorySegment srcSeg, final long expectedSeed) {
checkSegPreambleCap(srcSeg);
final int familyID = extractFamilyID(srcSeg);
if (familyID == Family.COMPACT.getID()) {
@@ -113,7 +113,7 @@ public abstract class Sketch implements MemorySegmentStatus {
* @param srcSeg a MemorySegment with an image of a Sketch.
* @return a read-only Sketch backed by the given MemorySegment
*/
- public static Sketch wrap(final MemorySegment srcSeg) {
+ public static ThetaSketch wrap(final MemorySegment srcSeg) {
return wrap(srcSeg, Util.DEFAULT_UPDATE_SEED);
}
@@ -136,7 +136,7 @@ public abstract class Sketch implements MemorySegmentStatus {
* <a href="{@docRoot}/resources/dictionary.html#seed">See Update Hash Seed</a>.
* @return a read-only Sketch backed by the given MemorySegment.
*/
- public static Sketch wrap(final MemorySegment srcSeg, final long expectedSeed) {
+ public static ThetaSketch wrap(final MemorySegment srcSeg, final long expectedSeed) {
checkSegPreambleCap(srcSeg);
final int familyID = extractFamilyID(srcSeg);
if (familyID == Family.QUICKSELECT.getID()) {
@@ -242,7 +242,7 @@ public abstract class Sketch implements MemorySegmentStatus {
throw new SketchesArgumentException("Source MemorySegment not a valid Sketch Family: "
+ Family.idToFamily(familyId).toString());
}
- return Sketch.estimate(extractThetaLong(srcSeg), getRetainedEntries(srcSeg));
+ return ThetaSketch.estimate(extractThetaLong(srcSeg), getRetainedEntries(srcSeg));
}
/**
@@ -633,7 +633,7 @@ public abstract class Sketch implements MemorySegmentStatus {
* @return the lower bound.
*/
public static double getLowerBound(final int numStdDev, final MemorySegment srcSeg) {
- return lowerBound(getRetainedEntries(srcSeg), Sketch.getThetaLong(srcSeg), numStdDev, Sketch.getEmpty(srcSeg));
+ return lowerBound(getRetainedEntries(srcSeg), ThetaSketch.getThetaLong(srcSeg), numStdDev, ThetaSketch.getEmpty(srcSeg));
}
static final double lowerBound(final int curCount, final long thetaLong, final int numStdDev, final boolean empty) {
@@ -652,7 +652,7 @@ public abstract class Sketch implements MemorySegmentStatus {
* @return the upper bound.
*/
public static double getUpperBound(final int numStdDev, final MemorySegment srcSeg) {
- return upperBound(getRetainedEntries(srcSeg), Sketch.getThetaLong(srcSeg), numStdDev, Sketch.getEmpty(srcSeg));
+ return upperBound(getRetainedEntries(srcSeg), ThetaSketch.getThetaLong(srcSeg), numStdDev, ThetaSketch.getEmpty(srcSeg));
}
static final double upperBound(final int curCount, final long thetaLong, final int numStdDev,
@@ -668,7 +668,7 @@ public abstract class Sketch implements MemorySegmentStatus {
* <a href="{@docRoot}/resources/dictionary.html#seed">See Update Hash Seed</a>.
* @return a Sketch
*/
- private static final Sketch heapifyUpdateSketchFromMemorySegment(final MemorySegment srcSeg, final long expectedSeed) {
+ private static final ThetaSketch heapifyUpdateSketchFromMemorySegment(final MemorySegment srcSeg, final long expectedSeed) {
final Family family = idToFamily(extractFamilyID(srcSeg));
if (family == Family.ALPHA) {
diff --git a/src/main/java/org/apache/datasketches/theta/Union.java b/src/main/java/org/apache/datasketches/theta/Union.java
index 7503729cb..25b00a7f7 100644
--- a/src/main/java/org/apache/datasketches/theta/Union.java
+++ b/src/main/java/org/apache/datasketches/theta/Union.java
@@ -154,7 +154,7 @@ public abstract class Union extends SetOperation {
* @param sketchB The second argument
* @return the result ordered CompactSketch on the heap.
*/
- public CompactSketch union(final Sketch sketchA, final Sketch sketchB) {
+ public CompactSketch union(final ThetaSketch sketchA, final ThetaSketch sketchB) {
return union(sketchA, sketchB, true, null);
}
@@ -170,7 +170,7 @@ public abstract class Union extends SetOperation {
* @param dstSeg If not null, the returned CompactSketch will be placed in this MemorySegment.
* @return the result CompactSketch.
*/
- public abstract CompactSketch union(Sketch sketchA, Sketch sketchB, boolean dstOrdered,
+ public abstract CompactSketch union(ThetaSketch sketchA, ThetaSketch sketchB, boolean dstOrdered,
MemorySegment dstSeg);
/**
@@ -183,7 +183,7 @@ public abstract class Union extends SetOperation {
*
* @param sketchIn The incoming sketch.
*/
- public abstract void union(Sketch sketchIn);
+ 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
diff --git a/src/main/java/org/apache/datasketches/theta/UnionImpl.java b/src/main/java/org/apache/datasketches/theta/UnionImpl.java
index bbefd958c..dcc773996 100644
--- a/src/main/java/org/apache/datasketches/theta/UnionImpl.java
+++ b/src/main/java/org/apache/datasketches/theta/UnionImpl.java
@@ -258,7 +258,7 @@ final class UnionImpl extends Union {
}
@Override //Stateless Union
- public CompactSketch union(final Sketch sketchA, final Sketch sketchB, final boolean dstOrdered,
+ public CompactSketch union(final ThetaSketch sketchA, final ThetaSketch sketchB, final boolean dstOrdered,
final MemorySegment dstSeg) {
reset();
union(sketchA);
@@ -269,7 +269,7 @@ final class UnionImpl extends Union {
}
@Override
- public void union(final Sketch sketchIn) {
+ public void union(final ThetaSketch sketchIn) {
//UNION Empty Rule: AND the empty states.
if (sketchIn == null || sketchIn.isEmpty()) {
@@ -305,7 +305,7 @@ final class UnionImpl extends Union {
@Override
public void union(final MemorySegment seg) {
Objects.requireNonNull(seg, "MemorySegment must be non-null");
- union(Sketch.wrap(seg.asReadOnly()));
+ union(ThetaSketch.wrap(seg.asReadOnly()));
}
@Override
@@ -379,7 +379,7 @@ final class UnionImpl extends Union {
* Checks Ordered and Compact flags for integrity between sketch and its MemorySegment
* @param sketch the given sketch
*/
- private static final void checkSketchAndMemorySegmentFlags(final Sketch sketch) {
+ private static final void checkSketchAndMemorySegmentFlags(final ThetaSketch sketch) {
final MemorySegment seg = sketch.getMemorySegment();
if (seg == null) { return; }
final int flags = PreambleUtil.extractFlags(seg);
diff --git a/src/main/java/org/apache/datasketches/theta/UpdateSketch.java b/src/main/java/org/apache/datasketches/theta/UpdateSketch.java
index 723d57a96..b02e8caf7 100644
--- a/src/main/java/org/apache/datasketches/theta/UpdateSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/UpdateSketch.java
@@ -56,7 +56,7 @@ import org.apache.datasketches.thetacommon.ThetaUtil;
*
* @author Lee Rhodes
*/
-public abstract class UpdateSketch extends Sketch {
+public abstract class UpdateSketch extends ThetaSketch {
private final long seed_;
UpdateSketch(final long seed) {
diff --git a/src/main/java/org/apache/datasketches/thetacommon/BoundsOnRatiosInThetaSketchedSets.java b/src/main/java/org/apache/datasketches/thetacommon/BoundsOnRatiosInThetaSketchedSets.java
index b92b1d4d4..5337efc44 100644
--- a/src/main/java/org/apache/datasketches/thetacommon/BoundsOnRatiosInThetaSketchedSets.java
+++ b/src/main/java/org/apache/datasketches/thetacommon/BoundsOnRatiosInThetaSketchedSets.java
@@ -23,7 +23,7 @@ import static org.apache.datasketches.common.Util.LONG_MAX_VALUE_AS_DOUBLE;
import org.apache.datasketches.common.BoundsOnRatiosInSampledSets;
import org.apache.datasketches.common.SketchesArgumentException;
-import org.apache.datasketches.theta.Sketch;
+import org.apache.datasketches.theta.ThetaSketch;
/**
* This class is used to compute the bounds on the estimate of the ratio <i>B / A</i>, where:
@@ -56,7 +56,7 @@ public final class BoundsOnRatiosInThetaSketchedSets {
* @param sketchB the sketch B
* @return the approximate lower bound for B over A
*/
- public static double getLowerBoundForBoverA(final Sketch sketchA, final Sketch sketchB) {
+ public static double getLowerBoundForBoverA(final ThetaSketch sketchA, final ThetaSketch sketchB) {
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
checkThetas(thetaLongA, thetaLongB);
@@ -77,7 +77,7 @@ public final class BoundsOnRatiosInThetaSketchedSets {
* @param sketchB the sketch B
* @return the approximate upper bound for B over A
*/
- public static double getUpperBoundForBoverA(final Sketch sketchA, final Sketch sketchB) {
+ public static double getUpperBoundForBoverA(final ThetaSketch sketchA, final ThetaSketch sketchB) {
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
checkThetas(thetaLongA, thetaLongB);
@@ -98,7 +98,7 @@ public final class BoundsOnRatiosInThetaSketchedSets {
* @param sketchB the sketch B
* @return the estimate for B over A
*/
- public static double getEstimateOfBoverA(final Sketch sketchA, final Sketch sketchB) {
+ public static double getEstimateOfBoverA(final ThetaSketch sketchA, final ThetaSketch sketchB) {
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
checkThetas(thetaLongA, thetaLongB);
diff --git a/src/main/java/org/apache/datasketches/thetacommon/BoundsOnRatiosInTupleSketchedSets.java b/src/main/java/org/apache/datasketches/thetacommon/BoundsOnRatiosInTupleSketchedSets.java
index 49391fdb8..81e677687 100644
--- a/src/main/java/org/apache/datasketches/thetacommon/BoundsOnRatiosInTupleSketchedSets.java
+++ b/src/main/java/org/apache/datasketches/thetacommon/BoundsOnRatiosInTupleSketchedSets.java
@@ -85,7 +85,7 @@ public final class BoundsOnRatiosInTupleSketchedSets {
*/
public static <S extends Summary> double getLowerBoundForBoverA(
final Sketch<S> sketchA,
- final org.apache.datasketches.theta.Sketch sketchB) {
+ final org.apache.datasketches.theta.ThetaSketch sketchB) {
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
checkThetas(thetaLongA, thetaLongB);
@@ -133,7 +133,7 @@ public final class BoundsOnRatiosInTupleSketchedSets {
*/
public static <S extends Summary> double getUpperBoundForBoverA(
final Sketch<S> sketchA,
- final org.apache.datasketches.theta.Sketch sketchB) {
+ final org.apache.datasketches.theta.ThetaSketch sketchB) {
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
checkThetas(thetaLongA, thetaLongB);
@@ -181,7 +181,7 @@ public final class BoundsOnRatiosInTupleSketchedSets {
*/
public static <S extends Summary> double getEstimateOfBoverA(
final Sketch<S> sketchA,
- final org.apache.datasketches.theta.Sketch sketchB) {
+ final org.apache.datasketches.theta.ThetaSketch sketchB) {
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
checkThetas(thetaLongA, thetaLongB);
diff --git a/src/main/java/org/apache/datasketches/tuple/AnotB.java b/src/main/java/org/apache/datasketches/tuple/AnotB.java
index a6d33a7e6..75c80a8d8 100644
--- a/src/main/java/org/apache/datasketches/tuple/AnotB.java
+++ b/src/main/java/org/apache/datasketches/tuple/AnotB.java
@@ -78,7 +78,7 @@ public final class AnotB<S extends Summary> {
static {
try {
- GET_CACHE = org.apache.datasketches.theta.Sketch.class.getDeclaredMethod("getCache");
+ GET_CACHE = org.apache.datasketches.theta.ThetaSketch.class.getDeclaredMethod("getCache");
GET_CACHE.setAccessible(true);
} catch (final Exception e) {
throw new SketchesStateException("Could not reflect getCache(): " + e);
@@ -199,7 +199,7 @@ public final class AnotB<S extends Summary> {
* 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.
* Calls to this method can be intermingled with calls to
- * {@link #notB(org.apache.datasketches.theta.Sketch)}.
+ * {@link #notB(org.apache.datasketches.theta.ThetaSketch)}.
*
* <p>An input argument of null or empty is ignored.</p>
*
@@ -213,7 +213,7 @@ public final class AnotB<S extends Summary> {
*
* @param skB The incoming Theta sketch for the second (or following) argument <i>B</i>.
*/
- public void notB(final org.apache.datasketches.theta.Sketch skB) {
+ public void notB(final org.apache.datasketches.theta.ThetaSketch skB) {
if (skB == null) { return; } //ignore
final long thetaLongB = skB.getThetaLong();
@@ -268,7 +268,7 @@ public final class AnotB<S extends Summary> {
/**
* Gets the result of the multistep, stateful operation AnotB that have been executed with calls
* to {@link #setA(Sketch)} and ({@link #notB(Sketch)} or
- * {@link #notB(org.apache.datasketches.theta.Sketch)}).
+ * {@link #notB(org.apache.datasketches.theta.ThetaSketch)}).
*
* @param reset If <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.
@@ -291,7 +291,7 @@ public final class AnotB<S extends Summary> {
*
* <p>This a stateless operation and has no impact on the internal state of this operator.
* Thus, this is not an accumulating update and is independent of the {@link #setA(Sketch)},
- * {@link #notB(Sketch)}, {@link #notB(org.apache.datasketches.theta.Sketch)}, and
+ * {@link #notB(Sketch)}, {@link #notB(org.apache.datasketches.theta.ThetaSketch)}, and
* {@link #getResult(boolean)} methods.</p>
*
* <p>If either argument is null an exception is thrown.</p>
@@ -383,7 +383,7 @@ public final class AnotB<S extends Summary> {
*
* <p>This a stateless operation and has no impact on the internal state of this operator.
* Thus, this is not an accumulating update and is independent of the {@link #setA(Sketch)},
- * {@link #notB(Sketch)}, {@link #notB(org.apache.datasketches.theta.Sketch)}, and
+ * {@link #notB(Sketch)}, {@link #notB(org.apache.datasketches.theta.ThetaSketch)}, and
* {@link #getResult(boolean)} methods.</p>
*
* <p>If either argument is null an exception is thrown.</p>
@@ -406,7 +406,7 @@ public final class AnotB<S extends Summary> {
justification = "hashArr and summaryArr are guaranteed to be valid due to the switch on CornerCase")
public static <S extends Summary> CompactSketch<S> aNotB(
final Sketch<S> skA,
- final org.apache.datasketches.theta.Sketch skB) {
+ final org.apache.datasketches.theta.ThetaSketch skB) {
if (skA == null || skB == null) {
throw new SketchesArgumentException("Neither argument may be null for this stateless operation.");
}
@@ -553,7 +553,7 @@ public final class AnotB<S extends Summary> {
final int countA,
final long[] hashArrA,
final S[] summaryArrA,
- final org.apache.datasketches.theta.Sketch skB) {
+ final org.apache.datasketches.theta.ThetaSketch skB) {
final DataArrays<S> daB = new DataArrays<>();
//Rebuild/get hashtable of skB
diff --git a/src/main/java/org/apache/datasketches/tuple/HashTables.java b/src/main/java/org/apache/datasketches/tuple/HashTables.java
index bd42f4980..419b3dad6 100644
--- a/src/main/java/org/apache/datasketches/tuple/HashTables.java
+++ b/src/main/java/org/apache/datasketches/tuple/HashTables.java
@@ -58,7 +58,7 @@ class HashTables<S extends Summary> {
}
//must have valid entries
- void fromSketch(final org.apache.datasketches.theta.Sketch sketch, final S summary) {
+ void fromSketch(final org.apache.datasketches.theta.ThetaSketch sketch, final S summary) {
numKeys = sketch.getRetainedEntries(true);
lgTableSize = getLgTableSize(numKeys);
@@ -123,7 +123,7 @@ class HashTables<S extends Summary> {
//For Theta Sketches
HashTables<S> getIntersectHashTables(
- final org.apache.datasketches.theta.Sketch nextThetaSketch,
+ final org.apache.datasketches.theta.ThetaSketch nextThetaSketch,
final long thetaLong,
final SummarySetOperations<S> summarySetOps,
final S summary) {
diff --git a/src/main/java/org/apache/datasketches/tuple/Intersection.java b/src/main/java/org/apache/datasketches/tuple/Intersection.java
index b6f53249a..6467ad055 100644
--- a/src/main/java/org/apache/datasketches/tuple/Intersection.java
+++ b/src/main/java/org/apache/datasketches/tuple/Intersection.java
@@ -89,7 +89,7 @@ public class Intersection<S extends Summary> {
*/
public CompactSketch<S> intersect(
final Sketch<S> tupleSketch,
- final org.apache.datasketches.theta.Sketch
+ final org.apache.datasketches.theta.ThetaSketch
thetaSketch, final S summary) {
reset();
intersect(tupleSketch);
@@ -148,7 +148,7 @@ public class Intersection<S extends Summary> {
* @param summary the given proxy summary for the theta sketch, which doesn't have one.
* It will be copied for each matching index. It must not be null.
*/
- public void intersect(final org.apache.datasketches.theta.Sketch thetaSketch, final S summary) {
+ public void intersect(final org.apache.datasketches.theta.ThetaSketch thetaSketch, final S summary) {
if (thetaSketch == null) { throw new SketchesArgumentException("Sketch must not be null"); }
if (summary == null) { throw new SketchesArgumentException("Summary cannot be null."); }
final boolean firstCall = firstCall_;
@@ -173,7 +173,7 @@ public class Intersection<S extends Summary> {
// input sketch will have valid entries > 0
if (firstCall) {
- final org.apache.datasketches.theta.Sketch firstSketch = thetaSketch;
+ final org.apache.datasketches.theta.ThetaSketch firstSketch = thetaSketch;
//Copy firstSketch data into local instance hashTables_
hashTables_.fromSketch(firstSketch, summary);
}
diff --git a/src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java b/src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java
index 73c6c7fe0..2a57a16a5 100644
--- a/src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java
+++ b/src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java
@@ -125,7 +125,7 @@ public final class JaccardSimilarity {
*/
public static <S extends Summary> double[] jaccard(
final Sketch<S> sketchA,
- final org.apache.datasketches.theta.Sketch sketchB,
+ final org.apache.datasketches.theta.ThetaSketch sketchB,
final S summary, final SummarySetOperations<S> summarySetOps) {
// Null case checks
if (summary == null) {
@@ -227,7 +227,7 @@ public final class JaccardSimilarity {
*/
public static <S extends Summary> boolean exactlyEqual(
final Sketch<S> sketchA,
- final org.apache.datasketches.theta.Sketch sketchB,
+ final org.apache.datasketches.theta.ThetaSketch sketchB,
final S summary, final SummarySetOperations<S> summarySetOps) {
// Null case checks
if (summary == null) {
@@ -303,7 +303,7 @@ public final class JaccardSimilarity {
* with at least 97.7% confidence.
*/
public static <S extends Summary> boolean similarityTest(
- final Sketch<S> measured, final org.apache.datasketches.theta.Sketch expected,
+ final Sketch<S> measured, final org.apache.datasketches.theta.ThetaSketch expected,
final S summary, final SummarySetOperations<S> summarySetOps,
final double threshold) {
//index 0: the lower bound
@@ -357,7 +357,7 @@ public final class JaccardSimilarity {
* with at least 97.7% confidence.
*/
public static <S extends Summary> boolean dissimilarityTest(
- final Sketch<S> measured, final org.apache.datasketches.theta.Sketch expected,
+ final Sketch<S> measured, final org.apache.datasketches.theta.ThetaSketch expected,
final S summary, final SummarySetOperations<S> summarySetOps,
final double threshold) {
//index 0: the lower bound
diff --git a/src/main/java/org/apache/datasketches/tuple/Union.java b/src/main/java/org/apache/datasketches/tuple/Union.java
index f67626d1b..9c663f88a 100644
--- a/src/main/java/org/apache/datasketches/tuple/Union.java
+++ b/src/main/java/org/apache/datasketches/tuple/Union.java
@@ -89,7 +89,7 @@ public class Union<S extends Summary> {
* @return the result ordered CompactSketch on the heap.
*/
public CompactSketch<S> union(final Sketch<S> tupleSketch,
- final org.apache.datasketches.theta.Sketch thetaSketch, final S summary) {
+ final org.apache.datasketches.theta.ThetaSketch thetaSketch, final S summary) {
reset();
union(tupleSketch);
union(thetaSketch, summary);
@@ -120,7 +120,7 @@ public class Union<S extends Summary> {
* @param summary the given proxy summary for the theta sketch, which doesn't have one. This may
* not be null.
*/
- public void union(final org.apache.datasketches.theta.Sketch thetaSketch, final S summary) {
+ public void union(final org.apache.datasketches.theta.ThetaSketch thetaSketch, final S summary) {
if (summary == null) {
throw new SketchesArgumentException("Summary cannot be null."); }
if (thetaSketch == null || thetaSketch.isEmpty()) { return; }
diff --git a/src/test/java/org/apache/datasketches/theta/AnotBimplTest.java b/src/test/java/org/apache/datasketches/theta/AnotBimplTest.java
index 6482712e8..6960fbc32 100644
--- a/src/test/java/org/apache/datasketches/theta/AnotBimplTest.java
+++ b/src/test/java/org/apache/datasketches/theta/AnotBimplTest.java
@@ -215,7 +215,7 @@ public class AnotBimplTest {
final UpdateSketch cU = UpdateSketch.builder().setNominalEntries(k).build();
for (int i=k/2; i<3*k/4; i++) { cU.update(i); } //third 256
- final int segBytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int segBytes = ThetaSketch.getMaxUpdateSketchBytes(k);
CompactSketch result1, result2, result3;
final MemorySegment wseg1 = MemorySegment.ofArray(new byte[segBytes]);
@@ -259,7 +259,7 @@ public class AnotBimplTest {
final UpdateSketch c = UpdateSketch.builder().setNominalEntries(k).build();
for (int i=k/2; i<3*k/4; i++) { c.update(i); } //third 256
- final int segBytes = Sketch.getMaxCompactSketchBytes(a.getRetainedEntries(true));
+ final int segBytes = ThetaSketch.getMaxCompactSketchBytes(a.getRetainedEntries(true));
final MemorySegment seg = MemorySegment.ofArray(new byte[segBytes]);
CompactSketch result1, result2;
diff --git a/src/test/java/org/apache/datasketches/theta/CompactSketchTest.java b/src/test/java/org/apache/datasketches/theta/CompactSketchTest.java
index fc35891b3..4b2feb1bc 100644
--- a/src/test/java/org/apache/datasketches/theta/CompactSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/CompactSketchTest.java
@@ -63,14 +63,14 @@ public class CompactSketchTest {
CompactSketch refSk = usk.compact(ordered, null);
final byte[] barr = refSk.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(barr);
- CompactSketch testSk = (CompactSketch) Sketch.heapify(srcSeg);
+ CompactSketch testSk = (CompactSketch) ThetaSketch.heapify(srcSeg);
checkByRange(refSk, testSk, u, ordered);
/**Via byte[]**/
final byte[] byteArray = refSk.toByteArray();
final MemorySegment heapROSeg = MemorySegment.ofArray(byteArray).asReadOnly();
- testSk = (CompactSketch)Sketch.heapify(heapROSeg);
+ testSk = (CompactSketch)ThetaSketch.heapify(heapROSeg);
checkByRange(refSk, testSk, u, ordered);
@@ -83,19 +83,19 @@ public class CompactSketchTest {
/**Via CompactSketch.compact**/
refSk = usk.compact(ordered, directSeg);
- testSk = (CompactSketch)Sketch.wrap(directSeg);
+ testSk = (CompactSketch)ThetaSketch.wrap(directSeg);
checkByRange(refSk, testSk, u, ordered);
/**Via CompactSketch.compact**/
- testSk = (CompactSketch)Sketch.wrap(directSeg);
+ testSk = (CompactSketch)ThetaSketch.wrap(directSeg);
checkByRange(refSk, testSk, u, ordered);
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
- private static void checkByRange(final Sketch refSk, final Sketch testSk, final int u, final boolean ordered) {
+ private static void checkByRange(final ThetaSketch refSk, final ThetaSketch testSk, final int u, final boolean ordered) {
if (u == 0) {
checkEmptySketch(testSk);
} else if (u == 1) {
@@ -105,7 +105,7 @@ public class CompactSketchTest {
}
}
- private static void checkEmptySketch(final Sketch testSk) {
+ private static void checkEmptySketch(final ThetaSketch testSk) {
assertEquals(testSk.getFamily(), Family.COMPACT);
assertTrue(testSk instanceof EmptyCompactSketch);
assertTrue(testSk.isEmpty());
@@ -123,7 +123,7 @@ public class CompactSketchTest {
assertEquals(testSk.getCompactPreambleLongs(), 1);
}
- private static void checkSingleItemSketch(final Sketch testSk, final Sketch refSk) {
+ private static void checkSingleItemSketch(final ThetaSketch testSk, final ThetaSketch refSk) {
assertEquals(testSk.getFamily(), Family.COMPACT);
assertTrue(testSk instanceof SingleItemSketch);
assertFalse(testSk.isEmpty());
@@ -141,7 +141,7 @@ public class CompactSketchTest {
assertEquals(testSk.getCompactPreambleLongs(), 1);
}
- private static void checkOtherCompactSketch(final Sketch testSk, final Sketch refSk, final boolean ordered) {
+ private static void checkOtherCompactSketch(final ThetaSketch testSk, final ThetaSketch refSk, final boolean ordered) {
assertEquals(testSk.getFamily(), Family.COMPACT);
assertFalse(testSk.isEmpty());
assertNotNull(testSk.iterator());
@@ -179,7 +179,7 @@ public class CompactSketchTest {
final int bytes = sk.getCompactBytes();
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
sk.compact(true, wseg);
- final Sketch csk2 = Sketch.heapify(wseg);
+ final ThetaSketch csk2 = ThetaSketch.heapify(wseg);
assertTrue(csk2 instanceof SingleItemSketch);
}
@@ -443,10 +443,10 @@ public class CompactSketchTest {
public void checkHeapifySingleItemSketch() {
final UpdateSketch sk = UpdateSketch.builder().build();
sk.update(1);
- final int bytes = Sketch.getMaxCompactSketchBytes(2); //1 more than needed
+ final int bytes = ThetaSketch.getMaxCompactSketchBytes(2); //1 more than needed
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
sk.compact(false, wseg);
- final Sketch csk = Sketch.heapify(wseg);
+ final ThetaSketch csk = ThetaSketch.heapify(wseg);
assertTrue(csk instanceof SingleItemSketch);
}
@@ -456,7 +456,7 @@ public class CompactSketchTest {
final MemorySegment wseg = MemorySegment.ofArray(new byte[16]); //empty, but extra bytes
final CompactSketch csk = sk.compact(false, wseg); //ignores order because it is empty
assertTrue(csk instanceof DirectCompactSketch);
- final Sketch csk2 = Sketch.heapify(wseg);
+ final ThetaSketch csk2 = ThetaSketch.heapify(wseg);
assertTrue(csk2 instanceof EmptyCompactSketch);
}
diff --git a/src/test/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketchTest.java b/src/test/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketchTest.java
index e0816b0e5..f12d5809e 100644
--- a/src/test/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketchTest.java
@@ -101,10 +101,10 @@ public class ConcurrentDirectQuickSelectSketchTest {
final byte[] serArr = shared.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(serArr).asReadOnly();
- final Sketch recoveredShared = Sketch.heapify(srcSeg);
+ final ThetaSketch recoveredShared = ThetaSketch.heapify(srcSeg);
//reconstruct to Native/Direct
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
shared = sl.bldr.buildSharedFromSketch((UpdateSketch)recoveredShared, wseg);
final UpdateSketch local2 = sl.bldr.buildLocal(shared);
@@ -143,10 +143,10 @@ public class ConcurrentDirectQuickSelectSketchTest {
final byte[] serArr = shared.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(serArr).asReadOnly();
- final Sketch recoveredShared = Sketch.heapify(srcSeg);
+ final ThetaSketch recoveredShared = ThetaSketch.heapify(srcSeg);
//reconstruct to Native/Direct
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
shared = sl.bldr.buildSharedFromSketch((UpdateSketch)recoveredShared, wseg);
final UpdateSketch local2 = sl.bldr.buildLocal(shared);
@@ -179,7 +179,7 @@ public class ConcurrentDirectQuickSelectSketchTest {
final double sk1ub = local.getUpperBound(2);
assertTrue(local.isEstimationMode());
- final Sketch local2 = Sketch.wrap(sl.wseg);
+ final ThetaSketch local2 = ThetaSketch.wrap(sl.wseg);
assertEquals(local2.getEstimate(), sk1est);
assertEquals(local2.getLowerBound(2), sk1lb);
@@ -503,7 +503,7 @@ public class ConcurrentDirectQuickSelectSketchTest {
final UpdateSketch recoveredShared = UpdateSketch.wrap(seg);
//reconstruct to Native/Direct
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
shared = sl.bldr.buildSharedFromSketch(recoveredShared, wseg);
final UpdateSketch local2 = sl.bldr.buildLocal(shared);
@@ -558,7 +558,7 @@ public 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
- Sketch.heapify(sl.wseg); //catch in Sketch.constructHeapSketch
+ ThetaSketch.heapify(sl.wseg); //catch in Sketch.constructHeapSketch
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -627,7 +627,7 @@ public class ConcurrentDirectQuickSelectSketchTest {
assertEquals(shared.getRetainedEntries(false), k);
sl.wseg.set(JAVA_BYTE, SER_VER_BYTE, (byte) 0); //corrupt the SerVer byte
- Sketch.wrap(sl.wseg);
+ ThetaSketch.wrap(sl.wseg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -638,7 +638,7 @@ public class ConcurrentDirectQuickSelectSketchTest {
sl.wseg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Sketch ID byte
//try to wrap the corrupted seg
- Sketch.wrap(sl.wseg); //catch in Sketch.constructDirectSketch
+ ThetaSketch.wrap(sl.wseg); //catch in Sketch.constructDirectSketch
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -662,7 +662,7 @@ public class ConcurrentDirectQuickSelectSketchTest {
final UpdateSketch shared = sl.shared;
final MemorySegment srcSeg = MemorySegment.ofArray(shared.toByteArray()).asReadOnly();
- Sketch.heapify(srcSeg, seed2);
+ ThetaSketch.heapify(srcSeg, seed2);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -672,7 +672,7 @@ public class ConcurrentDirectQuickSelectSketchTest {
final SharedLocal sl = new SharedLocal(lgK, lgK, useSeg);
sl.wseg.set(JAVA_BYTE, LG_NOM_LONGS_BYTE, (byte)2); //corrupt
- Sketch.heapify(sl.wseg, Util.DEFAULT_UPDATE_SEED);
+ ThetaSketch.heapify(sl.wseg, Util.DEFAULT_UPDATE_SEED);
}
@Test(expectedExceptions = UnsupportedOperationException.class)
@@ -696,7 +696,7 @@ public class ConcurrentDirectQuickSelectSketchTest {
//System.out.println(s); //disable here
}
- private static void checkMemorySegmentDirectProxyMethods(final Sketch local, final Sketch shared) {
+ private static void checkMemorySegmentDirectProxyMethods(final ThetaSketch local, final ThetaSketch shared) {
assertEquals(
local.hasMemorySegment(),
shared.hasMemorySegment());
@@ -704,7 +704,7 @@ public class ConcurrentDirectQuickSelectSketchTest {
}
//Does not check hasMemorySegment(), isOffHeap()
- private static void checkOtherProxyMethods(final Sketch local, final Sketch shared) {
+ private static void checkOtherProxyMethods(final ThetaSketch local, final ThetaSketch shared) {
assertEquals(local.getCompactBytes(), shared.getCompactBytes());
assertEquals(local.getCurrentBytes(), shared.getCurrentBytes());
assertEquals(local.getEstimate(), shared.getEstimate());
diff --git a/src/test/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketchTest.java b/src/test/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketchTest.java
index c354fd344..e3f4e8823 100644
--- a/src/test/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketchTest.java
@@ -64,11 +64,11 @@ public class ConcurrentHeapQuickSelectSketchTest {
final byte[] serArr = shared.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(serArr);
- final Sketch sk = Sketch.heapify(seg, sl.seed);
+ final ThetaSketch sk = ThetaSketch.heapify(seg, sl.seed);
assertTrue(sk instanceof HeapQuickSelectSketch); //Intentional promotion to Parent
seg.set(JAVA_BYTE, SER_VER_BYTE, (byte) 0); //corrupt the SerVer byte
- Sketch.heapify(seg, sl.seed);
+ ThetaSketch.heapify(seg, sl.seed);
}
@Test
@@ -115,7 +115,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Sketch ID byte
//try to heapify the corrupted seg
- Sketch.heapify(seg, sl.seed);
+ ThetaSketch.heapify(seg, sl.seed);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -126,7 +126,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
final SharedLocal sl = new SharedLocal(lgK, lgK, seed);
final byte[] byteArray = sl.shared.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(byteArray);
- Sketch.heapify(srcSeg, seed2);
+ ThetaSketch.heapify(srcSeg, seed2);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -136,7 +136,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
final byte[] serArr = sl.shared.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(serArr);
srcSeg.set(JAVA_BYTE, LG_NOM_LONGS_BYTE, (byte)2); //corrupt
- Sketch.heapify(srcSeg, Util.DEFAULT_UPDATE_SEED);
+ ThetaSketch.heapify(srcSeg, Util.DEFAULT_UPDATE_SEED);
}
@Test(expectedExceptions = UnsupportedOperationException.class)
@@ -162,10 +162,10 @@ public class ConcurrentHeapQuickSelectSketchTest {
final byte[] serArr = shared.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(serArr).asReadOnly();
- final Sketch recoveredShared = UpdateSketch.heapify(srcSeg);
+ final ThetaSketch recoveredShared = UpdateSketch.heapify(srcSeg);
//reconstruct to Native/Direct
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
shared = sl.bldr.buildSharedFromSketch((UpdateSketch)recoveredShared, wseg);
final UpdateSketch local2 = sl.bldr.buildLocal(shared);
@@ -203,7 +203,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
final MemorySegment srcSeg = MemorySegment.ofArray(serArr).asReadOnly();
final UpdateSketch recoveredShared = UpdateSketch.heapify(srcSeg, sl.seed);
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
shared = sl.bldr.buildSharedFromSketch(recoveredShared, wseg);
final UpdateSketch local2 = sl.bldr.buildLocal(shared);
@@ -242,7 +242,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
final MemorySegment srcSeg = MemorySegment.ofArray(serArr).asReadOnly();
final UpdateSketch recoveredShared = UpdateSketch.heapify(srcSeg, Util.DEFAULT_UPDATE_SEED);
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
shared = sl.bldr.buildSharedFromSketch(recoveredShared, wseg);
final UpdateSketch local2 = sl.bldr.buildLocal(shared);
@@ -577,7 +577,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
final byte[] byteArray = sl.shared.toByteArray();
final byte[] badBytes = Arrays.copyOfRange(byteArray, 0, 24); //corrupt no. bytes
final MemorySegment seg = MemorySegment.ofArray(badBytes).asReadOnly();
- Sketch.heapify(seg);
+ ThetaSketch.heapify(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -591,7 +591,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
final MemorySegment seg = MemorySegment.ofArray(badArray);
PreambleUtil.insertLgArrLongs(seg, 4); //corrupt
PreambleUtil.insertThetaLong(seg, Long.MAX_VALUE / 2); //corrupt
- Sketch.heapify(seg);
+ ThetaSketch.heapify(seg);
}
@Test
diff --git a/src/test/java/org/apache/datasketches/theta/DirectQuickSelectSketchTest.java b/src/test/java/org/apache/datasketches/theta/DirectQuickSelectSketchTest.java
index a06206ff5..7f3f79281 100644
--- a/src/test/java/org/apache/datasketches/theta/DirectQuickSelectSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/DirectQuickSelectSketchTest.java
@@ -76,7 +76,7 @@ public class DirectQuickSelectSketchTest {
wseg.set(JAVA_BYTE, SER_VER_BYTE, (byte) 0); //corrupt the SerVer byte
- Sketch.wrap(wseg);
+ ThetaSketch.wrap(wseg);
} catch (final Exception e) {
if (e instanceof SketchesArgumentException) {}
else { throw new RuntimeException(e); }
@@ -117,7 +117,7 @@ public class DirectQuickSelectSketchTest {
seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Family ID byte
//try to heapify the corrupted seg
- Sketch.heapify(seg); //catch in Sketch.constructHeapSketch
+ ThetaSketch.heapify(seg); //catch in Sketch.constructHeapSketch
}
@Test
@@ -173,7 +173,7 @@ public class DirectQuickSelectSketchTest {
seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Sketch ID byte
//try to wrap the corrupted seg
- Sketch.wrap(seg); //catch in Sketch.constructDirectSketch
+ ThetaSketch.wrap(seg); //catch in Sketch.constructDirectSketch
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -200,7 +200,7 @@ public class DirectQuickSelectSketchTest {
final UpdateSketch usk = UpdateSketch.builder().setSeed(seed1).setNominalEntries(k).build(wseg);
final byte[] byteArray = usk.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(byteArray);
- Sketch.heapify(srcSeg, seed2);
+ ThetaSketch.heapify(srcSeg, seed2);
} catch (final Exception e) {
if (e instanceof SketchesArgumentException) {}
else { throw new RuntimeException(e); }
@@ -215,7 +215,7 @@ public class DirectQuickSelectSketchTest {
final MemorySegment wseg = makeNativeMemorySegment(k, arena);
UpdateSketch.builder().setNominalEntries(k).build(wseg);
wseg.set(JAVA_BYTE, LG_NOM_LONGS_BYTE, (byte)2); //corrupt
- Sketch.heapify(wseg, Util.DEFAULT_UPDATE_SEED);
+ ThetaSketch.heapify(wseg, Util.DEFAULT_UPDATE_SEED);
} catch (final Exception e) {
if (e instanceof SketchesArgumentException) {}
else { throw new RuntimeException(e); }
@@ -237,7 +237,7 @@ public class DirectQuickSelectSketchTest {
assertEquals(bytes, byteArray.length);
final MemorySegment srcSeg = MemorySegment.ofArray(byteArray);
- final Sketch usk2 = Sketch.heapify(srcSeg);
+ final ThetaSketch usk2 = ThetaSketch.heapify(srcSeg);
assertEquals(usk2.getEstimate(), k, 0.0);
assertEquals(usk2.getLowerBound(2), k, 0.0);
assertEquals(usk2.getUpperBound(2), k, 0.0);
@@ -271,7 +271,7 @@ public class DirectQuickSelectSketchTest {
final byte[] byteArray = usk.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(byteArray);
- final Sketch usk2 = Sketch.heapify(srcSeg);
+ final ThetaSketch usk2 = ThetaSketch.heapify(srcSeg);
assertEquals(usk2.getEstimate(), uskEst);
assertEquals(usk2.getLowerBound(2), uskLB);
assertEquals(usk2.getUpperBound(2), uskUB);
@@ -297,7 +297,7 @@ public class DirectQuickSelectSketchTest {
final double sk1ub = sk1.getUpperBound(2);
assertTrue(sk1.isEstimationMode());
- final Sketch sk2 = Sketch.wrap(wseg);
+ final ThetaSketch sk2 = ThetaSketch.wrap(wseg);
assertEquals(sk2.getEstimate(), sk1est);
assertEquals(sk2.getLowerBound(2), sk1lb);
@@ -734,7 +734,7 @@ public class DirectQuickSelectSketchTest {
@Test(expectedExceptions = SketchesReadOnlyException.class)
public void updateAfterReadOnlyWrap() {
final UpdateSketch usk1 = UpdateSketch.builder().build();
- final UpdateSketch usk2 = (UpdateSketch) Sketch.wrap(MemorySegment.ofArray(usk1.toByteArray()));
+ final UpdateSketch usk2 = (UpdateSketch) ThetaSketch.wrap(MemorySegment.ofArray(usk1.toByteArray()));
usk2.update(0);
}
@@ -756,7 +756,7 @@ public class DirectQuickSelectSketchTest {
final int k = 1024; //lgNomLongs = 10
final int u = k; //exact mode, lgArrLongs = 11
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
final byte[] arr1 = new byte[bytes];
final MemorySegment seg1 = MemorySegment.ofArray(arr1);
final ResizeFactor rf = ResizeFactor.X1; //0
@@ -823,7 +823,7 @@ public class DirectQuickSelectSketchTest {
public void checkCorruptRFWithInsufficientArray() {
final int k = 1024; //lgNomLongs = 10
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
final byte[] arr = new byte[bytes];
final MemorySegment seg = MemorySegment.ofArray(arr);
final ResizeFactor rf = ResizeFactor.X8; // 3
@@ -867,7 +867,7 @@ public class DirectQuickSelectSketchTest {
public void checkMoveAndResize() {
final int k = 1 << 12;
final int u = 2 * k;
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
MemorySegment wseg;
try (Arena arena = Arena.ofConfined()) {
wseg = arena.allocate(bytes / 2);
@@ -883,7 +883,7 @@ public class DirectQuickSelectSketchTest {
public void checkReadOnlyRebuildResize() {
final int k = 1 << 12;
final int u = 2 * k;
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
MemorySegment wseg;
try (Arena arena = Arena.ofConfined()) {
wseg = arena.allocate(bytes / 2);
@@ -892,7 +892,7 @@ public class DirectQuickSelectSketchTest {
final double est1 = sketch.getEstimate();
final byte[] serBytes = sketch.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(serBytes).asReadOnly();
- final UpdateSketch roSketch = (UpdateSketch) Sketch.wrap(seg);
+ final UpdateSketch roSketch = (UpdateSketch) ThetaSketch.wrap(seg);
final double est2 = roSketch.getEstimate();
assertEquals(est2, est1);
try {
diff --git a/src/test/java/org/apache/datasketches/theta/DirectUnionTest.java b/src/test/java/org/apache/datasketches/theta/DirectUnionTest.java
index e83651aed..c488abcb4 100644
--- a/src/test/java/org/apache/datasketches/theta/DirectUnionTest.java
+++ b/src/test/java/org/apache/datasketches/theta/DirectUnionTest.java
@@ -435,8 +435,8 @@ public 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)Sketch.wrap(skSeg1);
- final CompactSketch csk2 = (CompactSketch)Sketch.wrap(skSeg2);
+ final CompactSketch csk1 = (CompactSketch)ThetaSketch.wrap(skSeg1);
+ final CompactSketch csk2 = (CompactSketch)ThetaSketch.wrap(skSeg2);
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]); //union segment
final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
@@ -518,7 +518,7 @@ public class DirectUnionTest {
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]); //union segment
final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
- final MemorySegment seg = MemorySegment.ofArray(new byte[Sketch.getMaxCompactSketchBytes(0)]);
+ final MemorySegment seg = MemorySegment.ofArray(new byte[ThetaSketch.getMaxCompactSketchBytes(0)]);
final CompactSketch csk = union.getResult(false, seg); //DirectCompactSketch
assertTrue(csk.isEmpty());
}
@@ -530,7 +530,7 @@ public class DirectUnionTest {
final MemorySegment uSeg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]); //union segment
final Union union = SetOperation.builder().setNominalEntries(k).buildUnion(uSeg);
- final MemorySegment seg = MemorySegment.ofArray(new byte[Sketch.getMaxCompactSketchBytes(0)]);
+ final MemorySegment seg = MemorySegment.ofArray(new byte[ThetaSketch.getMaxCompactSketchBytes(0)]);
final CompactSketch csk = union.getResult(true, seg); //DirectCompactSketch
assertTrue(csk.isEmpty());
}
@@ -617,7 +617,7 @@ public class DirectUnionTest {
final SetOperation setOp = new SetOperationBuilder().setNominalEntries(k).build(Family.UNION, seg);
println(setOp.toString());
final int familyID = PreambleUtil.extractFamilyID(seg);
- final int preLongs = Sketch.getPreambleLongs(seg);
+ final int preLongs = ThetaSketch.getPreambleLongs(seg);
assertEquals(familyID, Family.UNION.getID());
assertEquals(preLongs, Family.UNION.getMaxPreLongs());
PreambleUtil.insertPreLongs(seg, 3); //Corrupt with 3; correct value is 4
@@ -644,7 +644,7 @@ public class DirectUnionTest {
}
usk.rebuild(); //optional but created the symptom
- final Sketch s = usk.compact();
+ final ThetaSketch s = usk.compact();
//create empty target union in off-heap segment
final MemorySegment seg = MemorySegment.ofArray(new byte[getMaxUnionBytes(k)]);
diff --git a/src/test/java/org/apache/datasketches/theta/HeapAlphaSketchTest.java b/src/test/java/org/apache/datasketches/theta/HeapAlphaSketchTest.java
index 31f1992c1..38fc8f629 100644
--- a/src/test/java/org/apache/datasketches/theta/HeapAlphaSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/HeapAlphaSketchTest.java
@@ -78,7 +78,7 @@ public class HeapAlphaSketchTest {
MemorySegment seg = MemorySegment.ofArray(byteArray);
seg.set(JAVA_BYTE, SER_VER_BYTE, (byte) 0); //corrupt the SerVer byte
- Sketch.heapify(seg, seed);
+ ThetaSketch.heapify(seg, seed);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -115,7 +115,7 @@ public class HeapAlphaSketchTest {
seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Sketch ID byte
//try to heapify the corrupted seg
- Sketch.heapify(seg, seed);
+ ThetaSketch.heapify(seg, seed);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -127,7 +127,7 @@ public class HeapAlphaSketchTest {
.setNominalEntries(k).build();
byte[] byteArray = usk.toByteArray();
MemorySegment srcSeg = MemorySegment.ofArray(byteArray).asReadOnly();
- Sketch.heapify(srcSeg, seed2);
+ ThetaSketch.heapify(srcSeg, seed2);
}
@Test
@@ -147,7 +147,7 @@ public class HeapAlphaSketchTest {
assertEquals(bytes, byteArray.length);
MemorySegment srcSeg = MemorySegment.ofArray(byteArray);
- UpdateSketch usk2 = (UpdateSketch)Sketch.heapify(srcSeg, seed);
+ UpdateSketch usk2 = (UpdateSketch)ThetaSketch.heapify(srcSeg, seed);
assertEquals(usk2.getEstimate(), u, 0.0);
assertEquals(usk2.getLowerBound(2), u, 0.0);
assertEquals(usk2.getUpperBound(2), u, 0.0);
@@ -177,7 +177,7 @@ public class HeapAlphaSketchTest {
byte[] byteArray = usk.toByteArray();
MemorySegment srcSeg = MemorySegment.ofArray(byteArray).asReadOnly();
- UpdateSketch usk2 = (UpdateSketch)Sketch.heapify(srcSeg, seed);
+ UpdateSketch usk2 = (UpdateSketch)ThetaSketch.heapify(srcSeg, seed);
assertEquals(usk2.getEstimate(), uskEst);
assertEquals(usk2.getLowerBound(2), uskLB);
assertEquals(usk2.getUpperBound(2), uskUB);
@@ -208,7 +208,7 @@ public class HeapAlphaSketchTest {
byte[] byteArray = sk1.toByteArray();
MemorySegment seg = MemorySegment.ofArray(byteArray).asReadOnly();
- UpdateSketch sk2 = (UpdateSketch)Sketch.heapify(seg, Util.DEFAULT_UPDATE_SEED);
+ UpdateSketch sk2 = (UpdateSketch)ThetaSketch.heapify(seg, Util.DEFAULT_UPDATE_SEED);
assertEquals(sk2.getEstimate(), sk1est);
assertEquals(sk2.getLowerBound(2), sk1lb);
@@ -545,40 +545,40 @@ public class HeapAlphaSketchTest {
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkLBlimits0() {
int k = 512;
- Sketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ ThetaSketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
alpha.getLowerBound(0);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkUBlimits0() {
int k = 512;
- Sketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ ThetaSketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
alpha.getUpperBound(0);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkLBlimits4() {
int k = 512;
- Sketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ ThetaSketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
alpha.getLowerBound(4);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkUBlimits4() {
int k = 512;
- Sketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ ThetaSketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
alpha.getUpperBound(4);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkBadPreambleLongs() {
int k = 512;
- Sketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ ThetaSketch alpha = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
byte[] byteArray = alpha.toByteArray();
MemorySegment seg = MemorySegment.ofArray(byteArray);
//corrupt:
seg.set(JAVA_BYTE, PREAMBLE_LONGS_BYTE, (byte) 4);
- Sketch.heapify(seg);
+ ThetaSketch.heapify(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
diff --git a/src/test/java/org/apache/datasketches/theta/HeapQuickSelectSketchTest.java b/src/test/java/org/apache/datasketches/theta/HeapQuickSelectSketchTest.java
index 1fd536128..dafd4e4fc 100644
--- a/src/test/java/org/apache/datasketches/theta/HeapQuickSelectSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/HeapQuickSelectSketchTest.java
@@ -76,7 +76,7 @@ public class HeapQuickSelectSketchTest {
final MemorySegment seg = MemorySegment.ofArray(byteArray);
seg.set(JAVA_BYTE, SER_VER_BYTE, (byte) 0); //corrupt the SerVer byte
- Sketch.heapify(seg, seed);
+ ThetaSketch.heapify(seg, seed);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -100,7 +100,7 @@ public class HeapQuickSelectSketchTest {
seg.set(JAVA_BYTE, FAMILY_BYTE, (byte) 0); //corrupt the Sketch ID byte
//try to heapify the corrupted seg
- Sketch.heapify(seg, seed);
+ ThetaSketch.heapify(seg, seed);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -111,7 +111,7 @@ public class HeapQuickSelectSketchTest {
final UpdateSketch usk = UpdateSketch.builder().setFamily(fam_).setSeed(seed1).setNominalEntries(k).build();
final byte[] byteArray = usk.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(byteArray).asReadOnly();
- Sketch.heapify(srcSeg, seed2);
+ ThetaSketch.heapify(srcSeg, seed2);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -119,7 +119,7 @@ public class HeapQuickSelectSketchTest {
final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(16).build();
final MemorySegment srcSeg = MemorySegment.ofArray(usk.toByteArray());
srcSeg.set(JAVA_BYTE, LG_NOM_LONGS_BYTE, (byte)2); //corrupt
- Sketch.heapify(srcSeg, Util.DEFAULT_UPDATE_SEED);
+ ThetaSketch.heapify(srcSeg, Util.DEFAULT_UPDATE_SEED);
}
@Test
@@ -547,7 +547,7 @@ public class HeapQuickSelectSketchTest {
final byte[] byteArray = s1.toByteArray();
final byte[] badBytes = Arrays.copyOfRange(byteArray, 0, 24);
final MemorySegment seg = MemorySegment.ofArray(badBytes);
- Sketch.heapify(seg);
+ ThetaSketch.heapify(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -559,7 +559,7 @@ public class HeapQuickSelectSketchTest {
final MemorySegment seg = MemorySegment.ofArray(badArray);
PreambleUtil.insertLgArrLongs(seg, 4);
PreambleUtil.insertThetaLong(seg, Long.MAX_VALUE / 2);
- Sketch.heapify(seg);
+ ThetaSketch.heapify(seg);
}
@Test
diff --git a/src/test/java/org/apache/datasketches/theta/HeapUnionTest.java b/src/test/java/org/apache/datasketches/theta/HeapUnionTest.java
index 8863a971b..bc602a6f8 100644
--- a/src/test/java/org/apache/datasketches/theta/HeapUnionTest.java
+++ b/src/test/java/org/apache/datasketches/theta/HeapUnionTest.java
@@ -389,8 +389,8 @@ public 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)Sketch.wrap(skSeg1);
- final CompactSketch csk2 = (CompactSketch)Sketch.wrap(skSeg2);
+ final CompactSketch csk1 = (CompactSketch)ThetaSketch.wrap(skSeg1);
+ final CompactSketch csk2 = (CompactSketch)ThetaSketch.wrap(skSeg2);
final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
diff --git a/src/test/java/org/apache/datasketches/theta/HeapifyWrapSerVer3Test.java b/src/test/java/org/apache/datasketches/theta/HeapifyWrapSerVer3Test.java
index b1dba552c..79e0252af 100644
--- a/src/test/java/org/apache/datasketches/theta/HeapifyWrapSerVer3Test.java
+++ b/src/test/java/org/apache/datasketches/theta/HeapifyWrapSerVer3Test.java
@@ -82,7 +82,7 @@ public class HeapifyWrapSerVer3Test {
final MemorySegment cskSeg = MemorySegment.ofArray(csk.toByteArray()).asReadOnly();
CompactSketch cskResult;
- cskResult = (CompactSketch) Sketch.heapify(cskSeg);
+ cskResult = (CompactSketch) ThetaSketch.heapify(cskSeg);
assertEquals(cskResult.getEstimate(), usk.getEstimate());
assertEquals(cskResult.getSeedHash(), seedHash);
}
@@ -99,7 +99,7 @@ public class HeapifyWrapSerVer3Test {
final MemorySegment cskSeg = MemorySegment.ofArray(csk.toByteArray()).asReadOnly();
CompactSketch cskResult;
- cskResult = (CompactSketch) Sketch.heapify(cskSeg, seed);
+ cskResult = (CompactSketch) ThetaSketch.heapify(cskSeg, seed);
assertEquals(cskResult.getEstimate(), usk.getEstimate());
assertEquals(cskResult.getSeedHash(), seedHash);
}
@@ -162,7 +162,7 @@ public class HeapifyWrapSerVer3Test {
//SerialVersion3 test
try(Arena arena = Arena.ofConfined()) {
offHeap = putOffHeap(MemorySegment.ofArray(csk.toByteArray()), arena);
- cskResult = (CompactSketch) Sketch.wrap(offHeap);
+ cskResult = (CompactSketch) ThetaSketch.wrap(offHeap);
assertEquals(cskResult.getEstimate(), usk.getEstimate());
assertEquals(cskResult.getSeedHash(), seedHash);
assertTrue(cskResult.isOffHeap());
@@ -183,7 +183,7 @@ public class HeapifyWrapSerVer3Test {
//SerialVersion3 test
try(Arena arena = Arena.ofConfined()) {
offHeap = putOffHeap(MemorySegment.ofArray(csk.toByteArray()), arena);
- cskResult = (CompactSketch) Sketch.wrap(offHeap, seed);
+ cskResult = (CompactSketch) ThetaSketch.wrap(offHeap, seed);
assertEquals(cskResult.getEstimate(), usk.getEstimate());
assertEquals(cskResult.getSeedHash(), seedHash);
assertTrue(cskResult.isOffHeap());
diff --git a/src/test/java/org/apache/datasketches/theta/IteratorTest.java b/src/test/java/org/apache/datasketches/theta/IteratorTest.java
index 343142044..7e3dbd159 100644
--- a/src/test/java/org/apache/datasketches/theta/IteratorTest.java
+++ b/src/test/java/org/apache/datasketches/theta/IteratorTest.java
@@ -26,7 +26,7 @@ import org.testng.annotations.Test;
import org.apache.datasketches.common.Family;
import org.apache.datasketches.theta.CompactSketch;
import org.apache.datasketches.theta.HashIterator;
-import org.apache.datasketches.theta.Sketch;
+import org.apache.datasketches.theta.ThetaSketch;
import org.apache.datasketches.theta.UpdateSketch;
@@ -39,7 +39,7 @@ public class IteratorTest {
@Test
public void checkDirectCompactSketch() {
int k = 16;
- int maxBytes = Sketch.getMaxUpdateSketchBytes(k);
+ int maxBytes = ThetaSketch.getMaxUpdateSketchBytes(k);
MemorySegment wseg = MemorySegment.ofArray(new byte[maxBytes]);
UpdateSketch sk1 = UpdateSketch.builder().setNominalEntries(k).build(wseg);
println(sk1.getClass().getSimpleName());
@@ -52,7 +52,7 @@ public class IteratorTest {
assertEquals(count, k/2);
println("");
- Sketch sk2 = sk1.compact();
+ ThetaSketch sk2 = sk1.compact();
println(sk2.getClass().getSimpleName());
HashIterator itr2 = sk2.iterator();
count = 0;
@@ -62,7 +62,7 @@ public class IteratorTest {
assertEquals(count, k/2);
println("");
- Sketch sk3 = sk1.compact(false, MemorySegment.ofArray(new byte[maxBytes]));
+ ThetaSketch sk3 = sk1.compact(false, MemorySegment.ofArray(new byte[maxBytes]));
println(sk3.getClass().getSimpleName());
HashIterator itr3 = sk3.iterator();
count = 0;
diff --git a/src/test/java/org/apache/datasketches/theta/PairwiseSetOperationsTest.java b/src/test/java/org/apache/datasketches/theta/PairwiseSetOperationsTest.java
index 2d1e71103..e2682453a 100644
--- a/src/test/java/org/apache/datasketches/theta/PairwiseSetOperationsTest.java
+++ b/src/test/java/org/apache/datasketches/theta/PairwiseSetOperationsTest.java
@@ -27,7 +27,7 @@ import org.apache.datasketches.theta.AnotB;
import org.apache.datasketches.theta.CompactSketch;
import org.apache.datasketches.theta.Intersection;
import org.apache.datasketches.theta.SetOperation;
-import org.apache.datasketches.theta.Sketch;
+import org.apache.datasketches.theta.ThetaSketch;
import org.apache.datasketches.theta.Union;
import org.apache.datasketches.theta.UpdateSketch;
import org.testng.annotations.Test;
@@ -52,7 +52,7 @@ public class PairwiseSetOperationsTest {
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
Intersection inter = SetOperation.builder().buildIntersection();
- Sketch rsk = inter.intersect(csk1, csk2);
+ ThetaSketch rsk = inter.intersect(csk1, csk2);
assertEquals(rsk.getEstimate(), 0.0);
}
@@ -73,7 +73,7 @@ public class PairwiseSetOperationsTest {
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch rsk = inter.intersect(csk1, csk2);
+ ThetaSketch rsk = inter.intersect(csk1, csk2);
assertEquals(rsk.getEstimate(), k, 0.0);
}
@@ -98,7 +98,7 @@ public class PairwiseSetOperationsTest {
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch rsk = inter.intersect(csk1, csk2);
+ ThetaSketch rsk = inter.intersect(csk1, csk2);
double result1 = rsk.getEstimate();
inter.intersect(csk1);
@@ -133,7 +133,7 @@ public class PairwiseSetOperationsTest {
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch rsk = anotb.aNotB(csk1, csk2);
+ ThetaSketch rsk = anotb.aNotB(csk1, csk2);
assertEquals(rsk.getEstimate(), k, 0.0);
}
@@ -154,7 +154,7 @@ public class PairwiseSetOperationsTest {
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch rsk = anotb.aNotB(csk1, csk2);
+ ThetaSketch rsk = anotb.aNotB(csk1, csk2);
assertEquals(rsk.getEstimate(), 0.0, 0.0);
}
@@ -180,7 +180,7 @@ public class PairwiseSetOperationsTest {
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch rsk = aNotB.aNotB(csk1, csk2);
+ ThetaSketch rsk = aNotB.aNotB(csk1, csk2);
double result1 = rsk.getEstimate();
CompactSketch csk3 = aNotB.aNotB(csk1, csk2);
@@ -214,9 +214,9 @@ public class PairwiseSetOperationsTest {
union.union(csk1);
union.union(csk2);
- Sketch stdSk = union.getResult(true, null);
+ ThetaSketch stdSk = union.getResult(true, null);
- Sketch rsk = union.union(csk1, csk2);
+ ThetaSketch rsk = union.union(csk1, csk2);
assertEquals(rsk.getEstimate(), stdSk.getEstimate(), 0.0);
}
@@ -238,7 +238,7 @@ public class PairwiseSetOperationsTest {
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch rsk = union.union(csk1, csk2);
+ ThetaSketch rsk = union.union(csk1, csk2);
assertEquals(rsk.getEstimate(), k, 0.0);
}
@@ -264,7 +264,7 @@ public class PairwiseSetOperationsTest {
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch pwSk = union.union(csk1, csk2);
+ ThetaSketch pwSk = union.union(csk1, csk2);
double pwEst = pwSk.getEstimate();
union.union(csk1);
@@ -298,7 +298,7 @@ public class PairwiseSetOperationsTest {
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch pwSk = union.union(csk1, csk2);
+ ThetaSketch pwSk = union.union(csk1, csk2);
double pwEst = pwSk.getEstimate();
union.union(csk1);
diff --git a/src/test/java/org/apache/datasketches/theta/PreambleUtilTest.java b/src/test/java/org/apache/datasketches/theta/PreambleUtilTest.java
index 61093c2a5..a17b6f64c 100644
--- a/src/test/java/org/apache/datasketches/theta/PreambleUtilTest.java
+++ b/src/test/java/org/apache/datasketches/theta/PreambleUtilTest.java
@@ -74,7 +74,7 @@ public class PreambleUtilTest {
final MemorySegment seg = MemorySegment.ofArray(byteArray);
final UpdateSketch quick1 = UpdateSketch.builder().setNominalEntries(k).build(seg);
- println(Sketch.toString(byteArray));
+ println(ThetaSketch.toString(byteArray));
Assert.assertTrue(quick1.isEmpty());
@@ -103,14 +103,14 @@ public class PreambleUtilTest {
quick1.update(i);
}
final byte[] bytes = quick1.compact().toByteArray();
- println(Sketch.toString(bytes));
+ println(ThetaSketch.toString(bytes));
}
@Test
public void checkPreambleToStringExceptions() {
byte[] byteArr = new byte[7];
try { //check preLongs < 8 fails
- Sketch.toString(byteArr);
+ ThetaSketch.toString(byteArr);
fail("Did not throw SketchesArgumentException.");
} catch (final SketchesArgumentException e) {
//expected
@@ -118,7 +118,7 @@ public class PreambleUtilTest {
byteArr = new byte[8];
byteArr[0] = (byte) 2; //needs min capacity of 16
try { //check preLongs == 2 fails
- Sketch.toString(MemorySegment.ofArray(byteArr).asReadOnly());
+ ThetaSketch.toString(MemorySegment.ofArray(byteArr).asReadOnly());
fail("Did not throw SketchesArgumentException.");
} catch (final SketchesArgumentException e) {
//expected
@@ -136,19 +136,19 @@ public class PreambleUtilTest {
final UpdateSketch sketch = UpdateSketch.builder().setNominalEntries(16).build();
CompactSketch comp = sketch.compact(false, null);
byte[] byteArr = comp.toByteArray();
- println(Sketch.toString(byteArr)); //PreLongs = 1
+ println(ThetaSketch.toString(byteArr)); //PreLongs = 1
sketch.update(1);
comp = sketch.compact(false, null);
byteArr = comp.toByteArray();
- println(Sketch.toString(byteArr)); //PreLongs = 2
+ println(ThetaSketch.toString(byteArr)); //PreLongs = 2
for (int i=2; i<=32; i++) {
sketch.update(i);
}
comp = sketch.compact(false, null);
byteArr = comp.toByteArray();
- println(Sketch.toString(MemorySegment.ofArray(byteArr).asReadOnly())); //PreLongs = 3
+ println(ThetaSketch.toString(MemorySegment.ofArray(byteArr).asReadOnly())); //PreLongs = 3
}
@Test
diff --git a/src/test/java/org/apache/datasketches/theta/ReadOnlyMemorySegmentTest.java b/src/test/java/org/apache/datasketches/theta/ReadOnlyMemorySegmentTest.java
index ab6caf793..d196fc95b 100644
--- a/src/test/java/org/apache/datasketches/theta/ReadOnlyMemorySegmentTest.java
+++ b/src/test/java/org/apache/datasketches/theta/ReadOnlyMemorySegmentTest.java
@@ -39,7 +39,7 @@ public class ReadOnlyMemorySegmentTest {
updateSketch.update(1);
final MemorySegment seg = MemorySegment.ofBuffer(
ByteBuffer.wrap(updateSketch.toByteArray()).asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
- final UpdateSketch sketch = (UpdateSketch) Sketch.wrap(seg);
+ final UpdateSketch sketch = (UpdateSketch) ThetaSketch.wrap(seg);
assertEquals(sketch.getEstimate(), 1.0);
assertTrue(seg.isReadOnly());
@@ -58,7 +58,7 @@ public class ReadOnlyMemorySegmentTest {
updateSketch.update(1);
final MemorySegment seg = MemorySegment.ofBuffer(
ByteBuffer.wrap(updateSketch.compact(false, null).toByteArray()).asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
- final Sketch sketch = Sketch.wrap(seg);
+ final ThetaSketch sketch = ThetaSketch.wrap(seg);
assertEquals(sketch.getEstimate(), 1.0);
assertTrue(seg.isReadOnly());
}
@@ -69,7 +69,7 @@ public class ReadOnlyMemorySegmentTest {
updateSketch.update(1);
final MemorySegment seg = MemorySegment.ofBuffer(ByteBuffer.wrap(updateSketch.compact().toByteArray())
.asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
- final Sketch sketch = Sketch.wrap(seg);
+ final ThetaSketch sketch = ThetaSketch.wrap(seg);
assertEquals(sketch.getEstimate(), 1.0);
assertTrue(seg.isReadOnly());
}
@@ -81,7 +81,7 @@ public class ReadOnlyMemorySegmentTest {
final MemorySegment seg = MemorySegment.ofBuffer(
ByteBuffer.wrap(us1.toByteArray()).asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
// downcasting is not recommended, for testing only
- final UpdateSketch us2 = (UpdateSketch) Sketch.heapify(seg);
+ final UpdateSketch us2 = (UpdateSketch) ThetaSketch.heapify(seg);
us2.update(2);
assertEquals(us2.getEstimate(), 2.0);
assertTrue(seg.isReadOnly());
@@ -93,7 +93,7 @@ public class ReadOnlyMemorySegmentTest {
updateSketch.update(1);
final MemorySegment seg = MemorySegment.ofBuffer(
ByteBuffer.wrap(updateSketch.compact(false, null).toByteArray()).asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
- final Sketch sketch = Sketch.heapify(seg);
+ final ThetaSketch sketch = ThetaSketch.heapify(seg);
assertEquals(sketch.getEstimate(), 1.0);
assertTrue(seg.isReadOnly());
}
@@ -104,7 +104,7 @@ public class ReadOnlyMemorySegmentTest {
updateSketch.update(1);
final MemorySegment seg = MemorySegment.ofBuffer(
ByteBuffer.wrap(updateSketch.compact().toByteArray()).asReadOnlyBuffer().order(ByteOrder.nativeOrder()));
- final Sketch sketch = Sketch.heapify(seg);
+ final ThetaSketch sketch = ThetaSketch.heapify(seg);
assertEquals(sketch.getEstimate(), 1.0);
assertTrue(seg.isReadOnly());
}
diff --git a/src/test/java/org/apache/datasketches/theta/SetOperationTest.java b/src/test/java/org/apache/datasketches/theta/SetOperationTest.java
index 8d4660d91..e19b405c6 100644
--- a/src/test/java/org/apache/datasketches/theta/SetOperationTest.java
+++ b/src/test/java/org/apache/datasketches/theta/SetOperationTest.java
@@ -20,7 +20,7 @@
package org.apache.datasketches.theta;
import static org.apache.datasketches.common.ResizeFactor.X4;
-import static org.apache.datasketches.theta.Sketch.getMaxUpdateSketchBytes;
+import static org.apache.datasketches.theta.ThetaSketch.getMaxUpdateSketchBytes;
import static org.apache.datasketches.thetacommon.HashOperations.minLgHashTableSize;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
@@ -347,7 +347,7 @@ public class SetOperationTest {
final int[] heapLayout = new int[6];
final int unionBytes = SetOperation.getMaxUnionBytes(unionNomEntries);
final int sketchBytes = getMaxUpdateSketchBytes(sketchNomEntries);
- final int resultBytes = Sketch.getMaxCompactSketchBytes(unionNomEntries);
+ final int resultBytes = ThetaSketch.getMaxCompactSketchBytes(unionNomEntries);
heapLayout[0] = 0; //offset for Union
heapLayout[1] = unionBytes; //offset for sketch1
heapLayout[2] = unionBytes + sketchBytes; //offset for sketch2
@@ -395,9 +395,9 @@ public class SetOperationTest {
//Let's recover the union and the 3rd sketch
union = Union.wrap(unionSeg);
- union.union(Sketch.wrap(sketch3seg));
+ union.union(ThetaSketch.wrap(sketch3seg));
- final Sketch resSk = union.getResult(true, resultSeg);
+ final ThetaSketch resSk = union.getResult(true, resultSeg);
final double est = resSk.getEstimate();
return est;
@@ -413,9 +413,9 @@ public class SetOperationTest {
final MemorySegment resultSeg = heapSeg.asSlice(heapLayout[4], heapLayout[5]-heapLayout[4]);
//Recover the 3 sketches
- final UpdateSketch sk1 = (UpdateSketch) Sketch.wrap(sketch1seg);
- final UpdateSketch sk2 = (UpdateSketch) Sketch.wrap(sketch2seg);
- final UpdateSketch sk3 = (UpdateSketch) Sketch.wrap(sketch3seg);
+ final UpdateSketch sk1 = (UpdateSketch) ThetaSketch.wrap(sketch1seg);
+ final UpdateSketch sk2 = (UpdateSketch) ThetaSketch.wrap(sketch2seg);
+ final UpdateSketch sk3 = (UpdateSketch) ThetaSketch.wrap(sketch3seg);
//confirm that each of these 3 sketches is exact.
assertEquals(sk1.getEstimate(), sketchNomEntries, 0.0);
@@ -429,7 +429,7 @@ public class SetOperationTest {
union.union(sk2);
union.union(sk3);
- final Sketch resSk = union.getResult(true, resultSeg);
+ final ThetaSketch resSk = union.getResult(true, resultSeg);
final double est = resSk.getEstimate();
return est;
diff --git a/src/test/java/org/apache/datasketches/theta/SetOpsCornerCasesTest.java b/src/test/java/org/apache/datasketches/theta/SetOpsCornerCasesTest.java
index 4f5380658..80a876991 100644
--- a/src/test/java/org/apache/datasketches/theta/SetOpsCornerCasesTest.java
+++ b/src/test/java/org/apache/datasketches/theta/SetOpsCornerCasesTest.java
@@ -34,7 +34,7 @@ import org.apache.datasketches.theta.AnotB;
import org.apache.datasketches.theta.CompactSketch;
import org.apache.datasketches.theta.Intersection;
import org.apache.datasketches.theta.SetOperation;
-import org.apache.datasketches.theta.Sketch;
+import org.apache.datasketches.theta.ThetaSketch;
import org.apache.datasketches.theta.Union;
import org.apache.datasketches.theta.UpdateSketch;
import org.testng.Assert;
@@ -169,36 +169,36 @@ public class SetOpsCornerCasesTest {
checkCornerCase(rcskStdStatefulAnotB, rcskStdAnotB);
}
- private static CompactSketch doStdUnion(final Sketch tskA, final Sketch tskB, final int k, final MemorySegment wseg) {
+ private static CompactSketch doStdUnion(final ThetaSketch tskA, final ThetaSketch tskB, final int k, final MemorySegment wseg) {
final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
union.union(tskA);
union.union(tskB);
return union.getResult(true, wseg);
}
- private static CompactSketch doStdPairUnion(final Sketch tskA, final Sketch tskB, final int k, final MemorySegment wseg) {
+ private static CompactSketch doStdPairUnion(final ThetaSketch tskA, final ThetaSketch tskB, final int k, final MemorySegment wseg) {
final Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
return union.union(tskA, tskB, true, wseg);
}
- private static CompactSketch doStdIntersection(final Sketch tskA, final Sketch tskB, final MemorySegment wseg) {
+ private static CompactSketch doStdIntersection(final ThetaSketch tskA, final ThetaSketch tskB, final MemorySegment wseg) {
final Intersection inter = SetOperation.builder().buildIntersection();
inter.intersect(tskA);
inter.intersect(tskB);
return inter.getResult(true, wseg);
}
- private static CompactSketch doStdPairIntersection(final Sketch tskA, final Sketch tskB, final MemorySegment wseg) {
+ private static CompactSketch doStdPairIntersection(final ThetaSketch tskA, final ThetaSketch tskB, final MemorySegment wseg) {
final Intersection inter = SetOperation.builder().buildIntersection();
return inter.intersect(tskA, tskB, true, wseg);
}
- private static CompactSketch doStdAnotB(final Sketch tskA, final Sketch tskB, final MemorySegment wseg) {
+ private static CompactSketch doStdAnotB(final ThetaSketch tskA, final ThetaSketch tskB, final MemorySegment wseg) {
final AnotB anotb = SetOperation.builder().buildANotB();
return anotb.aNotB(tskA, tskB, true, wseg);
}
- private static CompactSketch doStdStatefulAnotB(final Sketch tskA, final Sketch tskB, final MemorySegment wseg) {
+ private static CompactSketch doStdStatefulAnotB(final ThetaSketch tskA, final ThetaSketch tskB, final MemorySegment wseg) {
final AnotB anotb = SetOperation.builder().buildANotB();
anotb.setA(tskA);
anotb.notB(tskB);
@@ -206,7 +206,7 @@ public class SetOpsCornerCasesTest {
return anotb.getResult(true, wseg, true);
}
- private static CompactSketch doPwUnion(final Sketch tskA, final Sketch tskB, final int k) {
+ private static CompactSketch doPwUnion(final ThetaSketch tskA, final ThetaSketch tskB, final int k) {
CompactSketch tcskA, tcskB;
if (tskA == null) { tcskA = null; }
else { tcskA = (tskA instanceof CompactSketch) ? (CompactSketch) tskA : tskA.compact(); }
@@ -216,18 +216,18 @@ public class SetOpsCornerCasesTest {
return union.union(tcskA, tcskB);
}
- private static CompactSketch doPwIntersection(final Sketch tskA, final Sketch tskB) {
+ private static CompactSketch doPwIntersection(final ThetaSketch tskA, final ThetaSketch tskB) {
final Intersection inter = SetOperation.builder().buildIntersection();
return inter.intersect(tskA, tskB);
}
- private static CompactSketch doPwAnotB(final Sketch tskA, final Sketch tskB) {
+ private static CompactSketch doPwAnotB(final ThetaSketch tskA, final ThetaSketch tskB) {
final AnotB aNotB = SetOperation.builder().buildANotB();
return aNotB.aNotB(tskA, tskB);
}
- private static void checkCornerCase(final Sketch rskA, final Sketch rskB) {
+ private static void checkCornerCase(final ThetaSketch rskA, final ThetaSketch rskB) {
final double estA = rskA.getEstimate();
final double estB = rskB.getEstimate();
final boolean emptyA = rskA.isEmpty();
@@ -494,7 +494,7 @@ public class SetOpsCornerCasesTest {
for (int i = 0; i < (4 * k); i++) {
sk.update(i);
}
- final int bytes = Sketch.getMaxCompactSketchBytes(sk.getRetainedEntries(true));
+ final int bytes = ThetaSketch.getMaxCompactSketchBytes(sk.getRetainedEntries(true));
final byte[] byteArr = new byte[bytes];
final MemorySegment wseg = MemorySegment.ofArray(byteArr);
csk = sk.compact(false, wseg);
diff --git a/src/test/java/org/apache/datasketches/theta/SingleItemSketchTest.java b/src/test/java/org/apache/datasketches/theta/SingleItemSketchTest.java
index b073ca255..a0c3cd346 100644
--- a/src/test/java/org/apache/datasketches/theta/SingleItemSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/SingleItemSketchTest.java
@@ -175,7 +175,7 @@ public class SingleItemSketchTest {
@Test
public void unionWrapped() {
- final Sketch sketch = SingleItemSketch.create(1);
+ final ThetaSketch sketch = SingleItemSketch.create(1);
final Union union = SetOperation.builder().buildUnion();
final MemorySegment seg = MemorySegment.ofArray(sketch.toByteArray());
union.union(seg );
@@ -196,7 +196,7 @@ public class SingleItemSketchTest {
assertTrue(csk instanceof SingleItemSketch);
//Off-heap
- bytes = Sketch.getMaxUpdateSketchBytes(32);
+ bytes = ThetaSketch.getMaxUpdateSketchBytes(32);
MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
sk1= UpdateSketch.builder().setNominalEntries(32).build(wseg );
sk1.update(1);
@@ -205,7 +205,7 @@ public class SingleItemSketchTest {
csk = sk1.compact(false, null);
assertTrue(csk instanceof SingleItemSketch);
- bytes = Sketch.getMaxCompactSketchBytes(1);
+ bytes = ThetaSketch.getMaxCompactSketchBytes(1);
wseg = MemorySegment.ofArray(new byte[bytes]);
csk = sk1.compact(true, wseg );
assertTrue(csk.isOrdered());
@@ -299,7 +299,7 @@ public class SingleItemSketchTest {
final MemorySegment wseg = MemorySegment.ofArray(new byte[16]);
final CompactSketch csk = inter.getResult(false, wseg );
assertTrue(csk.isOrdered());
- final Sketch csk2 = Sketch.heapify(wseg );
+ final ThetaSketch csk2 = ThetaSketch.heapify(wseg );
assertTrue(csk2 instanceof SingleItemSketch);
println(csk2.toString(true, true, 1, true));
}
@@ -320,10 +320,10 @@ public class SingleItemSketchTest {
@Test
public void checkDirectUnionSingleItem2() {
- Sketch sk = Sketch.wrap(siSkWoutSiFlag24Bytes());
+ ThetaSketch sk = ThetaSketch.wrap(siSkWoutSiFlag24Bytes());
assertEquals(sk.getEstimate(), 1.0, 0.0);
//println(sk.toString());
- sk = Sketch.wrap(siSkWithSiFlag24Bytes());
+ sk = ThetaSketch.wrap(siSkWithSiFlag24Bytes());
assertEquals(sk.getEstimate(), 1.0, 0.0);
//println(sk.toString());
}
diff --git a/src/test/java/org/apache/datasketches/theta/SketchMiscTest.java b/src/test/java/org/apache/datasketches/theta/SketchMiscTest.java
index e46fd20e6..a920b8426 100644
--- a/src/test/java/org/apache/datasketches/theta/SketchMiscTest.java
+++ b/src/test/java/org/apache/datasketches/theta/SketchMiscTest.java
@@ -64,16 +64,16 @@ public class SketchMiscTest {
final int k = 1024;
final MemorySegment seg = getCompactSketchMemorySegment(k, 0, k);
- CompactSketch csk2 = (CompactSketch) Sketch.heapify(seg);
+ CompactSketch csk2 = (CompactSketch) ThetaSketch.heapify(seg);
assertEquals((int)csk2.getEstimate(), k);
- csk2 = (CompactSketch) Sketch.heapify(seg, Util.DEFAULT_UPDATE_SEED);
+ csk2 = (CompactSketch) ThetaSketch.heapify(seg, Util.DEFAULT_UPDATE_SEED);
assertEquals((int)csk2.getEstimate(), k);
- csk2 = (CompactSketch) Sketch.wrap(seg);
+ csk2 = (CompactSketch) ThetaSketch.wrap(seg);
assertEquals((int)csk2.getEstimate(), k);
- csk2 = (CompactSketch) Sketch.wrap(seg, Util.DEFAULT_UPDATE_SEED);
+ csk2 = (CompactSketch) ThetaSketch.wrap(seg, Util.DEFAULT_UPDATE_SEED);
assertEquals((int)csk2.getEstimate(), k);
}
@@ -112,7 +112,7 @@ public class SketchMiscTest {
cSk = union2.getResult(true, null);
assertEquals((int)cSk.getEstimate(), 3*k/2);
- final int serVer = Sketch.getSerializationVersion(uSeg);
+ final int serVer = ThetaSketch.getSerializationVersion(uSeg);
assertEquals(serVer, 3);
}
@@ -127,15 +127,15 @@ public class SketchMiscTest {
final int maxInterBytes = SetOperation.getMaxIntersectionBytes(k);
assertEquals(2*k*8+24, maxInterBytes);
- final int maxCompSkBytes = Sketch.getMaxCompactSketchBytes(k+1);
+ final int maxCompSkBytes = ThetaSketch.getMaxCompactSketchBytes(k+1);
assertEquals(24+(k+1)*8, maxCompSkBytes);
- final int compSkMaxBytes = Sketch.getCompactSketchMaxBytes(lgK); {
+ final int compSkMaxBytes = ThetaSketch.getCompactSketchMaxBytes(lgK); {
int bytes = (int)((2 << lgK) * ThetaUtil.REBUILD_THRESHOLD + Family.QUICKSELECT.getMaxPreLongs()) * Long.BYTES;
assertEquals(compSkMaxBytes, bytes);
}
- final int maxSkBytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int maxSkBytes = ThetaSketch.getMaxUpdateSketchBytes(k);
assertEquals(24+2*k*8, maxSkBytes);
}
@@ -144,7 +144,7 @@ public class SketchMiscTest {
final Union union = SetOperation.builder().buildUnion();
final byte[] byteArr = union.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(byteArr);
- Sketch.getEstimate(srcSeg); //Union is not a Theta Sketch, it is an operation
+ ThetaSketch.getEstimate(srcSeg); //Union is not a Theta Sketch, it is an operation
}
@Test
diff --git a/src/test/java/org/apache/datasketches/theta/SketchTest.java b/src/test/java/org/apache/datasketches/theta/SketchTest.java
index cffee0b08..0891aea80 100644
--- a/src/test/java/org/apache/datasketches/theta/SketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/SketchTest.java
@@ -31,7 +31,7 @@ import static org.apache.datasketches.theta.CompactOperations.computeCompactPreL
import static org.apache.datasketches.theta.PreambleUtil.COMPACT_FLAG_MASK;
import static org.apache.datasketches.theta.PreambleUtil.FLAGS_BYTE;
import static org.apache.datasketches.theta.PreambleUtil.READ_ONLY_FLAG_MASK;
-import static org.apache.datasketches.theta.Sketch.getMaxCompactSketchBytes;
+import static org.apache.datasketches.theta.ThetaSketch.getMaxCompactSketchBytes;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
@@ -108,7 +108,7 @@ public class SketchTest {
assertEquals(compPreLongs, 3);
for (int i=0; i<3; i++) {
- final int maxCompBytes = Sketch.getMaxCompactSketchBytes(i);
+ final int maxCompBytes = ThetaSketch.getMaxCompactSketchBytes(i);
if (i == 0) { assertEquals(maxCompBytes, 8); }
if (i == 1) { assertEquals(maxCompBytes, 16); }
if (i > 1) { assertEquals(maxCompBytes, 24 + (i * 8)); } //assumes maybe estimation mode
@@ -182,7 +182,7 @@ public class SketchTest {
final UpdateSketch sketch = UpdateSketch.builder().setFamily(Family.ALPHA).setNominalEntries(1024).build();
final byte[] byteArr = sketch.toByteArray();
final MemorySegment srcSeg = MemorySegment.ofArray(byteArr);
- Sketch.wrap(srcSeg);
+ ThetaSketch.wrap(srcSeg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -196,7 +196,7 @@ public class SketchTest {
final UpdateSketch sketch = UpdateSketch.builder().setNominalEntries(1024).build();
final byte[] sketchArray = sketch.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(sketchArray);
- int serVer = Sketch.getSerializationVersion(seg);
+ int serVer = ThetaSketch.getSerializationVersion(seg);
assertEquals(serVer, 3);
final MemorySegment wseg = MemorySegment.ofArray(sketchArray);
final UpdateSketch sk2 = UpdateSketch.wrap(wseg);
@@ -207,36 +207,36 @@ public class SketchTest {
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkHeapifyAlphaCompactExcep() {
final int k = 512;
- final Sketch sketch1 = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ final ThetaSketch sketch1 = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
final byte[] byteArray = sketch1.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
//corrupt:
Util.setBits(seg, FLAGS_BYTE, (byte) COMPACT_FLAG_MASK);
- Sketch.heapify(seg);
+ ThetaSketch.heapify(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkHeapifyQSCompactExcep() {
final int k = 512;
- final Sketch sketch1 = UpdateSketch.builder().setFamily(QUICKSELECT).setNominalEntries(k).build();
+ final ThetaSketch sketch1 = UpdateSketch.builder().setFamily(QUICKSELECT).setNominalEntries(k).build();
final byte[] byteArray = sketch1.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
//corrupt:
Util.setBits(seg, FLAGS_BYTE, (byte) COMPACT_FLAG_MASK);
- Sketch.heapify(seg);
+ ThetaSketch.heapify(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkHeapifyNotCompactExcep() {
final int k = 512;
final UpdateSketch sketch1 = UpdateSketch.builder().setFamily(QUICKSELECT).setNominalEntries(k).build();
- final int bytes = Sketch.getMaxCompactSketchBytes(0);
+ final int bytes = ThetaSketch.getMaxCompactSketchBytes(0);
final byte[] byteArray = new byte[bytes];
final MemorySegment seg = MemorySegment.ofArray(byteArray);
sketch1.compact(false, seg);
//corrupt:
Util.clearBits(seg, FLAGS_BYTE, (byte) COMPACT_FLAG_MASK);
- Sketch.heapify(seg);
+ ThetaSketch.heapify(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
@@ -246,50 +246,50 @@ public class SketchTest {
final byte[] byteArray = union.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
//Improper use
- Sketch.heapify(seg);
+ ThetaSketch.heapify(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkWrapAlphaCompactExcep() {
final int k = 512;
- final Sketch sketch1 = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
+ final ThetaSketch sketch1 = UpdateSketch.builder().setFamily(ALPHA).setNominalEntries(k).build();
final byte[] byteArray = sketch1.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
//corrupt:
Util.setBits(seg, FLAGS_BYTE, (byte) COMPACT_FLAG_MASK);
- Sketch.wrap(seg);
+ ThetaSketch.wrap(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkWrapQSCompactExcep() {
final int k = 512;
- final Sketch sketch1 = UpdateSketch.builder().setFamily(QUICKSELECT).setNominalEntries(k).build();
+ final ThetaSketch sketch1 = UpdateSketch.builder().setFamily(QUICKSELECT).setNominalEntries(k).build();
final byte[] byteArray = sketch1.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArray);
//corrupt:
Util.setBits(seg, FLAGS_BYTE, (byte) COMPACT_FLAG_MASK);
- Sketch.wrap(seg);
+ ThetaSketch.wrap(seg);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkWrapNotCompactExcep() {
final int k = 512;
final UpdateSketch sketch1 = UpdateSketch.builder().setFamily(QUICKSELECT).setNominalEntries(k).build();
- final int bytes = Sketch.getMaxCompactSketchBytes(0);
+ final int bytes = ThetaSketch.getMaxCompactSketchBytes(0);
final byte[] byteArray = new byte[bytes];
final MemorySegment seg = MemorySegment.ofArray(byteArray);
sketch1.compact(false, seg);
//corrupt:
Util.clearBits(seg, FLAGS_BYTE, (byte) COMPACT_FLAG_MASK);
- Sketch.wrap(seg);
+ ThetaSketch.wrap(seg);
}
@Test
public void checkValidSketchID() {
- assertFalse(Sketch.isValidSketchID(0));
- assertTrue(Sketch.isValidSketchID(ALPHA.getID()));
- assertTrue(Sketch.isValidSketchID(QUICKSELECT.getID()));
- assertTrue(Sketch.isValidSketchID(COMPACT.getID()));
+ assertFalse(ThetaSketch.isValidSketchID(0));
+ assertTrue(ThetaSketch.isValidSketchID(ALPHA.getID()));
+ assertTrue(ThetaSketch.isValidSketchID(QUICKSELECT.getID()));
+ assertTrue(ThetaSketch.isValidSketchID(COMPACT.getID()));
}
@Test
@@ -325,7 +325,7 @@ public class SketchTest {
private static MemorySegment createCompactSketchMemorySegment(final int k, final int u) {
final UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build();
for (int i = 0; i < u; i++) { usk.update(i); }
- final int bytes = Sketch.getMaxCompactSketchBytes(usk.getRetainedEntries(true));
+ final int bytes = ThetaSketch.getMaxCompactSketchBytes(usk.getRetainedEntries(true));
final MemorySegment wseg = MemorySegment.ofArray(new byte[bytes]);
usk.compact(true, wseg);
return wseg;
@@ -334,27 +334,27 @@ public class SketchTest {
@Test
public void checkCompactFlagsOnWrap() {
final MemorySegment wseg = createCompactSketchMemorySegment(16, 32);
- Sketch sk = Sketch.wrap(wseg);
+ ThetaSketch sk = ThetaSketch.wrap(wseg);
assertTrue(sk instanceof CompactSketch);
final int flags = PreambleUtil.extractFlags(wseg);
final int flagsNoCompact = flags & ~COMPACT_FLAG_MASK;
PreambleUtil.insertFlags(wseg, flagsNoCompact);
try {
- sk = Sketch.wrap(wseg);
+ sk = ThetaSketch.wrap(wseg);
fail();
} catch (final SketchesArgumentException e) { }
final int flagsNoReadOnly = flags & ~READ_ONLY_FLAG_MASK;
PreambleUtil.insertFlags(wseg, flagsNoReadOnly);
try {
- sk = Sketch.wrap(wseg);
+ sk = ThetaSketch.wrap(wseg);
fail();
} catch (final SketchesArgumentException e) { }
PreambleUtil.insertFlags(wseg, flags); //repair to original
PreambleUtil.insertSerVer(wseg, 5);
try {
- sk = Sketch.wrap(wseg);
+ sk = ThetaSketch.wrap(wseg);
fail();
} catch (final SketchesArgumentException e) { }
}
@@ -362,14 +362,14 @@ public class SketchTest {
@Test
public void checkCompactSizeAndFlagsOnHeapify() {
MemorySegment wseg = createCompactSketchMemorySegment(16, 32);
- Sketch sk = Sketch.heapify(wseg);
+ ThetaSketch sk = ThetaSketch.heapify(wseg);
assertTrue(sk instanceof CompactSketch);
final int flags = PreambleUtil.extractFlags(wseg);
final int flagsNoCompact = flags & ~READ_ONLY_FLAG_MASK;
PreambleUtil.insertFlags(wseg, flagsNoCompact);
try {
- sk = Sketch.heapify(wseg);
+ sk = ThetaSketch.heapify(wseg);
fail();
} catch (final SketchesArgumentException e) { }
@@ -377,7 +377,7 @@ public class SketchTest {
PreambleUtil.insertSerVer(wseg, 3);
//PreambleUtil.insertFamilyID(wseg, 3);
try {
- sk = Sketch.heapify(wseg);
+ sk = ThetaSketch.heapify(wseg);
fail();
} catch (final SketchesArgumentException e) { }
}
@@ -385,7 +385,7 @@ public class SketchTest {
@Test
public void check2Methods() {
final int k = 16;
- final Sketch sk = UpdateSketch.builder().setNominalEntries(k).build();
+ final ThetaSketch sk = UpdateSketch.builder().setNominalEntries(k).build();
final int bytes1 = sk.getCompactBytes();
final int bytes2 = sk.getCurrentBytes();
assertEquals(bytes1, 8);
diff --git a/src/test/java/org/apache/datasketches/theta/UnionImplTest.java b/src/test/java/org/apache/datasketches/theta/UnionImplTest.java
index 1cc7c76e7..98fdfb582 100644
--- a/src/test/java/org/apache/datasketches/theta/UnionImplTest.java
+++ b/src/test/java/org/apache/datasketches/theta/UnionImplTest.java
@@ -150,7 +150,7 @@ public class UnionImplTest {
public void checkMoveAndResizeOffHeap() {
final int k = 1 << 12;
final int u = 2 * k;
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
MemorySegment skWseg, uWseg;
try (Arena arena = Arena.ofConfined()) {
skWseg = arena.allocate(bytes / 2); //we never populate the sketch so this size is not relevant
@@ -203,7 +203,7 @@ public class UnionImplTest {
for (int i = 0; i < k; i++) { sk.update(i); }
final double est1 = sk.getEstimate();
- final int bytes = Sketch.getCompactSketchMaxBytes(lgK);
+ final int bytes = ThetaSketch.getCompactSketchMaxBytes(lgK);
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = arena.allocate(bytes);
@@ -220,7 +220,7 @@ public class UnionImplTest {
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkCompactFlagCorruption() {
final int k = 1 << 12;
- final int bytes = Sketch.getMaxUpdateSketchBytes(k);
+ final int bytes = ThetaSketch.getMaxUpdateSketchBytes(k);
final MemorySegment wseg1 = MemorySegment.ofArray(new byte[bytes]);
final UpdateSketch sk = UpdateSketch.builder().setNominalEntries(k).build(wseg1);
for (int i = 0; i < k; i++) { sk.update(i); }
diff --git a/src/test/java/org/apache/datasketches/theta/UpdateSketchTest.java b/src/test/java/org/apache/datasketches/theta/UpdateSketchTest.java
index a3bdaa221..00dbb6c70 100644
--- a/src/test/java/org/apache/datasketches/theta/UpdateSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/UpdateSketchTest.java
@@ -173,13 +173,13 @@ public class UpdateSketchTest {
final MemorySegment wseg = MemorySegment.ofArray(sk.toByteArray());
try {
wseg.set(JAVA_BYTE, SER_VER_BYTE, (byte) 2);
- Sketch.wrap(wseg, Util.DEFAULT_UPDATE_SEED);
+ ThetaSketch.wrap(wseg, Util.DEFAULT_UPDATE_SEED);
fail();
} catch (final SketchesArgumentException e) { }
try {
wseg.set(JAVA_BYTE, SER_VER_BYTE, (byte) 3);
wseg.set(JAVA_BYTE, PREAMBLE_LONGS_BYTE, (byte) 2);
- Sketch.wrap(wseg, Util.DEFAULT_UPDATE_SEED);
+ ThetaSketch.wrap(wseg, Util.DEFAULT_UPDATE_SEED);
fail();
} catch (final SketchesArgumentException e) { }
}
diff --git a/src/test/java/org/apache/datasketches/tuple/adouble/AdoubleAnotBTest.java b/src/test/java/org/apache/datasketches/tuple/adouble/AdoubleAnotBTest.java
index a878e50dc..c8b4a8135 100644
--- a/src/test/java/org/apache/datasketches/tuple/adouble/AdoubleAnotBTest.java
+++ b/src/test/java/org/apache/datasketches/tuple/adouble/AdoubleAnotBTest.java
@@ -49,7 +49,7 @@ public class AdoubleAnotBTest {
final AnotB<DoubleSummary> aNotB,
final Sketch<DoubleSummary> skA,
final Sketch<DoubleSummary> skB,
- final org.apache.datasketches.theta.Sketch skThetaB,
+ final org.apache.datasketches.theta.ThetaSketch skThetaB,
final Results results)
{
CompactSketch<DoubleSummary> result;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org