diff --git a/pom.xml b/pom.xml
index e130f2694..1cce4056c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -117,7 +117,7 @@ under the License.
A Count-Min sketch is a probabilistic data structure that estimates the frequency of items in a large data stream using a
+ * fixed amount of memory. It uses a 2D array of counters and multiple hash functions to map each item to a position in every row.
+ * To estimate an item's frequency, it takes the minimum count from all the positions it hashes to, which provides an overestimate
+ * that is guaranteed to be greater than or equal to the true count. A Count sketch is a type of dimensionality reduction that is particularly efficient in statistics, machine learning and
+ * algorithms. It was invented by Moses Charikar, Kevin Chen and Martin Farach-Colton in an effort to speed up the AMS Sketch by
+ * Alon, Matias and Szegedy for approximating the frequency moments of streams[4] (these calculations require counting of the
+ * number of occurrences for the distinct elements of the stream). This implementation produces exactly the same hash result as the
* MurmurHash3 function in datasketches-java given compatible inputs. This FFM21 version of the implementation leverages the java.lang.foreign package (FFM) of JDK-21 in place of
+ * This FFM version of the implementation leverages the java.lang.foreign package (FFM) of JDK-25 in place of
* the Unsafe class.
*
* @author Lee Rhodes
*/
-public final class MurmurHash3FFM21 {
+public final class MurmurHash3FFM {
private static final long C1 = 0x87c37b91114253d5L;
private static final long C2 = 0x4cf5ad432745937fL;
- private MurmurHash3FFM21() { }
+ private MurmurHash3FFM() { }
/**
* Returns a 128-bit hash of the input.
@@ -199,7 +199,7 @@ public static long[] hash(final MemorySegment seg, final long offsetBytes, final
final long k1 = seg.get(JAVA_LONG_UNALIGNED, cumOff); //0, 16, 32, ...
final long k2 = seg.get(JAVA_LONG_UNALIGNED, cumOff + 8); //8, 24, 40, ...
- synchronized (MurmurHash3FFM21.class) {
+ synchronized (MurmurHash3FFM.class) {
cumOff += 16L;
rem -= 16L;
}
diff --git a/src/main/java/org/apache/datasketches/kll/KllDoublesSketch.java b/src/main/java/org/apache/datasketches/kll/KllDoublesSketch.java
index 541d551c1..2981d3628 100644
--- a/src/main/java/org/apache/datasketches/kll/KllDoublesSketch.java
+++ b/src/main/java/org/apache/datasketches/kll/KllDoublesSketch.java
@@ -35,7 +35,7 @@
import org.apache.datasketches.quantilescommon.DoublesSketchSortedView;
import org.apache.datasketches.quantilescommon.QuantileSearchCriteria;
import org.apache.datasketches.quantilescommon.QuantilesDoublesAPI;
-import org.apache.datasketches.quantilescommon.QuantilesDoublesSketchIterator;
+import org.apache.datasketches.quantilescommon.QuantilesDoublesSketchIteratorAPI;
/**
* This variation of the KllSketch implements primitive doubles.
@@ -266,7 +266,7 @@ public double[] getRanks(final double[] quantiles, final QuantileSearchCriteria
}
@Override
- public QuantilesDoublesSketchIterator iterator() {
+ public QuantilesDoublesSketchIteratorAPI iterator() {
return new KllDoublesSketchIterator(
getDoubleItemsArray(), getLevelsArray(SketchStructure.UPDATABLE), getNumLevels());
}
diff --git a/src/main/java/org/apache/datasketches/kll/KllDoublesSketchIterator.java b/src/main/java/org/apache/datasketches/kll/KllDoublesSketchIterator.java
index bc18c5347..9c7e4bd13 100644
--- a/src/main/java/org/apache/datasketches/kll/KllDoublesSketchIterator.java
+++ b/src/main/java/org/apache/datasketches/kll/KllDoublesSketchIterator.java
@@ -19,12 +19,12 @@
package org.apache.datasketches.kll;
-import org.apache.datasketches.quantilescommon.QuantilesDoublesSketchIterator;
+import org.apache.datasketches.quantilescommon.QuantilesDoublesSketchIteratorAPI;
/**
* Iterator over KllDoublesSketch. The order is not defined.
*/
-public final class KllDoublesSketchIterator extends KllSketchIterator implements QuantilesDoublesSketchIterator {
+public final class KllDoublesSketchIterator extends KllSketchIterator implements QuantilesDoublesSketchIteratorAPI {
private final double[] quantiles;
KllDoublesSketchIterator(final double[] quantiles, final int[] levelsArr, final int numLevels) {
diff --git a/src/main/java/org/apache/datasketches/kll/KllItemsSketch.java b/src/main/java/org/apache/datasketches/kll/KllItemsSketch.java
index 6e3b6c374..89f277fb8 100644
--- a/src/main/java/org/apache/datasketches/kll/KllItemsSketch.java
+++ b/src/main/java/org/apache/datasketches/kll/KllItemsSketch.java
@@ -37,7 +37,7 @@
import org.apache.datasketches.quantilescommon.ItemsSketchSortedView;
import org.apache.datasketches.quantilescommon.QuantileSearchCriteria;
import org.apache.datasketches.quantilescommon.QuantilesGenericAPI;
-import org.apache.datasketches.quantilescommon.QuantilesGenericSketchIterator;
+import org.apache.datasketches.quantilescommon.QuantilesGenericSketchIteratorAPI;
/**
* This variation of the KllSketch implements generic data types. The user must provide
@@ -256,7 +256,7 @@ public final ItemsSketchSortedView KLL is an implementation of a very compact quantiles sketch with lazy compaction scheme
diff --git a/src/main/java/org/apache/datasketches/kll/KllSketchIterator.java b/src/main/java/org/apache/datasketches/kll/KllSketchIterator.java
index feaf33f53..3e16fbc11 100644
--- a/src/main/java/org/apache/datasketches/kll/KllSketchIterator.java
+++ b/src/main/java/org/apache/datasketches/kll/KllSketchIterator.java
@@ -19,7 +19,7 @@
package org.apache.datasketches.kll;
-import org.apache.datasketches.quantilescommon.QuantilesSketchIterator;
+import org.apache.datasketches.quantilescommon.QuantilesSketchIteratorAPI;
/**
* The base implementation for the KLL sketch iterator hierarchy used for viewing the
@@ -35,7 +35,7 @@
*
* @author Lee Rhodes
*/
-public class KllSketchIterator implements QuantilesSketchIterator {
+public class KllSketchIterator implements QuantilesSketchIteratorAPI {
protected final int[] levelsArr;
protected final int numLevels;
protected int level;
diff --git a/src/main/java/org/apache/datasketches/partitions/package-info.java b/src/main/java/org/apache/datasketches/partitions/package-info.java
index cee11ec1d..58bd126b3 100644
--- a/src/main/java/org/apache/datasketches/partitions/package-info.java
+++ b/src/main/java/org/apache/datasketches/partitions/package-info.java
@@ -18,6 +18,7 @@
*/
/**
- *
+ * This package is for classes that simplify the task of partitioning large data into many approximately equal-sized
+ * partitions.
*/
package org.apache.datasketches.partitions;
diff --git a/src/main/java/org/apache/datasketches/quantiles/ClassicUtil.java b/src/main/java/org/apache/datasketches/quantiles/ClassicUtil.java
index 4e49a7dbb..d86a0f487 100644
--- a/src/main/java/org/apache/datasketches/quantiles/ClassicUtil.java
+++ b/src/main/java/org/apache/datasketches/quantiles/ClassicUtil.java
@@ -57,7 +57,7 @@ private ClassicUtil() {}
/**
* Used by Classic Quantiles.
- * Gets the normalized rank error given k and pmf for the Quantiles DoubleSketch and ItemsSketch.
+ * Gets the normalized rank error given k and pmf for the QuantilesDoubleSketch and QuantilesItemsSketch.
* @param k the configuration parameter
* @param pmf if true, returns the "double-sided" normalized rank error for the getPMF() function.
* Otherwise, it is the "single-sided" normalized rank error for all the other queries.
@@ -75,7 +75,7 @@ public static double getNormalizedRankError(final int k, final boolean pmf) {
/**
* Used by Classic Quantiles.
* Gets the approximate k to use given epsilon, the normalized rank error
- * for the Quantiles DoubleSketch and ItemsSketch.
+ * for the QuantilesDoubleSketch and QuantilesItemsSketch.
* @param epsilon the normalized rank error between zero and one.
* @param pmf if true, this function returns k assuming the input epsilon
* is the desired "double-sided" epsilon for the getPMF() function. Otherwise, this function
@@ -109,7 +109,7 @@ public static int getKFromEpsilon(final double epsilon, final boolean pmf) {
static int computeGrowingBaseBufferCap(final int k, final int curCombinedBufCap) {
if (curCombinedBufCap < (2 * k)) {
return 2 * Math.max(Math.min(k, curCombinedBufCap), MIN_K);
- }
+ }
return 2 * k;
}
diff --git a/src/main/java/org/apache/datasketches/quantiles/CompactDoublesSketch.java b/src/main/java/org/apache/datasketches/quantiles/CompactQuantilesDoublesSketch.java
similarity index 91%
rename from src/main/java/org/apache/datasketches/quantiles/CompactDoublesSketch.java
rename to src/main/java/org/apache/datasketches/quantiles/CompactQuantilesDoublesSketch.java
index 18e05d315..490ac35eb 100644
--- a/src/main/java/org/apache/datasketches/quantiles/CompactDoublesSketch.java
+++ b/src/main/java/org/apache/datasketches/quantiles/CompactQuantilesDoublesSketch.java
@@ -25,8 +25,8 @@
* Compact sketches are inherently read only.
* @author Jon Malkin
*/
-public abstract class CompactDoublesSketch extends DoublesSketch {
- CompactDoublesSketch(final int k) {
+public abstract class CompactQuantilesDoublesSketch extends QuantilesDoublesSketch {
+ CompactQuantilesDoublesSketch(final int k) {
super(k);
}
diff --git a/src/main/java/org/apache/datasketches/quantiles/DirectCompactDoublesSketch.java b/src/main/java/org/apache/datasketches/quantiles/DirectCompactDoublesSketch.java
index af0579eef..baf03736a 100644
--- a/src/main/java/org/apache/datasketches/quantiles/DirectCompactDoublesSketch.java
+++ b/src/main/java/org/apache/datasketches/quantiles/DirectCompactDoublesSketch.java
@@ -59,13 +59,13 @@
import org.apache.datasketches.quantilescommon.QuantilesAPI;
/**
- * Implements the DoublesSketch off-heap.
+ * Implements the QuantilesDoublesSketch off-heap.
*
* @author Kevin Lang
* @author Lee Rhodes
* @author Jon Malkin
*/
-final class DirectCompactDoublesSketch extends CompactDoublesSketch {
+final class DirectCompactDoublesSketch extends CompactQuantilesDoublesSketch {
private static final int MIN_DIRECT_DOUBLES_SER_VER = 3;
private final MemorySegment seg_;
@@ -76,13 +76,13 @@ private DirectCompactDoublesSketch(final int k, final MemorySegment seg) {
}
/**
- * Converts the given UpdateDoublesSketch to this compact form.
+ * Converts the given UpdatableQuantilesDoublesSketch to this compact form.
*
* @param sketch the sketch to convert
* @param dstSeg the MemorySegment to use for the destination
- * @return a DirectCompactDoublesSketch created from an UpdateDoublesSketch
+ * @return a DirectCompactDoublesSketch created from an UpdatableQuantilesDoublesSketch
*/
- static DirectCompactDoublesSketch createFromUpdateSketch(final UpdateDoublesSketch sketch,
+ static DirectCompactDoublesSketch createFromUpdateSketch(final UpdatableQuantilesDoublesSketch sketch,
final MemorySegment dstSeg) {
final long segCap = dstSeg.byteSize();
final int k = sketch.getK();
@@ -133,9 +133,9 @@ static DirectCompactDoublesSketch createFromUpdateSketch(final UpdateDoublesSket
}
/**
- * Wrap this sketch around the given compact MemorySegment image of a DoublesSketch.
+ * Wrap this sketch around the given compact MemorySegment image of a QuantilesDoublesSketch.
*
- * @param srcSeg the given compact MemorySegment image of a DoublesSketch,
+ * @param srcSeg the given compact MemorySegment image of a QuantilesDoublesSketch,
* @return a sketch that wraps the given srcSeg.
*/
static DirectCompactDoublesSketch wrapInstance(final MemorySegment srcSeg) {
diff --git a/src/main/java/org/apache/datasketches/quantiles/DirectDoublesSketchAccessor.java b/src/main/java/org/apache/datasketches/quantiles/DirectDoublesSketchAccessor.java
index dd66e6466..4452645b2 100644
--- a/src/main/java/org/apache/datasketches/quantiles/DirectDoublesSketchAccessor.java
+++ b/src/main/java/org/apache/datasketches/quantiles/DirectDoublesSketchAccessor.java
@@ -29,7 +29,7 @@
*/
final class DirectDoublesSketchAccessor extends DoublesSketchAccessor {
- DirectDoublesSketchAccessor(final DoublesSketch ds,
+ DirectDoublesSketchAccessor(final QuantilesDoublesSketch ds,
final boolean forceSize,
final int level) {
super(ds, forceSize, level);
diff --git a/src/main/java/org/apache/datasketches/quantiles/DirectUpdateDoublesSketch.java b/src/main/java/org/apache/datasketches/quantiles/DirectUpdateDoublesSketch.java
index 168b80b16..a3b717beb 100644
--- a/src/main/java/org/apache/datasketches/quantiles/DirectUpdateDoublesSketch.java
+++ b/src/main/java/org/apache/datasketches/quantiles/DirectUpdateDoublesSketch.java
@@ -62,12 +62,12 @@
import org.apache.datasketches.quantilescommon.QuantilesAPI;
/**
- * Implements the DoublesSketch in a MemorySegment.
+ * Implements the QuantilesDoublesSketch in a MemorySegment.
*
* @author Kevin Lang
* @author Lee Rhodes
*/
-final class DirectUpdateDoublesSketch extends UpdateDoublesSketch {
+final class DirectUpdateDoublesSketch extends UpdatableQuantilesDoublesSketch {
private static final int MIN_DIRECT_DOUBLES_SER_VER = 3;
private MemorySegmentRequest mSegReq_ = null;
private MemorySegment seg_;
@@ -80,7 +80,7 @@ private DirectUpdateDoublesSketch(final int k, final MemorySegment seg, final Me
}
/**
- * Creates a new instance of a DoublesSketch in a MemorySegment.
+ * Creates a new instance of a QuantilesDoublesSketch in a MemorySegment.
*
* @param k Parameter that controls space usage of sketch and accuracy of estimates.
* Must be greater than 1 and less than 65536 and a power of 2.
@@ -114,9 +114,9 @@ static DirectUpdateDoublesSketch newInstance(final int k, final MemorySegment ds
}
/**
- * Wrap this sketch around the given updatable MemorySegment image of a DoublesSketch.
+ * Wrap this sketch around the given updatable MemorySegment image of a QuantilesDoublesSketch.
*
- * @param srcSeg the given MemorySegment image of an UpdateDoublesSketch and must not be null.
+ * @param srcSeg the given MemorySegment image of an UpdatableQuantilesDoublesSketch and must not be null.
* @param mSegReq the MemorySegmentRequest used if the given MemorySegment needs to expand.
* Otherwise, it can be null and the default MemorySegmentRequest will be used.
* @return a sketch that wraps the given srcSeg
@@ -294,7 +294,7 @@ MemorySegment getMemorySegment() {
}
@Override
- UpdateDoublesSketch getSketchAndReset() {
+ UpdatableQuantilesDoublesSketch getSketchAndReset() {
final HeapUpdateDoublesSketch skCopy = HeapUpdateDoublesSketch.heapifyInstance(seg_);
reset();
return skCopy;
diff --git a/src/main/java/org/apache/datasketches/quantiles/DoublesByteArrayImpl.java b/src/main/java/org/apache/datasketches/quantiles/DoublesByteArrayImpl.java
index 8d5f817de..0deea1d9b 100644
--- a/src/main/java/org/apache/datasketches/quantiles/DoublesByteArrayImpl.java
+++ b/src/main/java/org/apache/datasketches/quantiles/DoublesByteArrayImpl.java
@@ -51,7 +51,7 @@ final class DoublesByteArrayImpl {
private DoublesByteArrayImpl() {}
- static byte[] toByteArray(final DoublesSketch sketch, final boolean ordered, final boolean compact) {
+ static byte[] toByteArray(final QuantilesDoublesSketch sketch, final boolean ordered, final boolean compact) {
final boolean empty = sketch.isEmpty();
//create the flags byte
@@ -72,13 +72,13 @@ static byte[] toByteArray(final DoublesSketch sketch, final boolean ordered, fin
/**
* Returns a byte array, including preamble, min, max and data extracted from the sketch.
- * @param sketch the given DoublesSketch
+ * @param sketch the given QuantilesDoublesSketch
* @param flags the Flags field
* @param ordered true if the desired form of the resulting array has the base buffer sorted.
* @param compact true if the desired form of the resulting array is in compact form.
* @return a byte array, including preamble, min, max and data extracted from the Combined Buffer.
*/
- private static byte[] convertToByteArray(final DoublesSketch sketch, final int flags,
+ private static byte[] convertToByteArray(final QuantilesDoublesSketch sketch, final int flags,
final boolean ordered, final boolean compact) {
final int preLongs = sketch.isEmpty() ? 1 : 2;
diff --git a/src/main/java/org/apache/datasketches/quantiles/DoublesMergeImpl.java b/src/main/java/org/apache/datasketches/quantiles/DoublesMergeImpl.java
index ab1747472..c8ae7de0a 100644
--- a/src/main/java/org/apache/datasketches/quantiles/DoublesMergeImpl.java
+++ b/src/main/java/org/apache/datasketches/quantiles/DoublesMergeImpl.java
@@ -61,7 +61,7 @@ private DoublesMergeImpl() {}
* @param src The source sketch
* @param tgt The target sketch
*/
- static void mergeInto(final DoublesSketch src, final UpdateDoublesSketch tgt) {
+ static void mergeInto(final QuantilesDoublesSketch src, final UpdatableQuantilesDoublesSketch tgt) {
final int srcK = src.getK();
final int tgtK = tgt.getK();
final long srcN = src.getN();
@@ -141,8 +141,8 @@ static void mergeInto(final DoublesSketch src, final UpdateDoublesSketch tgt) {
* @param src The source sketch
* @param tgt The target sketch
*/
- //also used by DoublesSketch, DoublesUnionImpl and HeapDoublesSketchTest
- static void downSamplingMergeInto(final DoublesSketch src, final UpdateDoublesSketch tgt) {
+ //also used by QuantilesDoublesSketch, QuantilesDoublesUnionImpl and HeapDoublesSketchTest
+ static void downSamplingMergeInto(final QuantilesDoublesSketch src, final UpdatableQuantilesDoublesSketch tgt) {
final int sourceK = src.getK();
final int targetK = tgt.getK();
final long tgtN = tgt.getN();
@@ -227,7 +227,7 @@ private static void justZipWithStride(
final DoublesBufferAccessor bufC, // output
final int kC, // number of items that should be in the output
final int stride) {
- final int randomOffset = DoublesSketch.rand.nextInt(stride);
+ final int randomOffset = QuantilesDoublesSketch.rand.nextInt(stride);
for (int a = randomOffset, c = 0; c < kC; a += stride, c++ ) {
bufC.set(c, bufA.get(a));
}
diff --git a/src/main/java/org/apache/datasketches/quantiles/DoublesSketchAccessor.java b/src/main/java/org/apache/datasketches/quantiles/DoublesSketchAccessor.java
index 41355f63d..4c4bdd5cd 100644
--- a/src/main/java/org/apache/datasketches/quantiles/DoublesSketchAccessor.java
+++ b/src/main/java/org/apache/datasketches/quantiles/DoublesSketchAccessor.java
@@ -32,7 +32,7 @@
abstract class DoublesSketchAccessor extends DoublesBufferAccessor {
static final int BB_LVL_IDX = -1;
- final DoublesSketch ds_;
+ final QuantilesDoublesSketch ds_;
final boolean forceSize_;
long n_;
@@ -41,10 +41,10 @@ abstract class DoublesSketchAccessor extends DoublesBufferAccessor {
int offset_; //bytes for Direct, doubles for heap
DoublesSketchAccessor(
- final DoublesSketch ds,
- final boolean forceSize,
- final int level) {
- checkLvl(level);
+ final QuantilesDoublesSketch ds,
+ final boolean forceSize,
+ final int level) {
+ checkLvl(level);
ds_ = ds;
forceSize_ = forceSize;
setLevel(level);
@@ -57,14 +57,14 @@ private static final void checkLvl(final int level) {
}
/**
- * Wrap the given DoublesSketch
- * @param ds the given DoublesSketch
+ * Wrap the given QuantilesDoublesSketch
+ * @param ds the given QuantilesDoublesSketch
* @param forceSize Generally, this must be true if modeling an updatable sketch, i.e., not compact.
* See {@link #setLevel(int) setLevel(int)} below.
*
* @return this
*/
- static DoublesSketchAccessor wrap(final DoublesSketch ds, final boolean forceSize) {
+ static DoublesSketchAccessor wrap(final QuantilesDoublesSketch ds, final boolean forceSize) {
if (ds.hasMemorySegment()) {
return new DirectDoublesSketchAccessor(ds, forceSize, BB_LVL_IDX);
}
@@ -76,7 +76,7 @@ static DoublesSketchAccessor wrap(final DoublesSketch ds, final boolean forceSiz
/*
* This initializes the following internal member variables:
* An empty ItemsSketch, on-heap DoublesSketch or compact off-heap DoublesSketch only require 8
- * bytes. An off-heap UpdateDoublesSketch and all non-empty sketches require at least 16 bytes of
+ * An empty QuantilesItemsSketch, on-heap QuantilesDoublesSketch or compact off-heap QuantilesDoublesSketch only require 8
+ * bytes. An off-heap UpdatableQuantilesDoublesSketch and all non-empty sketches require at least 16 bytes of
* preamble.
- *
{@code
- * Long || Start Byte Adr: Common for both DoublesSketch and ItemsSketch
+ * Long || Start Byte Adr: Common for both QuantilesDoublesSketch and QuantilesItemsSketch
* Adr:
* || 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
* 0 ||------unused-----|--------K--------| Flags | FamID | SerVer | Preamble_Longs |
@@ -57,8 +57,8 @@
* || 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 |
* 1 ||-----------------------------------N_LONG--------------------------------------|
*
- * Applies only to DoublesSketch:
- * (ItemsSketch has elements in the same order, but size depends on sizeOf(T)
+ * Applies only to QuantilesDoublesSketch:
+ * (QuantilesItemsSketch has elements in the same order, but size depends on sizeOf(T)
*
* || 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
* 2 ||---------------------------START OF DATA, MIN_DOUBLE---------------------------|
@@ -86,9 +86,9 @@ private PreambleUtil() {}
static final int N_LONG = 8; //to 15
//After Preamble:
- static final int MIN_DOUBLE = 16; //to 23 (Only for DoublesSketch)
- static final int MAX_DOUBLE = 24; //to 31 (Only for DoublesSketch)
- static final int COMBINED_BUFFER = 32; //to 39 (Only for DoublesSketch)
+ static final int MIN_DOUBLE = 16; //to 23 (Only for QuantilesDoublesSketch)
+ static final int MAX_DOUBLE = 24; //to 31 (Only for QuantilesDoublesSketch)
+ static final int COMBINED_BUFFER = 32; //to 39 (Only for QuantilesDoublesSketch)
// flag bit masks
static final int RESERVED_FLAG_MASK = 1;
@@ -110,7 +110,7 @@ private PreambleUtil() {}
* Used primarily in testing.
*
* @param byteArr the given byte array.
- * @param isDoublesSketch flag to indicate that the byte array represents DoublesSketch
+ * @param isDoublesSketch flag to indicate that the byte array represents QuantilesDoublesSketch
* to output min and max quantiles in the summary
* @return the summary string.
*/
@@ -121,11 +121,11 @@ static String toString(final byte[] byteArr, final boolean isDoublesSketch) {
/**
* Returns a human readable string summary of the Preamble of the given MemorySegment. If this MemorySegment
- * image is from a DoublesSketch, the MinQuantile and MaxQuantile will also be output.
+ * image is from a QuantilesDoublesSketch, the MinQuantile and MaxQuantile will also be output.
* Used primarily in testing.
*
* @param seg the given MemorySegment
- * @param isDoublesSketch flag to indicate that the byte array represents DoublesSketch
+ * @param isDoublesSketch flag to indicate that the byte array represents QuantilesDoublesSketch
* to output min and max quantiles in the summary
* @return the summary string.
*/
diff --git a/src/main/java/org/apache/datasketches/quantiles/DoublesSketch.java b/src/main/java/org/apache/datasketches/quantiles/QuantilesDoublesSketch.java
similarity index 93%
rename from src/main/java/org/apache/datasketches/quantiles/DoublesSketch.java
rename to src/main/java/org/apache/datasketches/quantiles/QuantilesDoublesSketch.java
index e14d5301e..85bf957d7 100644
--- a/src/main/java/org/apache/datasketches/quantiles/DoublesSketch.java
+++ b/src/main/java/org/apache/datasketches/quantiles/QuantilesDoublesSketch.java
@@ -19,10 +19,10 @@
package org.apache.datasketches.quantiles;
-import static java.lang.foreign.ValueLayout.JAVA_BYTE;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.System.arraycopy;
+import static java.lang.foreign.ValueLayout.JAVA_BYTE;
import static org.apache.datasketches.common.Util.ceilingPowerOf2;
import static org.apache.datasketches.quantiles.ClassicUtil.MAX_PRELONGS;
import static org.apache.datasketches.quantiles.ClassicUtil.MIN_K;
@@ -44,7 +44,7 @@
import org.apache.datasketches.quantilescommon.QuantileSearchCriteria;
import org.apache.datasketches.quantilescommon.QuantilesAPI;
import org.apache.datasketches.quantilescommon.QuantilesDoublesAPI;
-import org.apache.datasketches.quantilescommon.QuantilesDoublesSketchIterator;
+import org.apache.datasketches.quantilescommon.QuantilesDoublesSketchIteratorAPI;
/**
* This is an implementation of the Low Discrepancy Mergeable Quantiles Sketch, using doubles,
@@ -59,7 +59,7 @@
* a confidence of about 99%.
-Table Guide for DoublesSketch Size in Bytes and Approximate Error:
+Table Guide for QuantilesDoublesSketch Size in Bytes and Approximate Error:
K => | 16 32 64 128 256 512 1,024
~ Error => | 12.145% 6.359% 3.317% 1.725% 0.894% 0.463% 0.239%
N | Size in Bytes ->
@@ -101,7 +101,7 @@
*
* @see QuantilesAPI
*/
-public abstract class DoublesSketch implements QuantilesDoublesAPI, MemorySegmentStatus {
+public abstract class QuantilesDoublesSketch implements QuantilesDoublesAPI, MemorySegmentStatus {
/**
* Setting the seed makes the results of the sketch deterministic if the input quantiles are
@@ -120,21 +120,21 @@ public abstract class DoublesSketch implements QuantilesDoublesAPI, MemorySegmen
*/
DoublesSketchSortedView doublesSV = null;
- DoublesSketch(final int k) {
+ QuantilesDoublesSketch(final int k) {
checkK(k);
k_ = k;
}
synchronized static void setRandom(final long seed) {
- DoublesSketch.rand = new Random(seed);
+ QuantilesDoublesSketch.rand = new Random(seed);
}
/**
* Returns a new builder
* @return a new builder
*/
- public static final DoublesSketchBuilder builder() {
- return new DoublesSketchBuilder();
+ public static final QuantilesDoublesSketchBuilder builder() {
+ return new QuantilesDoublesSketchBuilder();
}
/**
@@ -143,7 +143,7 @@ public static final DoublesSketchBuilder builder() {
* @param srcSeg a MemorySegment image of a Sketch.
* @return a heap-based Sketch based on the given MemorySegment
*/
- public static DoublesSketch heapify(final MemorySegment srcSeg) {
+ public static QuantilesDoublesSketch heapify(final MemorySegment srcSeg) {
if (checkIsMemorySegmentCompact(srcSeg)) {
return HeapCompactDoublesSketch.heapifyInstance(srcSeg);
}
@@ -151,12 +151,12 @@ public static DoublesSketch heapify(final MemorySegment srcSeg) {
}
/**
- * Wrap this sketch around the given MemorySegment image of a compact, read-only DoublesSketch.
+ * Wrap this sketch around the given MemorySegment image of a compact, read-only QuantilesDoublesSketch.
*
- * @param srcSeg the given MemorySegment image of a compact, read-only DoublesSketch.
+ * @param srcSeg the given MemorySegment image of a compact, read-only QuantilesDoublesSketch.
* @return a compact, read-only sketch that wraps the given MemorySegment.
*/
- public static DoublesSketch wrap(final MemorySegment srcSeg) {
+ public static QuantilesDoublesSketch wrap(final MemorySegment srcSeg) {
if (!checkIsMemorySegmentCompact(srcSeg)) {
throw new SketchesArgumentException(
"MemorySegment sketch image must be in compact form. "
@@ -166,9 +166,9 @@ public static DoublesSketch wrap(final MemorySegment srcSeg) {
}
/**
- * Wrap this sketch around the given MemorySegment image of an updatable DoublesSketch.
+ * Wrap this sketch around the given MemorySegment image of an updatable QuantilesDoublesSketch.
*
- * The given MemorySegment must be writable and it must contain a UpdateDoublesSketch.
+ *
The given MemorySegment must be writable and it must contain a UpdatableQuantilesDoublesSketch.
* The sketch will be updated and managed totally within the MemorySegment. If the given source
* MemorySegment is created off-heap, then all the management of the sketch's internal data will be off-heap as well.
*
@@ -176,10 +176,10 @@ public static DoublesSketch wrap(final MemorySegment srcSeg) {
* will request more capacity using the {@link MemorySegmentRequest MemorySegmentRequest} interface. The default of this interface will
* return a new MemorySegment on the heap.
*
- * @param srcSeg the given MemorySegment image of an UpdateDoublesSketch.
+ * @param srcSeg the given MemorySegment image of an UpdatableQuantilesDoublesSketch.
* @return an updatable sketch that wraps the given MemorySegment.
*/
- public static DoublesSketch writableWrap(final MemorySegment srcSeg) {
+ public static QuantilesDoublesSketch writableWrap(final MemorySegment srcSeg) {
if (checkIsMemorySegmentCompact(srcSeg)) {
throw new SketchesArgumentException(
"MemorySegment sketch image must be in updatable form. "
@@ -189,9 +189,9 @@ public static DoublesSketch writableWrap(final MemorySegment srcSeg) {
}
/**
- * Wrap this sketch around the given MemorySegment image of an updatable DoublesSketch.
+ * Wrap this sketch around the given MemorySegment image of an updatable QuantilesDoublesSketch.
*
- * The given MemorySegment must be writable and it must contain a UpdateDoublesSketch.
+ *
The given MemorySegment must be writable and it must contain a UpdatableQuantilesDoublesSketch.
* The sketch will be updated and managed totally within the MemorySegment. If the given source
* MemorySegment is created off-heap, then all the management of the sketch's internal data will be off-heap as well.
*
@@ -200,12 +200,12 @@ public static DoublesSketch writableWrap(final MemorySegment srcSeg) {
* return a new MemorySegment on the heap. It is up to the user to optionally extend this interface if more flexible
* handling of requests for more capacity is required.
*
- * @param srcSeg the given MemorySegment image of a DoublesSketch.
+ * @param srcSeg the given MemorySegment image of a QuantilesDoublesSketch.
* @param mSegReq the MemorySegmentRequest used if the given MemorySegment needs to expand.
* Otherwise, it can be null and the default MemorySegmentRequest will be used.
* @return a sketch that wraps the given MemorySegment.
*/
- public static DoublesSketch writableWrap(final MemorySegment srcSeg, final MemorySegmentRequest mSegReq) {
+ public static QuantilesDoublesSketch writableWrap(final MemorySegment srcSeg, final MemorySegmentRequest mSegReq) {
if (checkIsMemorySegmentCompact(srcSeg)) {
throw new SketchesArgumentException("MemorySegment sketch image must be in updatable form.");
}
@@ -413,20 +413,20 @@ public String toString(final boolean withLevels, final boolean withLevelsAndItem
}
/**
- * Returns a human readable string of the preamble of a byte array image of a DoublesSketch.
+ * Returns a human readable string of the preamble of a byte array image of a QuantilesDoublesSketch.
* Used for debugging.
* @param byteArr the given byte array
- * @return a human readable string of the preamble of a byte array image of a DoublesSketch.
+ * @return a human readable string of the preamble of a byte array image of a QuantilesDoublesSketch.
*/
public static String toString(final byte[] byteArr) {
return PreambleUtil.toString(byteArr, true);
}
/**
- * Returns a human readable string of the preamble of a MemorySegment image of a DoublesSketch.
+ * Returns a human readable string of the preamble of a MemorySegment image of a QuantilesDoublesSketch.
* Used for debugging.
* @param seg the given MemorySegment
- * @return a human readable string of the preamble of a MemorySegment image of a DoublesSketch.
+ * @return a human readable string of the preamble of a MemorySegment image of a QuantilesDoublesSketch.
*/
public static String toString(final MemorySegment seg) {
return PreambleUtil.toString(seg, true);
@@ -445,7 +445,7 @@ public static String toString(final MemorySegment seg) {
* Otherwise, it can be null and the default MemorySegmentRequest will be used.
* @return the new sketch.
*/
- public DoublesSketch downSample(final DoublesSketch srcSketch, final int smallerK, final MemorySegment dstSeg,
+ public QuantilesDoublesSketch downSample(final QuantilesDoublesSketch srcSketch, final int smallerK, final MemorySegment dstSeg,
final MemorySegmentRequest mSegReq) {
return downSampleInternal(srcSketch, smallerK, dstSeg, mSegReq);
}
@@ -464,7 +464,7 @@ public int getCurrentCompactSerializedSizeBytes() {
}
/**
- * Returns the number of bytes a DoublesSketch would require to store in compact form
+ * Returns the number of bytes a QuantilesDoublesSketch would require to store in compact form
* given k and n. The compact form is not updatable.
* @param k the size configuration parameter for the sketch
* @param n the number of quantiles input into the sketch
@@ -544,8 +544,8 @@ public void putIntoMemorySegment(final MemorySegment dstSeg, final boolean compa
}
@Override
- public QuantilesDoublesSketchIterator iterator() {
- return new DoublesSketchIterator(this, getBitPattern());
+ public QuantilesDoublesSketchIteratorAPI iterator() {
+ return new QuantilesDoublesSketchIterator(this, getBitPattern());
}
@Override
@@ -556,12 +556,12 @@ public QuantilesDoublesSketchIterator iterator() {
/*
* DoublesMergeImpl.downSamplingMergeInto requires the target sketch to implement update(), so
* we ensure that the target is an UpdateSketch. The public API, on the other hand, just
- * specifies a DoublesSketch. This lets us be more specific about the type without changing the
+ * specifies a QuantilesDoublesSketch. This lets us be more specific about the type without changing the
* public API.
*/
- UpdateDoublesSketch downSampleInternal(final DoublesSketch srcSketch, final int smallerK, final MemorySegment dstSeg,
+ UpdatableQuantilesDoublesSketch downSampleInternal(final QuantilesDoublesSketch srcSketch, final int smallerK, final MemorySegment dstSeg,
final MemorySegmentRequest mSegReq) {
- final UpdateDoublesSketch newSketch = dstSeg == null
+ final UpdatableQuantilesDoublesSketch newSketch = dstSeg == null
? HeapUpdateDoublesSketch.newInstance(smallerK)
: DirectUpdateDoublesSketch.newInstance(smallerK, dstSeg, mSegReq);
if (srcSketch.isEmpty()) { return newSketch; }
@@ -626,7 +626,7 @@ private DoublesSketchSortedView getSV() {
final long[] svCumWeights = new long[numQuantiles];
final DoublesSketchAccessor sketchAccessor = DoublesSketchAccessor.wrap(this, false);
- // Populate from DoublesSketch:
+ // Populate from QuantilesDoublesSketch:
// copy over the "levels" and then the base buffer, all with appropriate weights
populateFromDoublesSketch(getK(), totalN, getBitPattern(), sketchAccessor, svQuantiles, svCumWeights);
diff --git a/src/main/java/org/apache/datasketches/quantiles/DoublesSketchBuilder.java b/src/main/java/org/apache/datasketches/quantiles/QuantilesDoublesSketchBuilder.java
similarity index 75%
rename from src/main/java/org/apache/datasketches/quantiles/DoublesSketchBuilder.java
rename to src/main/java/org/apache/datasketches/quantiles/QuantilesDoublesSketchBuilder.java
index ffb51a612..6155b5803 100644
--- a/src/main/java/org/apache/datasketches/quantiles/DoublesSketchBuilder.java
+++ b/src/main/java/org/apache/datasketches/quantiles/QuantilesDoublesSketchBuilder.java
@@ -27,21 +27,21 @@
import org.apache.datasketches.common.MemorySegmentRequest;
/**
- * For building a new quantiles DoublesSketch.
+ * For building a new quantiles QuantilesDoublesSketch.
*
* @author Lee Rhodes
*/
-public class DoublesSketchBuilder {
+public class QuantilesDoublesSketchBuilder {
private int bK = PreambleUtil.DEFAULT_K;
/**
- * Constructor for a new DoublesSketchBuilder. The default configuration is
+ * Constructor for a new QuantilesDoublesSketchBuilder. The default configuration is
* The size of an ItemsSketch is very dependent on the size of the generic Items input into the sketch, - * so there is no comparable size table as there is for the DoublesSketch.
+ *The size of an QuantilesItemsSketch is very dependent on the size of the generic Items input into the sketch, + * so there is no comparable size table as there is for the QuantilesDoublesSketch.
* * @see QuantilesAPI * * @paramThe given MemorySegment must be writable and it must contain a UpdateDoublesSketch. + *
The given MemorySegment must be writable and it must contain a UpdatableQuantilesDoublesSketch. * The sketch will be updated and managed totally within the MemorySegment. If the given source * MemorySegment is created off-heap, then all the management of the sketch's internal data will be off-heap as well.
* @@ -47,7 +47,7 @@ public abstract class UpdateDoublesSketch extends DoublesSketch { * @param srcSeg a MemorySegment that contains sketch data. * @return an instance of this sketch that wraps the given MemorySegment. */ - public static UpdateDoublesSketch wrap(final MemorySegment srcSeg) { + public static UpdatableQuantilesDoublesSketch wrap(final MemorySegment srcSeg) { return DirectUpdateDoublesSketch.wrapInstance(srcSeg, null); } @@ -55,7 +55,7 @@ public static UpdateDoublesSketch wrap(final MemorySegment srcSeg) { * Wrap a sketch around the given source MemorySegment containing sketch data that originated from this sketch and including an * optional, user defined {@link MemorySegmentRequest MemorySegmentRequest}. * - *The given MemorySegment must be writable and it must contain a UpdateDoublesSketch. + *
The given MemorySegment must be writable and it must contain a UpdatableQuantilesDoublesSketch. * The sketch will be updated and managed totally within the MemorySegment. If the given source * MemorySegment is created off-heap, then all the management of the sketch's internal data will be off-heap as well.
* @@ -69,7 +69,7 @@ public static UpdateDoublesSketch wrap(final MemorySegment srcSeg) { * Otherwise, it can be null and the default MemorySegmentRequest will be used. * @return an instance of this sketch that wraps the given MemorySegment. */ - public static UpdateDoublesSketch wrap(final MemorySegment srcSeg, final MemorySegmentRequest mSegReq) { + public static UpdatableQuantilesDoublesSketch wrap(final MemorySegment srcSeg, final MemorySegmentRequest mSegReq) { return DirectUpdateDoublesSketch.wrapInstance(srcSeg, mSegReq); } @@ -79,15 +79,15 @@ public static UpdateDoublesSketch wrap(final MemorySegment srcSeg, final MemoryS * @param srcSeg compact MemorySegment image of a sketch serialized by this sketch. * @return a heap-based sketch based on the given MemorySegment. */ - public static UpdateDoublesSketch heapify(final MemorySegment srcSeg) { + public static UpdatableQuantilesDoublesSketch heapify(final MemorySegment srcSeg) { return HeapUpdateDoublesSketch.heapifyInstance(srcSeg); } /** - * Returns a CompactDoublesSketch of this class - * @return a CompactDoublesSketch of this class + * Returns a CompactQuantilesDoublesSketch of this class + * @return a CompactQuantilesDoublesSketch of this class */ - public CompactDoublesSketch compact() { + public CompactQuantilesDoublesSketch compact() { return compact(null); } @@ -97,7 +97,7 @@ public CompactDoublesSketch compact() { * @param dstSeg An optional target MemorySegment to hold the sketch. * @return A compact version of this sketch */ - public CompactDoublesSketch compact(final MemorySegment dstSeg) { + public CompactQuantilesDoublesSketch compact(final MemorySegment dstSeg) { if (dstSeg == null) { return HeapCompactDoublesSketch.createFromUpdateSketch(this); } @@ -108,7 +108,7 @@ public CompactDoublesSketch compact(final MemorySegment dstSeg) { * Returns an on-heap copy of this sketch and then resets this sketch with the same value of k. * @return an on-heap copy of this sketch and then resets this sketch with the same value of k. */ - abstract UpdateDoublesSketch getSketchAndReset(); + abstract UpdatableQuantilesDoublesSketch getSketchAndReset(); /** * Grows the combined buffer to the given spaceNeeded diff --git a/src/main/java/org/apache/datasketches/quantiles/package-info.java b/src/main/java/org/apache/datasketches/quantiles/package-info.java index 8767757b7..7ff0dcdb3 100644 --- a/src/main/java/org/apache/datasketches/quantiles/package-info.java +++ b/src/main/java/org/apache/datasketches/quantiles/package-info.java @@ -21,7 +21,7 @@ * The quantiles package contains stochastic streaming algorithms that enable single-pass * analysis of the distribution of a stream of quantiles. * - * @see org.apache.datasketches.quantiles.DoublesSketch - * @see org.apache.datasketches.quantiles.ItemsSketch + * @see org.apache.datasketches.quantiles.QuantilesDoublesSketch + * @see org.apache.datasketches.quantiles.QuantilesItemsSketch */ package org.apache.datasketches.quantiles; diff --git a/src/main/java/org/apache/datasketches/quantilescommon/BinarySearch.java b/src/main/java/org/apache/datasketches/quantilescommon/BinarySearch.java index 1d1059193..9a5bd7592 100644 --- a/src/main/java/org/apache/datasketches/quantilescommon/BinarySearch.java +++ b/src/main/java/org/apache/datasketches/quantilescommon/BinarySearch.java @@ -26,6 +26,11 @@ */ public final class BinarySearch { + /** + * No argument constructor. + */ + public BinarySearch() { } + /** * Binary Search for the index of the exact float value in the given search range. * If -1 is returned there are no values in the search range that equals the given value. diff --git a/src/main/java/org/apache/datasketches/quantilescommon/DoublesSketchSortedView.java b/src/main/java/org/apache/datasketches/quantilescommon/DoublesSketchSortedView.java index b5a8b8a45..2ad3ecdd0 100644 --- a/src/main/java/org/apache/datasketches/quantilescommon/DoublesSketchSortedView.java +++ b/src/main/java/org/apache/datasketches/quantilescommon/DoublesSketchSortedView.java @@ -19,15 +19,15 @@ package org.apache.datasketches.quantilescommon; -import static org.apache.datasketches.quantilescommon.IncludeMinMax.DoublesPair; import static org.apache.datasketches.quantilescommon.QuantileSearchCriteria.INCLUSIVE; import static org.apache.datasketches.quantilescommon.QuantilesAPI.EMPTY_MSG; import static org.apache.datasketches.quantilescommon.QuantilesUtil.getNaturalRank; import org.apache.datasketches.common.SketchesArgumentException; +import org.apache.datasketches.quantilescommon.IncludeMinMax.DoublesPair; /** - * The SortedView of the Quantiles Classic DoublesSketch and the KllDoublesSketch. + * The SortedView of the Quantiles Classic QuantilesDoublesSketch and the KllDoublesSketch. * @author Alexander Saydakov * @author Lee Rhodes */ diff --git a/src/main/java/org/apache/datasketches/quantilescommon/GenericInequalitySearch.java b/src/main/java/org/apache/datasketches/quantilescommon/GenericInequalitySearch.java index 7b9d6d665..460ef6b7b 100644 --- a/src/main/java/org/apache/datasketches/quantilescommon/GenericInequalitySearch.java +++ b/src/main/java/org/apache/datasketches/quantilescommon/GenericInequalitySearch.java @@ -47,6 +47,11 @@ */ public final class GenericInequalitySearch { + /** + * No argument constructor. + */ + public GenericInequalitySearch() { } + /** * The enumerator of inequalities */ diff --git a/src/main/java/org/apache/datasketches/quantilescommon/IncludeMinMax.java b/src/main/java/org/apache/datasketches/quantilescommon/IncludeMinMax.java index 1edfc2054..84061f840 100644 --- a/src/main/java/org/apache/datasketches/quantilescommon/IncludeMinMax.java +++ b/src/main/java/org/apache/datasketches/quantilescommon/IncludeMinMax.java @@ -27,6 +27,11 @@ */ public class IncludeMinMax { + /** + * No argument constructor. + */ + public IncludeMinMax() { } + /** A simple structure to hold a pair of arrays */ public static class DoublesPair { /** the array of quantiles */ diff --git a/src/main/java/org/apache/datasketches/quantilescommon/ItemsSketchSortedView.java b/src/main/java/org/apache/datasketches/quantilescommon/ItemsSketchSortedView.java index 515783825..ebbed228d 100644 --- a/src/main/java/org/apache/datasketches/quantilescommon/ItemsSketchSortedView.java +++ b/src/main/java/org/apache/datasketches/quantilescommon/ItemsSketchSortedView.java @@ -21,7 +21,6 @@ import static java.lang.Math.min; import static org.apache.datasketches.quantilescommon.GenericInequalitySearch.find; -import static org.apache.datasketches.quantilescommon.IncludeMinMax.ItemsPair; import static org.apache.datasketches.quantilescommon.QuantileSearchCriteria.INCLUSIVE; import static org.apache.datasketches.quantilescommon.QuantilesAPI.EMPTY_MSG; import static org.apache.datasketches.quantilescommon.QuantilesUtil.evenlySpacedDoubles; @@ -32,9 +31,10 @@ import org.apache.datasketches.common.SketchesArgumentException; import org.apache.datasketches.quantilescommon.GenericInequalitySearch.Inequality; +import org.apache.datasketches.quantilescommon.IncludeMinMax.ItemsPair; /** - * The SortedView for the KllItemsSketch and the classic ItemsSketch. + * The SortedView for the KllItemsSketch and the classic QuantilesItemsSketch. * @paramPrototype example of the recommended iteration loop:
*{@code
@@ -34,7 +34,7 @@
* @author Lee Rhodes
*/
-public interface QuantilesSketchIterator {
+public interface QuantilesSketchIteratorAPI {
/**
* Gets the natural weight at the current index.
diff --git a/src/main/java/org/apache/datasketches/tdigest/BinarySearch.java b/src/main/java/org/apache/datasketches/tdigest/BinarySearch.java
index fdb0ca3c6..cdd14b89b 100644
--- a/src/main/java/org/apache/datasketches/tdigest/BinarySearch.java
+++ b/src/main/java/org/apache/datasketches/tdigest/BinarySearch.java
@@ -24,6 +24,11 @@
*/
public final class BinarySearch {
+ /**
+ * No argument constructor.
+ */
+ public BinarySearch() { }
+
/**
* Returns an index to the first element in the range [first, last) such that
* element < value is false (i.e. that is greater than or equal to value),
@@ -43,7 +48,7 @@ public final class BinarySearch {
static int lowerBound(final double[] values, int first, final int last, final double value) {
int current;
int step;
- int count = last - first;
+ int count = last - first;
while (count > 0) {
step = count / 2;
current = first + step;
@@ -76,9 +81,9 @@ static int lowerBound(final double[] values, int first, final int last, final do
static int upperBound(final double[] values, int first, final int last, final double value) {
int current;
int step;
- int count = last - first;
+ int count = last - first;
while (count > 0) {
- step = count / 2;
+ step = count / 2;
current = first + step;
if (!(value < values[current])) {
first = ++current;
diff --git a/src/main/java/org/apache/datasketches/tdigest/Sort.java b/src/main/java/org/apache/datasketches/tdigest/Sort.java
index 331a3433f..849f36a09 100644
--- a/src/main/java/org/apache/datasketches/tdigest/Sort.java
+++ b/src/main/java/org/apache/datasketches/tdigest/Sort.java
@@ -26,6 +26,11 @@
*/
public final class Sort {
+ /**
+ * No argument constructor.
+ */
+ public Sort() { }
+
/**
* Stable sort two arrays.
* The first array is sorted while the second array is permuted the same way.
@@ -139,7 +144,7 @@ private static void stableLimitedInsertionSort(final double[] keys, final long[]
}
}
}
-
+
private static void swap(final double[] values, final int i, final int j) {
final double tmpValue = values[i];
values[i] = values[j];
diff --git a/src/main/java/org/apache/datasketches/theta/CompactThetaSketch.java b/src/main/java/org/apache/datasketches/theta/CompactThetaSketch.java
index 9dedaac46..5b784469c 100644
--- a/src/main/java/org/apache/datasketches/theta/CompactThetaSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/CompactThetaSketch.java
@@ -60,6 +60,11 @@
*/
public abstract class CompactThetaSketch extends ThetaSketch {
+ /**
+ * No argument constructor.
+ */
+ public CompactThetaSketch() { }
+
/**
* Heapify takes a CompactThetaSketch image in a MemorySegment and instantiates an on-heap CompactThetaSketch.
*
diff --git a/src/main/java/org/apache/datasketches/theta/ThetaIntersection.java b/src/main/java/org/apache/datasketches/theta/ThetaIntersection.java
index a1d0809cd..e72aa62ff 100644
--- a/src/main/java/org/apache/datasketches/theta/ThetaIntersection.java
+++ b/src/main/java/org/apache/datasketches/theta/ThetaIntersection.java
@@ -35,6 +35,11 @@
*/
public abstract class ThetaIntersection extends ThetaSetOperation {
+ /**
+ * No argument constructor.
+ */
+ public ThetaIntersection() { }
+
@Override
public Family getFamily() {
return Family.INTERSECTION;
diff --git a/src/main/java/org/apache/datasketches/theta/ThetaUnion.java b/src/main/java/org/apache/datasketches/theta/ThetaUnion.java
index 72da65053..5ba80d14c 100644
--- a/src/main/java/org/apache/datasketches/theta/ThetaUnion.java
+++ b/src/main/java/org/apache/datasketches/theta/ThetaUnion.java
@@ -37,6 +37,11 @@
*/
public abstract class ThetaUnion extends ThetaSetOperation {
+ /**
+ * No argument constructor.
+ */
+ public ThetaUnion() { }
+
/**
* Wrap a ThetaUnion object around a ThetaUnion MemorySegment object containing data.
* This method assumes the Default Update Seed.
diff --git a/src/main/java/org/apache/datasketches/theta/package-info.java b/src/main/java/org/apache/datasketches/theta/package-info.java
index 870f4f968..6da1a6a62 100644
--- a/src/main/java/org/apache/datasketches/theta/package-info.java
+++ b/src/main/java/org/apache/datasketches/theta/package-info.java
@@ -18,10 +18,10 @@
*/
/**
- * The /theta/ package contains the basic sketch classes that are members of the
- * ThetaSketch Framework.
+ * The theta package contains the basic sketch classes that are members of the
+ * Theta-Sketch Framework.
*
* There is a separate /tuple/ package for many of the sketches that are derived from the
- * same algorithms defined in the ThetaSketch Framework paper.
+ * same algorithms defined in the Theta-Sketch Framework paper.
*/
package org.apache.datasketches.theta;
diff --git a/src/main/java/org/apache/datasketches/thetacommon/SetOperationCornerCases.java b/src/main/java/org/apache/datasketches/thetacommon/SetOperationCornerCases.java
index 2457b37fe..d77496bc2 100644
--- a/src/main/java/org/apache/datasketches/thetacommon/SetOperationCornerCases.java
+++ b/src/main/java/org/apache/datasketches/thetacommon/SetOperationCornerCases.java
@@ -32,6 +32,11 @@
public class SetOperationCornerCases {
private static final long MAX = Long.MAX_VALUE;
+ /**
+ * No argument constructor.
+ */
+ public SetOperationCornerCases() { }
+
/** Intersection actions */
public enum IntersectAction {
/** Degenerate{MinTheta, 0, F} */
diff --git a/src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java b/src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java
index 3df418737..bc0c1e5b3 100644
--- a/src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java
+++ b/src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java
@@ -43,6 +43,11 @@ public final class JaccardSimilarity {
private static final double[] ZEROS = {0.0, 0.0, 0.0}; // LB, Estimate, UB
private static final double[] ONES = {1.0, 1.0, 1.0};
+ /**
+ * No argument constructor.
+ */
+ public JaccardSimilarity() { }
+
/**
* Computes the Jaccard similarity index with upper and lower bounds. The Jaccard similarity index
* J(A,B) = (A ^ B)/(A U B) is used to measure how similar the two sketches are to each
diff --git a/src/main/java/org/apache/datasketches/tuple/SerializerDeserializer.java b/src/main/java/org/apache/datasketches/tuple/SerializerDeserializer.java
index 367ef9971..6088e2022 100644
--- a/src/main/java/org/apache/datasketches/tuple/SerializerDeserializer.java
+++ b/src/main/java/org/apache/datasketches/tuple/SerializerDeserializer.java
@@ -31,6 +31,11 @@
*/
public final class SerializerDeserializer {
+ /**
+ * No argument constructor.
+ */
+ public SerializerDeserializer() { }
+
/**
* Defines the sketch classes that this SerializerDeserializer can handle.
*/
diff --git a/src/main/java/org/apache/datasketches/tuple/TupleAnotB.java b/src/main/java/org/apache/datasketches/tuple/TupleAnotB.java
index 7676211b8..cdc6f18cf 100644
--- a/src/main/java/org/apache/datasketches/tuple/TupleAnotB.java
+++ b/src/main/java/org/apache/datasketches/tuple/TupleAnotB.java
@@ -87,6 +87,11 @@ public final class TupleAnotB {
}
}
+ /**
+ * No argument constructor.
+ */
+ public TupleAnotB() { }
+
/**
* This is part of a multistep, stateful TupleAnotB operation and sets the given TupleSketch as the
* first argument A of A-AND-NOT-B. This overwrites the internal state of this
diff --git a/src/main/java/org/apache/datasketches/tuple/Util.java b/src/main/java/org/apache/datasketches/tuple/Util.java
index 46f069724..45168fa4a 100644
--- a/src/main/java/org/apache/datasketches/tuple/Util.java
+++ b/src/main/java/org/apache/datasketches/tuple/Util.java
@@ -34,6 +34,11 @@
public final class Util {
private static final int PRIME = 0x7A3C_CA71;
+ /**
+ * No argument constructor.
+ */
+ public Util() { }
+
/**
* Converts a double to a long[].
* @param value the given double value
diff --git a/src/main/java/org/apache/datasketches/tuple/adouble/DoubleSummaryDeserializer.java b/src/main/java/org/apache/datasketches/tuple/adouble/DoubleSummaryDeserializer.java
index b105a6b16..3027a3777 100644
--- a/src/main/java/org/apache/datasketches/tuple/adouble/DoubleSummaryDeserializer.java
+++ b/src/main/java/org/apache/datasketches/tuple/adouble/DoubleSummaryDeserializer.java
@@ -30,6 +30,11 @@
*/
public class DoubleSummaryDeserializer implements SummaryDeserializer {
+ /**
+ * No argument constructor.
+ */
+ public DoubleSummaryDeserializer() { }
+
@Override
public DeserializeResult heapifySummary(final MemorySegment seg) {
return DoubleSummary.fromMemorySegment(seg);
diff --git a/src/main/java/org/apache/datasketches/tuple/aninteger/IntegerSummaryDeserializer.java b/src/main/java/org/apache/datasketches/tuple/aninteger/IntegerSummaryDeserializer.java
index 0941a1088..0fb8f55a5 100644
--- a/src/main/java/org/apache/datasketches/tuple/aninteger/IntegerSummaryDeserializer.java
+++ b/src/main/java/org/apache/datasketches/tuple/aninteger/IntegerSummaryDeserializer.java
@@ -30,6 +30,11 @@
*/
public class IntegerSummaryDeserializer implements SummaryDeserializer {
+ /**
+ * No argument constructor.
+ */
+ public IntegerSummaryDeserializer() { }
+
@Override
public DeserializeResult heapifySummary(final MemorySegment seg) {
return IntegerSummary.fromMemorySegment(seg);
diff --git a/src/main/java/org/apache/datasketches/tuple/package-info.java b/src/main/java/org/apache/datasketches/tuple/package-info.java
index d7ea21cd7..4a6be9210 100644
--- a/src/main/java/org/apache/datasketches/tuple/package-info.java
+++ b/src/main/java/org/apache/datasketches/tuple/package-info.java
@@ -18,7 +18,7 @@
*/
/**
- * The tuple package contains a number of sketches based on the same
+ * The tuple package contains a number of sketches based on the same
* fundamental algorithms of the Theta Sketch Framework and extend these
* concepts for whole new families of sketches.
*/
diff --git a/src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSummary.java b/src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSummary.java
index 12d587398..4197cd285 100644
--- a/src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSummary.java
+++ b/src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSummary.java
@@ -38,6 +38,9 @@ public final class ArrayOfStringsSummary implements UpdatableSummary {
private String[] stringArr = null;
+ /**
+ * No argument constructor.
+ */
ArrayOfStringsSummary() { //required for ArrayOfStringsSummaryFactory
stringArr = null;
}
diff --git a/src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSummaryDeserializer.java b/src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSummaryDeserializer.java
index 5363605d4..dffe91983 100644
--- a/src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSummaryDeserializer.java
+++ b/src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSummaryDeserializer.java
@@ -32,6 +32,11 @@
*/
public class ArrayOfStringsSummaryDeserializer implements SummaryDeserializer {
+ /**
+ * No argument constructor.
+ */
+ public ArrayOfStringsSummaryDeserializer() { }
+
@Override
public DeserializeResult heapifySummary(final MemorySegment seg) {
return ArrayOfStringsSummaryDeserializer.fromMemorySegment(seg);
diff --git a/src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSummaryFactory.java b/src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSummaryFactory.java
index 98fb7fb58..8ca2a6a1a 100644
--- a/src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSummaryFactory.java
+++ b/src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSummaryFactory.java
@@ -27,6 +27,11 @@
*/
public class ArrayOfStringsSummaryFactory implements SummaryFactory {
+ /**
+ * No argument constructor.
+ */
+ public ArrayOfStringsSummaryFactory() { }
+
@Override
public ArrayOfStringsSummary newSummary() {
return new ArrayOfStringsSummary();
diff --git a/src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSummarySetOperations.java b/src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSummarySetOperations.java
index 2650b84ae..270acbe3c 100644
--- a/src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSummarySetOperations.java
+++ b/src/main/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSummarySetOperations.java
@@ -27,6 +27,11 @@
*/
public class ArrayOfStringsSummarySetOperations implements SummarySetOperations {
+ /**
+ * No argument constructor.
+ */
+ public ArrayOfStringsSummarySetOperations() { }
+
@Override
public ArrayOfStringsSummary union(final ArrayOfStringsSummary a, final ArrayOfStringsSummary b) {
return a.copy();
diff --git a/src/test/java/org/apache/datasketches/hash/MurmurHash3FFM21Test.java b/src/test/java/org/apache/datasketches/hash/MurmurHash3FFMTest.java
similarity index 85%
rename from src/test/java/org/apache/datasketches/hash/MurmurHash3FFM21Test.java
rename to src/test/java/org/apache/datasketches/hash/MurmurHash3FFMTest.java
index d389aef0a..4e2bb00e7 100644
--- a/src/test/java/org/apache/datasketches/hash/MurmurHash3FFM21Test.java
+++ b/src/test/java/org/apache/datasketches/hash/MurmurHash3FFMTest.java
@@ -38,7 +38,7 @@
/**
* @author Lee Rhodes
*/
-public class MurmurHash3FFM21Test {
+public class MurmurHash3FFMTest {
private final Random rand = new Random();
private static final int trials = 1 << 20;
@@ -158,25 +158,25 @@ private static final long[] hashV1(final byte[] key, final long seed) {
}
private static final long[] hashV2(final long[] key, final long seed) {
- return MurmurHash3FFM21.hash(key, seed);
+ return MurmurHash3FFM.hash(key, seed);
}
private static final long[] hashV2(final int[] key2, final long seed) {
- return MurmurHash3FFM21.hash(key2, seed);
+ return MurmurHash3FFM.hash(key2, seed);
}
private static final long[] hashV2(final char[] key, final long seed) {
- return MurmurHash3FFM21.hash(key, seed);
+ return MurmurHash3FFM.hash(key, seed);
}
private static final long[] hashV2(final byte[] key, final long seed) {
- return MurmurHash3FFM21.hash(key, seed);
+ return MurmurHash3FFM.hash(key, seed);
}
//V2 single primitives
private static final long[] hashV2(final long key, final long seed, final long[] out) {
- return MurmurHash3FFM21.hash(key, seed, out);
+ return MurmurHash3FFM.hash(key, seed, out);
}
// private static final long[] hashV2(double key, long seed, long[] out) {
@@ -201,7 +201,7 @@ public void offsetChecks() {
for (int offset = 0; offset < 16; offset++) {
final int arrLen = cap - offset;
- hash1 = MurmurHash3FFM21.hash(wseg, offset, arrLen, seed, hash1);
+ hash1 = MurmurHash3FFM.hash(wseg, offset, arrLen, seed, hash1);
final byte[] byteArr2 = new byte[arrLen];
MemorySegment.copy(wseg, JAVA_BYTE, offset, byteArr2, 0, arrLen);
hash2 = MurmurHash3.hash(byteArr2, seed);
@@ -224,8 +224,8 @@ public void byteArrChecks() {
for (int i = 0; i < j; i++) { wseg.set(JAVA_BYTE, i, (byte) (-128 + i)); }
final long[] hash1 = MurmurHash3.hash(in, seed);
- hash2 = MurmurHash3FFM21.hash(wseg, offset, bytes, seed, hash2);
- final long[] hash3 = MurmurHash3FFM21.hash(in, seed);
+ hash2 = MurmurHash3FFM.hash(wseg, offset, bytes, seed, hash2);
+ final long[] hash3 = MurmurHash3FFM.hash(in, seed);
assertEquals(hash1, hash2);
assertEquals(hash1, hash3);
@@ -248,8 +248,8 @@ public void charArrChecks() {
for (int i = 0; i < j; i++) { wseg.set(JAVA_INT_UNALIGNED, i, i); }
final long[] hash1 = MurmurHash3.hash(in, 0);
- hash2 = MurmurHash3FFM21.hash(wseg, offset, bytes, seed, hash2);
- final long[] hash3 = MurmurHash3FFM21.hash(in, seed);
+ hash2 = MurmurHash3FFM.hash(wseg, offset, bytes, seed, hash2);
+ final long[] hash3 = MurmurHash3FFM.hash(in, seed);
assertEquals(hash1, hash2);
assertEquals(hash1, hash3);
@@ -272,8 +272,8 @@ public void intArrChecks() {
for (int i = 0; i < j; i++) { wseg.set(JAVA_INT_UNALIGNED, i, i); }
final long[] hash1 = MurmurHash3.hash(in, 0);
- hash2 = MurmurHash3FFM21.hash(wseg, offset, bytes, seed, hash2);
- final long[] hash3 = MurmurHash3FFM21.hash(in, seed);
+ hash2 = MurmurHash3FFM.hash(wseg, offset, bytes, seed, hash2);
+ final long[] hash3 = MurmurHash3FFM.hash(in, seed);
assertEquals(hash1, hash2);
assertEquals(hash1, hash3);
@@ -296,8 +296,8 @@ public void longArrChecks() {
for (int i = 0; i < j; i++) { wseg.set(JAVA_LONG_UNALIGNED, i, i); }
final long[] hash1 = MurmurHash3.hash(in, 0);
- hash2 = MurmurHash3FFM21.hash(wseg, offset, bytes, seed, hash2);
- final long[] hash3 = MurmurHash3FFM21.hash(in, seed);
+ hash2 = MurmurHash3FFM.hash(wseg, offset, bytes, seed, hash2);
+ final long[] hash3 = MurmurHash3FFM.hash(in, seed);
assertEquals(hash1, hash2);
assertEquals(hash1, hash3);
@@ -315,8 +315,8 @@ public void longCheck() {
final MemorySegment wseg = MemorySegment.ofArray(in);
final long[] hash1 = MurmurHash3.hash(in, 0);
- hash2 = MurmurHash3FFM21.hash(wseg, offset, bytes, seed, hash2);
- final long[] hash3 = MurmurHash3FFM21.hash(in, seed);
+ hash2 = MurmurHash3FFM.hash(wseg, offset, bytes, seed, hash2);
+ final long[] hash3 = MurmurHash3FFM.hash(in, seed);
assertEquals(hash1, hash2);
assertEquals(hash1, hash3);
@@ -327,57 +327,57 @@ public void checkEmptiesNulls() {
final long seed = 123;
final long[] hashOut = new long[2];
try {
- MurmurHash3FFM21.hash(MemorySegment.ofArray(new long[0]), 0, 0, seed, hashOut); //seg empty
+ MurmurHash3FFM.hash(MemorySegment.ofArray(new long[0]), 0, 0, seed, hashOut); //seg empty
fail();
} catch (final IllegalArgumentException e) { } //OK
try {
final String s = "";
- MurmurHash3FFM21.hash(s, seed, hashOut); //string empty
+ MurmurHash3FFM.hash(s, seed, hashOut); //string empty
fail();
} catch (final IllegalArgumentException e) { } //OK
try {
final String s = null;
- MurmurHash3FFM21.hash(s, seed, hashOut); //string null
+ MurmurHash3FFM.hash(s, seed, hashOut); //string null
fail();
} catch (final IllegalArgumentException e) { } //OK
try {
final byte[] barr = {};
- MurmurHash3FFM21.hash(barr, seed); //byte[] empty
+ MurmurHash3FFM.hash(barr, seed); //byte[] empty
fail();
} catch (final IllegalArgumentException e) { } //OK
try {
final byte[] barr = null;
- MurmurHash3FFM21.hash(barr, seed); //byte[] null
+ MurmurHash3FFM.hash(barr, seed); //byte[] null
fail();
} catch (final IllegalArgumentException e) { } //OK
try {
final char[] carr = {};
- MurmurHash3FFM21.hash(carr, seed); //char[] empty
+ MurmurHash3FFM.hash(carr, seed); //char[] empty
fail();
} catch (final IllegalArgumentException e) { } //OK
try {
final char[] carr = null;
- MurmurHash3FFM21.hash(carr, seed); //char[] null
+ MurmurHash3FFM.hash(carr, seed); //char[] null
fail();
} catch (final IllegalArgumentException e) { } //OK
try {
final int[] iarr = {};
- MurmurHash3FFM21.hash(iarr, seed); //int[] empty
+ MurmurHash3FFM.hash(iarr, seed); //int[] empty
fail();
} catch (final IllegalArgumentException e) { } //OK
try {
final int[] iarr = null;
- MurmurHash3FFM21.hash(iarr, seed); //int[] null
+ MurmurHash3FFM.hash(iarr, seed); //int[] null
fail();
} catch (final IllegalArgumentException e) { } //OK
try {
final long[] larr = {};
- MurmurHash3FFM21.hash(larr, seed); //long[] empty
+ MurmurHash3FFM.hash(larr, seed); //long[] empty
fail();
} catch (final IllegalArgumentException e) { } //OK
try {
final long[] larr = null;
- MurmurHash3FFM21.hash(larr, seed); //long[] null
+ MurmurHash3FFM.hash(larr, seed); //long[] null
fail();
} catch (final IllegalArgumentException e) { } //OK
}
@@ -387,9 +387,9 @@ public void checkStringLong() {
final long seed = 123;
final long[] hashOut = new long[2];
final String s = "123";
- assertTrue(MurmurHash3FFM21.hash(s, seed, hashOut)[0] != 0);
+ assertTrue(MurmurHash3FFM.hash(s, seed, hashOut)[0] != 0);
final long v = 123;
- assertTrue(MurmurHash3FFM21.hash(v, seed, hashOut)[0] != 0);
+ assertTrue(MurmurHash3FFM.hash(v, seed, hashOut)[0] != 0);
}
@Test
@@ -417,8 +417,8 @@ private static long[] checkDouble(final double dbl) {
final MemorySegment wseg = MemorySegment.ofArray(dataArr);
final long[] hash1 = MurmurHash3.hash(dataArr, 0);
- hash2 = MurmurHash3FFM21.hash(wseg, offset, bytes, seed, hash2);
- final long[] hash3 = MurmurHash3FFM21.hash(dbl, seed, hash2);
+ hash2 = MurmurHash3FFM.hash(wseg, offset, bytes, seed, hash2);
+ final long[] hash3 = MurmurHash3FFM.hash(dbl, seed, hash2);
assertEquals(hash1, hash2);
assertEquals(hash1, hash3);
diff --git a/src/test/java/org/apache/datasketches/hash/MurmurHash3FFM21bTest.java b/src/test/java/org/apache/datasketches/hash/MurmurHash3FFMbTest.java
similarity index 98%
rename from src/test/java/org/apache/datasketches/hash/MurmurHash3FFM21bTest.java
rename to src/test/java/org/apache/datasketches/hash/MurmurHash3FFMbTest.java
index 867f4a126..ab61a33a2 100644
--- a/src/test/java/org/apache/datasketches/hash/MurmurHash3FFM21bTest.java
+++ b/src/test/java/org/apache/datasketches/hash/MurmurHash3FFMbTest.java
@@ -20,7 +20,7 @@
package org.apache.datasketches.hash;
import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.apache.datasketches.hash.MurmurHash3FFM21.hash;
+import static org.apache.datasketches.hash.MurmurHash3FFM.hash;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
@@ -36,7 +36,7 @@
*
* @author Lee Rhodes
*/
-public class MurmurHash3FFM21bTest {
+public class MurmurHash3FFMbTest {
@Test
public void checkByteArrRemainderGT8() { //byte[], remainder > 8
@@ -195,7 +195,7 @@ public void checkByteArrAllOnesZeros() { //byte[], test a ones byte and a zeros
0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6c, 0x61, 0x7a, 0x79, 0x20, 0x64, 0x6f, 0x67,
(byte) 0xff, 0x64, 0x6f, 0x67, 0x00
};
- final long[] result = MurmurHash3FFM21.hash(key, 0);
+ final long[] result = MurmurHash3FFM.hash(key, 0);
//Should be:
final long h1 = 0xe88abda785929c9eL;
final long h2 = 0x96b98587cacc83d6L;
diff --git a/src/test/java/org/apache/datasketches/kll/KllCrossLanguageTest.java b/src/test/java/org/apache/datasketches/kll/KllCrossLanguageTest.java
index d40cd3723..45fb4d8c9 100644
--- a/src/test/java/org/apache/datasketches/kll/KllCrossLanguageTest.java
+++ b/src/test/java/org/apache/datasketches/kll/KllCrossLanguageTest.java
@@ -41,9 +41,9 @@
import org.apache.datasketches.kll.KllHeapItemsSketch;
import org.apache.datasketches.kll.KllItemsSketch;
import org.apache.datasketches.kll.KllLongsSketch;
-import org.apache.datasketches.quantilescommon.QuantilesDoublesSketchIterator;
+import org.apache.datasketches.quantilescommon.QuantilesDoublesSketchIteratorAPI;
import org.apache.datasketches.quantilescommon.QuantilesFloatsSketchIterator;
-import org.apache.datasketches.quantilescommon.QuantilesGenericSketchIterator;
+import org.apache.datasketches.quantilescommon.QuantilesGenericSketchIteratorAPI;
import org.testng.annotations.Test;
/**
@@ -156,7 +156,7 @@ public void kllDouble() throws IOException {
assertEquals(sketch.getMinItem(), 1);
assertEquals(sketch.getMaxItem(), n);
long weight = 0;
- final QuantilesDoublesSketchIterator it = sketch.iterator();
+ final QuantilesDoublesSketchIteratorAPI it = sketch.iterator();
while (it.next()) {
assertTrue(it.getQuantile() >= sketch.getMinItem());
assertTrue(it.getQuantile() <= sketch.getMaxItem());
@@ -198,7 +198,7 @@ public int compare(final String s1, final String s2) {
assertEquals(sketch.getMinItem(), Integer.toString(1));
assertEquals(sketch.getMaxItem(), Integer.toString(n));
long weight = 0;
- final QuantilesGenericSketchIterator it = sketch.iterator();
+ final QuantilesGenericSketchIteratorAPI it = sketch.iterator();
while (it.next()) {
assertTrue(numericOrder.compare(it.getQuantile(), sketch.getMinItem()) >= 0);
assertTrue(numericOrder.compare(it.getQuantile(), sketch.getMaxItem()) <= 0);
diff --git a/src/test/java/org/apache/datasketches/kll/KllDirectCompactItemsSketchIteratorTest.java b/src/test/java/org/apache/datasketches/kll/KllDirectCompactItemsSketchIteratorTest.java
index 74d3d5448..a41eb321e 100644
--- a/src/test/java/org/apache/datasketches/kll/KllDirectCompactItemsSketchIteratorTest.java
+++ b/src/test/java/org/apache/datasketches/kll/KllDirectCompactItemsSketchIteratorTest.java
@@ -34,7 +34,7 @@
import org.apache.datasketches.kll.KllItemsSketch;
import org.apache.datasketches.quantilescommon.GenericSortedViewIterator;
import org.apache.datasketches.quantilescommon.ItemsSketchSortedView;
-import org.apache.datasketches.quantilescommon.QuantilesGenericSketchIterator;
+import org.apache.datasketches.quantilescommon.QuantilesGenericSketchIteratorAPI;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -48,7 +48,7 @@ public void emptySketch() {
final byte[] byteArr = sk.toByteArray();
final KllItemsSketch sk2 = KllItemsSketch.wrap(MemorySegment.ofArray(byteArr), Comparator.naturalOrder(), serDe);
assertTrue(sk2 instanceof KllDirectCompactItemsSketch);
- final QuantilesGenericSketchIterator itr = sk2.iterator();
+ final QuantilesGenericSketchIteratorAPI itr = sk2.iterator();
assertFalse(itr.next());
}
@@ -59,7 +59,7 @@ public void oneItemSketch() {
final byte[] byteArr = sk.toByteArray();
final KllItemsSketch sk2 = KllItemsSketch.wrap(MemorySegment.ofArray(byteArr), Comparator.naturalOrder(), serDe);
assertTrue(sk2 instanceof KllDirectCompactItemsSketch);
- final QuantilesGenericSketchIterator itr = sk2.iterator();
+ final QuantilesGenericSketchIteratorAPI itr = sk2.iterator();
assertTrue(itr.next());
assertEquals(itr.getQuantile(), "1");
assertEquals(itr.getWeight(), 1);
@@ -74,7 +74,7 @@ public void twoItemSketchForIterator() {
final byte[] byteArr = sk.toByteArray();
final KllItemsSketch sk2 = KllItemsSketch.wrap(MemorySegment.ofArray(byteArr), Comparator.naturalOrder(), serDe);
assertTrue(sk2 instanceof KllDirectCompactItemsSketch);
- final QuantilesGenericSketchIterator itr = sk2.iterator();
+ final QuantilesGenericSketchIteratorAPI itr = sk2.iterator();
assertTrue(itr.next());
assertEquals(itr.getQuantile(), "2");
@@ -128,7 +128,7 @@ public void bigSketches() {
final byte[] byteArr = sk.toByteArray();
final KllItemsSketch sk2 = KllItemsSketch.wrap(MemorySegment.ofArray(byteArr), Comparator.naturalOrder(), serDe);
assertTrue(sk2 instanceof KllDirectCompactItemsSketch);
- final QuantilesGenericSketchIterator itr = sk2.iterator();
+ final QuantilesGenericSketchIteratorAPI itr = sk2.iterator();
int count = 0;
int weight = 0;
while (itr.next()) {
diff --git a/src/test/java/org/apache/datasketches/kll/KllDirectDoublesSketchIteratorTest.java b/src/test/java/org/apache/datasketches/kll/KllDirectDoublesSketchIteratorTest.java
index 20afe16b2..06a0b8ce1 100644
--- a/src/test/java/org/apache/datasketches/kll/KllDirectDoublesSketchIteratorTest.java
+++ b/src/test/java/org/apache/datasketches/kll/KllDirectDoublesSketchIteratorTest.java
@@ -23,7 +23,7 @@
import org.apache.datasketches.kll.KllDoublesSketch;
import org.apache.datasketches.kll.KllHelper;
-import org.apache.datasketches.quantilescommon.QuantilesDoublesSketchIterator;
+import org.apache.datasketches.quantilescommon.QuantilesDoublesSketchIteratorAPI;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -32,7 +32,7 @@ public class KllDirectDoublesSketchIteratorTest {
@Test
public void emptySketch() {
final KllDoublesSketch sketch = getDDSketch(200, 0);
- final QuantilesDoublesSketchIterator it = sketch.iterator();
+ final QuantilesDoublesSketchIteratorAPI it = sketch.iterator();
Assert.assertFalse(it.next());
}
@@ -40,7 +40,7 @@ public void emptySketch() {
public void oneItemSketch() {
final KllDoublesSketch sketch = getDDSketch(200, 0);
sketch.update(0);
- final QuantilesDoublesSketchIterator it = sketch.iterator();
+ final QuantilesDoublesSketchIteratorAPI it = sketch.iterator();
Assert.assertTrue(it.next());
Assert.assertEquals(it.getQuantile(), 0);
Assert.assertEquals(it.getWeight(), 1);
@@ -54,7 +54,7 @@ public void bigSketches() {
for (int i = 0; i < n; i++) {
sketch.update(i);
}
- final QuantilesDoublesSketchIterator it = sketch.iterator();
+ final QuantilesDoublesSketchIteratorAPI it = sketch.iterator();
int count = 0;
int weight = 0;
while (it.next()) {
diff --git a/src/test/java/org/apache/datasketches/kll/KllDoublesSketchIteratorTest.java b/src/test/java/org/apache/datasketches/kll/KllDoublesSketchIteratorTest.java
index 2abb30022..ff66caccd 100644
--- a/src/test/java/org/apache/datasketches/kll/KllDoublesSketchIteratorTest.java
+++ b/src/test/java/org/apache/datasketches/kll/KllDoublesSketchIteratorTest.java
@@ -26,7 +26,7 @@
import org.apache.datasketches.kll.KllDoublesSketch;
import org.apache.datasketches.quantilescommon.DoublesSortedViewIterator;
-import org.apache.datasketches.quantilescommon.QuantilesDoublesSketchIterator;
+import org.apache.datasketches.quantilescommon.QuantilesDoublesSketchIteratorAPI;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -35,7 +35,7 @@ public class KllDoublesSketchIteratorTest {
@Test
public void emptySketch() {
KllDoublesSketch sketch = KllDoublesSketch.newHeapInstance();
- QuantilesDoublesSketchIterator it = sketch.iterator();
+ QuantilesDoublesSketchIteratorAPI it = sketch.iterator();
Assert.assertFalse(it.next());
}
@@ -43,7 +43,7 @@ public void emptySketch() {
public void oneItemSketch() {
KllDoublesSketch sketch = KllDoublesSketch.newHeapInstance();
sketch.update(1);
- QuantilesDoublesSketchIterator it = sketch.iterator();
+ QuantilesDoublesSketchIteratorAPI it = sketch.iterator();
Assert.assertTrue(it.next());
Assert.assertEquals(it.getQuantile(), 1.0);
Assert.assertEquals(it.getWeight(), 1);
@@ -55,7 +55,7 @@ public void twoItemSketchForIterator() {
KllDoublesSketch sketch = KllDoublesSketch.newHeapInstance();
sketch.update(1);
sketch.update(2);
- QuantilesDoublesSketchIterator itr = sketch.iterator();
+ QuantilesDoublesSketchIteratorAPI itr = sketch.iterator();
assertTrue(itr.next());
assertEquals(itr.getQuantile(), 2.0);
@@ -100,7 +100,7 @@ public void bigSketches() {
for (int i = 0; i < n; i++) {
sketch.update(i);
}
- QuantilesDoublesSketchIterator it = sketch.iterator();
+ QuantilesDoublesSketchIteratorAPI it = sketch.iterator();
int count = 0;
int weight = 0;
while (it.next()) {
diff --git a/src/test/java/org/apache/datasketches/kll/KllItemsSketchTest.java b/src/test/java/org/apache/datasketches/kll/KllItemsSketchTest.java
index c249961a8..193c1e502 100644
--- a/src/test/java/org/apache/datasketches/kll/KllItemsSketchTest.java
+++ b/src/test/java/org/apache/datasketches/kll/KllItemsSketchTest.java
@@ -51,7 +51,7 @@
import org.apache.datasketches.kll.KllSketch.SketchType;
import org.apache.datasketches.quantilescommon.GenericSortedView;
import org.apache.datasketches.quantilescommon.GenericSortedViewIterator;
-import org.apache.datasketches.quantilescommon.QuantilesGenericSketchIterator;
+import org.apache.datasketches.quantilescommon.QuantilesGenericSketchIteratorAPI;
import org.testng.annotations.Test;
public class KllItemsSketchTest {
@@ -767,7 +767,7 @@ public void checkL0SortDuringMergeIssue527() throws NumberFormatException {
sk1.merge(sk2);
println(sk1.toString(true, true)); //L1 and above should be sorted in reverse. Ignore L0.
final int lvl1size = sk1.levelsArr[2] - sk1.levelsArr[1];
- final QuantilesGenericSketchIterator itr = sk1.iterator();
+ final QuantilesGenericSketchIteratorAPI itr = sk1.iterator();
itr.next();
int prev = Integer.parseInt(itr.getQuantile().trim());
for (int i = 1; i < lvl1size; i++) {
diff --git a/src/test/java/org/apache/datasketches/kll/KllItemsSketchiteratorTest.java b/src/test/java/org/apache/datasketches/kll/KllItemsSketchiteratorTest.java
index 2533802ac..1e8623b47 100644
--- a/src/test/java/org/apache/datasketches/kll/KllItemsSketchiteratorTest.java
+++ b/src/test/java/org/apache/datasketches/kll/KllItemsSketchiteratorTest.java
@@ -30,7 +30,7 @@
import org.apache.datasketches.common.Util;
import org.apache.datasketches.kll.KllItemsSketch;
import org.apache.datasketches.quantilescommon.GenericSortedViewIterator;
-import org.apache.datasketches.quantilescommon.QuantilesGenericSketchIterator;
+import org.apache.datasketches.quantilescommon.QuantilesGenericSketchIteratorAPI;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -40,7 +40,7 @@ public class KllItemsSketchiteratorTest {
@Test
public void emptySketch() {
final KllItemsSketch sketch = KllItemsSketch.newHeapInstance(Comparator.naturalOrder(), serDe);
- final QuantilesGenericSketchIterator it = sketch.iterator();
+ final QuantilesGenericSketchIteratorAPI it = sketch.iterator();
Assert.assertFalse(it.next());
}
@@ -48,7 +48,7 @@ public void emptySketch() {
public void oneItemSketch() {
final KllItemsSketch sketch = KllItemsSketch.newHeapInstance(Comparator.naturalOrder(), serDe);
sketch.update("1");
- final QuantilesGenericSketchIterator it = sketch.iterator();
+ final QuantilesGenericSketchIteratorAPI it = sketch.iterator();
Assert.assertTrue(it.next());
Assert.assertEquals(it.getQuantile(), "1");
Assert.assertEquals(it.getWeight(), 1);
@@ -60,7 +60,7 @@ public void twoItemSketchForIterator() {
final KllItemsSketch sketch = KllItemsSketch.newHeapInstance(Comparator.naturalOrder(), serDe);
sketch.update("1");
sketch.update("2");
- final QuantilesGenericSketchIterator itr = sketch.iterator();
+ final QuantilesGenericSketchIteratorAPI itr = sketch.iterator();
assertTrue(itr.next());
assertEquals(itr.getQuantile(), "2");
@@ -106,7 +106,7 @@ public void bigSketches() {
for (int i = 0; i < n; i++) {
sketch.update(Util.longToFixedLengthString(i, digits));
}
- final QuantilesGenericSketchIterator it = sketch.iterator();
+ final QuantilesGenericSketchIteratorAPI it = sketch.iterator();
int count = 0;
int weight = 0;
while (it.next()) {
diff --git a/src/test/java/org/apache/datasketches/partitions/ClassicPartitionsTest.java b/src/test/java/org/apache/datasketches/partitions/ClassicPartitionsTest.java
index 52e6c50d7..5175ecab0 100644
--- a/src/test/java/org/apache/datasketches/partitions/ClassicPartitionsTest.java
+++ b/src/test/java/org/apache/datasketches/partitions/ClassicPartitionsTest.java
@@ -27,7 +27,7 @@
import org.apache.datasketches.common.SketchesArgumentException;
import org.apache.datasketches.partitions.Partitioner.PartitionBoundsRow;
-import org.apache.datasketches.quantiles.ItemsSketch;
+import org.apache.datasketches.quantiles.QuantilesItemsSketch;
import org.apache.datasketches.quantilescommon.QuantileSearchCriteria;
import org.testng.annotations.Test;
@@ -94,9 +94,9 @@ public void classicPartitioner(
final long startTime_mS = System.currentTimeMillis();
final ItemsSketchFillRequestLongAsString fillReq = new ItemsSketchFillRequestLongAsString(k, totalN);
- final ItemsSketch sk = fillReq.getRange(1L, totalN, INCLUDE_BOTH);
+ final QuantilesItemsSketch sk = fillReq.getRange(1L, totalN, INCLUDE_BOTH);
final long endFillInitialSketchTime_mS = System.currentTimeMillis();
- final Partitioner> partitioner = new Partitioner<>(
+ final Partitioner> partitioner = new Partitioner<>(
tgtPartitionSize,
maxPartsPerSk,
fillReq,
diff --git a/src/test/java/org/apache/datasketches/partitions/ItemsSketchFillRequestLongAsString.java b/src/test/java/org/apache/datasketches/partitions/ItemsSketchFillRequestLongAsString.java
index 9f3cfb9fb..8e39ba55f 100644
--- a/src/test/java/org/apache/datasketches/partitions/ItemsSketchFillRequestLongAsString.java
+++ b/src/test/java/org/apache/datasketches/partitions/ItemsSketchFillRequestLongAsString.java
@@ -27,13 +27,13 @@
import java.util.Comparator;
import org.apache.datasketches.common.SketchesArgumentException;
-import org.apache.datasketches.quantiles.ItemsSketch;
+import org.apache.datasketches.quantiles.QuantilesItemsSketch;
/**
* This is an simulated data set with a given N used for testing.
* @author Lee Rhodes
*/
-public class ItemsSketchFillRequestLongAsString implements SketchFillRequest> {
+public class ItemsSketchFillRequestLongAsString implements SketchFillRequest> {
private int k;
private int numDigits;
@@ -48,9 +48,9 @@ public ItemsSketchFillRequestLongAsString(final int k, final long totalN) {
}
@Override
- public ItemsSketch getRange(final String lowerQuantile, final String upperQuantile,
+ public QuantilesItemsSketch getRange(final String lowerQuantile, final String upperQuantile,
final BoundsRule bounds) {
- final ItemsSketch sk = ItemsSketch.getInstance(String.class, k, Comparator.naturalOrder());
+ final QuantilesItemsSketch sk = QuantilesItemsSketch.getInstance(String.class, k, Comparator.naturalOrder());
long upper, lower;
try {
lower = Long.parseLong(lowerQuantile.trim());
@@ -66,8 +66,8 @@ public ItemsSketch getRange(final String lowerQuantile, final String upp
return sk;
}
- public ItemsSketch getRange(final long lowerQuantile, final long upperQuantile, final BoundsRule bounds) {
- final ItemsSketch sk = ItemsSketch.getInstance(String.class, k, Comparator.naturalOrder());
+ public QuantilesItemsSketch getRange(final long lowerQuantile, final long upperQuantile, final BoundsRule bounds) {
+ final QuantilesItemsSketch sk = QuantilesItemsSketch.getInstance(String.class, k, Comparator.naturalOrder());
final long lower = lowerQuantile;
final long upper = upperQuantile;
if (bounds == INCLUDE_BOTH) {
diff --git a/src/test/java/org/apache/datasketches/partitions/PartitionResults.java b/src/test/java/org/apache/datasketches/partitions/PartitionResults.java
index b061ce921..65d8a2ba8 100644
--- a/src/test/java/org/apache/datasketches/partitions/PartitionResults.java
+++ b/src/test/java/org/apache/datasketches/partitions/PartitionResults.java
@@ -74,7 +74,7 @@ public static void output(
final double rmsRelErr = sqrt(normMeanSqErr); //a.k.a. Normalized RMS Error or NRMSE
final double maxAbsErrFraction = maxAbsErr / meanPartSize;
- println(LS + sketchType +" ItemsSketch Partitions Test");
+ println(LS + sketchType + " Generic Quantiles Sketch Partitions Test");
println(LS + "INPUT:");
printf("Sketch K :%,20d\n", k);
printf("Search Criteria :%20s\n", searchCrit.name());
diff --git a/src/test/java/org/apache/datasketches/quantiles/AccuracyTest.java b/src/test/java/org/apache/datasketches/quantiles/AccuracyTest.java
index 015a4fbe5..2fed90dc8 100644
--- a/src/test/java/org/apache/datasketches/quantiles/AccuracyTest.java
+++ b/src/test/java/org/apache/datasketches/quantiles/AccuracyTest.java
@@ -41,7 +41,7 @@ public void baseTest() {
}
double[] randArr = seqArr.clone();
shuffle(randArr);
- UpdateDoublesSketch sketch = DoublesSketch.builder().setK(k).build();
+ UpdatableQuantilesDoublesSketch sketch = QuantilesDoublesSketch.builder().setK(k).build();
for (int i = 0; i < n; i++) {
sketch.update(randArr[i]);
}
diff --git a/src/test/java/org/apache/datasketches/quantiles/ClassicQuantilesMemorySegmentRequestApp.java b/src/test/java/org/apache/datasketches/quantiles/ClassicQuantilesMemorySegmentRequestApp.java
index cfd4f61e1..6e96578ca 100644
--- a/src/test/java/org/apache/datasketches/quantiles/ClassicQuantilesMemorySegmentRequestApp.java
+++ b/src/test/java/org/apache/datasketches/quantiles/ClassicQuantilesMemorySegmentRequestApp.java
@@ -22,7 +22,6 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
-import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;
import org.apache.datasketches.common.MemorySegmentRequestExample;
@@ -32,8 +31,8 @@ public class ClassicQuantilesMemorySegmentRequestApp {
@Test
/**
- * This method emulates an application using an off-heap DoublesSketch that needs to expand off-heap.
- * This demonstrates one example of how to manage a growing off-heap DoublesSketch where the
+ * This method emulates an application using an off-heap QuantilesDoublesSketch that needs to expand off-heap.
+ * This demonstrates one example of how to manage a growing off-heap QuantilesDoublesSketch where the
* expanded MemorySegments are also off-heap.
*/
public void checkMemorySegmentRequestExample() {
@@ -43,14 +42,14 @@ public void checkMemorySegmentRequestExample() {
//Use the custom MemorySegmentRequestExample to do the allocations.
final MemorySegmentRequestExample mSegReqEx = new MemorySegmentRequestExample();
- //The allocation of the original off-heap MemorySegment for the DoublesSketch
+ //The allocation of the original off-heap MemorySegment for the QuantilesDoublesSketch
//Note that this targets the size to only handle 2k values, which is quite small.
- final int initalBytes = DoublesSketch.getUpdatableStorageBytes(k, 2 * k);
+ final int initalBytes = QuantilesDoublesSketch.getUpdatableStorageBytes(k, 2 * k);
final MemorySegment seg = mSegReqEx.request(initalBytes);
//Create a new KllLongsSketch and pass the mSegReqEx
- final DoublesSketch sk = DoublesSketch.builder().setK(k).build(seg, mSegReqEx);
+ final QuantilesDoublesSketch sk = QuantilesDoublesSketch.builder().setK(k).build(seg, mSegReqEx);
//Update the sketch with way more data than the original MemorySegment can handle, forcing it to request larger MemorySegments.
for (int n = 1; n <= itemsIn; n++) { sk.update(n); }
diff --git a/src/test/java/org/apache/datasketches/quantiles/CustomQuantilesTest.java b/src/test/java/org/apache/datasketches/quantiles/CustomQuantilesTest.java
index 101c26cdd..d0816c4dc 100644
--- a/src/test/java/org/apache/datasketches/quantiles/CustomQuantilesTest.java
+++ b/src/test/java/org/apache/datasketches/quantiles/CustomQuantilesTest.java
@@ -32,7 +32,7 @@
public class CustomQuantilesTest {
/**
- * Currently, this test only exercises the classic DoublesSketch, but all the quantiles
+ * Currently, this test only exercises the classic QuantilesDoublesSketch, but all the quantiles
* sketches use the same code for getQuantile() and getRank() anyway.
* This same pattern is also part of the CrossCheckQuantilesTest.
* This structure of this test allows more detailed analysis for troubleshooting.
@@ -49,7 +49,7 @@ public void checkQuantilesV400() {
//quantiles sketches it is easier to create by loading the sorted view directly via
//a package-private constructor.
int k = 4;
- UpdateDoublesSketch sk = DoublesSketch.builder().setK(k).build();
+ UpdatableQuantilesDoublesSketch sk = QuantilesDoublesSketch.builder().setK(k).build();
for (int i = 1; i <= 3; i++) {
for (int q = 10; q <= k * 10; q += 10) {
sk.update(q);
diff --git a/src/test/java/org/apache/datasketches/quantiles/DebugUnionTest.java b/src/test/java/org/apache/datasketches/quantiles/DebugUnionTest.java
index b7c70572c..cdc1f7a93 100644
--- a/src/test/java/org/apache/datasketches/quantiles/DebugUnionTest.java
+++ b/src/test/java/org/apache/datasketches/quantiles/DebugUnionTest.java
@@ -27,7 +27,7 @@
import java.lang.foreign.MemorySegment;
import java.util.HashSet;
-import org.apache.datasketches.quantilescommon.QuantilesDoublesSketchIterator;
+import org.apache.datasketches.quantilescommon.QuantilesDoublesSketchIteratorAPI;
import org.testng.annotations.Test;
/**
@@ -42,28 +42,28 @@ public void test() {
final int numSketches = 3;
final int sketchK = 8;
final int unionK = 8;
- final UpdateDoublesSketch[] sketchArr = new UpdateDoublesSketch[numSketches];
+ final UpdatableQuantilesDoublesSketch[] sketchArr = new UpdatableQuantilesDoublesSketch[numSketches];
//builds the input sketches, all on heap
- DoublesSketch.setRandom(1); //make deterministic for test
+ QuantilesDoublesSketch.setRandom(1); //make deterministic for test
final HashSet set = new HashSet<>(); //holds input values
for (int s = 0; s < numSketches; s++) {
sketchArr[s] = buildHeapSketch(sketchK, n, valueLimit, set);
}
//loads the on heap union
- DoublesSketch.setRandom(1); //make deterministic for test
- final DoublesUnion hUnion = DoublesUnion.builder().setMaxK(unionK).build();
+ QuantilesDoublesSketch.setRandom(1); //make deterministic for test
+ final QuantilesDoublesUnion hUnion = QuantilesDoublesUnion.builder().setMaxK(unionK).build();
for (int s = 0; s < numSketches; s++) { hUnion.union(sketchArr[s]); }
- final DoublesSketch hSketch = hUnion.getResult();
+ final QuantilesDoublesSketch hSketch = hUnion.getResult();
//loads the direct union
- DoublesSketch.setRandom(1); //make deterministic for test
- DoublesUnion dUnion;
- DoublesSketch dSketch;
+ QuantilesDoublesSketch.setRandom(1); //make deterministic for test
+ QuantilesDoublesUnion dUnion;
+ QuantilesDoublesSketch dSketch;
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = arena.allocate(10_000_000);
- dUnion = DoublesUnion.builder().setMaxK(8).build(wseg, null);
+ dUnion = QuantilesDoublesUnion.builder().setMaxK(8).build(wseg, null);
for (int s = 0; s < numSketches; s++) { dUnion.union(sketchArr[s]); }
dSketch = dUnion.getResult(); //result is on heap
} catch (final Exception e) {
@@ -79,8 +79,8 @@ public void test() {
int hErrors = 0;
int dErrors = 0;
- final QuantilesDoublesSketchIterator hit = hSketch.iterator();
- final QuantilesDoublesSketchIterator dit = dSketch.iterator();
+ final QuantilesDoublesSketchIteratorAPI hit = hSketch.iterator();
+ final QuantilesDoublesSketchIteratorAPI dit = dSketch.iterator();
while (hit.next() && dit.next()) {
final double v = hit.getQuantile();
@@ -100,11 +100,11 @@ public void test() {
//println(dSketch.toString(true, true));
}
- private static UpdateDoublesSketch buildHeapSketch(final int k, final int n, final int valueLimit,
+ private static UpdatableQuantilesDoublesSketch buildHeapSketch(final int k, final int n, final int valueLimit,
final HashSet set) {
- final UpdateDoublesSketch uSk = DoublesSketch.builder().setK(k).build();
+ final UpdatableQuantilesDoublesSketch uSk = QuantilesDoublesSketch.builder().setK(k).build();
for (int i = 0; i < n; i++) {
- final double value = DoublesSketch.rand.nextInt(valueLimit) + 1;
+ final double value = QuantilesDoublesSketch.rand.nextInt(valueLimit) + 1;
uSk.update(value);
set.add(value);
}
diff --git a/src/test/java/org/apache/datasketches/quantiles/DirectCompactDoublesSketchTest.java b/src/test/java/org/apache/datasketches/quantiles/DirectCompactDoublesSketchTest.java
index 973b42846..4e8d405c8 100644
--- a/src/test/java/org/apache/datasketches/quantiles/DirectCompactDoublesSketchTest.java
+++ b/src/test/java/org/apache/datasketches/quantiles/DirectCompactDoublesSketchTest.java
@@ -38,14 +38,14 @@ public class DirectCompactDoublesSketchTest {
@BeforeMethod
public void setUp() {
- DoublesSketch.rand.setSeed(32749); // make sketches deterministic for testing
+ QuantilesDoublesSketch.rand.setSeed(32749); // make sketches deterministic for testing
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void wrapFromUpdateSketch() {
final int k = 4;
final int n = 27;
- final UpdateDoublesSketch qs = HeapUpdateDoublesSketchTest.buildAndLoadQS(k, n);
+ final UpdatableQuantilesDoublesSketch qs = HeapUpdateDoublesSketchTest.buildAndLoadQS(k, n);
final byte[] qsBytes = qs.toByteArray();
final MemorySegment qsSeg = MemorySegment.ofArray(qsBytes);
@@ -58,7 +58,7 @@ public void wrapFromUpdateSketch() {
public void createFromUnsortedUpdateSketch() {
final int k = 4;
final int n = 13;
- final UpdateDoublesSketch qs = DoublesSketch.builder().setK(k).build();
+ final UpdatableQuantilesDoublesSketch qs = QuantilesDoublesSketch.builder().setK(k).build();
for (int i = n; i > 0; --i) {
qs.update(i);
}
@@ -94,10 +94,10 @@ public void wrapFromCompactSketch() {
@Test
public void wrapEmptyCompactSketch() {
- final CompactDoublesSketch s1 = DoublesSketch.builder().build().compact();
+ final CompactQuantilesDoublesSketch s1 = QuantilesDoublesSketch.builder().build().compact();
final MemorySegment seg
= MemorySegment.ofBuffer(ByteBuffer.wrap(s1.toByteArray()).order(ByteOrder.nativeOrder()));
- final DoublesSketch s2 = DoublesSketch.wrap(seg);
+ final QuantilesDoublesSketch s2 = QuantilesDoublesSketch.wrap(seg);
assertTrue(s2.isEmpty());
assertEquals(s2.getN(), 0);
assertTrue(Double.isNaN(s2.isEmpty() ? Double.NaN : s2.getMinItem()));
@@ -141,7 +141,7 @@ static DirectCompactDoublesSketch buildAndLoadDCQS(final int k, final int n) {
}
static DirectCompactDoublesSketch buildAndLoadDCQS(final int k, final int n, final int startV) {
- final UpdateDoublesSketch qs = DoublesSketch.builder().setK(k).build();
+ final UpdatableQuantilesDoublesSketch qs = QuantilesDoublesSketch.builder().setK(k).build();
for (int i = 1; i <= n; i++) {
qs.update(startV + i);
}
diff --git a/src/test/java/org/apache/datasketches/quantiles/DirectQuantilesMemoryRequestTest.java b/src/test/java/org/apache/datasketches/quantiles/DirectQuantilesMemoryRequestTest.java
index 060e28f00..2b37b00a4 100644
--- a/src/test/java/org/apache/datasketches/quantiles/DirectQuantilesMemoryRequestTest.java
+++ b/src/test/java/org/apache/datasketches/quantiles/DirectQuantilesMemoryRequestTest.java
@@ -53,7 +53,7 @@ public void checkLimitedMemoryScenarios() { //Requesting application
//########## Receiving Application
// The receiving application has been given wseg to use for a sketch,
// but alas, it is not ultimately large enough.
- final UpdateDoublesSketch usk = DoublesSketch.builder().setK(k).build(wseg);
+ final UpdatableQuantilesDoublesSketch usk = QuantilesDoublesSketch.builder().setK(k).build(wseg);
assertTrue(usk.isEmpty());
//Load the sketch
@@ -84,7 +84,7 @@ public void checkGrowBaseBuf() {
try (Arena arena = Arena.ofConfined()) {
wseg = arena.allocate(initBytes);
println("Initial seg size: " + wseg.byteSize());
- final UpdateDoublesSketch usk1 = DoublesSketch.builder().setK(k).build(wseg);
+ final UpdatableQuantilesDoublesSketch usk1 = QuantilesDoublesSketch.builder().setK(k).build(wseg);
for (int i = 1; i <= u; i++) {
usk1.update(i);
}
@@ -105,7 +105,7 @@ public void checkGrowCombBuf() {
try (Arena arena = Arena.ofConfined()) {
wseg = arena.allocate(initBytes);
println("Initial seg size: " + wseg.byteSize());
- final UpdateDoublesSketch usk1 = DoublesSketch.builder().setK(k).build(wseg);
+ final UpdatableQuantilesDoublesSketch usk1 = QuantilesDoublesSketch.builder().setK(k).build(wseg);
for (int i = 1; i <= u; i++) {
usk1.update(i);
}
@@ -123,9 +123,9 @@ public void checkGrowCombBuf() {
@Test
public void checkUpdatableStorageBytes() {
final int k = 16;
- final int initBytes = DoublesSketch.getUpdatableStorageBytes(k, 1);
+ final int initBytes = QuantilesDoublesSketch.getUpdatableStorageBytes(k, 1);
println("Predicted Updatable Storage Bytes: " + initBytes);
- final UpdateDoublesSketch usk1 = DoublesSketch.builder().setK(k).build();
+ final UpdatableQuantilesDoublesSketch usk1 = QuantilesDoublesSketch.builder().setK(k).build();
usk1.update(1.0);
final byte[] uarr = usk1.toByteArray();
println("Actual Storage Bytes " + uarr.length);
@@ -138,14 +138,14 @@ public void checkUpdatableStorageBytes() {
public void checkGrowFromWrappedEmptySketch() {
final int k = 16;
final int n = 0;
- final int initBytes = DoublesSketch.getUpdatableStorageBytes(k, n); //empty: 8 bytes
- final UpdateDoublesSketch usk1 = DoublesSketch.builder().setK(k).build();
+ final int initBytes = QuantilesDoublesSketch.getUpdatableStorageBytes(k, n); //empty: 8 bytes
+ final UpdatableQuantilesDoublesSketch usk1 = QuantilesDoublesSketch.builder().setK(k).build();
final MemorySegment origSketchSeg = MemorySegment.ofArray(usk1.toByteArray()); //on heap
MemorySegment wseg;
try (Arena arena = Arena.ofConfined()) {
wseg = arena.allocate(initBytes); //off heap
MemorySegment.copy(origSketchSeg, 0, wseg, 0, initBytes);
- final UpdateDoublesSketch usk2 = DirectUpdateDoublesSketch.wrapInstance(wseg, null);
+ final UpdatableQuantilesDoublesSketch usk2 = DirectUpdateDoublesSketch.wrapInstance(wseg, null);
assertTrue(isSameResource(wseg, usk2.getMemorySegment()));
assertEquals(wseg.byteSize(), initBytes);
assertTrue(wseg.isNative());
diff --git a/src/test/java/org/apache/datasketches/quantiles/DirectUpdateDoublesSketchTest.java b/src/test/java/org/apache/datasketches/quantiles/DirectUpdateDoublesSketchTest.java
index 17c7b0384..088b4462c 100644
--- a/src/test/java/org/apache/datasketches/quantiles/DirectUpdateDoublesSketchTest.java
+++ b/src/test/java/org/apache/datasketches/quantiles/DirectUpdateDoublesSketchTest.java
@@ -40,16 +40,16 @@ public class DirectUpdateDoublesSketchTest {
@BeforeMethod
public void setUp() {
- DoublesSketch.rand.setSeed(32749); // make sketches deterministic for testing
+ QuantilesDoublesSketch.rand.setSeed(32749); // make sketches deterministic for testing
}
@Test
public void checkSmallMinMax () {
final int k = 32;
final int n = 8;
- final UpdateDoublesSketch qs1 = buildDQS(k, n);
- final UpdateDoublesSketch qs2 = buildDQS(k, n);
- final UpdateDoublesSketch qs3 = buildDQS(k, n);
+ final UpdatableQuantilesDoublesSketch qs1 = buildDQS(k, n);
+ final UpdatableQuantilesDoublesSketch qs2 = buildDQS(k, n);
+ final UpdatableQuantilesDoublesSketch qs3 = buildDQS(k, n);
for (int i = n; i >= 1; i--) {
qs1.update(i);
@@ -75,13 +75,13 @@ public void checkSmallMinMax () {
assertEquals(resultsA[1], 5.0);
assertEquals(resultsA[2], 8.0);
- final DoublesUnion union1 = DoublesUnion.heapify(qs1);
+ final QuantilesDoublesUnion union1 = QuantilesDoublesUnion.heapify(qs1);
union1.union(qs2);
- final DoublesSketch result1 = union1.getResult();
+ final QuantilesDoublesSketch result1 = union1.getResult();
- final DoublesUnion union2 = DoublesUnion.heapify(qs2);
+ final QuantilesDoublesUnion union2 = QuantilesDoublesUnion.heapify(qs2);
union2.union(qs3);
- final DoublesSketch result2 = union2.getResult();
+ final QuantilesDoublesSketch result2 = union2.getResult();
final double[] resultsB = result1.getQuantiles(queries, EXCLUSIVE);
printResults(resultsB);
@@ -101,9 +101,9 @@ static void printResults(final double[] results) {
@Test
public void wrapEmptyUpdateSketch() {
- final UpdateDoublesSketch s1 = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch s1 = QuantilesDoublesSketch.builder().build();
final MemorySegment seg = MemorySegment.ofBuffer(ByteBuffer.wrap(s1.toByteArray()).order(ByteOrder.nativeOrder()));
- final UpdateDoublesSketch s2 = DirectUpdateDoublesSketch.wrapInstance(seg, null);
+ final UpdatableQuantilesDoublesSketch s2 = DirectUpdateDoublesSketch.wrapInstance(seg, null);
assertTrue(s2.isEmpty());
assertEquals(s2.getN(), 0);
@@ -119,7 +119,7 @@ public void checkPutCombinedBuffer() {
final int k = PreambleUtil.DEFAULT_K;
final int cap = 32 + ((2 * k) << 3);
MemorySegment seg = MemorySegment.ofArray(new byte[cap]);
- final UpdateDoublesSketch qs = DoublesSketch.builder().setK(k).build(seg);
+ final UpdatableQuantilesDoublesSketch qs = QuantilesDoublesSketch.builder().setK(k).build(seg);
seg = qs.getMemorySegment();
assertEquals(seg.byteSize(), cap);
assertTrue(qs.isEmpty());
@@ -147,7 +147,7 @@ public void checkMisc() {
final int n = 48;
final int cap = 32 + ((2 * k) << 3);
MemorySegment seg = MemorySegment.ofArray(new byte[cap]);
- UpdateDoublesSketch qs = DoublesSketch.builder().setK(k).build(seg);
+ UpdatableQuantilesDoublesSketch qs = QuantilesDoublesSketch.builder().setK(k).build(seg);
seg = qs.getMemorySegment();
assertEquals(seg.byteSize(), cap);
double[] combBuf = qs.getCombinedBuffer();
@@ -213,14 +213,14 @@ public void checkCheckDirectSegCapacity() {
@Test
public void serializeDeserialize() {
- final int sizeBytes = DoublesSketch.getUpdatableStorageBytes(128, 2000);
+ final int sizeBytes = QuantilesDoublesSketch.getUpdatableStorageBytes(128, 2000);
final MemorySegment seg = MemorySegment.ofArray(new byte[sizeBytes]);
- final UpdateDoublesSketch sketch1 = DoublesSketch.builder().build(seg);
+ final UpdatableQuantilesDoublesSketch sketch1 = QuantilesDoublesSketch.builder().build(seg);
for (int i = 0; i < 1000; i++) {
sketch1.update(i);
}
- final UpdateDoublesSketch sketch2 = UpdateDoublesSketch.wrap(seg, null);
+ final UpdatableQuantilesDoublesSketch sketch2 = UpdatableQuantilesDoublesSketch.wrap(seg, null);
for (int i = 0; i < 1000; i++) {
sketch2.update(i + 1000);
}
@@ -230,7 +230,7 @@ public void serializeDeserialize() {
final byte[] arr2 = sketch2.toByteArray(false);
assertEquals(arr2.length, sketch2.getSerializedSizeBytes());
- final DoublesSketch sketch3 = DoublesSketch.writableWrap(MemorySegment.ofArray(arr2), null);
+ final QuantilesDoublesSketch sketch3 = QuantilesDoublesSketch.writableWrap(MemorySegment.ofArray(arr2), null);
assertEquals(sketch3.getMinItem(), 0.0);
assertEquals(sketch3.getMaxItem(), 1999.0);
assertEquals(sketch3.getQuantile(0.5), 1000.0, 10.0);
@@ -238,12 +238,12 @@ public void serializeDeserialize() {
@Test
public void mergeTest() {
- final DoublesSketch dqs1 = buildAndLoadDQS(128, 256);
- final DoublesSketch dqs2 = buildAndLoadDQS(128, 256, 256);
- final DoublesUnion union = DoublesUnion.builder().setMaxK(128).build();
+ final QuantilesDoublesSketch dqs1 = buildAndLoadDQS(128, 256);
+ final QuantilesDoublesSketch dqs2 = buildAndLoadDQS(128, 256, 256);
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().setMaxK(128).build();
union.union(dqs1);
union.union(dqs2);
- final DoublesSketch result = union.getResult();
+ final QuantilesDoublesSketch result = union.getResult();
final double median = result.getQuantile(0.5);
println("Median: " + median);
assertEquals(median, 258.0, .05 * 258);
@@ -254,10 +254,10 @@ public void checkSimplePropagateCarryDirect() {
final int k = 16;
final int n = k * 2;
- final int segBytes = DoublesSketch.getUpdatableStorageBytes(k, n);
+ final int segBytes = QuantilesDoublesSketch.getUpdatableStorageBytes(k, n);
final MemorySegment seg = MemorySegment.ofArray(new byte[segBytes]);
- final DoublesSketchBuilder bldr = DoublesSketch.builder();
- final UpdateDoublesSketch ds = bldr.setK(k).build(seg);
+ final QuantilesDoublesSketchBuilder bldr = QuantilesDoublesSketch.builder();
+ final UpdatableQuantilesDoublesSketch ds = bldr.setK(k).build(seg);
for (int i = 1; i <= n; i++) { // 1 ... n
ds.update(i);
}
@@ -275,9 +275,9 @@ public void checkSimplePropagateCarryDirect() {
public void getRankAndGetCdfConsistency() {
final int k = 128;
final int n = 1_000_000;
- final int segBytes = DoublesSketch.getUpdatableStorageBytes(k, n);
+ final int segBytes = QuantilesDoublesSketch.getUpdatableStorageBytes(k, n);
final MemorySegment seg = MemorySegment.ofArray(new byte[segBytes]);
- final UpdateDoublesSketch sketch = DoublesSketch.builder().build(seg);
+ final UpdatableQuantilesDoublesSketch sketch = QuantilesDoublesSketch.builder().build(seg);
final double[] values = new double[n];
for (int i = 0; i < n; i++) {
sketch.update(i);
@@ -289,22 +289,22 @@ public void getRankAndGetCdfConsistency() {
}
}
- static UpdateDoublesSketch buildAndLoadDQS(final int k, final int n) {
+ static UpdatableQuantilesDoublesSketch buildAndLoadDQS(final int k, final int n) {
return buildAndLoadDQS(k, n, 0);
}
- static UpdateDoublesSketch buildAndLoadDQS(final int k, final long n, final int startV) {
- final UpdateDoublesSketch qs = buildDQS(k, n);
+ static UpdatableQuantilesDoublesSketch buildAndLoadDQS(final int k, final long n, final int startV) {
+ final UpdatableQuantilesDoublesSketch qs = buildDQS(k, n);
for (long i = 1; i <= n; i++) {
qs.update(startV + i);
}
return qs;
}
- static UpdateDoublesSketch buildDQS(final int k, final long n) {
- int cap = DoublesSketch.getUpdatableStorageBytes(k, n);
+ static UpdatableQuantilesDoublesSketch buildDQS(final int k, final long n) {
+ int cap = QuantilesDoublesSketch.getUpdatableStorageBytes(k, n);
if (cap < (2 * k)) { cap = 2 * k; }
- final DoublesSketchBuilder bldr = new DoublesSketchBuilder();
+ final QuantilesDoublesSketchBuilder bldr = new QuantilesDoublesSketchBuilder();
bldr.setK(k);
return bldr.build(MemorySegment.ofArray(new byte[cap]));
}
diff --git a/src/test/java/org/apache/datasketches/quantiles/DoublesMiscTest.java b/src/test/java/org/apache/datasketches/quantiles/DoublesMiscTest.java
index 40b349d84..51d062564 100644
--- a/src/test/java/org/apache/datasketches/quantiles/DoublesMiscTest.java
+++ b/src/test/java/org/apache/datasketches/quantiles/DoublesMiscTest.java
@@ -36,7 +36,7 @@ public class DoublesMiscTest {
@Test
public void wrapAndUpdating() {
- final UpdateDoublesSketch sk1 = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch sk1 = QuantilesDoublesSketch.builder().build();
sk1.update(1);
sk1.update(2);
final byte[] bytes = sk1.toByteArray(false);
@@ -44,7 +44,7 @@ public void wrapAndUpdating() {
Assert.assertEquals(bytes.length, curBytes);
//convert to MemorySegment
final MemorySegment seg = MemorySegment.ofArray(bytes);
- final UpdateDoublesSketch sk2 = (UpdateDoublesSketch) DoublesSketch.writableWrap(seg, null);
+ final UpdatableQuantilesDoublesSketch sk2 = (UpdatableQuantilesDoublesSketch) QuantilesDoublesSketch.writableWrap(seg, null);
assertEquals(seg.byteSize(), curBytes);
sk2.update(3);
sk2.update(4);
@@ -52,16 +52,16 @@ public void wrapAndUpdating() {
assertEquals(sk2.getMaxItem(), 4.0);
//check the size for just 4 elements
final MemorySegment seg2 = sk2.getMemorySegment();
- assertEquals(seg2.byteSize(), DoublesSketch.getUpdatableStorageBytes(sk2.getK(), sk2.getN()));
+ assertEquals(seg2.byteSize(), QuantilesDoublesSketch.getUpdatableStorageBytes(sk2.getK(), sk2.getN()));
}
@Test
public void wrapCompactSketch() {
- final UpdateDoublesSketch s1 = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch s1 = QuantilesDoublesSketch.builder().build();
s1.update(1);
s1.update(2);
final MemorySegment seg = MemorySegment.ofArray(s1.compact().toByteArray());
- final DoublesSketch s2 = DoublesSketch.wrap(seg); // compact, so this is ok
+ final QuantilesDoublesSketch s2 = QuantilesDoublesSketch.wrap(seg); // compact, so this is ok
assertEquals(s2.getMinItem(), 1.0);
assertEquals(s2.getMaxItem(), 2.0);
assertEquals(s2.getN(), 2);
@@ -69,22 +69,22 @@ public void wrapCompactSketch() {
@Test
public void heapifySparseSketch() {
- final UpdateDoublesSketch s1 = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch s1 = QuantilesDoublesSketch.builder().build();
s1.update(1);
s1.update(2);
final MemorySegment seg = MemorySegment.ofArray(s1.toByteArray(false));
- final DoublesSketch s2 = DoublesSketch.heapify(seg);
+ final QuantilesDoublesSketch s2 = QuantilesDoublesSketch.heapify(seg);
assertEquals(s2.getMinItem(), 1.0);
assertEquals(s2.getMaxItem(), 2.0);
}
@Test
public void heapifyAndUpdateSparseSketch() {
- final UpdateDoublesSketch s1 = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch s1 = QuantilesDoublesSketch.builder().build();
s1.update(1);
s1.update(2);
final MemorySegment seg = MemorySegment.ofArray(s1.toByteArray(false));
- final UpdateDoublesSketch s2 = (UpdateDoublesSketch) DoublesSketch.heapify(seg);
+ final UpdatableQuantilesDoublesSketch s2 = (UpdatableQuantilesDoublesSketch) QuantilesDoublesSketch.heapify(seg);
s2.update(3);
assertEquals(s2.getMinItem(), 1.0);
assertEquals(s2.getMaxItem(), 3.0);
@@ -92,36 +92,36 @@ public void heapifyAndUpdateSparseSketch() {
@Test
public void heapifyCompactSketch() {
- final UpdateDoublesSketch s1 = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch s1 = QuantilesDoublesSketch.builder().build();
s1.update(1);
s1.update(2);
final MemorySegment seg = MemorySegment.ofArray(s1.toByteArray(true));
- final DoublesSketch s2 = DoublesSketch.heapify(seg);
+ final QuantilesDoublesSketch s2 = QuantilesDoublesSketch.heapify(seg);
assertEquals(s2.getMinItem(), 1.0);
assertEquals(s2.getMaxItem(), 2.0);
}
@Test
public void heapifyEmptyUpdateSketch() {
- final UpdateDoublesSketch s1 = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch s1 = QuantilesDoublesSketch.builder().build();
final MemorySegment seg = MemorySegment.ofArray(s1.toByteArray());
- final DoublesSketch s2 = DoublesSketch.heapify(seg);
+ final QuantilesDoublesSketch s2 = QuantilesDoublesSketch.heapify(seg);
assertTrue(s2.isEmpty());
}
@Test
public void heapifyEmptyCompactSketch() {
- final CompactDoublesSketch s1 = DoublesSketch.builder().build().compact();
+ final CompactQuantilesDoublesSketch s1 = QuantilesDoublesSketch.builder().build().compact();
final MemorySegment seg = MemorySegment.ofArray(s1.toByteArray());
- final DoublesSketch s2 = DoublesSketch.heapify(seg);
+ final QuantilesDoublesSketch s2 = QuantilesDoublesSketch.heapify(seg);
assertTrue(s2.isEmpty());
}
@Test
public void wrapEmptyUpdateSketch() {
- final UpdateDoublesSketch s1 = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch s1 = QuantilesDoublesSketch.builder().build();
final MemorySegment seg = MemorySegment.ofArray(s1.toByteArray()).asReadOnly();
- final UpdateDoublesSketch s2 = (UpdateDoublesSketch) DoublesSketch.writableWrap(seg, null);
+ final UpdatableQuantilesDoublesSketch s2 = (UpdatableQuantilesDoublesSketch) QuantilesDoublesSketch.writableWrap(seg, null);
assertTrue(s2.isEmpty());
// ensure the various put calls fail
@@ -185,59 +185,59 @@ public void wrapEmptyUpdateSketch() {
@Test
public void wrapEmptyCompactSketch() {
- final UpdateDoublesSketch s1 = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch s1 = QuantilesDoublesSketch.builder().build();
final MemorySegment seg = MemorySegment.ofArray(s1.compact().toByteArray());
- final DoublesSketch s2 = DoublesSketch.wrap(seg); // compact, so this is ok
+ final QuantilesDoublesSketch s2 = QuantilesDoublesSketch.wrap(seg); // compact, so this is ok
Assert.assertTrue(s2.isEmpty());
}
@Test
public void heapifyUnionFromSparse() {
- final UpdateDoublesSketch s1 = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch s1 = QuantilesDoublesSketch.builder().build();
s1.update(1);
s1.update(2);
final MemorySegment seg = MemorySegment.ofArray(s1.toByteArray(false));
- final DoublesUnion u = DoublesUnion.heapify(seg);
+ final QuantilesDoublesUnion u = QuantilesDoublesUnion.heapify(seg);
u.update(3);
- final DoublesSketch s2 = u.getResult();
+ final QuantilesDoublesSketch s2 = u.getResult();
Assert.assertEquals(s2.getMinItem(), 1.0);
Assert.assertEquals(s2.getMaxItem(), 3.0);
}
@Test
public void initializeUnionFromCompactSegment() {
- final UpdateDoublesSketch s1 = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch s1 = QuantilesDoublesSketch.builder().build();
s1.update(1);
s1.update(2);
final MemorySegment seg = MemorySegment.ofArray(s1.toByteArray(true));
- final DoublesUnion u = DoublesUnion.heapify(seg);
+ final QuantilesDoublesUnion u = QuantilesDoublesUnion.heapify(seg);
u.update(3);
- final DoublesSketch s2 = u.getResult();
+ final QuantilesDoublesSketch s2 = u.getResult();
Assert.assertEquals(s2.getMinItem(), 1.0);
Assert.assertEquals(s2.getMaxItem(), 3.0);
}
@Test
public void unionFromUpdatableSegment() {
- final UpdateDoublesSketch s1 = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch s1 = QuantilesDoublesSketch.builder().build();
s1.update(1);
s1.update(2);
final MemorySegment seg = MemorySegment.ofArray(s1.toByteArray(false));
- final DoublesUnion u = DoublesUnion.wrap(seg);
+ final QuantilesDoublesUnion u = QuantilesDoublesUnion.wrap(seg);
u.update(3);
- final DoublesSketch s2 = u.getResult();
+ final QuantilesDoublesSketch s2 = u.getResult();
Assert.assertEquals(s2.getMinItem(), 1.0);
Assert.assertEquals(s2.getMaxItem(), 3.0);
}
@Test
public void wrapUnionFromHeap() {
- final UpdateDoublesSketch s1 = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch s1 = QuantilesDoublesSketch.builder().build();
s1.update(1);
s1.update(2);
final MemorySegment seg = MemorySegment.ofArray(s1.toByteArray(false)).asReadOnly();
try {
- final DoublesUnion u = DoublesUnion.wrap(seg, null);
+ final QuantilesDoublesUnion u = QuantilesDoublesUnion.wrap(seg, null);
} catch (final SketchesReadOnlyException e) {
//expected
}
@@ -246,11 +246,11 @@ public void wrapUnionFromHeap() {
@Test(expectedExceptions = SketchesArgumentException.class)
public void wrapUnionFromCompact() {
- final UpdateDoublesSketch s1 = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch s1 = QuantilesDoublesSketch.builder().build();
s1.update(1);
s1.update(2);
final MemorySegment seg = MemorySegment.ofArray(s1.toByteArray(true));
- DoublesUnion.wrap(seg, null); //compact seg
+ QuantilesDoublesUnion.wrap(seg, null); //compact seg
fail();
}
diff --git a/src/test/java/org/apache/datasketches/quantiles/DoublesSketchBuilderTest.java b/src/test/java/org/apache/datasketches/quantiles/DoublesSketchBuilderTest.java
index 55c29fc28..c6759ac03 100644
--- a/src/test/java/org/apache/datasketches/quantiles/DoublesSketchBuilderTest.java
+++ b/src/test/java/org/apache/datasketches/quantiles/DoublesSketchBuilderTest.java
@@ -32,19 +32,19 @@ public class DoublesSketchBuilderTest {
@Test
public void checkBuilder() {
final int k = 256; //default is 128
- DoublesSketchBuilder bldr = DoublesSketch.builder();
+ QuantilesDoublesSketchBuilder bldr = QuantilesDoublesSketch.builder();
bldr.setK(k);
assertEquals(bldr.getK(), k); //confirms new k
println(bldr.toString());
- final int bytes = DoublesSketch.getUpdatableStorageBytes(k, 0);
+ final int bytes = QuantilesDoublesSketch.getUpdatableStorageBytes(k, 0);
final byte[] byteArr = new byte[bytes];
final MemorySegment seg = MemorySegment.ofArray(byteArr);
- final DoublesSketch ds = bldr.build(seg);
+ final QuantilesDoublesSketch ds = bldr.build(seg);
assertTrue(ds.hasMemorySegment());
assertFalse(ds.isOffHeap());
println(bldr.toString());
- bldr = DoublesSketch.builder();
+ bldr = QuantilesDoublesSketch.builder();
assertEquals(bldr.getK(), PreambleUtil.DEFAULT_K);
}
diff --git a/src/test/java/org/apache/datasketches/quantiles/DoublesSketchIteratorTest.java b/src/test/java/org/apache/datasketches/quantiles/DoublesSketchIteratorTest.java
index e10e72351..a84c0f068 100644
--- a/src/test/java/org/apache/datasketches/quantiles/DoublesSketchIteratorTest.java
+++ b/src/test/java/org/apache/datasketches/quantiles/DoublesSketchIteratorTest.java
@@ -19,7 +19,7 @@
package org.apache.datasketches.quantiles;
-import org.apache.datasketches.quantilescommon.QuantilesDoublesSketchIterator;
+import org.apache.datasketches.quantilescommon.QuantilesDoublesSketchIteratorAPI;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -27,16 +27,16 @@ public class DoublesSketchIteratorTest {
@Test
public void emptySketch() {
- DoublesSketch sketch = DoublesSketch.builder().build();
- QuantilesDoublesSketchIterator it = sketch.iterator();
+ QuantilesDoublesSketch sketch = QuantilesDoublesSketch.builder().build();
+ QuantilesDoublesSketchIteratorAPI it = sketch.iterator();
Assert.assertFalse(it.next());
}
@Test
public void oneItemSketch() {
- UpdateDoublesSketch sketch = DoublesSketch.builder().build();
+ UpdatableQuantilesDoublesSketch sketch = QuantilesDoublesSketch.builder().build();
sketch.update(0);
- QuantilesDoublesSketchIterator it = sketch.iterator();
+ QuantilesDoublesSketchIteratorAPI it = sketch.iterator();
Assert.assertTrue(it.next());
Assert.assertEquals(it.getQuantile(), 0.0);
Assert.assertEquals(it.getWeight(), 1);
@@ -46,11 +46,11 @@ public void oneItemSketch() {
@Test
public void bigSketches() {
for (int n = 1000; n < 100000; n += 2000) {
- UpdateDoublesSketch sketch = DoublesSketch.builder().build();
+ UpdatableQuantilesDoublesSketch sketch = QuantilesDoublesSketch.builder().build();
for (int i = 0; i < n; i++) {
sketch.update(i);
}
- QuantilesDoublesSketchIterator it = sketch.iterator();
+ QuantilesDoublesSketchIteratorAPI it = sketch.iterator();
int count = 0;
int weight = 0;
while (it.next()) {
diff --git a/src/test/java/org/apache/datasketches/quantiles/DoublesSketchTest.java b/src/test/java/org/apache/datasketches/quantiles/DoublesSketchTest.java
index bcbb16cc2..48d361ed8 100644
--- a/src/test/java/org/apache/datasketches/quantiles/DoublesSketchTest.java
+++ b/src/test/java/org/apache/datasketches/quantiles/DoublesSketchTest.java
@@ -39,11 +39,11 @@ public class DoublesSketchTest {
@Test
public void heapToDirect() {
- final UpdateDoublesSketch heapSketch = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch heapSketch = QuantilesDoublesSketch.builder().build();
for (int i = 0; i < 1000; i++) {
heapSketch.update(i);
}
- final DoublesSketch directSketch = DoublesSketch.writableWrap(MemorySegment.ofArray(heapSketch.toByteArray(false)), null);
+ final QuantilesDoublesSketch directSketch = QuantilesDoublesSketch.writableWrap(MemorySegment.ofArray(heapSketch.toByteArray(false)), null);
assertEquals(directSketch.getMinItem(), 0.0);
assertEquals(directSketch.getMaxItem(), 999.0);
@@ -53,12 +53,12 @@ public void heapToDirect() {
@Test
public void directToHeap() {
final int sizeBytes = 10000;
- final UpdateDoublesSketch directSketch = DoublesSketch.builder().build(MemorySegment.ofArray(new byte[sizeBytes]));
+ final UpdatableQuantilesDoublesSketch directSketch = QuantilesDoublesSketch.builder().build(MemorySegment.ofArray(new byte[sizeBytes]));
for (int i = 0; i < 1000; i++) {
directSketch.update(i);
}
- UpdateDoublesSketch heapSketch;
- heapSketch = (UpdateDoublesSketch) DoublesSketch.heapify(MemorySegment.ofArray(directSketch.toByteArray()));
+ UpdatableQuantilesDoublesSketch heapSketch;
+ heapSketch = (UpdatableQuantilesDoublesSketch) QuantilesDoublesSketch.heapify(MemorySegment.ofArray(directSketch.toByteArray()));
for (int i = 0; i < 1000; i++) {
heapSketch.update(i + 1000);
}
@@ -69,7 +69,7 @@ public void directToHeap() {
@Test
public void checkToByteArray() {
- final UpdateDoublesSketch ds = DoublesSketch.builder().build(); //k = 128
+ final UpdatableQuantilesDoublesSketch ds = QuantilesDoublesSketch.builder().build(); //k = 128
ds.update(1);
ds.update(2);
final byte[] arr = ds.toByteArray(false);
@@ -83,8 +83,8 @@ public void checkToByteArray() {
* @param sketch1 input sketch 1
* @param sketch2 input sketch 2
*/
- static void testSketchEquality(final DoublesSketch sketch1,
- final DoublesSketch sketch2) {
+ static void testSketchEquality(final QuantilesDoublesSketch sketch1,
+ final QuantilesDoublesSketch sketch2) {
assertEquals(sketch1.getK(), sketch2.getK());
assertEquals(sketch1.getN(), sketch2.getN());
assertEquals(sketch1.getBitPattern(), sketch2.getBitPattern());
@@ -118,19 +118,19 @@ public void checkIsSameResource() {
final MemorySegment seg = MemorySegment.ofArray(new byte[(k*16) +24]);
final MemorySegment cseg = MemorySegment.ofArray(new byte[8]);
final DirectUpdateDoublesSketch duds =
- (DirectUpdateDoublesSketch) DoublesSketch.builder().setK(k).build(seg);
+ (DirectUpdateDoublesSketch) QuantilesDoublesSketch.builder().setK(k).build(seg);
assertTrue(duds.isSameResource(seg));
final DirectCompactDoublesSketch dcds = (DirectCompactDoublesSketch) duds.compact(cseg);
assertTrue(dcds.isSameResource(cseg));
- final UpdateDoublesSketch uds = DoublesSketch.builder().setK(k).build();
+ final UpdatableQuantilesDoublesSketch uds = QuantilesDoublesSketch.builder().setK(k).build();
assertFalse(uds.isSameResource(seg));
}
@Test
public void checkEmptyExceptions() {
final int k = 16;
- final UpdateDoublesSketch uds = DoublesSketch.builder().setK(k).build();
+ final UpdatableQuantilesDoublesSketch uds = QuantilesDoublesSketch.builder().setK(k).build();
try { uds.getMaxItem(); fail(); } catch (final IllegalArgumentException e) {}
try { uds.getMinItem(); fail(); } catch (final IllegalArgumentException e) {}
try { uds.getRank(1.0); fail(); } catch (final IllegalArgumentException e) {}
@@ -142,7 +142,7 @@ public void checkEmptyExceptions() {
public void directSketchShouldMoveOntoHeapEventually() {
final Arena arena = Arena.ofConfined();
final MemorySegment wseg = arena.allocate(1000);
- final UpdateDoublesSketch sketch = DoublesSketch.builder().build(wseg);
+ final UpdatableQuantilesDoublesSketch sketch = QuantilesDoublesSketch.builder().build(wseg);
Assert.assertTrue(sketch.isSameResource(wseg));
for (int i = 0; i < 1000; i++) {
sketch.update(i);
@@ -157,7 +157,7 @@ public void directSketchShouldMoveOntoHeapEventually2() {
final Arena arena = Arena.ofConfined();
int i = 0;
final MemorySegment wseg = arena.allocate(50);
- final UpdateDoublesSketch sketch = DoublesSketch.builder().build(wseg);
+ final UpdatableQuantilesDoublesSketch sketch = QuantilesDoublesSketch.builder().build(wseg);
Assert.assertTrue(sketch.isSameResource(wseg));
for (; i < 1000; i++) {
if (sketch.isSameResource(wseg)) {
@@ -175,7 +175,7 @@ public void directSketchShouldMoveOntoHeapEventually2() {
public void checkEmptyDirect() {
try (Arena arena = Arena.ofConfined()) {
final MemorySegment wseg = arena.allocate(1000);
- final UpdateDoublesSketch sketch = DoublesSketch.builder().build(wseg);
+ final UpdatableQuantilesDoublesSketch sketch = QuantilesDoublesSketch.builder().build(wseg);
sketch.toByteArray(); //exercises a specific path
} catch (final Exception e) {
throw new RuntimeException(e);
@@ -184,7 +184,7 @@ public void checkEmptyDirect() {
@Test
public void sortedView() {
- final UpdateDoublesSketch sketch = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch sketch = QuantilesDoublesSketch.builder().build();
sketch.update(3);
sketch.update(1);
sketch.update(2);
@@ -209,7 +209,7 @@ public void sortedView() {
@Test
public void checkRankLBError() {
- final UpdateDoublesSketch sk = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch sk = QuantilesDoublesSketch.builder().build();
final double eps = sk.getNormalizedRankError(false);
println("" + (2 * eps));
for (int i = 1; i <= 10000; i++) { sk.update(i); }
@@ -220,7 +220,7 @@ public void checkRankLBError() {
@Test
public void checkRankUBError() {
- final UpdateDoublesSketch sk = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch sk = QuantilesDoublesSketch.builder().build();
final double eps = sk.getNormalizedRankError(false);
println(""+ (2 * eps));
for (int i = 1; i <= 10000; i++) { sk.update(i); }
@@ -231,7 +231,7 @@ public void checkRankUBError() {
@Test
public void checkGetRanks() {
- final UpdateDoublesSketch sk = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch sk = QuantilesDoublesSketch.builder().build();
for (int i = 1; i <= 10000; i++) { sk.update(i); }
final double[] qArr = {1000,2000,3000,4000,5000,6000,7000,8000,9000,10000};
final double[] ranks = sk.getRanks(qArr, INCLUSIVE);
@@ -246,7 +246,7 @@ public void checkGetRanks() {
@Test
public void checkToStringHeap() {
- final DoublesSketch sk = DoublesSketch.builder().setK(8).build();
+ final QuantilesDoublesSketch sk = QuantilesDoublesSketch.builder().setK(8).build();
final int n = 32;
for (int i = 1; i <= n; i++) {
final double item = i;
diff --git a/src/test/java/org/apache/datasketches/quantiles/DoublesUnionBuilderTest.java b/src/test/java/org/apache/datasketches/quantiles/DoublesUnionBuilderTest.java
index d2f1d6e9f..d41d79051 100644
--- a/src/test/java/org/apache/datasketches/quantiles/DoublesUnionBuilderTest.java
+++ b/src/test/java/org/apache/datasketches/quantiles/DoublesUnionBuilderTest.java
@@ -30,7 +30,7 @@ public class DoublesUnionBuilderTest {
@Test
public void checkBuilds() {
- final UpdateDoublesSketch qs1 = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch qs1 = QuantilesDoublesSketch.builder().build();
for (int i=0; i<1000; i++) { qs1.update(i); }
final int bytes = qs1.getCurrentCompactSerializedSizeBytes();
@@ -38,16 +38,16 @@ public void checkBuilds() {
qs1.putIntoMemorySegment(dstSeg);
final MemorySegment srcSeg = dstSeg;
- final DoublesUnionBuilder bldr = new DoublesUnionBuilder();
+ final QuantilesDoublesUnionBuilder bldr = new QuantilesDoublesUnionBuilder();
bldr.setMaxK(128);
- DoublesUnion union = bldr.build(); //virgin union
+ QuantilesDoublesUnion union = bldr.build(); //virgin union
- union = DoublesUnion.heapify(srcSeg);
- final DoublesSketch qs2 = union.getResult();
+ union = QuantilesDoublesUnion.heapify(srcSeg);
+ final QuantilesDoublesSketch qs2 = union.getResult();
assertEquals(qs1.getCurrentCompactSerializedSizeBytes(), qs2.getCurrentCompactSerializedSizeBytes());
- union = DoublesUnion.heapify(qs2);
- final DoublesSketch qs3 = union.getResult();
+ union = QuantilesDoublesUnion.heapify(qs2);
+ final QuantilesDoublesSketch qs3 = union.getResult();
assertEquals(qs2.getCurrentCompactSerializedSizeBytes(), qs3.getCurrentCompactSerializedSizeBytes());
assertFalse(qs2 == qs3);
}
@@ -55,7 +55,7 @@ public void checkBuilds() {
@Test
public void checkDeprecated1() {
- final UpdateDoublesSketch qs1 = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch qs1 = QuantilesDoublesSketch.builder().build();
for (int i=0; i<1000; i++) {
qs1.update(i);
}
@@ -65,17 +65,17 @@ public void checkDeprecated1() {
qs1.putIntoMemorySegment(dstSeg);
final MemorySegment srcSeg = dstSeg;
- final DoublesUnionBuilder bldr = new DoublesUnionBuilder();
+ final QuantilesDoublesUnionBuilder bldr = new QuantilesDoublesUnionBuilder();
bldr.setMaxK(128);
- DoublesUnion union = bldr.build(); //virgin union
+ QuantilesDoublesUnion union = bldr.build(); //virgin union
- union = DoublesUnion.heapify(srcSeg); //heapify
- final DoublesSketch qs2 = union.getResult();
+ union = QuantilesDoublesUnion.heapify(srcSeg); //heapify
+ final QuantilesDoublesSketch qs2 = union.getResult();
assertEquals(qs1.getCurrentCompactSerializedSizeBytes(), qs2.getCurrentCompactSerializedSizeBytes());
assertEquals(qs1.getCurrentUpdatableSerializedSizeBytes(), qs2.getCurrentUpdatableSerializedSizeBytes());
- union = DoublesUnion.heapify(qs2); //heapify again
- final DoublesSketch qs3 = union.getResult();
+ union = QuantilesDoublesUnion.heapify(qs2); //heapify again
+ final QuantilesDoublesSketch qs3 = union.getResult();
assertEquals(qs2.getCurrentCompactSerializedSizeBytes(), qs3.getCurrentCompactSerializedSizeBytes());
assertEquals(qs2.getCurrentUpdatableSerializedSizeBytes(), qs3.getCurrentUpdatableSerializedSizeBytes());
assertFalse(qs2 == qs3); //different objects
diff --git a/src/test/java/org/apache/datasketches/quantiles/DoublesUnionImplTest.java b/src/test/java/org/apache/datasketches/quantiles/DoublesUnionImplTest.java
index 094b786d3..3c64cd87a 100644
--- a/src/test/java/org/apache/datasketches/quantiles/DoublesUnionImplTest.java
+++ b/src/test/java/org/apache/datasketches/quantiles/DoublesUnionImplTest.java
@@ -38,11 +38,11 @@ public class DoublesUnionImplTest {
@Test
public void checkUnion1() {
- DoublesSketch result;
- final DoublesSketch qs1;
- final DoublesUnion union = DoublesUnion.builder().setMaxK(256).build(); //virgin 256
+ QuantilesDoublesSketch result;
+ final QuantilesDoublesSketch qs1;
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().setMaxK(256).build(); //virgin 256
- final DoublesSketch qs0 = buildAndLoadQS(256, 500);
+ final QuantilesDoublesSketch qs0 = buildAndLoadQS(256, 500);
union.union(qs0); //me = null, that = valid, exact
result = union.getResult();
assertEquals(result.getN(), 500);
@@ -58,7 +58,7 @@ public void checkUnion1() {
assertEquals(result.getK(), 256);
//check merge me = valid, that = valid, both K's the same
- final DoublesSketch qs2 = buildAndLoadQS(256, 1000, 1000); //add 1000
+ final QuantilesDoublesSketch qs2 = buildAndLoadQS(256, 1000, 1000); //add 1000
union.union(qs2);
result = union.getResult();
assertEquals(result.getN(), 2000);
@@ -67,11 +67,11 @@ public void checkUnion1() {
@Test
public void checkUnion1Direct() {
- DoublesSketch result;
- final DoublesSketch qs1;
- final DoublesUnion union = DoublesUnion.builder().setMaxK(256).build(); //virgin 256
+ QuantilesDoublesSketch result;
+ final QuantilesDoublesSketch qs1;
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().setMaxK(256).build(); //virgin 256
- final DoublesSketch qs0 = buildAndLoadDQS(256, 500);
+ final QuantilesDoublesSketch qs0 = buildAndLoadDQS(256, 500);
union.union(qs0); //me = null, that = valid, exact
result = union.getResult();
assertEquals(result.getN(), 500);
@@ -87,7 +87,7 @@ public void checkUnion1Direct() {
assertEquals(result.getK(), 256);
//check merge me = valid, that = valid, both K's the same
- final DoublesSketch qs2 = buildAndLoadDQS(256, 1000, 1000).compact(); //add 1000
+ final QuantilesDoublesSketch qs2 = buildAndLoadDQS(256, 1000, 1000).compact(); //add 1000
union.union(qs2);
result = union.getResult();
assertEquals(result.getN(), 2000);
@@ -96,19 +96,19 @@ public void checkUnion1Direct() {
@Test
public void checkUnion2() {
- final DoublesSketch qs1 = buildAndLoadQS(256, 1000).compact();
- final DoublesSketch qs2 = buildAndLoadQS(128, 1000);
- final DoublesUnion union = DoublesUnion.builder().setMaxK(256).build(); //virgin 256
+ final QuantilesDoublesSketch qs1 = buildAndLoadQS(256, 1000).compact();
+ final QuantilesDoublesSketch qs2 = buildAndLoadQS(128, 1000);
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().setMaxK(256).build(); //virgin 256
assertEquals(union.getEffectiveK(), 256);
union.union(qs1);
- final DoublesSketch res1 = union.getResult();
+ final QuantilesDoublesSketch res1 = union.getResult();
//println(res1.toString());
assertEquals(res1.getN(), 1000);
assertEquals(res1.getK(), 256);
union.union(qs2);
- final DoublesSketch res2 = union.getResult();
+ final QuantilesDoublesSketch res2 = union.getResult();
assertEquals(res2.getN(), 2000);
assertEquals(res2.getK(), 128);
assertEquals(union.getEffectiveK(), 128);
@@ -117,19 +117,19 @@ public void checkUnion2() {
@Test
public void checkUnion2Direct() {
- final DoublesSketch qs1 = buildAndLoadDQS(256, 1000);
- final DoublesSketch qs2 = buildAndLoadDQS(128, 1000);
- final DoublesUnion union = DoublesUnion.builder().setMaxK(256).build(); //virgin 256
+ final QuantilesDoublesSketch qs1 = buildAndLoadDQS(256, 1000);
+ final QuantilesDoublesSketch qs2 = buildAndLoadDQS(128, 1000);
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().setMaxK(256).build(); //virgin 256
assertEquals(union.getEffectiveK(), 256);
union.union(qs1);
- final DoublesSketch res1 = union.getResult();
+ final QuantilesDoublesSketch res1 = union.getResult();
//println(res1.toString());
assertEquals(res1.getN(), 1000);
assertEquals(res1.getK(), 256);
union.union(qs2);
- final DoublesSketch res2 = union.getResult();
+ final QuantilesDoublesSketch res2 = union.getResult();
assertEquals(res2.getN(), 2000);
assertEquals(res2.getK(), 128);
assertEquals(union.getEffectiveK(), 128);
@@ -142,14 +142,14 @@ public void checkUnion3() { //Union is direct, empty and with larger K than vali
final int n1 = 2 * k1;
final int k2 = 256;
final int n2 = 2000;
- final DoublesSketch sketchIn1 = buildAndLoadQS(k1, n1);
- final int bytes = DoublesSketch.getUpdatableStorageBytes(k2, n2);//just for size
+ final QuantilesDoublesSketch sketchIn1 = buildAndLoadQS(k1, n1);
+ final int bytes = QuantilesDoublesSketch.getUpdatableStorageBytes(k2, n2);//just for size
final MemorySegment seg = MemorySegment.ofArray(new byte[bytes]);
- final DoublesUnion union = DoublesUnion.builder().setMaxK(k2).build(seg, null); //virgin 256
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().setMaxK(k2).build(seg, null); //virgin 256
union.union(sketchIn1);
assertEquals(union.getMaxK(), k2);
assertEquals(union.getEffectiveK(), k1);
- final DoublesSketch result = union.getResult();
+ final QuantilesDoublesSketch result = union.getResult();
assertEquals(result.getMaxItem(), n1, 0.0);
assertEquals(result.getMinItem(), 1.0, 0.0);
assertEquals(result.getK(), k1);
@@ -161,14 +161,14 @@ public void checkUnion3Direct() { //Union is direct, empty and with larger K tha
final int n1 = 2 * k1;
final int k2 = 256;
final int n2 = 2000;
- final DoublesSketch sketchIn1 = buildAndLoadDQS(k1, n1);
- final int bytes = DoublesSketch.getUpdatableStorageBytes(k2, n2);//just for size
+ final QuantilesDoublesSketch sketchIn1 = buildAndLoadDQS(k1, n1);
+ final int bytes = QuantilesDoublesSketch.getUpdatableStorageBytes(k2, n2);//just for size
final MemorySegment seg = MemorySegment.ofArray(new byte[bytes]);
- final DoublesUnion union = DoublesUnion.builder().setMaxK(k2).build(seg, null); //virgin 256
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().setMaxK(k2).build(seg, null); //virgin 256
union.union(sketchIn1);
assertEquals(union.getMaxK(), k2);
assertEquals(union.getEffectiveK(), k1);
- final DoublesSketch result = union.getResult();
+ final QuantilesDoublesSketch result = union.getResult();
assertEquals(result.getMaxItem(), n1, 0.0);
assertEquals(result.getMinItem(), 1.0, 0.0);
assertEquals(result.getK(), k1);
@@ -180,25 +180,25 @@ public void checkUnion4() { //Union is direct, valid and with larger K than vali
final int n1 = 2 * k1; //16
final int k2 = 4;
final int n2 = 2 * k2; //8
- final int bytes = DoublesSketch.getUpdatableStorageBytes(256, 50);//just for size
+ final int bytes = QuantilesDoublesSketch.getUpdatableStorageBytes(256, 50);//just for size
final MemorySegment skSeg = MemorySegment.ofArray(new byte[bytes]);
- final UpdateDoublesSketch sketchIn1 = DoublesSketch.builder().setK(k1).build(skSeg);
+ final UpdatableQuantilesDoublesSketch sketchIn1 = QuantilesDoublesSketch.builder().setK(k1).build(skSeg);
for (int i = 0; i < n1; i++) { sketchIn1.update(i + 1); }
final MemorySegment uSeg = MemorySegment.ofArray(new byte[bytes]);
- final DoublesUnion union = DoublesUnion.builder().setMaxK(256).build(uSeg, null); //virgin 256
- //DoublesUnion union = DoublesUnion.builder().setMaxK(256).build(); //virgin 256
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().setMaxK(256).build(uSeg, null); //virgin 256
+ //QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().setMaxK(256).build(); //virgin 256
union.union(sketchIn1);
assertEquals(union.getResult().getN(), n1);
assertEquals(union.getMaxK(), 256);
assertEquals(union.getEffectiveK(), k1);
- DoublesSketch result = union.getResult();
+ QuantilesDoublesSketch result = union.getResult();
assertEquals(result.getN(), 16);
assertEquals(result.getMaxItem(), n1, 0.0);
assertEquals(result.getMinItem(), 1.0, 0.0);
assertEquals(result.getK(), k1);
- final DoublesSketch sketchIn2 = buildAndLoadQS(k2, n2, 17);
+ final QuantilesDoublesSketch sketchIn2 = buildAndLoadQS(k2, n2, 17);
union.reset();
union.union(sketchIn2);
result = union.getResult();
@@ -213,24 +213,24 @@ public void checkUnion4Direct() { //Union is direct, valid and with larger K tha
final int n1 = 2 * k1; //16
final int k2 = 4;
final int n2 = 2 * k2; //8
- final int bytes = DoublesSketch.getUpdatableStorageBytes(256, 50);//just for size
+ final int bytes = QuantilesDoublesSketch.getUpdatableStorageBytes(256, 50);//just for size
final MemorySegment skSeg = MemorySegment.ofArray(new byte[bytes]);
- final UpdateDoublesSketch sketchIn1 = DoublesSketch.builder().setK(k1).build(skSeg);
+ final UpdatableQuantilesDoublesSketch sketchIn1 = QuantilesDoublesSketch.builder().setK(k1).build(skSeg);
for (int i = 0; i < n1; i++) { sketchIn1.update(i + 1); }
final MemorySegment uSeg = MemorySegment.ofArray(new byte[bytes]);
- final DoublesUnion union = DoublesUnion.builder().setMaxK(256).build(uSeg, null); //virgin 256
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().setMaxK(256).build(uSeg, null); //virgin 256
union.union(sketchIn1);
assertEquals(union.getResult().getN(), n1);
assertEquals(union.getMaxK(), 256);
assertEquals(union.getEffectiveK(), k1);
- DoublesSketch result = union.getResult();
+ QuantilesDoublesSketch result = union.getResult();
assertEquals(result.getN(), 16);
assertEquals(result.getMaxItem(), n1, 0.0);
assertEquals(result.getMinItem(), 1.0, 0.0);
assertEquals(result.getK(), k1);
- final DoublesSketch sketchIn2 = buildAndLoadDQS(k2, n2, 17);
+ final QuantilesDoublesSketch sketchIn2 = buildAndLoadDQS(k2, n2, 17);
union.reset();
union.union(sketchIn2);
result = union.getResult();
@@ -245,25 +245,25 @@ public void checkUnion4DirectCompact() {
final int n1 = 2 * k1; //16
final int k2 = 4;
final int n2 = 5 * k2; //8
- final int bytes = DoublesSketch.getUpdatableStorageBytes(256, 50);//just for size
+ final int bytes = QuantilesDoublesSketch.getUpdatableStorageBytes(256, 50);//just for size
final MemorySegment skSeg = MemorySegment.ofArray(new byte[bytes]);
- final UpdateDoublesSketch sketchIn0 = DoublesSketch.builder().setK(k1).build(skSeg);
+ final UpdatableQuantilesDoublesSketch sketchIn0 = QuantilesDoublesSketch.builder().setK(k1).build(skSeg);
for (int i = 0; i < n1; i++) { sketchIn0.update(i + 1); }
- final CompactDoublesSketch sketchIn1 = sketchIn0.compact();
+ final CompactQuantilesDoublesSketch sketchIn1 = sketchIn0.compact();
final MemorySegment uSeg = MemorySegment.ofArray(new byte[bytes]);
- final DoublesUnion union = DoublesUnion.builder().setMaxK(256).build(uSeg, null); //virgin 256
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().setMaxK(256).build(uSeg, null); //virgin 256
union.union(sketchIn1);
assertEquals(union.getResult().getN(), n1);
assertEquals(union.getMaxK(), 256);
assertEquals(union.getEffectiveK(), k1);
- DoublesSketch result = union.getResult();
+ QuantilesDoublesSketch result = union.getResult();
assertEquals(result.getN(), 16);
assertEquals(result.getMaxItem(), n1, 0.0);
assertEquals(result.getMinItem(), 1.0, 0.0);
assertEquals(result.getK(), k1);
- final CompactDoublesSketch sketchIn2 = buildAndLoadDQS(k2, n2, 17).compact();
+ final CompactQuantilesDoublesSketch sketchIn2 = buildAndLoadDQS(k2, n2, 17).compact();
union.reset();
union.union(sketchIn2);
result = union.getResult();
@@ -276,18 +276,18 @@ public void checkUnion4DirectCompact() {
public void checkUnion5() { //Union is direct, valid and with larger K than valid input
final int k2 = 4;
final int n2 = 2 * k2; //8
- final int bytes = DoublesSketch.getUpdatableStorageBytes(256, 50);//big enough
+ final int bytes = QuantilesDoublesSketch.getUpdatableStorageBytes(256, 50);//big enough
final MemorySegment skSeg = MemorySegment.ofArray(new byte[bytes]);
- DoublesSketch.builder().setK(256).build(skSeg);
+ QuantilesDoublesSketch.builder().setK(256).build(skSeg);
- final DoublesUnion union = DoublesUnionImpl.heapifyInstance(skSeg);
+ final QuantilesDoublesUnion union = QuantilesDoublesUnionImpl.heapifyInstance(skSeg);
assertEquals(union.getResult().getN(), 0);
assertEquals(union.getMaxK(), 256);
assertEquals(union.getEffectiveK(), 256);
- final DoublesSketch result = union.getResult();
+ final QuantilesDoublesSketch result = union.getResult();
assertEquals(result.getK(), 256);
- final DoublesSketch sketchIn2 = buildAndLoadQS(k2, n2, 17);
+ final QuantilesDoublesSketch sketchIn2 = buildAndLoadQS(k2, n2, 17);
union.union(sketchIn2);
println("\nFinal" + union.getResult().toString(true, true));
assertEquals(union.getResult().getN(), n2);
@@ -297,18 +297,18 @@ public void checkUnion5() { //Union is direct, valid and with larger K than vali
public void checkUnion5Direct() { //Union is direct, valid and with larger K than valid input
final int k2 = 4;
final int n2 = 2 * k2; //8
- final int bytes = DoublesSketch.getUpdatableStorageBytes(256, 50);//big enough
+ final int bytes = QuantilesDoublesSketch.getUpdatableStorageBytes(256, 50);//big enough
final MemorySegment skSeg = MemorySegment.ofArray(new byte[bytes]);
- DoublesSketch.builder().setK(256).build(skSeg);
+ QuantilesDoublesSketch.builder().setK(256).build(skSeg);
- final DoublesUnion union = DoublesUnionImpl.heapifyInstance(skSeg);
+ final QuantilesDoublesUnion union = QuantilesDoublesUnionImpl.heapifyInstance(skSeg);
assertEquals(union.getResult().getN(), 0);
assertEquals(union.getMaxK(), 256);
assertEquals(union.getEffectiveK(), 256);
- final DoublesSketch result = union.getResult();
+ final QuantilesDoublesSketch result = union.getResult();
assertEquals(result.getK(), 256);
- final DoublesSketch sketchIn2 = buildAndLoadDQS(k2, n2, 17);
+ final QuantilesDoublesSketch sketchIn2 = buildAndLoadDQS(k2, n2, 17);
union.union(sketchIn2);
println("\nFinal" + union.getResult().toString(true, true));
assertEquals(union.getResult().getN(), n2);
@@ -320,11 +320,11 @@ public void checkUnion6() {
final int n1 = 2 * k1; //16
final int k2 = 16;
final int n2 = 2 * k2; //32
- final DoublesSketch sk1 = buildAndLoadQS(k1, n1, 0);
- final DoublesSketch sk2 = buildAndLoadQS(k2, n2, n1);
- final DoublesUnion union = DoublesUnionImpl.heapifyInstance(sk1);
+ final QuantilesDoublesSketch sk1 = buildAndLoadQS(k1, n1, 0);
+ final QuantilesDoublesSketch sk2 = buildAndLoadQS(k2, n2, n1);
+ final QuantilesDoublesUnion union = QuantilesDoublesUnionImpl.heapifyInstance(sk1);
union.union(sk2);
- final DoublesSketch result = union.getResult();
+ final QuantilesDoublesSketch result = union.getResult();
assertEquals(result.getMaxItem(), n1 + n2, 0.0);
assertEquals(result.getMinItem(), 1.0, 0.0);
println("\nFinal" + union.getResult().toString(true, true));
@@ -336,11 +336,11 @@ public void checkUnion6Direct() {
final int n1 = 2 * k1; //16
final int k2 = 16;
final int n2 = 2 * k2; //32
- final DoublesSketch sk1 = buildAndLoadDQS(k1, n1, 0);
- final DoublesSketch sk2 = buildAndLoadDQS(k2, n2, n1);
- final DoublesUnion union = DoublesUnionImpl.heapifyInstance(sk1);
+ final QuantilesDoublesSketch sk1 = buildAndLoadDQS(k1, n1, 0);
+ final QuantilesDoublesSketch sk2 = buildAndLoadDQS(k2, n2, n1);
+ final QuantilesDoublesUnion union = QuantilesDoublesUnionImpl.heapifyInstance(sk1);
union.union(sk2);
- final DoublesSketch result = union.getResult();
+ final QuantilesDoublesSketch result = union.getResult();
assertEquals(result.getMaxItem(), n1 + n2, 0.0);
assertEquals(result.getMinItem(), 1.0, 0.0);
println("\nFinal" + union.getResult().toString(true, true));
@@ -348,12 +348,12 @@ public void checkUnion6Direct() {
@Test
public void checkUnion7() {
- final DoublesUnion union = DoublesUnionImpl.heapInstance(16);
- final DoublesSketch skEst = buildAndLoadQS(32, 64); //other is bigger, est
+ final QuantilesDoublesUnion union = QuantilesDoublesUnionImpl.heapInstance(16);
+ final QuantilesDoublesSketch skEst = buildAndLoadQS(32, 64); //other is bigger, est
union.union(skEst);
println(skEst.toString(true, true));
println(union.toString(true, true));
- final DoublesSketch result = union.getResult();
+ final QuantilesDoublesSketch result = union.getResult();
assertEquals(result.getMaxItem(), 64, 0.0);
assertEquals(result.getMinItem(), 1.0, 0.0);
}
@@ -365,13 +365,13 @@ public void checkUnionQuantiles() {
final int n2 = (k * 8) + (k / 2);
final int n = n1 + n2;
final double errorTolerance = 0.0175 * n; // assuming k = 128
- final UpdateDoublesSketch sketch1 = buildAndLoadQS(k, n1);
- final CompactDoublesSketch sketch2 = buildAndLoadQS(k, n2, n1).compact();
- final DoublesUnion union = DoublesUnion.builder().setMaxK(256).build(); //virgin 256
+ final UpdatableQuantilesDoublesSketch sketch1 = buildAndLoadQS(k, n1);
+ final CompactQuantilesDoublesSketch sketch2 = buildAndLoadQS(k, n2, n1).compact();
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().setMaxK(256).build(); //virgin 256
union.union(sketch2);
union.union(sketch1);
final MemorySegment seg = MemorySegment.ofArray(union.getResult().toByteArray(true));
- final DoublesSketch result = DoublesSketch.wrap(seg);
+ final QuantilesDoublesSketch result = QuantilesDoublesSketch.wrap(seg);
assertEquals(result.getN(), n1 + n2);
assertEquals(result.getK(), k);
@@ -382,10 +382,10 @@ public void checkUnionQuantiles() {
@Test
public void checkUnion7Direct() {
- final DoublesUnion union = DoublesUnionImpl.heapInstance(16);
- final DoublesSketch skEst = buildAndLoadDQS(32, 64); //other is bigger, est
+ final QuantilesDoublesUnion union = QuantilesDoublesUnionImpl.heapInstance(16);
+ final QuantilesDoublesSketch skEst = buildAndLoadDQS(32, 64); //other is bigger, est
union.union(skEst);
- final DoublesSketch result = union.getResult();
+ final QuantilesDoublesSketch result = union.getResult();
assertEquals(result.getMaxItem(), 64, 0.0);
assertEquals(result.getMinItem(), 1.0, 0.0);
// println(skEst.toString(true, true));
@@ -394,16 +394,16 @@ public void checkUnion7Direct() {
@Test
public void checkUpdateMemory() {
- final DoublesSketch qs1 = buildAndLoadQS(256, 1000);
+ final QuantilesDoublesSketch qs1 = buildAndLoadQS(256, 1000);
final int bytes = qs1.getCurrentCompactSerializedSizeBytes();
final MemorySegment dstSeg = MemorySegment.ofArray(new byte[bytes]);
qs1.putIntoMemorySegment(dstSeg);
final MemorySegment srcSeg = dstSeg;
- final DoublesUnion union = DoublesUnion.builder().build(); //virgin
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().build(); //virgin
union.union(srcSeg);
for (int i = 1000; i < 2000; i++) { union.update(i); }
- final DoublesSketch qs2 = union.getResult();
+ final QuantilesDoublesSketch qs2 = union.getResult();
assertEquals(qs2.getMaxItem(), 1999, 0.0);
final String s = union.toString();
println(s); //enable printing to see
@@ -412,16 +412,16 @@ public void checkUpdateMemory() {
@Test
public void checkUpdateMemoryDirect() {
- final DoublesSketch qs1 = buildAndLoadDQS(256, 1000);
+ final QuantilesDoublesSketch qs1 = buildAndLoadDQS(256, 1000);
final int bytes = qs1.getCurrentCompactSerializedSizeBytes();
final MemorySegment dstSeg = MemorySegment.ofArray(new byte[bytes]);
qs1.putIntoMemorySegment(dstSeg);
final MemorySegment srcSeg = dstSeg;
- final DoublesUnion union = DoublesUnion.builder().build(); //virgin
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().build(); //virgin
union.union(srcSeg);
for (int i = 1000; i < 2000; i++) { union.update(i); }
- final DoublesSketch qs2 = union.getResult();
+ final QuantilesDoublesSketch qs2 = union.getResult();
assertEquals(qs2.getMaxItem(), 1999, 0.0);
final String s = union.toString();
println(s); //enable printing to see
@@ -432,10 +432,10 @@ public void checkUpdateMemoryDirect() {
public void checkUnionUpdateLogic() {
final HeapUpdateDoublesSketch qs1 = null;
final HeapUpdateDoublesSketch qs2 = (HeapUpdateDoublesSketch) buildAndLoadQS(256, 0);
- DoublesUnionImpl.updateLogic(256, qs1, qs2); //null, empty
- DoublesUnionImpl.updateLogic(256, qs2, qs1); //empty, null
+ QuantilesDoublesUnionImpl.updateLogic(256, qs1, qs2); //null, empty
+ QuantilesDoublesUnionImpl.updateLogic(256, qs2, qs1); //empty, null
qs2.update(1); //no longer empty
- final DoublesSketch result = DoublesUnionImpl.updateLogic(256, qs2, qs1); //valid, null
+ final QuantilesDoublesSketch result = QuantilesDoublesUnionImpl.updateLogic(256, qs2, qs1); //valid, null
assertEquals(result.getMaxItem(), result.getMinItem(), 0.0);
}
@@ -443,10 +443,10 @@ public void checkUnionUpdateLogic() {
public void checkUnionUpdateLogicDirect() {
final HeapUpdateDoublesSketch qs1 = null;
final DirectUpdateDoublesSketch qs2 = (DirectUpdateDoublesSketch) buildAndLoadDQS(256, 0);
- DoublesUnionImpl.updateLogic(256, qs1, qs2); //null, empty
- DoublesUnionImpl.updateLogic(256, qs2, qs1); //empty, null
+ QuantilesDoublesUnionImpl.updateLogic(256, qs1, qs2); //null, empty
+ QuantilesDoublesUnionImpl.updateLogic(256, qs2, qs1); //empty, null
qs2.update(1); //no longer empty
- final DoublesSketch result = DoublesUnionImpl.updateLogic(256, qs2, qs1); //valid, null
+ final QuantilesDoublesSketch result = QuantilesDoublesUnionImpl.updateLogic(256, qs2, qs1); //valid, null
assertEquals(result.getMaxItem(), result.getMinItem(), 0.0);
}
@@ -454,7 +454,7 @@ public void checkUnionUpdateLogicDirect() {
public void checkUnionUpdateLogicDirectDownsampled() {
final DirectUpdateDoublesSketch qs1 = (DirectUpdateDoublesSketch) buildAndLoadDQS(256, 1000);
final DirectUpdateDoublesSketch qs2 = (DirectUpdateDoublesSketch) buildAndLoadDQS(128, 2000);
- final DoublesSketch result = DoublesUnionImpl.updateLogic(128, qs1, qs2);
+ final QuantilesDoublesSketch result = QuantilesDoublesUnionImpl.updateLogic(128, qs1, qs2);
assertEquals(result.getMaxItem(), 2000.0, 0.0);
assertEquals(result.getMinItem(), 1.0, 0.0);
assertEquals(result.getN(), 3000);
@@ -463,15 +463,15 @@ public void checkUnionUpdateLogicDirectDownsampled() {
@Test
public void checkUnionUpdateLogic2() {
- DoublesSketch qs1 = DoublesSketch.builder().build();
- final DoublesSketch qs2 = DoublesSketch.builder().build();
- final DoublesUnion union = DoublesUnion.builder().build();
+ QuantilesDoublesSketch qs1 = QuantilesDoublesSketch.builder().build();
+ final QuantilesDoublesSketch qs2 = QuantilesDoublesSketch.builder().build();
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().build();
union.union(qs1);
union.union(qs2); //case 5
qs1 = buildAndLoadQS(128, 1000);
union.union(qs1);
union.union(qs2); //case 9
- final DoublesSketch result = union.getResult();
+ final QuantilesDoublesSketch result = union.getResult();
//println(union.toString(true, true));
assertEquals(result.getMaxItem(), 1000.0, 0.0);
assertEquals(result.getMinItem(), 1.0, 0.0);
@@ -480,15 +480,15 @@ public void checkUnionUpdateLogic2() {
@Test
public void checkUnionUpdateLogic2Direct() {
- DoublesSketch qs1 = DoublesSketch.builder().build();
- final DoublesSketch qs2 = DoublesSketch.builder().build();
- final DoublesUnion union = DoublesUnion.builder().build();
+ QuantilesDoublesSketch qs1 = QuantilesDoublesSketch.builder().build();
+ final QuantilesDoublesSketch qs2 = QuantilesDoublesSketch.builder().build();
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().build();
union.union(qs1);
union.union(qs2); //case 5
qs1 = buildAndLoadDQS(128, 1000);
union.union(qs1);
union.union(qs2); //case 9
- final DoublesSketch result = union.getResult();
+ final QuantilesDoublesSketch result = union.getResult();
//println(union.toString(true, true));
assertEquals(result.getMaxItem(), 1000.0, 0.0);
assertEquals(result.getMinItem(), 1.0, 0.0);
@@ -496,24 +496,24 @@ public void checkUnionUpdateLogic2Direct() {
@Test
public void checkResultAndReset() {
- final DoublesSketch qs1 = buildAndLoadQS(256, 0);
- final DoublesUnion union = DoublesUnion.heapify(qs1);
- final DoublesSketch qs2 = union.getResultAndReset();
+ final QuantilesDoublesSketch qs1 = buildAndLoadQS(256, 0);
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.heapify(qs1);
+ final QuantilesDoublesSketch qs2 = union.getResultAndReset();
assertEquals(qs2.getK(), 256);
}
@Test
public void checkResultAndResetDirect() {
- final DoublesSketch qs1 = buildAndLoadDQS(256, 0);
- final DoublesUnion union = DoublesUnion.heapify(qs1);
- final DoublesSketch qs2 = union.getResultAndReset();
+ final QuantilesDoublesSketch qs1 = buildAndLoadDQS(256, 0);
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.heapify(qs1);
+ final QuantilesDoublesSketch qs2 = union.getResultAndReset();
assertEquals(qs2.getK(), 256);
}
@Test
public void checkResultViaMemory() {
// empty gadget
- final DoublesUnion union = DoublesUnion.builder().build();
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().build();
// MemorySegment too small
MemorySegment seg = MemorySegment.ofArray(new byte[1]);
@@ -526,13 +526,13 @@ public void checkResultViaMemory() {
// sufficient MemorySegment
seg = MemorySegment.ofArray(new byte[8]);
- DoublesSketch result = union.getResult(seg, null);
+ QuantilesDoublesSketch result = union.getResult(seg, null);
assertTrue(result.isEmpty());
final int k = 128;
final int n = 1392;
- seg = MemorySegment.ofArray(new byte[DoublesSketch.getUpdatableStorageBytes(k, n)]);
- final DoublesSketch qs = buildAndLoadQS(k, n);
+ seg = MemorySegment.ofArray(new byte[QuantilesDoublesSketch.getUpdatableStorageBytes(k, n)]);
+ final QuantilesDoublesSketch qs = buildAndLoadQS(k, n);
union.union(qs);
result = union.getResult(seg, null);
DoublesSketchTest.testSketchEquality(result, qs);
@@ -540,16 +540,16 @@ public void checkResultViaMemory() {
@Test
public void updateWithDoubleValueOnly() {
- final DoublesUnion union = DoublesUnion.builder().build();
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().build();
union.update(123.456);
- final DoublesSketch qs = union.getResultAndReset();
+ final QuantilesDoublesSketch qs = union.getResultAndReset();
assertEquals(qs.getN(), 1);
}
@Test
public void checkEmptyUnion() {
- final DoublesUnionImpl union = DoublesUnionImpl.heapInstance(128);
- final DoublesSketch sk = union.getResult();
+ final QuantilesDoublesUnionImpl union = QuantilesDoublesUnionImpl.heapInstance(128);
+ final QuantilesDoublesSketch sk = union.getResult();
assertNotNull(sk);
final byte[] bytes = union.toByteArray();
assertEquals(bytes.length, 8); //
@@ -559,21 +559,21 @@ public void checkEmptyUnion() {
@Test
public void checkUnionNulls() {
- final DoublesUnion union = DoublesUnionImpl.heapInstance(128);
- final DoublesSketch sk1 = union.getResultAndReset();
- final DoublesSketch sk2 = union.getResultAndReset();
+ final QuantilesDoublesUnion union = QuantilesDoublesUnionImpl.heapInstance(128);
+ final QuantilesDoublesSketch sk1 = union.getResultAndReset();
+ final QuantilesDoublesSketch sk2 = union.getResultAndReset();
assertNull(sk1);
assertNull(sk2);
try { union.union(sk2); fail(); }
catch (final NullPointerException e) { }
- final DoublesSketch sk3 = union.getResultAndReset();
+ final QuantilesDoublesSketch sk3 = union.getResultAndReset();
assertNull(sk3);
}
@Test
public void differentLargerK() {
- final DoublesUnion union = DoublesUnion.builder().setMaxK(128).build();
- final UpdateDoublesSketch sketch1 = buildAndLoadQS(256, 0);
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().setMaxK(128).build();
+ final UpdatableQuantilesDoublesSketch sketch1 = buildAndLoadQS(256, 0);
union.union(sketch1);
Assert.assertEquals(union.getResult().getK(), 128);
sketch1.update(1.0);
@@ -583,8 +583,8 @@ public void differentLargerK() {
@Test
public void differentLargerKDirect() {
- final DoublesUnion union = DoublesUnion.builder().setMaxK(128).build();
- final UpdateDoublesSketch sketch1 = buildAndLoadDQS(256, 0);
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().setMaxK(128).build();
+ final UpdatableQuantilesDoublesSketch sketch1 = buildAndLoadDQS(256, 0);
union.union(sketch1);
Assert.assertEquals(union.getResult().getK(), 128);
sketch1.update(1.0);
@@ -596,7 +596,7 @@ public void differentLargerKDirect() {
public void differentEmptySmallerK() {
final int k128 = 128;
final int k64 = 64;
- final DoublesUnion union = DoublesUnion.builder().setMaxK(k128).build();
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().setMaxK(k128).build();
assertTrue(union.isEmpty()); //gadget is null
assertFalse(union.hasMemorySegment());
assertFalse(union.isOffHeap());
@@ -604,14 +604,14 @@ public void differentEmptySmallerK() {
// byte[] unionByteArr = union.toByteArray();
// Assert.assertEquals(unionByteArr.length, 32 + 32); //empty
- final UpdateDoublesSketch sketch1 = buildAndLoadQS(k64, 0); //build smaller empty sketch
+ final UpdatableQuantilesDoublesSketch sketch1 = buildAndLoadQS(k64, 0); //build smaller empty sketch
union.union(sketch1);
assertTrue(union.isEmpty()); //gadget is valid
assertFalse(union.hasMemorySegment());
assertFalse(union.isOffHeap());
// unionByteArr = union.toByteArray();
- // int udBytes = DoublesSketch.getUpdatableStorageBytes(k64, 0);
+ // int udBytes = QuantilesDoublesSketch.getUpdatableStorageBytes(k64, 0);
// Assert.assertEquals(unionByteArr.length, udBytes); //empty
assertEquals(union.getResult().getK(), 128);
@@ -624,7 +624,7 @@ public void differentEmptySmallerK() {
public void differentEmptySmallerKDirect() {
final int k128 = 128;
final int k64 = 64;
- final DoublesUnion union = DoublesUnion.builder().setMaxK(k128).build();
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().setMaxK(k128).build();
assertTrue(union.isEmpty()); //gadget is null
assertFalse(union.hasMemorySegment());
assertFalse(union.isOffHeap());
@@ -632,14 +632,14 @@ public void differentEmptySmallerKDirect() {
// byte[] unionByteArr = union.toByteArray();
// Assert.assertEquals(unionByteArr.length, 32 + 32); //empty
- final UpdateDoublesSketch sketch1 = buildAndLoadDQS(k64, 0); //build smaller empty sketch
+ final UpdatableQuantilesDoublesSketch sketch1 = buildAndLoadDQS(k64, 0); //build smaller empty sketch
union.union(sketch1);
assertTrue(union.isEmpty()); //gadget is valid
assertFalse(union.hasMemorySegment());
assertFalse(union.isOffHeap());
// unionByteArr = union.toByteArray();
- // int udBytes = DoublesSketch.getUpdatableStorageBytes(k64, 0);
+ // int udBytes = QuantilesDoublesSketch.getUpdatableStorageBytes(k64, 0);
// Assert.assertEquals(unionByteArr.length, udBytes); //empty
assertEquals(union.getResult().getK(), 128);
@@ -652,13 +652,13 @@ public void differentEmptySmallerKDirect() {
public void checkDirectInstance() {
final int k = 128;
final int n = 1000;
- final DoublesUnionBuilder bldr = DoublesUnion.builder();
+ final QuantilesDoublesUnionBuilder bldr = QuantilesDoublesUnion.builder();
bldr.setMaxK(k);
assertEquals(bldr.getMaxK(), k);
- final int bytes = DoublesSketch.getUpdatableStorageBytes(k, n);
+ final int bytes = QuantilesDoublesSketch.getUpdatableStorageBytes(k, n);
final byte[] byteArr = new byte[bytes];
final MemorySegment seg = MemorySegment.ofArray(byteArr);
- final DoublesUnion union = bldr.build(seg, null);
+ final QuantilesDoublesUnion union = bldr.build(seg, null);
assertTrue(union.isEmpty());
assertTrue(union.hasMemorySegment());
assertFalse(union.isOffHeap());
@@ -666,7 +666,7 @@ public void checkDirectInstance() {
union.update(i);
}
assertFalse(union.isEmpty());
- final DoublesSketch res = union.getResult();
+ final QuantilesDoublesSketch res = union.getResult();
final double median = res.getQuantile(.5);
assertEquals(median, 500, 10);
println(union.toString());
@@ -676,7 +676,7 @@ public void checkDirectInstance() {
public void checkWrapInstance() {
final int k = 128;
final int n = 1000;
- final UpdateDoublesSketch sketch = DoublesSketch.builder().setK(k).build();
+ final UpdatableQuantilesDoublesSketch sketch = QuantilesDoublesSketch.builder().setK(k).build();
for (int i = 1; i <= n; i++) {
sketch.update(i);
}
@@ -685,11 +685,11 @@ public void checkWrapInstance() {
final byte[] byteArr = sketch.toByteArray(false);
final MemorySegment seg = MemorySegment.ofArray(byteArr);
- final DoublesUnion union = DoublesUnion.wrap(seg, null);
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.wrap(seg, null);
Assert.assertFalse(union.isEmpty());
assertTrue(union.hasMemorySegment());
assertFalse(union.isOffHeap());
- final DoublesSketch sketch2 = union.getResult();
+ final QuantilesDoublesSketch sketch2 = union.getResult();
final double uMedian = sketch2.getQuantile(0.5);
Assert.assertEquals(skMedian, uMedian, 0.0);
@@ -701,14 +701,14 @@ public void checkWrapInstance() {
@Test
public void isSameResourceHeap() {
- final DoublesUnion union = DoublesUnion.builder().build();
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().build();
Assert.assertFalse(union.isSameResource(null));
}
@Test
public void isSameResourceDirect() {
final MemorySegment seg1 = MemorySegment.ofArray(new byte[1000000]);
- final DoublesUnion union = DoublesUnion.builder().build(seg1, null);
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().build(seg1, null);
Assert.assertTrue(union.isSameResource(seg1));
final MemorySegment seg2 = MemorySegment.ofArray(new byte[1000000]);
Assert.assertFalse(union.isSameResource(seg2));
@@ -716,10 +716,10 @@ public void isSameResourceDirect() {
@Test
public void emptyUnionSerDeIssue195() {
- final DoublesUnion union = DoublesUnion.builder().build();
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.builder().build();
final byte[] byteArr = union.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArr);
- final DoublesUnion union2 = DoublesUnion.heapify(seg);
+ final QuantilesDoublesUnion union2 = QuantilesDoublesUnion.heapify(seg);
Assert.assertEquals(seg.byteSize(), 8L);
Assert.assertTrue(union2.isEmpty());
}
diff --git a/src/test/java/org/apache/datasketches/quantiles/DoublesUtilTest.java b/src/test/java/org/apache/datasketches/quantiles/DoublesUtilTest.java
index 91f86f74f..24fb53a8e 100644
--- a/src/test/java/org/apache/datasketches/quantiles/DoublesUtilTest.java
+++ b/src/test/java/org/apache/datasketches/quantiles/DoublesUtilTest.java
@@ -32,7 +32,7 @@ public class DoublesUtilTest {
public void checkPrintSegmentData() {
final int k = 16;
final int n = 1000;
- final DoublesSketch qs = buildAndLoadQS(k,n);
+ final QuantilesDoublesSketch qs = buildAndLoadQS(k,n);
byte[] byteArr = qs.toByteArray(false);
MemorySegment seg = MemorySegment.ofArray(byteArr);
@@ -47,7 +47,7 @@ public void checkPrintSegmentData() {
public void checkPrintSegmentData2() {
final int k = PreambleUtil.DEFAULT_K;
final int n = 0;
- final DoublesSketch qs = buildAndLoadQS(k,n);
+ final QuantilesDoublesSketch qs = buildAndLoadQS(k,n);
final byte[] byteArr = qs.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArr);
@@ -56,7 +56,7 @@ public void checkPrintSegmentData2() {
static String segToString(final boolean withLevels, final boolean withLevelsAndItems,
final MemorySegment seg) {
- final DoublesSketch ds = DoublesSketch.heapify(seg);
+ final QuantilesDoublesSketch ds = QuantilesDoublesSketch.heapify(seg);
return ds.toString(withLevels, withLevelsAndItems);
}
@@ -72,20 +72,20 @@ public void checkCopyToHeap() {
// DirectUpdateDoublesSketch
final MemorySegment seg1 = MemorySegment.ofArray(huds.toByteArray());
- final DirectUpdateDoublesSketch duds = (DirectUpdateDoublesSketch) UpdateDoublesSketch.wrap(seg1, null);
+ final DirectUpdateDoublesSketch duds = (DirectUpdateDoublesSketch) UpdatableQuantilesDoublesSketch.wrap(seg1, null);
final HeapUpdateDoublesSketch target2 = DoublesUtil.copyToHeap(duds);
DoublesSketchTest.testSketchEquality(huds, duds);
DoublesSketchTest.testSketchEquality(duds, target2);
// HeapCompactDoublesSketch
- final CompactDoublesSketch hcds = huds.compact();
+ final CompactQuantilesDoublesSketch hcds = huds.compact();
final HeapUpdateDoublesSketch target3 = DoublesUtil.copyToHeap(hcds);
DoublesSketchTest.testSketchEquality(huds, hcds);
DoublesSketchTest.testSketchEquality(hcds, target3);
// DirectCompactDoublesSketch
final MemorySegment seg2 = MemorySegment.ofArray(hcds.toByteArray());
- final DirectCompactDoublesSketch dcds = (DirectCompactDoublesSketch) DoublesSketch.wrap(seg2);
+ final DirectCompactDoublesSketch dcds = (DirectCompactDoublesSketch) QuantilesDoublesSketch.wrap(seg2);
final HeapUpdateDoublesSketch target4 = DoublesUtil.copyToHeap(dcds);
DoublesSketchTest.testSketchEquality(huds, dcds);
DoublesSketchTest.testSketchEquality(dcds, target4);
diff --git a/src/test/java/org/apache/datasketches/quantiles/HeapCompactDoublesSketchTest.java b/src/test/java/org/apache/datasketches/quantiles/HeapCompactDoublesSketchTest.java
index fb5380a0a..9fe37355c 100644
--- a/src/test/java/org/apache/datasketches/quantiles/HeapCompactDoublesSketchTest.java
+++ b/src/test/java/org/apache/datasketches/quantiles/HeapCompactDoublesSketchTest.java
@@ -37,14 +37,14 @@ public class HeapCompactDoublesSketchTest {
@BeforeMethod
public void setUp() {
- DoublesSketch.rand.setSeed(32749); // make sketches deterministic for testing
+ QuantilesDoublesSketch.rand.setSeed(32749); // make sketches deterministic for testing
}
@Test
public void heapifyFromUpdateSketch() {
final int k = 4;
final int n = 45;
- final UpdateDoublesSketch qs = buildAndLoadQS(k, n);
+ final UpdatableQuantilesDoublesSketch qs = buildAndLoadQS(k, n);
final byte[] qsBytes = qs.toByteArray();
final MemorySegment qsSeg = MemorySegment.ofArray(qsBytes);
@@ -58,7 +58,7 @@ public void heapifyFromUpdateSketch() {
public void createFromUnsortedUpdateSketch() {
final int k = 4;
final int n = 13;
- final UpdateDoublesSketch qs = DoublesSketch.builder().setK(k).build();
+ final UpdatableQuantilesDoublesSketch qs = QuantilesDoublesSketch.builder().setK(k).build();
for (int i = n; i > 0; --i) {
qs.update(i);
}
@@ -72,7 +72,7 @@ public void createFromUnsortedUpdateSketch() {
public void heapifyFromCompactSketch() {
final int k = 8;
final int n = 177;
- final UpdateDoublesSketch qs = buildAndLoadQS(k, n); // assuming reverse ordered inserts
+ final UpdatableQuantilesDoublesSketch qs = buildAndLoadQS(k, n); // assuming reverse ordered inserts
final byte[] qsBytes = qs.compact().toByteArray();
final MemorySegment qsSeg = MemorySegment.ofArray(qsBytes);
@@ -84,7 +84,7 @@ public void heapifyFromCompactSketch() {
@Test
public void checkHeapifyUnsortedCompactV2() {
final int k = 64;
- final UpdateDoublesSketch qs = DoublesSketch.builder().setK(64).build();
+ final UpdatableQuantilesDoublesSketch qs = QuantilesDoublesSketch.builder().setK(64).build();
for (int i = 0; i < (3 * k); ++i) {
qs.update(i);
}
@@ -107,7 +107,7 @@ public void checkHeapifyUnsortedCompactV2() {
@Test
public void checkEmpty() {
final int k = PreambleUtil.DEFAULT_K;
- final UpdateDoublesSketch qs1 = buildAndLoadQS(k, 0);
+ final UpdatableQuantilesDoublesSketch qs1 = buildAndLoadQS(k, 0);
final byte[] byteArr = qs1.compact().toByteArray();
final byte[] byteArr2 = qs1.toByteArray(true);
final MemorySegment seg = MemorySegment.ofArray(byteArr);
@@ -135,12 +135,12 @@ static void checkBaseBufferIsSorted(final HeapCompactDoublesSketch qs) {
}
}
- static UpdateDoublesSketch buildAndLoadQS(final int k, final int n) {
+ static UpdatableQuantilesDoublesSketch buildAndLoadQS(final int k, final int n) {
return buildAndLoadQS(k, n, 0);
}
- static UpdateDoublesSketch buildAndLoadQS(final int k, final int n, final int startV) {
- final UpdateDoublesSketch qs = DoublesSketch.builder().setK(k).build();
+ static UpdatableQuantilesDoublesSketch buildAndLoadQS(final int k, final int n, final int startV) {
+ final UpdatableQuantilesDoublesSketch qs = QuantilesDoublesSketch.builder().setK(k).build();
for (int i = 1; i <= n; i++) {
qs.update(startV + i);
}
diff --git a/src/test/java/org/apache/datasketches/quantiles/HeapUpdateDoublesSketchTest.java b/src/test/java/org/apache/datasketches/quantiles/HeapUpdateDoublesSketchTest.java
index 78fb8c0c3..e9d72d1fa 100644
--- a/src/test/java/org/apache/datasketches/quantiles/HeapUpdateDoublesSketchTest.java
+++ b/src/test/java/org/apache/datasketches/quantiles/HeapUpdateDoublesSketchTest.java
@@ -49,7 +49,7 @@ public class HeapUpdateDoublesSketchTest {
@BeforeMethod
public void setUp() {
- DoublesSketch.rand.setSeed(32749); // make sketches deterministic for testing
+ QuantilesDoublesSketch.rand.setSeed(32749); // make sketches deterministic for testing
}
// Please note that this is a randomized test that could probabilistically fail
@@ -58,8 +58,8 @@ public void setUp() {
@Test
public void checkEndToEnd() {
final int k = 256;
- final UpdateDoublesSketch qs = DoublesSketch.builder().setK(k).build();
- final UpdateDoublesSketch qs2 = DoublesSketch.builder().setK(k).build();
+ final UpdatableQuantilesDoublesSketch qs = QuantilesDoublesSketch.builder().setK(k).build();
+ final UpdatableQuantilesDoublesSketch qs2 = QuantilesDoublesSketch.builder().setK(k).build();
final int n = 1000000;
for (int item = n; item >= 1; item--) {
if ((item % 4) == 0) {
@@ -70,9 +70,9 @@ public void checkEndToEnd() {
}
}
assertEquals(qs.getN() + qs2.getN(), n);
- final DoublesUnion union = DoublesUnion.heapify(qs);
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.heapify(qs);
union.union(qs2);
- final DoublesSketch result = union.getResult();
+ final QuantilesDoublesSketch result = union.getResult();
final int numPhiValues = 99;
final double[] phiArr = new double[numPhiValues];
@@ -117,9 +117,9 @@ public void checkEndToEnd() {
public void checkSmallMinMax () {
final int k = 32;
final int n = 8;
- final UpdateDoublesSketch qs1 = DoublesSketch.builder().setK(k).build();
- final UpdateDoublesSketch qs2 = DoublesSketch.builder().setK(k).build();
- final UpdateDoublesSketch qs3 = DoublesSketch.builder().setK(k).build();
+ final UpdatableQuantilesDoublesSketch qs1 = QuantilesDoublesSketch.builder().setK(k).build();
+ final UpdatableQuantilesDoublesSketch qs2 = QuantilesDoublesSketch.builder().setK(k).build();
+ final UpdatableQuantilesDoublesSketch qs3 = QuantilesDoublesSketch.builder().setK(k).build();
for (int i = n; i >= 1; i--) {
qs1.update(i);
@@ -145,13 +145,13 @@ public void checkSmallMinMax () {
assertEquals(resultsA[1], 5.0);
assertEquals(resultsA[2], 8.0);
- final DoublesUnion union1 = DoublesUnion.heapify(qs1);
+ final QuantilesDoublesUnion union1 = QuantilesDoublesUnion.heapify(qs1);
union1.union(qs2);
- final DoublesSketch result1 = union1.getResult();
+ final QuantilesDoublesSketch result1 = union1.getResult();
- final DoublesUnion union2 = DoublesUnion.heapify(qs2);
+ final QuantilesDoublesUnion union2 = QuantilesDoublesUnion.heapify(qs2);
union2.union(qs3);
- final DoublesSketch result2 = union2.getResult();
+ final QuantilesDoublesSketch result2 = union2.getResult();
final double[] resultsB = result1.getQuantiles(queries, EXCLUSIVE);
assertEquals(resultsB[0], 1.0);
@@ -168,7 +168,7 @@ public void checkSmallMinMax () {
public void checkMisc() {
final int k = PreambleUtil.DEFAULT_K;
final int n = 10000;
- final UpdateDoublesSketch qs = buildAndLoadQS(k, n);
+ final UpdatableQuantilesDoublesSketch qs = buildAndLoadQS(k, n);
qs.update(Double.NaN); //ignore
final int n2 = (int)qs.getN();
assertEquals(n2, n);
@@ -182,7 +182,7 @@ public void checkMisc() {
public void checkToStringDetail() {
final int k = PreambleUtil.DEFAULT_K;
final int n = 1000000;
- UpdateDoublesSketch qs = buildAndLoadQS(k, 0);
+ UpdatableQuantilesDoublesSketch qs = buildAndLoadQS(k, 0);
String s = qs.toString();
s = qs.toString(false, true);
//println(s);
@@ -201,13 +201,13 @@ public void checkToStringDetail() {
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkConstructorException() {
- DoublesSketch.builder().setK(0).build();
+ QuantilesDoublesSketch.builder().setK(0).build();
}
@Test
public void checkPreLongsFlagsAndSize() {
byte[] byteArr;
- final UpdateDoublesSketch ds = DoublesSketch.builder().build(); //k = 128
+ final UpdatableQuantilesDoublesSketch ds = QuantilesDoublesSketch.builder().build(); //k = 128
//empty
byteArr = ds.toByteArray(true); // compact
assertEquals(byteArr.length, 8);
@@ -247,7 +247,7 @@ public void checkPreLongsFlagsSerVer3() {
public void checkGetQuantiles() {
final int k = PreambleUtil.DEFAULT_K;
final int n = 1000000;
- final DoublesSketch qs = buildAndLoadQS(k, n);
+ final QuantilesDoublesSketch qs = buildAndLoadQS(k, n);
final double[] frac = {-0.5};
qs.getQuantiles(frac);
}
@@ -256,14 +256,14 @@ public void checkGetQuantiles() {
public void checkGetQuantile() {
final int k = PreambleUtil.DEFAULT_K;
final int n = 1000000;
- final DoublesSketch qs = buildAndLoadQS(k, n);
+ final QuantilesDoublesSketch qs = buildAndLoadQS(k, n);
final double frac = -0.5; //negative not allowed
qs.getQuantile(frac);
}
//@Test //visual only
public void summaryCheckViaMemory() {
- final DoublesSketch qs = buildAndLoadQS(256, 1000000);
+ final QuantilesDoublesSketch qs = buildAndLoadQS(256, 1000000);
String s = qs.toString();
println(s);
println("");
@@ -301,7 +301,7 @@ public void checkValidateSplitPointsOrder() {
@Test
public void checkGetStorageBytes() {
final int k = PreambleUtil.DEFAULT_K; //128
- DoublesSketch qs = buildAndLoadQS(k, 0); //k, n
+ QuantilesDoublesSketch qs = buildAndLoadQS(k, 0); //k, n
int stor = qs.getCurrentCompactSerializedSizeBytes();
assertEquals(stor, 8);
@@ -321,7 +321,7 @@ public void checkGetStorageBytes() {
public void checkGetStorageBytes2() {
final int k = PreambleUtil.DEFAULT_K;
long v = 1;
- final UpdateDoublesSketch qs = DoublesSketch.builder().setK(k).build();
+ final UpdatableQuantilesDoublesSketch qs = QuantilesDoublesSketch.builder().setK(k).build();
for (int i = 0; i< 1000; i++) {
qs.update(v++);
// for (int j = 0; j < 1000; j++) {
@@ -336,11 +336,11 @@ public void checkGetStorageBytes2() {
public void checkMerge() {
final int k = PreambleUtil.DEFAULT_K;
final int n = 1000000;
- final DoublesSketch qs1 = buildAndLoadQS(k,n,0);
- final DoublesSketch qs2 = buildAndLoadQS(k,0,0); //empty
- final DoublesUnion union = DoublesUnion.heapify(qs2);
+ final QuantilesDoublesSketch qs1 = buildAndLoadQS(k,n,0);
+ final QuantilesDoublesSketch qs2 = buildAndLoadQS(k,0,0); //empty
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.heapify(qs2);
union.union(qs1);
- final DoublesSketch result = union.getResult();
+ final QuantilesDoublesSketch result = union.getResult();
final double med1 = qs1.getQuantile(0.5);
final double med2 = result.getQuantile(0.5);
assertEquals(med1, med2, 0.0);
@@ -350,11 +350,11 @@ public void checkMerge() {
@Test
public void checkReverseMerge() {
final int k = PreambleUtil.DEFAULT_K;
- final DoublesSketch qs1 = buildAndLoadQS(k, 1000, 0);
- final DoublesSketch qs2 = buildAndLoadQS(2*k,1000, 1000);
- final DoublesUnion union = DoublesUnion.heapify(qs2);
+ final QuantilesDoublesSketch qs1 = buildAndLoadQS(k, 1000, 0);
+ final QuantilesDoublesSketch qs2 = buildAndLoadQS(2*k,1000, 1000);
+ final QuantilesDoublesUnion union = QuantilesDoublesUnion.heapify(qs2);
union.union(qs1); //attempt merge into larger k
- final DoublesSketch result = union.getResult();
+ final QuantilesDoublesSketch result = union.getResult();
assertEquals(result.getK(), k);
}
@@ -362,7 +362,7 @@ public void checkReverseMerge() {
public void checkInternalBuildHistogram() {
final int k = PreambleUtil.DEFAULT_K;
final int n = 1000000;
- final DoublesSketch qs = buildAndLoadQS(k,n,0);
+ final QuantilesDoublesSketch qs = buildAndLoadQS(k,n,0);
final double eps = qs.getNormalizedRankError(true);
//println("EPS:"+eps);
final double[] spts = {100000, 500000, 900000};
@@ -394,15 +394,15 @@ public void checkToFromByteArray() {
}
private static void checkToFromByteArray2(final int k, final int n) {
- final DoublesSketch qs = buildAndLoadQS(k, n);
+ final QuantilesDoublesSketch qs = buildAndLoadQS(k, n);
byte[] byteArr;
MemorySegment seg;
- DoublesSketch qs2;
+ QuantilesDoublesSketch qs2;
// from compact
byteArr = qs.toByteArray(true);
seg = MemorySegment.ofArray(byteArr);
- qs2 = UpdateDoublesSketch.heapify(seg);
+ qs2 = UpdatableQuantilesDoublesSketch.heapify(seg);
for (double f = 0.1; f < 0.95; f += 0.1) {
assertEquals(qs.getQuantile(f), qs2.getQuantile(f), 0.0);
}
@@ -410,7 +410,7 @@ private static void checkToFromByteArray2(final int k, final int n) {
// ordered, non-compact
byteArr = qs.toByteArray(false);
seg = MemorySegment.ofArray(byteArr);
- qs2 = DoublesSketch.heapify(seg);
+ qs2 = QuantilesDoublesSketch.heapify(seg);
final DoublesSketchAccessor dsa = DoublesSketchAccessor.wrap(qs2, false);
dsa.sort();
for (double f = 0.1; f < 0.95; f += 0.1) {
@@ -420,7 +420,7 @@ private static void checkToFromByteArray2(final int k, final int n) {
// not ordered, not compact
byteArr = qs.toByteArray(false);
seg = MemorySegment.ofArray(byteArr);
- qs2 = DoublesSketch.heapify(seg);
+ qs2 = QuantilesDoublesSketch.heapify(seg);
for (double f = 0.1; f < 0.95; f += 0.1) {
assertEquals(qs.getQuantile(f), qs2.getQuantile(f), 0.0);
}
@@ -429,10 +429,10 @@ private static void checkToFromByteArray2(final int k, final int n) {
@Test
public void checkEmpty() {
final int k = PreambleUtil.DEFAULT_K;
- final DoublesSketch qs1 = buildAndLoadQS(k, 0);
+ final QuantilesDoublesSketch qs1 = buildAndLoadQS(k, 0);
final byte[] byteArr = qs1.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArr);
- final DoublesSketch qs2 = DoublesSketch.heapify(seg);
+ final QuantilesDoublesSketch qs2 = QuantilesDoublesSketch.heapify(seg);
assertTrue(qs2.isEmpty());
final int expectedSizeBytes = 8; //COMBINED_BUFFER + ((2 * MIN_K) << 3);
assertEquals(byteArr.length, expectedSizeBytes);
@@ -508,7 +508,7 @@ public void checkFlags() {
@Test
public void checkZeroPatternReturn() {
final int k = PreambleUtil.DEFAULT_K;
- final DoublesSketch qs1 = buildAndLoadQS(k, 64);
+ final QuantilesDoublesSketch qs1 = buildAndLoadQS(k, 64);
final byte[] byteArr = qs1.toByteArray();
final MemorySegment seg = MemorySegment.ofArray(byteArr);
HeapUpdateDoublesSketch.heapifyInstance(seg);
@@ -517,7 +517,7 @@ public void checkZeroPatternReturn() {
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkBadDownSamplingRatio() {
final int k1 = 64;
- final DoublesSketch qs1 = buildAndLoadQS(k1, k1);
+ final QuantilesDoublesSketch qs1 = buildAndLoadQS(k1, k1);
qs1.downSample(qs1, 2*k1, null, null);//should be smaller
}
@@ -561,7 +561,7 @@ public void checkDownSampling() {
public void testDownSampling2() {
final HeapUpdateDoublesSketch sketch1 = HeapUpdateDoublesSketch.newInstance(8);
final HeapUpdateDoublesSketch sketch2 = HeapUpdateDoublesSketch.newInstance(2);
- DoublesSketch downSketch;
+ QuantilesDoublesSketch downSketch;
downSketch = sketch1.downSample(sketch1, 2, null, null);
assertTrue(sameStructurePredicate(sketch2, downSketch));
for (int i = 0; i < 50; i++) {
@@ -577,9 +577,9 @@ public void testDownSampling3() {
final int k1 = 8;
final int k2 = 2;
final int n = 50;
- final UpdateDoublesSketch sketch1 = DoublesSketch.builder().setK(k1).build();
- final UpdateDoublesSketch sketch2 = DoublesSketch.builder().setK(k2).build();
- DoublesSketch downSketch;
+ final UpdatableQuantilesDoublesSketch sketch1 = QuantilesDoublesSketch.builder().setK(k1).build();
+ final UpdatableQuantilesDoublesSketch sketch2 = QuantilesDoublesSketch.builder().setK(k2).build();
+ QuantilesDoublesSketch downSketch;
for (int i = 0; i < n; i++) {
sketch1.update (i);
sketch2.update (i);
@@ -593,10 +593,10 @@ public void testDownSampling3withSeg() {
final int k1 = 8;
final int k2 = 2;
final int n = 50;
- final UpdateDoublesSketch sketch1 = DoublesSketch.builder().setK(k1).build();
- final UpdateDoublesSketch sketch2 = DoublesSketch.builder().setK(k2).build();
- DoublesSketch downSketch;
- final int bytes = DoublesSketch.getUpdatableStorageBytes(k2, n);
+ final UpdatableQuantilesDoublesSketch sketch1 = QuantilesDoublesSketch.builder().setK(k1).build();
+ final UpdatableQuantilesDoublesSketch sketch2 = QuantilesDoublesSketch.builder().setK(k2).build();
+ QuantilesDoublesSketch downSketch;
+ final int bytes = QuantilesDoublesSketch.getUpdatableStorageBytes(k2, n);
final MemorySegment seg = MemorySegment.ofArray(new byte[bytes]);
for (int i = 0; i < n; i++) {
sketch1.update (i);
@@ -635,22 +635,22 @@ public void testDownSampling4() {
@Test(expectedExceptions = SketchesArgumentException.class)
public void testDownSamplingExceptions1() {
- final UpdateDoublesSketch qs1 = DoublesSketch.builder().setK(4).build(); // not smaller
- final DoublesSketch qs2 = DoublesSketch.builder().setK(3).build();
+ final UpdatableQuantilesDoublesSketch qs1 = QuantilesDoublesSketch.builder().setK(4).build(); // not smaller
+ final QuantilesDoublesSketch qs2 = QuantilesDoublesSketch.builder().setK(3).build();
DoublesMergeImpl.mergeInto(qs2, qs1);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void testDownSamplingExceptions2() {
- final UpdateDoublesSketch qs1 = DoublesSketch.builder().setK(4).build();
- final DoublesSketch qs2 = DoublesSketch.builder().setK(7).build(); // 7/4 not pwr of 2
+ final UpdatableQuantilesDoublesSketch qs1 = QuantilesDoublesSketch.builder().setK(4).build();
+ final QuantilesDoublesSketch qs2 = QuantilesDoublesSketch.builder().setK(7).build(); // 7/4 not pwr of 2
DoublesMergeImpl.mergeInto(qs2, qs1);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void testDownSamplingExceptions3() {
- final UpdateDoublesSketch qs1 = DoublesSketch.builder().setK(4).build();
- final DoublesSketch qs2 = DoublesSketch.builder().setK(12).build(); // 12/4 not pwr of 2
+ final UpdatableQuantilesDoublesSketch qs1 = QuantilesDoublesSketch.builder().setK(4).build();
+ final QuantilesDoublesSketch qs2 = QuantilesDoublesSketch.builder().setK(12).build(); // 12/4 not pwr of 2
DoublesMergeImpl.mergeInto(qs2, qs1);
}
@@ -658,7 +658,7 @@ public void testDownSamplingExceptions3() {
public void quantilesCheckViaMemory() {
final int k = 256;
final int n = 1000000;
- final DoublesSketch qs = buildAndLoadQS(k, n);
+ final QuantilesDoublesSketch qs = buildAndLoadQS(k, n);
final double[] ranks = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0};
final String s = getRanksTable(qs, ranks);
println(s);
@@ -670,7 +670,7 @@ public void quantilesCheckViaMemory() {
println(getRanksTable(qs2, ranks));
}
- static String getRanksTable(final DoublesSketch qs, final double[] ranks) {
+ static String getRanksTable(final QuantilesDoublesSketch qs, final double[] ranks) {
final double rankError = qs.getNormalizedRankError(false);
final double[] values = qs.getQuantiles(ranks);
final double maxV = qs.getMaxItem();
@@ -714,34 +714,34 @@ static String getRanksTable(final DoublesSketch qs, final double[] ranks) {
@Test
public void checkKisTwo() {
final int k = 2;
- final UpdateDoublesSketch qs1 = DoublesSketch.builder().setK(k).build();
+ final UpdatableQuantilesDoublesSketch qs1 = QuantilesDoublesSketch.builder().setK(k).build();
final double err = qs1.getNormalizedRankError(false);
assertTrue(err < 1.0);
byte[] arr = qs1.toByteArray(true); //8
- assertEquals(arr.length, DoublesSketch.getCompactSerialiedSizeBytes(k, 0));
+ assertEquals(arr.length, QuantilesDoublesSketch.getCompactSerialiedSizeBytes(k, 0));
qs1.update(1.0);
arr = qs1.toByteArray(true); //40
- assertEquals(arr.length, DoublesSketch.getCompactSerialiedSizeBytes(k, 1));
+ assertEquals(arr.length, QuantilesDoublesSketch.getCompactSerialiedSizeBytes(k, 1));
}
@Test
public void checkKisTwoDeprecated() {
final int k = 2;
- final UpdateDoublesSketch qs1 = DoublesSketch.builder().setK(k).build();
+ final UpdatableQuantilesDoublesSketch qs1 = QuantilesDoublesSketch.builder().setK(k).build();
final double err = qs1.getNormalizedRankError(false);
assertTrue(err < 1.0);
byte[] arr = qs1.toByteArray(true); //8
- assertEquals(arr.length, DoublesSketch.getCompactSerialiedSizeBytes(k, 0));
+ assertEquals(arr.length, QuantilesDoublesSketch.getCompactSerialiedSizeBytes(k, 0));
assertEquals(arr.length, qs1.getCurrentCompactSerializedSizeBytes());
qs1.update(1.0);
arr = qs1.toByteArray(true); //40
- assertEquals(arr.length, DoublesSketch.getCompactSerialiedSizeBytes(k, 1));
+ assertEquals(arr.length, QuantilesDoublesSketch.getCompactSerialiedSizeBytes(k, 1));
assertEquals(arr.length, qs1.getCurrentCompactSerializedSizeBytes());
}
@Test
public void checkPutMemory() {
- final UpdateDoublesSketch qs1 = DoublesSketch.builder().build(); //k = 128
+ final UpdatableQuantilesDoublesSketch qs1 = QuantilesDoublesSketch.builder().build(); //k = 128
for (int i=0; i<1000; i++) {
qs1.update(i);
}
@@ -749,14 +749,14 @@ public void checkPutMemory() {
final MemorySegment dstSeg = MemorySegment.ofArray(new byte[bytes]);
qs1.putIntoMemorySegment(dstSeg, false);
final MemorySegment srcSeg = dstSeg;
- final DoublesSketch qs2 = DoublesSketch.heapify(srcSeg);
+ final QuantilesDoublesSketch qs2 = QuantilesDoublesSketch.heapify(srcSeg);
assertEquals(qs1.getMinItem(), qs2.getMinItem(), 0.0);
assertEquals(qs1.getMaxItem(), qs2.getMaxItem(), 0.0);
}
@Test(expectedExceptions = SketchesArgumentException.class)
public void checkPutMemoryTooSmall() {
- final UpdateDoublesSketch qs1 = DoublesSketch.builder().build(); //k = 128
+ final UpdatableQuantilesDoublesSketch qs1 = QuantilesDoublesSketch.builder().build(); //k = 128
for (int i=0; i<1000; i++) {
qs1.update(i);
}
@@ -772,11 +772,11 @@ public void testIt() {
final MemorySegment seg = MemorySegment.ofBuffer(bb);
final int k = 1024;
- final DoublesSketch qsk = new DoublesSketchBuilder().setK(k).build();
- final DoublesUnion u1 = DoublesUnion.heapify(qsk);
+ final QuantilesDoublesSketch qsk = new QuantilesDoublesSketchBuilder().setK(k).build();
+ final QuantilesDoublesUnion u1 = QuantilesDoublesUnion.heapify(qsk);
u1.getResult().putIntoMemorySegment(seg);
- final DoublesUnion u2 = DoublesUnion.heapify(seg);
- final DoublesSketch qsk2 = u2.getResult();
+ final QuantilesDoublesUnion u2 = QuantilesDoublesUnion.heapify(seg);
+ final QuantilesDoublesSketch qsk2 = u2.getResult();
assertTrue(qsk2.isEmpty());
}
@@ -795,7 +795,7 @@ public void checkEquallySpacedRanks() {
@Test
public void checkPMFonEmpty() {
- final DoublesSketch qsk = buildAndLoadQS(32, 1001);
+ final QuantilesDoublesSketch qsk = buildAndLoadQS(32, 1001);
final double[] array = {};
final double[] qOut = qsk.getQuantiles(array);
assertEquals(qOut.length, 0);
@@ -808,7 +808,7 @@ public void checkPMFonEmpty() {
@Test
public void checkPuts() {
final long n1 = 1001;
- final UpdateDoublesSketch qsk = buildAndLoadQS(32, (int)n1);
+ final UpdatableQuantilesDoublesSketch qsk = buildAndLoadQS(32, (int)n1);
final long n2 = qsk.getN();
assertEquals(n2, n1);
@@ -832,12 +832,12 @@ public void checkPuts() {
@Test
public void serializeDeserializeCompact() {
- final UpdateDoublesSketch sketch1 = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch sketch1 = QuantilesDoublesSketch.builder().build();
for (int i = 0; i < 1000; i++) {
sketch1.update(i);
}
- UpdateDoublesSketch sketch2;
- sketch2 = (UpdateDoublesSketch) DoublesSketch.heapify(MemorySegment.ofArray(sketch1.toByteArray()));
+ UpdatableQuantilesDoublesSketch sketch2;
+ sketch2 = (UpdatableQuantilesDoublesSketch) QuantilesDoublesSketch.heapify(MemorySegment.ofArray(sketch1.toByteArray()));
for (int i = 0; i < 1000; i++) {
sketch2.update(i + 1000);
}
@@ -848,11 +848,11 @@ public void serializeDeserializeCompact() {
@Test
public void serializeDeserializeEmptyNonCompact() {
- final UpdateDoublesSketch sketch1 = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch sketch1 = QuantilesDoublesSketch.builder().build();
final byte[] byteArr = sketch1.toByteArray(false); //Ordered, Not Compact, Empty
assertEquals(byteArr.length, sketch1.getSerializedSizeBytes());
final MemorySegment seg = MemorySegment.ofArray(byteArr);
- final UpdateDoublesSketch sketch2 = (UpdateDoublesSketch) DoublesSketch.heapify(seg);
+ final UpdatableQuantilesDoublesSketch sketch2 = (UpdatableQuantilesDoublesSketch) QuantilesDoublesSketch.heapify(seg);
for (int i = 0; i < 1000; i++) {
sketch2.update(i);
}
@@ -863,7 +863,7 @@ public void serializeDeserializeEmptyNonCompact() {
@Test
public void getRankAndGetCdfConsistency() {
- final UpdateDoublesSketch sketch = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch sketch = QuantilesDoublesSketch.builder().build();
final int n = 1_000_000;
final double[] values = new double[n];
for (int i = 0; i < n; i++) {
@@ -886,13 +886,13 @@ public void getRankAndGetCdfConsistency() {
@Test
public void maxK() {
- final UpdateDoublesSketch sketch = DoublesSketch.builder().setK(32768).build();
+ final UpdatableQuantilesDoublesSketch sketch = QuantilesDoublesSketch.builder().setK(32768).build();
Assert.assertEquals(sketch.getK(), 32768);
}
@Test
public void checkBounds() {
- final UpdateDoublesSketch sketch = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch sketch = QuantilesDoublesSketch.builder().build();
for (int i = 0; i < 1000; i++) {
sketch.update(i);
}
@@ -909,19 +909,19 @@ public void checkBounds() {
@Test
public void checkGetKFromEqs() {
- final UpdateDoublesSketch sketch = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch sketch = QuantilesDoublesSketch.builder().build();
final int k = sketch.getK();
- final double eps = DoublesSketch.getNormalizedRankError(k, false);
- final double epsPmf = DoublesSketch.getNormalizedRankError(k, true);
- final int kEps = DoublesSketch.getKFromEpsilon(eps, false);
- final int kEpsPmf = DoublesSketch.getKFromEpsilon(epsPmf, true);
+ final double eps = QuantilesDoublesSketch.getNormalizedRankError(k, false);
+ final double epsPmf = QuantilesDoublesSketch.getNormalizedRankError(k, true);
+ final int kEps = QuantilesDoublesSketch.getKFromEpsilon(eps, false);
+ final int kEpsPmf = QuantilesDoublesSketch.getKFromEpsilon(epsPmf, true);
assertEquals(kEps, k);
assertEquals(kEpsPmf, k);
}
@Test
public void tenItems() {
- final UpdateDoublesSketch sketch = DoublesSketch.builder().build();
+ final UpdatableQuantilesDoublesSketch sketch = QuantilesDoublesSketch.builder().build();
for (int i = 1; i <= 10; i++) { sketch.update(i); }
assertFalse(sketch.isEmpty());
assertEquals(sketch.getN(), 10);
@@ -979,13 +979,13 @@ public void tenItems() {
private static void checksForImproperK(final int k) {
final String s = "Did not catch improper k: " + k;
try {
- DoublesSketch.builder().setK(k);
+ QuantilesDoublesSketch.builder().setK(k);
fail(s);
} catch (final SketchesArgumentException e) {
//pass
}
try {
- DoublesSketch.builder().setK(k).build();
+ QuantilesDoublesSketch.builder().setK(k).build();
fail(s);
} catch (final SketchesArgumentException e) {
//pass
@@ -998,7 +998,7 @@ private static void checksForImproperK(final int k) {
}
}
- private static boolean sameStructurePredicate(final DoublesSketch mq1, final DoublesSketch mq2) {
+ private static boolean sameStructurePredicate(final QuantilesDoublesSketch mq1, final QuantilesDoublesSketch mq2) {
final boolean b1 =
( (mq1.getK() == mq2.getK())
&& (mq1.getN() == mq2.getN())
@@ -1018,12 +1018,12 @@ private static boolean sameStructurePredicate(final DoublesSketch mq1, final Dou
return b1 && b2;
}
- static UpdateDoublesSketch buildAndLoadQS(final int k, final int n) {
+ static UpdatableQuantilesDoublesSketch buildAndLoadQS(final int k, final int n) {
return buildAndLoadQS(k, n, 0);
}
- static UpdateDoublesSketch buildAndLoadQS(final int k, final int n, final int startV) {
- final UpdateDoublesSketch qs = DoublesSketch.builder().setK(k).build();
+ static UpdatableQuantilesDoublesSketch buildAndLoadQS(final int k, final int n, final int startV) {
+ final UpdatableQuantilesDoublesSketch qs = QuantilesDoublesSketch.builder().setK(k).build();
for (int i=1; i<=n; i++) {
qs.update(startV + i);
}
diff --git a/src/test/java/org/apache/datasketches/quantiles/ItemsSketchIteratorTest.java b/src/test/java/org/apache/datasketches/quantiles/ItemsSketchIteratorTest.java
index 34ccf8099..912d6237e 100644
--- a/src/test/java/org/apache/datasketches/quantiles/ItemsSketchIteratorTest.java
+++ b/src/test/java/org/apache/datasketches/quantiles/ItemsSketchIteratorTest.java
@@ -21,7 +21,7 @@
import java.util.Comparator;
-import org.apache.datasketches.quantilescommon.QuantilesGenericSketchIterator;
+import org.apache.datasketches.quantilescommon.QuantilesGenericSketchIteratorAPI;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -29,16 +29,16 @@ public class ItemsSketchIteratorTest {
@Test
public void emptySketch() {
- ItemsSketch sketch = ItemsSketch.getInstance(Integer.class, 128, Comparator.naturalOrder());
- QuantilesGenericSketchIterator it = sketch.iterator();
+ QuantilesItemsSketch sketch = QuantilesItemsSketch.getInstance(Integer.class, 128, Comparator.naturalOrder());
+ QuantilesGenericSketchIteratorAPI it = sketch.iterator();
Assert.assertFalse(it.next());
}
@Test
public void oneItemSketch() {
- ItemsSketch sketch = ItemsSketch.getInstance(Integer.class, 128, Comparator.naturalOrder());
+ QuantilesItemsSketch sketch = QuantilesItemsSketch.getInstance(Integer.class, 128, Comparator.naturalOrder());
sketch.update(0);
- QuantilesGenericSketchIterator it = sketch.iterator();
+ QuantilesGenericSketchIteratorAPI it = sketch.iterator();
Assert.assertTrue(it.next());
Assert.assertEquals(it.getQuantile(), Integer.valueOf(0));
Assert.assertEquals(it.getWeight(), 1);
@@ -48,11 +48,11 @@ public void oneItemSketch() {
@Test
public void bigSketches() {
for (int n = 1000; n < 100000; n += 2000) {
- ItemsSketch sketch = ItemsSketch.getInstance(Integer.class, 128, Comparator.naturalOrder());
+ QuantilesItemsSketch sketch = QuantilesItemsSketch.getInstance(Integer.class, 128, Comparator.naturalOrder());
for (int i = 0; i < n; i++) {
sketch.update(i);
}
- QuantilesGenericSketchIterator it = sketch.iterator();
+ QuantilesGenericSketchIteratorAPI it = sketch.iterator();
int count = 0;
int weight = 0;
while (it.next()) {
diff --git a/src/test/java/org/apache/datasketches/quantiles/ItemsSketchTest.java b/src/test/java/org/apache/datasketches/quantiles/ItemsSketchTest.java
index 7eaee1238..d557868b9 100644
--- a/src/test/java/org/apache/datasketches/quantiles/ItemsSketchTest.java
+++ b/src/test/java/org/apache/datasketches/quantiles/ItemsSketchTest.java
@@ -43,7 +43,7 @@
import org.apache.datasketches.quantilescommon.GenericSortedView;
import org.apache.datasketches.quantilescommon.GenericSortedViewIterator;
import org.apache.datasketches.quantilescommon.ItemsSketchSortedView;
-import org.apache.datasketches.quantilescommon.QuantilesGenericSketchIterator;
+import org.apache.datasketches.quantilescommon.QuantilesGenericSketchIteratorAPI;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -51,12 +51,12 @@ public class ItemsSketchTest {
@BeforeMethod
public void setUp() {
- ItemsSketch.rand.setSeed(32749); // make sketches deterministic for testing
+ QuantilesItemsSketch.rand.setSeed(32749); // make sketches deterministic for testing
}
@Test
public void empty() {
- final ItemsSketch sketch = ItemsSketch.getInstance(String.class, 128, Comparator.naturalOrder());
+ final QuantilesItemsSketch sketch = QuantilesItemsSketch.getInstance(String.class, 128, Comparator.naturalOrder());
assertNotNull(sketch);
sketch.update(null);
assertTrue(sketch.isEmpty());
@@ -77,7 +77,7 @@ public void empty() {
@Test
public void oneItem() {
- final ItemsSketch sketch = ItemsSketch.getInstance(String.class, 128, Comparator.naturalOrder());
+ final QuantilesItemsSketch sketch = QuantilesItemsSketch.getInstance(String.class, 128, Comparator.naturalOrder());
sketch.update("a");
assertEquals(sketch.getN(), 1);
assertEquals(sketch.getNumRetained(), 1);
@@ -123,7 +123,7 @@ public void oneItem() {
@Test
public void tenItems() {
- final ItemsSketch sketch = ItemsSketch.getInstance(Integer.class, 128, Comparator.naturalOrder());
+ final QuantilesItemsSketch sketch = QuantilesItemsSketch.getInstance(Integer.class, 128, Comparator.naturalOrder());
for (int i = 1; i <= 10; i++) { sketch.update(i); }
assertFalse(sketch.isEmpty());
assertFalse(sketch.isReadOnly());
@@ -189,7 +189,7 @@ public void tenItems() {
@Test
public void estimation() {
- final ItemsSketch sketch = ItemsSketch.getInstance(Integer.class, 128, Comparator.naturalOrder());
+ final QuantilesItemsSketch sketch = QuantilesItemsSketch.getInstance(Integer.class, 128, Comparator.naturalOrder());
for (int i = 1; i <= 1000; i++) {
sketch.update(i);
}
@@ -255,15 +255,15 @@ public void estimation() {
@Test
public void serializeDeserializeLong() {
- final ItemsSketch sketch1 = ItemsSketch.getInstance(Long.class, 128, Comparator.naturalOrder());
+ final QuantilesItemsSketch sketch1 = QuantilesItemsSketch.getInstance(Long.class, 128, Comparator.naturalOrder());
for (int i = 1; i <= 500; i++) {
sketch1.update((long) i);
}
final ArrayOfItemsSerDe serDe = new ArrayOfLongsSerDe();
final byte[] bytes = sketch1.toByteArray(serDe);
- final ItemsSketch sketch2 =
- ItemsSketch.heapify(Long.class, MemorySegment.ofArray(bytes), Comparator.naturalOrder(), serDe);
+ final QuantilesItemsSketch sketch2 =
+ QuantilesItemsSketch.heapify(Long.class, MemorySegment.ofArray(bytes), Comparator.naturalOrder(), serDe);
for (int i = 501; i <= 1000; i++) {
sketch2.update((long) i);
@@ -278,15 +278,15 @@ public void serializeDeserializeLong() {
@Test
public void serializeDeserializeDouble() {
- final ItemsSketch sketch1 = ItemsSketch.getInstance(Double.class, 128, Comparator.naturalOrder());
+ final QuantilesItemsSketch sketch1 = QuantilesItemsSketch.getInstance(Double.class, 128, Comparator.naturalOrder());
for (int i = 1; i <= 500; i++) {
sketch1.update((double) i);
}
final ArrayOfItemsSerDe serDe = new ArrayOfDoublesSerDe();
final byte[] bytes = sketch1.toByteArray(serDe);
- final ItemsSketch sketch2 =
- ItemsSketch.heapify(Double.class, MemorySegment.ofArray(bytes), Comparator.naturalOrder(), serDe);
+ final QuantilesItemsSketch sketch2 =
+ QuantilesItemsSketch.heapify(Double.class, MemorySegment.ofArray(bytes), Comparator.naturalOrder(), serDe);
for (int i = 501; i <= 1000; i++) {
sketch2.update((double) i);
@@ -310,7 +310,7 @@ public int compare(final String s1, final String s2) {
return i1.compareTo(i2);
}
};
- final ItemsSketch sketch1 = ItemsSketch.getInstance(String.class, 128, numericOrder);
+ final QuantilesItemsSketch sketch1 = QuantilesItemsSketch.getInstance(String.class, 128, numericOrder);
for (int i = 1; i <= 500; i++)
{
sketch1.update(Integer.toBinaryString(i << 10)); // to make strings longer
@@ -318,7 +318,7 @@ public int compare(final String s1, final String s2) {
final ArrayOfItemsSerDe serDe = new ArrayOfStringsSerDe();
final byte[] bytes = sketch1.toByteArray(serDe);
- final ItemsSketch sketch2 = ItemsSketch.heapify(String.class, MemorySegment.ofArray(bytes), numericOrder, serDe);
+ final QuantilesItemsSketch sketch2 = QuantilesItemsSketch.heapify(String.class, MemorySegment.ofArray(bytes), numericOrder, serDe);
for (int i = 501; i <= 1000; i++) {
sketch2.update(Integer.toBinaryString(i << 10));
@@ -333,7 +333,7 @@ public int compare(final String s1, final String s2) {
@Test
public void toStringCrudeCheck() {
- final ItemsSketch sketch = ItemsSketch.getInstance(String.class, Comparator.naturalOrder());
+ final QuantilesItemsSketch sketch = QuantilesItemsSketch.getInstance(String.class, Comparator.naturalOrder());
String brief, full, part;
brief = sketch.toString();
full = sketch.toString(true, true);
@@ -347,15 +347,15 @@ public void toStringCrudeCheck() {
assertTrue(part.length() < full.length());
final ArrayOfItemsSerDe serDe = new ArrayOfStringsSerDe();
final byte[] bytes = sketch.toByteArray(serDe);
- ItemsSketch.toString(bytes);
- ItemsSketch.toString(MemorySegment.ofArray(bytes));
- //PreambleUtil.toString(bytes, true); // not a DoublesSketch so this will fail
- //ItemsSketch sketch2 = ItemsSketch.getInstance(MemorySegment.wrap(bytes), Comparator.naturalOrder(), serDe);
+ QuantilesItemsSketch.toString(bytes);
+ QuantilesItemsSketch.toString(MemorySegment.ofArray(bytes));
+ //PreambleUtil.toString(bytes, true); // not a QuantilesDoublesSketch so this will fail
+ //QuantilesItemsSketch