compactors = sk.getCompactors();
+ final int numComp = compactors.size();
+ final int totalValues = sk.getRetainedItems();
+ values = new float[totalValues];
+ cumWeights = new long[totalValues];
+ int count = 0;
+ for (int i = 0; i < numComp; i++) {
+ final ReqCompactor c = compactors.get(i);
+ final FloatBuffer bufIn = c.getBuffer();
+ final long bufWeight = 1 << c.getLgWeight();
+ final int bufInLen = bufIn.getCount();
+ mergeSortIn(bufIn, bufWeight, count);
+ count += bufInLen;
+ }
+ createCumulativeNativeRanks();
+ dedup();
+ }
+
+ private void createCumulativeNativeRanks() {
+ final int len = values.length;
+ for (int i = 1; i < len; i++) {
+ cumWeights[i] += cumWeights[i - 1];
+ }
+ assert cumWeights[len - 1] == N;
+ }
+
+ private void dedup() {
+ final int valuesLen = values.length;
+ final float[] valuesB = new float[valuesLen];
+ final long[] natRanksB = new long[valuesLen];
+ int bidx = 0;
+ int i = 0;
+ while (i < valuesLen) {
+ int j = i + 1;
+ int hidup = j;
+ while (j < valuesLen && values[i] == values[j]) {
+ hidup = j++;
+ }
+ if (j - i == 1) { //no dups
+ valuesB[bidx] = values[i];
+ natRanksB[bidx++] = cumWeights[i];
+ i++;
+ continue;
+ } else {
+ valuesB[bidx] = values[hidup];
+ natRanksB[bidx++] = cumWeights[hidup];
+ i = j;
+ continue;
+ }
+ }
+ values = Arrays.copyOf(valuesB, bidx);
+ cumWeights = Arrays.copyOf(natRanksB, bidx);
+ }
+
+
+ /**
+ * Specially modified version of FloatBuffer.mergeSortIn(). Here spaceAtBottom is always false and
+ * the ultimate array size has already been set. However, this must simultaneously deal with
+ * sorting the base FloatBuffer as well. Also used in test.
+ *
+ * @param bufIn given FloatBuffer. If not sorted it will be sorted here.
+ * @param bufWeight associated weight of input FloatBuffer
+ * @param count tracks number of values inserted into the class arrays
+ */
+ void mergeSortIn(final FloatBuffer bufIn, final long bufWeight, final int count) {
+ if (!bufIn.isSorted()) { bufIn.sort(); }
+ final float[] arrIn = bufIn.getArray(); //may be larger than its value count.
+ final int bufInLen = bufIn.getCount();
+ final int totLen = count + bufInLen;
+ int i = count - 1;
+ int j = bufInLen - 1;
+ int h = hra ? bufIn.getCapacity() - 1 : bufInLen - 1;
+ for (int k = totLen; k-- > 0; ) {
+ if (i >= 0 && j >= 0) { //both valid
+ if (values[i] >= arrIn[h]) {
+ values[k] = values[i];
+ cumWeights[k] = cumWeights[i--]; //not yet natRanks, just individual wts
+ } else {
+ values[k] = arrIn[h--]; j--;
+ cumWeights[k] = bufWeight;
+ }
+ } else if (i >= 0) { //i is valid
+ values[k] = values[i];
+ cumWeights[k] = cumWeights[i--];
+ } else if (j >= 0) { //j is valid
+ values[k] = arrIn[h--]; j--;
+ cumWeights[k] = bufWeight;
+ } else {
+ break;
+ }
+ }
+ }
+
+ //used for testing
+
+ Row getRow(final int index) {
+ return new Row(values[index], cumWeights[index]);
+ }
+
+ static class Row {
+ float value;
+ long cumWeight;
+
+ Row(final float value, final long cumWeight) {
+ this.value = value;
+ this.cumWeight = cumWeight;
+ }
+ }
+
+}
diff --git a/src/main/java/org/apache/datasketches/req/ReqSketchSortedViewIterator.java b/src/main/java/org/apache/datasketches/req/ReqSketchSortedViewIterator.java
new file mode 100644
index 000000000..d724d9be5
--- /dev/null
+++ b/src/main/java/org/apache/datasketches/req/ReqSketchSortedViewIterator.java
@@ -0,0 +1,110 @@
+/*
+
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.req;
+
+/**
+ * Iterator over KllDoublesSketchSortedView.
+ *
+ * The recommended iteration loop:
+ * {@code
+ * ReqSketchSortedViewIterator itr = sketch.getSortedView().iterator();
+ * while (itr.next()) {
+ * float v = itr.getValue();
+ * ...
+ * }
+ * }
+ */
+public class ReqSketchSortedViewIterator {
+
+ private final float[] values;
+ private final long[] cumWeights;
+ private int index;
+
+ ReqSketchSortedViewIterator(final float[] values, final long[] cumWeights) {
+ this.values = values;
+ this.cumWeights = cumWeights;
+ index = -1;
+ }
+
+ /**
+ * Gets the current value.
+ *
+ * Don't call this before calling next() for the first time
+ * or after getting false from next().
+ * @return the current value
+ */
+ public float getValue() {
+ return values[index];
+ }
+
+ /**
+ * Gets the cumulative weight for the current value.
+ *
+ * Don't call this before calling next() for the first time
+ * or after getting false from next().
+ * @param inclusive If true, includes the weight of the current value.
+ * Otherwise, returns the cumulative weightof the previous value.
+ * @return cumulative weight for the current value.
+ */
+ public long getCumulativeWeight(final boolean inclusive) {
+ return inclusive ? cumWeights[index]
+ : (index == 0) ? 0 : cumWeights[index - 1];
+ }
+
+ /**
+ * Gets the normalized rank for the current value or previous value.
+ *
+ * Don't call this before calling next() for the first time
+ * or after getting false from next().
+ * @param inclusive if true, returns the normalized rank of the current value.
+ * Otherwise, returns the normalized rank of the previous value.
+ * @return normalized rank for the current value or previous value.
+ */
+ public double getNormalizedRank(final boolean inclusive) {
+ final double N = cumWeights[ cumWeights.length - 1];
+ return getCumulativeWeight(inclusive) / N;
+ }
+
+ /**
+ * Gets the weight of the current value.
+ *
+ * Don't call this before calling next() for the first time
+ * or after getting false from next().
+ * @return item weight of the current value.
+ */
+ public long getWeight() {
+ if (index == 0) { return cumWeights[0]; }
+ return cumWeights[index] - cumWeights[index - 1];
+ }
+
+ /**
+ * Advancing the iterator and checking existence of the next element
+ * is combined here for efficiency. This results in an undefined
+ * state of the iterator before the first call of this method.
+ * @return true if the next element exists
+ */
+ public boolean next() {
+ index++;
+ return index < values.length;
+ }
+
+}
+
diff --git a/src/test/java/org/apache/datasketches/CrossCheckQuantiles.java b/src/test/java/org/apache/datasketches/CrossCheckQuantiles.java
new file mode 100644
index 000000000..4b01dd2a2
--- /dev/null
+++ b/src/test/java/org/apache/datasketches/CrossCheckQuantiles.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches;
+
+public class CrossCheckQuantiles {
+
+ private final static boolean enablePrinting = true;
+
+ /**
+ * @param format the format
+ * @param args the args
+ */
+ static final void printf(final String format, final Object ...args) {
+ if (enablePrinting) { System.out.printf(format, args); }
+ }
+
+ /**
+ * @param o the Object to println
+ */
+ static final void println(final Object o) {
+ if (enablePrinting) { System.out.println(o.toString()); }
+ }
+
+}
+
diff --git a/src/test/java/org/apache/datasketches/GenericInequalitySearchTest.java b/src/test/java/org/apache/datasketches/GenericInequalitySearchTest.java
index fa2e6387e..2d6729f6f 100644
--- a/src/test/java/org/apache/datasketches/GenericInequalitySearchTest.java
+++ b/src/test/java/org/apache/datasketches/GenericInequalitySearchTest.java
@@ -67,17 +67,6 @@ private static void checkBuildRandArr() {
}
}
- private static String listFltArray(final Float[] arr, final int low, final int high) {
- final StringBuilder sb = new StringBuilder();
- sb.append(LS);
- sb.append("arr: ");
- for (int i = 0; i < arr.length; i++) {
- if (i == low || i == high) { sb.append(String.format("(%.0f) ", arr[i])); }
- else { sb.append(String.format("%.0f ", arr[i])); }
- }
- return sb.toString();
- }
-
@Test
public void checkBinSearchFltLimits() {
for (int len = 10; len <= 13; len++) {
@@ -89,6 +78,19 @@ public void checkBinSearchFltLimits() {
}
}
+ private static String listFltArray(final Float[] arr, final int low, final int high) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append(LS);
+ sb.append("The values in parentheses are the low and high values of the sub-array to search");
+ sb.append(LS);
+ sb.append("arr: ");
+ for (int i = 0; i < arr.length; i++) {
+ if (i == low || i == high) { sb.append(String.format("(%.0f) ", arr[i])); }
+ else { sb.append(String.format("%.0f ", arr[i])); }
+ }
+ return sb.toString();
+ }
+
private void checkBinarySearchFloatLimits(final Float[] arr, final int low, final int high) {
final Float lowV = arr[low];
final Float highV = arr[high];
@@ -287,27 +289,28 @@ public static String desc(final T[] arr, final int low, final int high, fina
return "";
}
+ private final static boolean enablePrinting = false;
/**
* @param format the format
* @param args the args
*/
static final void printf(final String format, final Object ...args) {
- //System.out.printf(format, args);
+ if (enablePrinting) { System.out.printf(format, args); }
}
/**
* @param o the Object to println
*/
static final void println(final Object o) {
- //System.out.println(o.toString());
+ if (enablePrinting) { System.out.println(o.toString()); }
}
/**
* @param o the Object to print
*/
static final void print(final Object o) {
- //System.out.print(o.toString());
+ if (enablePrinting) { System.out.print(o.toString()); }
}
}
diff --git a/src/test/java/org/apache/datasketches/req/ReqAuxiliaryTest.java b/src/test/java/org/apache/datasketches/req/ReqAuxiliaryTest.java
deleted file mode 100644
index 66e90eb62..000000000
--- a/src/test/java/org/apache/datasketches/req/ReqAuxiliaryTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.datasketches.req;
-
-import static org.testng.Assert.assertTrue;
-
-import org.apache.datasketches.req.ReqAuxiliary.Row;
-import org.testng.annotations.Test;
-
-/**
- * @author Lee Rhodes
- */
-
-public class ReqAuxiliaryTest {
-
- @Test
- public void checkMergeSortIn() {
- checkMergeSortInImpl(true);
- checkMergeSortInImpl(false);
- }
-
- private static void checkMergeSortInImpl(final boolean hra) {
- final FloatBuffer buf1 = new FloatBuffer(25, 0, hra);
- for (int i = 1; i < 12; i += 2) { buf1.append(i); } //6 items
- final FloatBuffer buf2 = new FloatBuffer(25, 0, hra);
- for (int i = 2; i <= 12; i += 2) { buf2.append(i); } //6 items
- final long N = 12;
-
- final float[] items = new float[25];
- final long[] weights = new long[25];
-
- final ReqAuxiliary aux = new ReqAuxiliary(items, weights, hra, N);
- aux.mergeSortIn(buf1, 1, 0);
- aux.mergeSortIn(buf2, 2, 6);
- println(aux.toString(3, 12));
- Row row = aux.getRow(0);
- for (int i = 1; i < 12; i++) {
- final Row rowi = aux.getRow(i);
- assertTrue(rowi.item >= row.item);
- row = rowi;
- }
- }
-
- /**
- * output
- * @param o object
- */
- static final void println(final Object o) {
- //System.out.println(o.toString());
- }
-}
diff --git a/src/test/java/org/apache/datasketches/req/ReqSketchOtherTest.java b/src/test/java/org/apache/datasketches/req/ReqSketchOtherTest.java
index f4313d0ce..3f9499afd 100644
--- a/src/test/java/org/apache/datasketches/req/ReqSketchOtherTest.java
+++ b/src/test/java/org/apache/datasketches/req/ReqSketchOtherTest.java
@@ -104,7 +104,7 @@ public void checkEstimationMode() {
assertEquals(maxNomSize, 240);
final float v = sk.getQuantile(1.0);
assertEquals(v, 120.0f);
- final ReqAuxiliary aux = sk.getAux();
+ final ReqSketchSortedView aux = sk.getSortedView();
assertNotNull(aux);
assertTrue(sk.getRSE(sk.getK(), .5, false, 120) > 0);
assertTrue(sk.getSerializationBytes() > 0);
diff --git a/src/test/java/org/apache/datasketches/req/ReqSketchSortedViewTest.java b/src/test/java/org/apache/datasketches/req/ReqSketchSortedViewTest.java
new file mode 100644
index 000000000..8d340ead4
--- /dev/null
+++ b/src/test/java/org/apache/datasketches/req/ReqSketchSortedViewTest.java
@@ -0,0 +1,220 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.req;
+
+import static org.testng.Assert.assertTrue;
+
+import org.apache.datasketches.req.ReqSketchSortedView.Row;
+import org.testng.annotations.Test;
+
+/**
+ * @author Lee Rhodes
+ */
+
+public class ReqSketchSortedViewTest {
+
+ /**
+ * just tests the mergeSortIn. It does NOT test anything else.
+ */
+ @Test
+ public void checkMergeSortIn() {
+ checkMergeSortInImpl(true);
+ checkMergeSortInImpl(false);
+ }
+
+ private static void checkMergeSortInImpl(final boolean hra) {
+ final FloatBuffer buf1 = new FloatBuffer(25, 0, hra);
+ for (int i = 1; i < 12; i += 2) { buf1.append(i); } //6 odd values
+ final FloatBuffer buf2 = new FloatBuffer(25, 0, hra);
+ for (int i = 2; i <= 12; i += 2) { buf2.append(i); } //6 even values
+ final long N = 18;
+
+ final float[] values = new float[25];
+ final long[] valueWeights = new long[25]; //not used
+
+ final ReqSketchSortedView rssv = new ReqSketchSortedView(values, valueWeights, hra, N);
+ rssv.mergeSortIn(buf1, 1, 0);
+ rssv.mergeSortIn(buf2, 2, 6); //at weight of 2
+ println(rssv.toString(3, 12));
+ Row row = rssv.getRow(0);
+ for (int i = 1; i < 12; i++) {
+ final Row rowi = rssv.getRow(i);
+ assertTrue(rowi.value >= row.value);
+ row = rowi;
+ }
+ }
+
+ @Test
+ public void checkRssvVsSketch() {
+ int k = 4;
+ boolean hra = false;
+ boolean inclusive;
+ boolean useSketch;
+ int numV = 3;
+ int dup = 2;
+ inclusive = false;
+ useSketch = true;
+ checkRSSV(k, hra, inclusive, useSketch, numV, dup);
+ println("-------------------");
+ inclusive = false;
+ useSketch = false;
+ checkRSSV(k, hra, inclusive, useSketch, numV, dup);
+ println("###################");
+ inclusive = true;
+ useSketch = true;
+ checkRSSV(k, hra, inclusive, useSketch, numV, dup);
+ println("-------------------");
+ inclusive = true;
+ useSketch = false;
+ checkRSSV(k, hra, inclusive, useSketch, numV, dup);
+ println("");
+ println("###################");
+ println("");
+ }
+
+ private void checkRSSV(final int k, final boolean hra, final boolean inclusive,
+ final boolean useSketch, final int numV, final int dup) {
+ println("");
+ println("CHECK ReqSketchSortedView");
+ println(" k: " + k + ", hra: " + hra + ", inclusive: " + inclusive + ", useSketch: " + useSketch);
+ ReqSketchBuilder bldr = ReqSketch.builder();
+ bldr.setK(4).setHighRankAccuracy(hra).setLessThanOrEqual(inclusive);
+ ReqSketch sk = bldr.build();
+ int n = numV * dup; //Total values including duplicates
+ println(" numV: " + numV + ", dup: " + dup);
+
+ float[] arr = new float[n];
+
+ int h = 0;
+ for (int i = 0; i < numV; i++) {
+ float flt = (i + 1) * 10;
+ for (int j = 1; j <= dup; j++) { arr[h++] = flt; }
+ }
+ println("");
+ println("Example Sketch Input with illustrated weights and ranks:");
+ println(" Sketch only keeps individual value weights per level");
+ println(" Cumulative Weights are computed in RSSV.");
+ println(" Normalized Ranks are computed on the fly.");
+ println("");
+ printf("%16s%16s%16s\n", "Value", "CumWeight", "NormalizedRank");
+ for (int i = 0; i < n; i++) {
+ printf("%16.1f%16d%16.3f\n", arr[i], i + 1, (i + 1.0)/n);
+ sk.update(arr[i]);
+ }
+
+ println("");
+
+ //Sorted View Data:
+ ReqSketchSortedView rssv = new ReqSketchSortedView(sk);
+ println(rssv.toString(1, 16));
+
+ println("GetQuantile(NormalizedRank):");
+ println(" CumWeight is for illustration");
+ println(" Convert NormalizedRank to CumWeight (CW).");
+ println(" Search RSSV CumWeights[] array:");
+ println(" Non Inclusive (uses GT): arr[A] <= CW < arr[B], return B");
+ println(" Inclusive (uses GE): arr[A] < CW <= arr[B], return B");
+ println(" Return Values[B]");
+ println("");
+ printf("%16s%16s%16s\n", "NormalizedRank", "CumWeight", "Quantile");
+ int m = 2 * n;
+ for (int i = 0; i <= m; i++) {
+ double fract = (double) i / m;
+ float q = useSketch
+ ? sk.getQuantile(fract, inclusive)
+ : rssv.getQuantile(fract, inclusive); //until aux iterator is created
+ printf("%16.3f%16.3f%16.1f\n", fract, fract * n, q);
+ }
+
+ println("");
+ println("GetRank(Value):");
+ println(" Search RSSV Values[] array:");
+ println(" Non Inclusive (uses LT): arr[A] < V <= arr[B], return A");
+ println(" Inclusive (uses LE): arr[A] <= V < arr[B], return A");
+ println(" Convert CumWeights[A] to NormRank,");
+ println(" Return NormRank");
+ printf("%16s%16s\n", "ValueIn", "NormalizedRank");
+ float q = 5.0F;
+ for (int i = 1; i <= numV * 2 + 1; i++) {
+ double r = useSketch
+ ? sk.getRank(q, inclusive)
+ : rssv.getRank(q, inclusive); //until aux iterator is created
+ printf("%16.1f%16.3f\n", q, r);
+ q += 5.0F;
+ }
+ }
+
+ @Test
+ public void checkIterator() {
+ int k = 4;
+ boolean hra = false;
+ int numV = 3;
+ int dup = 2;
+ println("");
+ println("CHECK ReqSketchSortedViewIterator");
+ println(" k: " + k + ", hra: " + hra);
+ ReqSketchBuilder bldr = ReqSketch.builder();
+ ReqSketch sketch = bldr.build();
+ int n = numV * dup; //Total values including duplicates
+ println(" numV: " + numV + ", dup: " + dup);
+
+ float[] arr = new float[n];
+ int h = 0;
+ for (int i = 0; i < numV; i++) {
+ float flt = (i + 1) * 10;
+ for (int j = 1; j <= dup; j++) { arr[h++] = flt; }
+ }
+ for (int i = 0; i < n; i++) { sketch.update(arr[i]); }
+
+ ReqSketchSortedViewIterator itr = sketch.getSortedView().iterator();
+ println("");
+ String[] header = {"Value", "Wt", "CumWtNotInc", "nRankNotInc", "CumWtInc", "nRankInc"};
+ String hfmt = "%12s%12s%12s%12s%12s%12s\n";
+ String fmt = "%12.1f%12d%12d%12.3f%12d%12.3f\n";
+ printf(hfmt, (Object[]) header);
+ while (itr.next()) {
+ float v = itr.getValue();
+ long wt = itr.getWeight();
+ long cumWtNotInc = itr.getCumulativeWeight(false);
+ double nRankNotInc = itr.getNormalizedRank(false);
+ long cumWtInc = itr.getCumulativeWeight(true);
+ double nRankInc = itr.getNormalizedRank(true);
+ printf(fmt, v, wt, cumWtNotInc, nRankNotInc, cumWtInc, nRankInc);
+ }
+ }
+
+ private final static boolean enablePrinting = true;
+
+ /**
+ * @param format the format
+ * @param args the args
+ */
+ static final void printf(final String format, final Object ...args) {
+ if (enablePrinting) { System.out.printf(format, args); }
+ }
+
+ /**
+ * @param o the Object to println
+ */
+ static final void println(final Object o) {
+ if (enablePrinting) { System.out.println(o.toString()); }
+ }
+
+}
diff --git a/src/test/java/org/apache/datasketches/req/ReqSketchTest.java b/src/test/java/org/apache/datasketches/req/ReqSketchTest.java
index 643629248..ebff6672d 100644
--- a/src/test/java/org/apache/datasketches/req/ReqSketchTest.java
+++ b/src/test/java/org/apache/datasketches/req/ReqSketchTest.java
@@ -28,7 +28,7 @@
import org.apache.datasketches.SketchesArgumentException;
import org.apache.datasketches.memory.Memory;
//import static org.apache.datasketches.req.FloatBuffer.TAB;
-import org.apache.datasketches.req.ReqAuxiliary.Row;
+import org.apache.datasketches.req.ReqSketchSortedView.Row;
import org.testng.annotations.Test;
/**
@@ -154,22 +154,22 @@ private static void checkGetRanks(final ReqSketch sk, final int max, final int i
}
private static void checkAux(final ReqSketch sk, final int iDebug) {
- final ReqAuxiliary aux = new ReqAuxiliary(sk);
+ final ReqSketchSortedView aux = new ReqSketchSortedView(sk);
if (iDebug > 0) { println(aux.toString(3,12)); }
final int totalCount = sk.getRetainedItems();
- float item = 0;
+ float value = 0;
long wt = 0;
for (int i = 0; i < totalCount; i++) {
final Row row = aux.getRow(i);
if (i == 0) {
- item = row.item;
- wt = row.weight;
+ value = row.value;
+ wt = row.cumWeight;
} else {
- assertTrue(row.item >= item);
- assertTrue(row.weight >= wt);
- item = row.item;
- wt = row.weight;
+ assertTrue(row.value >= value);
+ assertTrue(row.cumWeight >= wt);
+ value = row.value;
+ wt = row.cumWeight;
}
}
}
@@ -303,7 +303,7 @@ private static void checkSerDeImpl(final int k, final boolean hra, final int cou
assertEquals(sk2.getHighRankAccuracy(),sk1.getHighRankAccuracy());
assertEquals(sk2.getK(), sk1.getK());
assertEquals(sk2.getMaxNomSize(), sk1.getMaxNomSize());
- assertEquals(sk2.getLtEq(), sk1.getLtEq());
+ //assertEquals(sk2.getLtEq(), sk1.getLtEq());
assertEquals(sk2.getNumLevels(), sk1.getNumLevels());
assertEquals(sk2.getSerializationBytes(), sk1.getSerializationBytes());
}
@@ -332,7 +332,7 @@ public void checkAuxDeDup() {
}
@Test
- public void tenItems() {
+ public void tenValues() {
final ReqSketch sketch = ReqSketch.builder().build();
for (int i = 1; i <= 10; i++) { sketch.update(i); }
assertFalse(sketch.isEmpty());