leerho commented on code in PR #546:
URL: https://github.com/apache/datasketches-java/pull/546#discussion_r1563727631


##########
src/test/java/org/apache/datasketches/quantilescommon/PartitionBoundariesTest.java:
##########
@@ -196,6 +196,40 @@ public void checkSimpleEndsAdjustment() {
     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);

Review Comment:
   I tested it manually, and it passes at sizeLimit and fails at sizeLimit - 1. 
   I didn't think it was necessary, but I could add a test that passes exactly 
at sizeLimit.  
   Same thing goes for the limit on num partitions.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@datasketches.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@datasketches.apache.org
For additional commands, e-mail: commits-h...@datasketches.apache.org

Reply via email to