You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by le...@apache.org on 2022/07/29 03:56:19 UTC
[datasketches-java] 07/08: Interim 3
This is an automated email from the ASF dual-hosted git repository.
leerho pushed a commit to branch More_changes_to_REQ
in repository https://gitbox.apache.org/repos/asf/datasketches-java.git
commit 4a828111a9a508ab5404809b2373959351b5dfde
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Wed Jul 27 10:06:38 2022 -0700
Interim 3
---
.../kll/KllDoublesSketchSortedView.java | 3 +-
.../apache/datasketches/kll/KllFloatsSketch.java | 90 +++++++++++-----------
.../kll/KllFloatsSketchSortedView.java | 44 +++++------
.../org/apache/datasketches/kll/KllHelper.java | 15 ++++
.../datasketches/kll/KllQuantilesHelper.java | 19 +----
.../datasketches/kll/KllFloatsSketchTest.java | 37 +--------
...blesTest.java => KllMiscDirectDoublesTest.java} | 2 +-
...loatsTest.java => KllMiscDirectFloatsTest.java} | 2 +-
...iscDoublesTest.java => KllMiscDoublesTest.java} | 2 +-
...{MiscFloatsTest.java => KllMiscFloatsTest.java} | 24 +++---
10 files changed, 102 insertions(+), 136 deletions(-)
diff --git a/src/main/java/org/apache/datasketches/kll/KllDoublesSketchSortedView.java b/src/main/java/org/apache/datasketches/kll/KllDoublesSketchSortedView.java
index 2fe496ac..cbf3f7fd 100644
--- a/src/main/java/org/apache/datasketches/kll/KllDoublesSketchSortedView.java
+++ b/src/main/java/org/apache/datasketches/kll/KllDoublesSketchSortedView.java
@@ -52,7 +52,6 @@ public final class KllDoublesSketchSortedView {
private int numLevels_;
// assumes that all levels are sorted including level 0
- @SuppressWarnings("deprecation")
KllDoublesSketchSortedView(final double[] items, final int[] levels, final int numLevels,
final long n, final boolean cumulative, final boolean inclusive) {
n_ = n;
@@ -63,7 +62,7 @@ public final class KllDoublesSketchSortedView {
populateFromSketch(items, levels, numLevels, numItems);
blockyTandemMergeSort(items_, weights_, levels_, numLevels_);
if (cumulative) {
- KllQuantilesHelper.convertToPrecedingCumulative(weights_, inclusive);
+ KllHelper.convertToCumulative(weights_);
}
}
diff --git a/src/main/java/org/apache/datasketches/kll/KllFloatsSketch.java b/src/main/java/org/apache/datasketches/kll/KllFloatsSketch.java
index 53538e2d..e420fcf6 100644
--- a/src/main/java/org/apache/datasketches/kll/KllFloatsSketch.java
+++ b/src/main/java/org/apache/datasketches/kll/KllFloatsSketch.java
@@ -34,6 +34,7 @@ import org.apache.datasketches.memory.MemoryRequestServer;
import org.apache.datasketches.memory.WritableMemory;
public abstract class KllFloatsSketch extends KllSketch {
+ KllFloatsSketchSortedView sortedView = null;
KllFloatsSketch(final WritableMemory wmem, final MemoryRequestServer memReqSvr) {
super(SketchType.FLOATS_SKETCH, wmem, memReqSvr);
@@ -156,6 +157,16 @@ public abstract class KllFloatsSketch extends KllSketch {
}
}
+ /**
+ * Same as {@link #getCDF(float[], boolean) getCDF(float[] splitPoints, false)}
+ * @param splitPoints splitPoints
+ * @return CDF
+ */
+ public double[] getCDF(final float[] splitPoints) {
+ //TDO add check for sorted view eventually
+ return KllFloatsSketchSortedView.getFloatsPmfOrCdf(this, splitPoints, true, false);
+ }
+
/**
* Returns an approximation to the Cumulative Distribution Function (CDF), which is the
* cumulative analog of the PMF, of the input stream given a set of splitPoint (values).
@@ -173,7 +184,7 @@ public abstract class KllFloatsSketch extends KllSketch {
* It is not necessary to include either the min or max values in these split points.
*
* @param inclusive if true the weight of the given value is included into the rank.
- * Otherwise the rank equals the sum of the weights of all values that are less than the given value
+ * Otherwise, the rank equals the sum of the weights of all values that are less than the given value
*
* @return an array of m+1 double values on the interval [0.0, 1.0),
* which are a consecutive approximation to the CDF of the input stream given the splitPoints.
@@ -181,18 +192,10 @@ public abstract class KllFloatsSketch extends KllSketch {
* in positions 0 through j of the returned PMF array.
*/
public double[] getCDF(final float[] splitPoints, final boolean inclusive) {
+ //TODO add check for sorted view eventually
return KllFloatsSketchSortedView.getFloatsPmfOrCdf(this, splitPoints, true, inclusive);
}
- /**
- * Same as {@link #getCDF(float[], boolean) getCDF(float[] splitPoints, false)}
- * @param splitPoints splitPoints
- * @return CDF
- */
- public double[] getCDF(final float[] splitPoints) {
- return KllFloatsSketchSortedView.getFloatsPmfOrCdf(this, splitPoints, true, false);
- }
-
/**
* Returns the max value of the stream.
* If the sketch is empty this returns NaN.
@@ -209,6 +212,15 @@ public abstract class KllFloatsSketch extends KllSketch {
*/
public float getMinValue() { return getMinFloatValue(); }
+ /**
+ * Same as {@link #getPMF(float[], boolean) getPMF(float[] splitPoints, false)}
+ * @param splitPoints splitPoints
+ * @return PMF
+ */
+ public double[] getPMF(final float[] splitPoints) {
+ return KllFloatsSketchSortedView.getFloatsPmfOrCdf(this, splitPoints, false, false);
+ }
+
/**
* Returns an approximation to the Probability Mass Function (PMF) of the input stream
* given a set of splitPoints (values).
@@ -235,16 +247,17 @@ public abstract class KllFloatsSketch extends KllSketch {
* splitPoint, with the exception that the last interval will include maximum value.
*/
public double[] getPMF(final float[] splitPoints, final boolean inclusive) {
+ //add check for sorted view eventually
return KllFloatsSketchSortedView.getFloatsPmfOrCdf(this, splitPoints, false, inclusive);
}
/**
- * Same as {@link #getPMF(float[], boolean) getPMF(float[] splitPoints, false)}
- * @param splitPoints splitPoints
- * @return PMF
+ * Same as {@link #getQuantile(double, boolean) getQuantile(double fraction, false)}
+ * @param rank the given normalized rank, a value in the interval [0.0,1.0].
+ * @return quantile
*/
- public double[] getPMF(final float[] splitPoints) {
- return KllFloatsSketchSortedView.getFloatsPmfOrCdf(this, splitPoints, false, false);
+ public float getQuantile(final double rank) {
+ return KllFloatsSketchSortedView.getFloatsQuantile(this, rank, false);
}
/**
@@ -258,36 +271,26 @@ public abstract class KllFloatsSketch extends KllSketch {
*
* <p>If the sketch is empty this returns NaN.
*
- * @param fraction the specified fractional position in the hypothetical sorted stream.
- * These are also called normalized ranks or fractional ranks.
- * If fraction = 0.0, the true minimum value of the stream is returned.
- * If fraction = 1.0, the true maximum value of the stream is returned.
+ * @param rank the given normalized rank, a value in the interval [0.0,1.0].
*
- * @param inclusive if true, the given fraction (rank) is considered inclusive
+ * @param inclusive if true, the given rank includes all values ≤ the value directly
+ * corresponding to the given rank.
* @return the approximation to the value at the given fraction
*/
- public float getQuantile(final double fraction, final boolean inclusive) {
- return KllFloatsSketchSortedView.getFloatsQuantile(this, fraction, inclusive);
- }
-
- /**
- * Same as {@link #getQuantile(double, boolean) getQuantile(double fraction, false)}
- * @param fraction fractional rank
- * @return quantile
- */
- public float getQuantile(final double fraction) {
- return KllFloatsSketchSortedView.getFloatsQuantile(this, fraction, false);
+ public float getQuantile(final double rank, final boolean inclusive) {
+ //TODO START HERE
+ return KllFloatsSketchSortedView.getFloatsQuantile(this, rank, inclusive);
}
/**
* Gets the lower bound of the value interval in which the true quantile of the given rank
* exists with a confidence of at least 99%.
- * @param fraction the given normalized rank as a fraction
+ * @param rank the given normalized rank, a value in the interval [0.0,1.0].
* @return the lower bound of the value interval in which the true quantile of the given rank
* exists with a confidence of at least 99%. Returns NaN if the sketch is empty.
*/
- public float getQuantileLowerBound(final double fraction) {
- return getQuantile(max(0, fraction - KllHelper.getNormalizedRankError(getMinK(), false)));
+ public float getQuantileLowerBound(final double rank) {
+ return getQuantile(max(0, rank - KllHelper.getNormalizedRankError(getMinK(), false)));
}
/**
@@ -301,11 +304,8 @@ public abstract class KllFloatsSketch extends KllSketch {
*
* <p>If the sketch is empty this returns null.
*
- * @param fractions given array of fractional positions in the hypothetical sorted stream.
- * These are also called normalized ranks or fractional ranks.
- * These fractions must be in the interval [0.0, 1.0], inclusive.
- *
- * @param inclusive if true, the given fractions (ranks) are considered inclusive
+ * @param fractions the given array of normalized ranks, each of which must be in the interval [0.0,1.0].
+ * @param inclusive if true, the given ranks include all values ≤ the value directly corresponding to each rank.
* @return array of approximations to the given fractions in the same order as given fractions
* array.
*/
@@ -315,11 +315,11 @@ public abstract class KllFloatsSketch extends KllSketch {
/**
* Same as {@link #getQuantiles(double[], boolean) getQuantiles(double[] fractions, false)}
- * @param fractions fractional ranks
+ * @param ranks fractional ranks
* @return quantiles
*/
- public float[] getQuantiles(final double[] fractions) {
- return KllFloatsSketchSortedView.getFloatsQuantiles(this, fractions, false);
+ public float[] getQuantiles(final double[] ranks) {
+ return KllFloatsSketchSortedView.getFloatsQuantiles(this, ranks, false);
}
/**
@@ -410,12 +410,10 @@ public abstract class KllFloatsSketch extends KllSketch {
/**
* Sorted view of the sketch.
* Complexity: linear, single-pass merge of sorted levels plus sorting of the level 0.
- * @param cumulative if true weights are cumulative
- * @param inclusive if true cumulative weight of an item includes its own weight
* @return sorted view object
*/
- public KllFloatsSketchSortedView getSortedView(final boolean cumulative, final boolean inclusive) {
- return KllFloatsSketchSortedView.getFloatsSortedView(this, cumulative, inclusive);
+ public KllFloatsSketchSortedView getSortedView() {
+ return KllFloatsSketchSortedView.getFloatsSortedView(this);
}
@Override //Artifact of inheritance
diff --git a/src/main/java/org/apache/datasketches/kll/KllFloatsSketchSortedView.java b/src/main/java/org/apache/datasketches/kll/KllFloatsSketchSortedView.java
index 2ea3d15a..b4f8191f 100644
--- a/src/main/java/org/apache/datasketches/kll/KllFloatsSketchSortedView.java
+++ b/src/main/java/org/apache/datasketches/kll/KllFloatsSketchSortedView.java
@@ -45,7 +45,6 @@ import org.apache.datasketches.SketchesStateException;
* @author Alexander Saydakov
*/
public final class KllFloatsSketchSortedView {
-
private final long n_;
private final float[] items_;
private final long[] weights_; //comes in as weights, converted to cumulative weights
@@ -53,19 +52,26 @@ public final class KllFloatsSketchSortedView {
private int numLevels_;
// assumes that all levels are sorted including level 0
- @SuppressWarnings("deprecation")
- KllFloatsSketchSortedView(final float[] items, final int[] levels, final int numLevels,
- final long n, final boolean cumulative, final boolean inclusive) {
+ KllFloatsSketchSortedView(final float[] items, final int[] levels, final int numLevels, final long n) {
n_ = n;
final int numItems = levels[numLevels] - levels[0];
items_ = new float[numItems];
- weights_ = new long[numItems + 1]; // one more is intentional
+ weights_ = new long[numItems];
levels_ = new int[numLevels + 1];
populateFromSketch(items, levels, numLevels, numItems);
blockyTandemMergeSort(items_, weights_, levels_, numLevels_);
- if (cumulative) {
- KllQuantilesHelper.convertToPrecedingCumulative(weights_, inclusive);
+ KllHelper.convertToCumulative(weights_);
+ }
+
+ static KllFloatsSketchSortedView getFloatsSortedView(final KllSketch sketch) {
+ final float[] skFloatItemsArr = sketch.getFloatItemsArray();
+ final int[] skLevelsArr = sketch.getLevelsArray();
+
+ if (!sketch.isLevelZeroSorted()) {
+ Arrays.sort(skFloatItemsArr, skLevelsArr[0], skLevelsArr[1]);
+ if (!sketch.hasMemory()) { sketch.setLevelZeroSorted(true); }
}
+ return new KllFloatsSketchSortedView(skFloatItemsArr, skLevelsArr, sketch.getNumLevels(), sketch.getN());
}
private void populateFromSketch(final float[] srcItems, final int[] srcLevels,
@@ -91,18 +97,6 @@ public final class KllFloatsSketchSortedView {
numLevels_ = dstLevel;
}
- static KllFloatsSketchSortedView getFloatsSortedView(final KllSketch sketch,
- final boolean cumulative, final boolean inclusive) {
- final float[] skFloatItemsArr = sketch.getFloatItemsArray();
- final int[] skLevelsArr = sketch.getLevelsArray();
-
- if (!sketch.isLevelZeroSorted()) {
- Arrays.sort(skFloatItemsArr, skLevelsArr[0], skLevelsArr[1]);
- if (!sketch.hasMemory()) { sketch.setLevelZeroSorted(true); }
- }
- return new KllFloatsSketchSortedView(skFloatItemsArr, skLevelsArr, sketch.getNumLevels(), sketch.getN(),
- cumulative, inclusive);
- }
//For testing only. Allows testing of getQuantile without a sketch. NOT USED
KllFloatsSketchSortedView(final float[] items, final long[] weights, final long n) {
@@ -151,7 +145,7 @@ public final class KllFloatsSketchSortedView {
return (double) total / sketch.getN();
}
- //Called only from KllFloatsSketch
+ //Called only from KllFloatsSketch TODO rewrite using sorted view and new getRanks
static double[] getFloatsPmfOrCdf(final KllSketch sketch, final float[] splitPoints,
final boolean isCdf, final boolean inclusive) {
if (sketch.isEmpty()) { return null; }
@@ -242,13 +236,13 @@ public final class KllFloatsSketchSortedView {
}
//Called only from KllFloatsSketch
- static float getFloatsQuantile(final KllSketch sketch, final double fraction, final boolean inclusive) {
+ static float getFloatsQuantile(final KllSketch sketch, final double rank, final boolean inclusive) {
if (sketch.isEmpty()) { return Float.NaN; }
- if (fraction < 0.0 || fraction > 1.0) {
+ if (rank < 0.0 || rank > 1.0) {
throw new SketchesArgumentException("Fraction cannot be less than zero nor greater than 1.0");
}
- final KllFloatsSketchSortedView kllFSV = KllFloatsSketchSortedView.getFloatsSortedView(sketch, true, inclusive);
- return kllFSV.getQuantile(fraction);
+ final KllFloatsSketchSortedView kllFSV = KllFloatsSketchSortedView.getFloatsSortedView(sketch);
+ return kllFSV.getQuantile(rank);
}
//Called only from KllFloatsSketch
@@ -262,7 +256,7 @@ public final class KllFloatsSketchSortedView {
throw new SketchesArgumentException("Fraction cannot be less than zero nor greater than 1.0");
}
if (kllFSV == null) {
- kllFSV = KllFloatsSketchSortedView.getFloatsSortedView(sketch, true, inclusive);
+ kllFSV = getFloatsSortedView(sketch);
}
quantiles[i] = kllFSV.getQuantile(fraction);
}
diff --git a/src/main/java/org/apache/datasketches/kll/KllHelper.java b/src/main/java/org/apache/datasketches/kll/KllHelper.java
index 94512e08..8f5d4cc5 100644
--- a/src/main/java/org/apache/datasketches/kll/KllHelper.java
+++ b/src/main/java/org/apache/datasketches/kll/KllHelper.java
@@ -260,6 +260,21 @@ final class KllHelper {
return (int) total;
}
+ /**
+ * Convert the individual weights into cumulative weights.
+ * An array of {1,1,1,1} becomes {1,2,3,4}
+ * @param array of actual weights from the sketch, where first element is not zero.
+ * @return total weight
+ */
+ public static long convertToCumulative(final long[] array) {
+ long subtotal = 0;
+ for (int i = 0; i < array.length; i++) {
+ final long newSubtotal = subtotal + array[i];
+ subtotal = array[i] = newSubtotal;
+ }
+ return subtotal;
+ }
+
static int currentLevelSize(final int level, final int numLevels, final int[] levels) {
if (level >= numLevels) { return 0; }
return levels[level + 1] - levels[level];
diff --git a/src/main/java/org/apache/datasketches/kll/KllQuantilesHelper.java b/src/main/java/org/apache/datasketches/kll/KllQuantilesHelper.java
index d07355b4..64667508 100644
--- a/src/main/java/org/apache/datasketches/kll/KllQuantilesHelper.java
+++ b/src/main/java/org/apache/datasketches/kll/KllQuantilesHelper.java
@@ -26,22 +26,6 @@ package org.apache.datasketches.kll;
*/
@Deprecated
public class KllQuantilesHelper {
- /**
- * Convert the weights into totals of the weights preceding each item.
- * An array of {1,1,1,0} becomes {0,1,2,3}
- * @param array of weights where first element is zero
- * @param inclusive for treating rank as including weight of an item
- * @return total weight
- */ //used by classic Quantiles and KLL
- public static long convertToPrecedingCumulative(final long[] array, final boolean inclusive) {
- long subtotal = 0;
- for (int i = 0; i < array.length; i++) {
- final long newSubtotal = subtotal + array[i];
- array[i] = inclusive ? newSubtotal : subtotal;
- subtotal = newSubtotal;
- }
- return subtotal;
- }
/**
* Returns the linear zero-based index (position) of a value in the hypothetical sorted stream of
@@ -50,6 +34,7 @@ public class KllQuantilesHelper {
* @param n the size of the stream
* @return the index, a value between 0 and n-1.
*/ //used by classic Quantiles and KLL
+ @Deprecated
public static long posOfRank(final double rank, final long n) {
final long pos = (long) Math.floor(rank * n);
return pos == n ? n - 1 : pos; //avoids ArrayIndexOutOfBoundException
@@ -74,6 +59,7 @@ public class KllQuantilesHelper {
* @param pos the position
* @return the index of the chunk containing the position
*/ //also used by KLL
+ @Deprecated
public static int chunkContainingPos(final long[] wtArr, final long pos) {
final int nominalLength = wtArr.length - 1; /* remember, wtArr contains an "extra" position */
assert nominalLength > 0;
@@ -102,6 +88,7 @@ public class KllQuantilesHelper {
//
// A) and B) provide the invariants for our binary search.
// Observe that they are satisfied by the initial conditions: l = 0 and r = len.
+ @Deprecated
private static int searchForChunkContainingPos(final long[] arr, final long pos, final int l, final int r) {
// the following three asserts can probably go away eventually, since it is fairly clear
// that if these invariants hold at the beginning of the search, they will be maintained
diff --git a/src/test/java/org/apache/datasketches/kll/KllFloatsSketchTest.java b/src/test/java/org/apache/datasketches/kll/KllFloatsSketchTest.java
index a2d97dd9..fb600ce9 100644
--- a/src/test/java/org/apache/datasketches/kll/KllFloatsSketchTest.java
+++ b/src/test/java/org/apache/datasketches/kll/KllFloatsSketchTest.java
@@ -28,7 +28,6 @@ import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import org.apache.datasketches.SketchesArgumentException;
-import org.apache.datasketches.SketchesStateException;
import org.apache.datasketches.memory.DefaultMemoryRequestServer;
import org.apache.datasketches.memory.Memory;
import org.apache.datasketches.memory.WritableMemory;
@@ -547,40 +546,8 @@ public class KllFloatsSketchTest {
sk.update(3);
sk.update(1);
sk.update(2);
- { // non-cumulative (inclusive does not matter in this case)
- final KllFloatsSketchSortedView view = sk.getSortedView(false, false);
- final KllFloatsSketchSortedViewIterator it = view.iterator();
- assertEquals(it.next(), true);
- assertEquals(it.getValue(), 1);
- assertEquals(it.getWeight(), 1);
- assertEquals(it.next(), true);
- assertEquals(it.getValue(), 2);
- assertEquals(it.getWeight(), 1);
- assertEquals(it.next(), true);
- assertEquals(it.getValue(), 3);
- assertEquals(it.getWeight(), 1);
- assertEquals(it.next(), false);
- try {
- view.getQuantile(0);
- fail();
- } catch(SketchesStateException e) {}
- }
- { // cumulative, non-inclusive
- final KllFloatsSketchSortedView view = sk.getSortedView(true, false);
- final KllFloatsSketchSortedViewIterator it = view.iterator();
- assertEquals(it.next(), true);
- assertEquals(it.getValue(), 1);
- assertEquals(it.getWeight(), 0);
- assertEquals(it.next(), true);
- assertEquals(it.getValue(), 2);
- assertEquals(it.getWeight(), 1);
- assertEquals(it.next(), true);
- assertEquals(it.getValue(), 3);
- assertEquals(it.getWeight(), 2);
- assertEquals(it.next(), false);
- }
- { // cumulative, inclusive
- final KllFloatsSketchSortedView view = sk.getSortedView(true, true);
+ {
+ final KllFloatsSketchSortedView view = sk.getSortedView();
final KllFloatsSketchSortedViewIterator it = view.iterator();
assertEquals(it.next(), true);
assertEquals(it.getValue(), 1);
diff --git a/src/test/java/org/apache/datasketches/kll/MiscDirectDoublesTest.java b/src/test/java/org/apache/datasketches/kll/KllMiscDirectDoublesTest.java
similarity index 99%
rename from src/test/java/org/apache/datasketches/kll/MiscDirectDoublesTest.java
rename to src/test/java/org/apache/datasketches/kll/KllMiscDirectDoublesTest.java
index 84f5f37b..127027be 100644
--- a/src/test/java/org/apache/datasketches/kll/MiscDirectDoublesTest.java
+++ b/src/test/java/org/apache/datasketches/kll/KllMiscDirectDoublesTest.java
@@ -29,7 +29,7 @@ import org.apache.datasketches.memory.DefaultMemoryRequestServer;
import org.apache.datasketches.memory.WritableMemory;
import org.testng.annotations.Test;
-public class MiscDirectDoublesTest {
+public class KllMiscDirectDoublesTest {
static final String LS = System.getProperty("line.separator");
private static final DefaultMemoryRequestServer memReqSvr = new DefaultMemoryRequestServer();
diff --git a/src/test/java/org/apache/datasketches/kll/MiscDirectFloatsTest.java b/src/test/java/org/apache/datasketches/kll/KllMiscDirectFloatsTest.java
similarity index 99%
rename from src/test/java/org/apache/datasketches/kll/MiscDirectFloatsTest.java
rename to src/test/java/org/apache/datasketches/kll/KllMiscDirectFloatsTest.java
index 6810dc2d..dacf8497 100644
--- a/src/test/java/org/apache/datasketches/kll/MiscDirectFloatsTest.java
+++ b/src/test/java/org/apache/datasketches/kll/KllMiscDirectFloatsTest.java
@@ -29,7 +29,7 @@ import org.apache.datasketches.memory.DefaultMemoryRequestServer;
import org.apache.datasketches.memory.WritableMemory;
import org.testng.annotations.Test;
-public class MiscDirectFloatsTest {
+public class KllMiscDirectFloatsTest {
static final String LS = System.getProperty("line.separator");
private static final DefaultMemoryRequestServer memReqSvr = new DefaultMemoryRequestServer();
diff --git a/src/test/java/org/apache/datasketches/kll/MiscDoublesTest.java b/src/test/java/org/apache/datasketches/kll/KllMiscDoublesTest.java
similarity index 99%
rename from src/test/java/org/apache/datasketches/kll/MiscDoublesTest.java
rename to src/test/java/org/apache/datasketches/kll/KllMiscDoublesTest.java
index 656343cc..c2ddb6eb 100644
--- a/src/test/java/org/apache/datasketches/kll/MiscDoublesTest.java
+++ b/src/test/java/org/apache/datasketches/kll/KllMiscDoublesTest.java
@@ -35,7 +35,7 @@ import org.testng.annotations.Test;
/**
* @author Lee Rhodes
*/
-public class MiscDoublesTest {
+public class KllMiscDoublesTest {
static final String LS = System.getProperty("line.separator");
private final MemoryRequestServer memReqSvr = new DefaultMemoryRequestServer();
diff --git a/src/test/java/org/apache/datasketches/kll/MiscFloatsTest.java b/src/test/java/org/apache/datasketches/kll/KllMiscFloatsTest.java
similarity index 98%
rename from src/test/java/org/apache/datasketches/kll/MiscFloatsTest.java
rename to src/test/java/org/apache/datasketches/kll/KllMiscFloatsTest.java
index 3f827dfc..cbccca81 100644
--- a/src/test/java/org/apache/datasketches/kll/MiscFloatsTest.java
+++ b/src/test/java/org/apache/datasketches/kll/KllMiscFloatsTest.java
@@ -35,10 +35,22 @@ import org.testng.annotations.Test;
/**
* @author Lee Rhodes
*/
-public class MiscFloatsTest {
+public class KllMiscFloatsTest {
static final String LS = System.getProperty("line.separator");
private final MemoryRequestServer memReqSvr = new DefaultMemoryRequestServer();
+ @Test
+ public void checkConvertToCumulative() {
+ long[] array = {1,2,3,2,1};
+ long out = KllHelper.convertToCumulative(array);
+ assertEquals(out, 9);
+ }
+
+ @Test
+ public void checkSortedViewConstruction() {
+
+ }
+
@Test
public void checkBounds() {
final KllFloatsSketch kll = KllFloatsSketch.newHeapInstance(); //default k = 200
@@ -150,16 +162,10 @@ public class MiscFloatsTest {
@Test
public void viewCompactionAndSortedView() {
KllFloatsSketch sk = KllFloatsSketch.newHeapInstance(20);
- boolean cumulative = false;
- boolean inclusive = false;
show(sk, 20);
- KllFloatsSketchSortedView sv = sk.getSortedView(cumulative, inclusive);
+ KllFloatsSketchSortedView sv = sk.getSortedView();
KllFloatsSketchSortedViewIterator itr = sv.iterator();
- if (cumulative) {
- printf("%12s%12s\n", "Value", "CumWeight");
- } else {
- printf("%12s%12s\n", "Value", "Weight");
- }
+ printf("%12s%12s\n", "Value", "CumWeight");
while (itr.next()) {
float v = itr.getValue();
long wt = itr.getWeight();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org