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 2024/04/12 19:38:04 UTC
(datasketches-java) 03/03: Added tests for new partition limits
This is an automated email from the ASF dual-hosted git repository.
leerho pushed a commit to branch methods_to_compute_partition_limits
in repository https://gitbox.apache.org/repos/asf/datasketches-java.git
commit 30a813d50fa267e0ff73afe0bc1dbaffc7e299e9
Author: Lee Rhodes <le...@gmail.com>
AuthorDate: Fri Apr 12 12:36:34 2024 -0700
Added tests for new partition limits
---
.../quantilescommon/PartitionBoundariesTest.java | 42 ++++++++++++++++++++--
1 file changed, 39 insertions(+), 3 deletions(-)
diff --git a/src/test/java/org/apache/datasketches/quantilescommon/PartitionBoundariesTest.java b/src/test/java/org/apache/datasketches/quantilescommon/PartitionBoundariesTest.java
index 1849c04f..abbce503 100644
--- a/src/test/java/org/apache/datasketches/quantilescommon/PartitionBoundariesTest.java
+++ b/src/test/java/org/apache/datasketches/quantilescommon/PartitionBoundariesTest.java
@@ -28,6 +28,7 @@ import static org.testng.Assert.assertEquals;
import java.util.Comparator;
import org.apache.datasketches.common.ArrayOfStringsSerDe;
+import org.apache.datasketches.common.SketchesArgumentException;
import org.apache.datasketches.kll.KllItemsSketch;
import org.apache.datasketches.quantiles.ItemsSketch;
import org.testng.annotations.Test;
@@ -49,6 +50,7 @@ public class PartitionBoundariesTest {
private static String rowhdrfmt2= "%5s %12s %12s %12s\n";
private static String rowdfmt2 = "%5d %12.8f %12d %12s\n";
+ //@Test //visual check only. set enablePrinting = true to view.
public void checkSkewWithClassic() {
int n = 2050;
int k = 1 << 15;
@@ -88,7 +90,7 @@ public class PartitionBoundariesTest {
}
}
- @Test
+ //@Test //visual check only. set enablePrinting = true to view.
public void checkSkewWithKll() {
int n = 2050;
int k = 1 << 15;
@@ -159,8 +161,8 @@ public class PartitionBoundariesTest {
}
/**
- * Because both Kll and Classic items sketches use the same Sorted View class
- * this test applies to both. The only difference is a different normalized error given the same k.
+ * Because both Kll and Classic items sketches use the same Sorted View class.
+ * This test applies to both.
*/
@Test
public void checkSimpleEndsAdjustment() {
@@ -194,6 +196,40 @@ public class PartitionBoundariesTest {
assertEquals(minItm, "1");
}
+ @Test(expectedExceptions = SketchesArgumentException.class)
+ public void checkSketchPartitionLimits() {
+ final long totalN = 1_000_000;
+ final Comparator<String> comparator = Comparator.naturalOrder();
+ final ArrayOfStringsSerDe serDe = new ArrayOfStringsSerDe();
+ final KllItemsSketch<String> sk = KllItemsSketch.newHeapInstance(comparator, serDe);
+ final int d = digits(totalN);
+ for (int i = 1; i <= totalN; i++) {
+ sk.update(getString(i, d));
+ }
+ final int numLimit = sk.getMaxPartitions();
+ final int ret = sk.getNumRetained();
+ println("ret: " + ret + ", numLimit " + numLimit);
+ @SuppressWarnings("unused")
+ GenericPartitionBoundaries<String> gpb = sk.getPartitionBoundariesFromNumParts(numLimit + 1);
+ }
+
+ @Test(expectedExceptions = SketchesArgumentException.class)
+ public void checkSketchPartitionLimits2() {
+ final long totalN = 1_000_000;
+ final Comparator<String> comparator = Comparator.naturalOrder();
+ final ArrayOfStringsSerDe serDe = new ArrayOfStringsSerDe();
+ final KllItemsSketch<String> sk = KllItemsSketch.newHeapInstance(comparator, serDe);
+ final int d = digits(totalN);
+ for (int i = 1; i <= totalN; i++) {
+ sk.update(getString(i, d));
+ }
+ final long sizeLimit= sk.getMinPartitionSizeItems();
+
+ println("Min Size Limit: " + sizeLimit);
+ @SuppressWarnings("unused")
+ GenericPartitionBoundaries<String> gpb = sk.getPartitionBoundariesFromPartSize(sizeLimit - 1);
+ }
+
@Test
public void printlnTest() {
println("PRINTING: " + this.getClass().getName());
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org