Copilot commented on code in PR #17186:
URL: https://github.com/apache/pinot/pull/17186#discussion_r2513679122
##########
pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/creator/impl/stats/NoDictColumnStatisticsCollectorTest.java:
##########
@@ -781,9 +781,13 @@ private void
compareCollectorStats(NoDictColumnStatisticsCollector noDictCollect
String context = String.format("Iteration %d, DataType: %s, SingleValue:
%s, Data: %s",
iteration, dataType, isSingleValue, Arrays.deepToString(testData));
- assertTrue(noDictCollector.getCardinality() >=
expectedCollector.getCardinality(),
- "Approx Cardinality " + noDictCollector.getCardinality() + " is lower
than actual cardinality "
- + expectedCollector.getCardinality() + " for " + context);
+ int approx = noDictCollector.getCardinality();
+ int exact = expectedCollector.getCardinality();
+ // allow 10% or at least 1; guard against overflow/precision in
intermediate calculation
+ int tolerance = Math.max(1, (int) Math.min(Integer.MAX_VALUE,
Math.ceil(0.1 * (double) exact)));
Review Comment:
The `Math.min(Integer.MAX_VALUE, ...)` check is unnecessary because
`Math.ceil(0.1 * (double) exact)` cannot exceed `Integer.MAX_VALUE` given that
`exact` is an `int`. The result of `0.1 * exact` will always be within
representable double range, and casting to int will clamp any theoretical
overflow. Consider simplifying to `Math.max(1, (int) Math.ceil(0.1 * exact))`.
```suggestion
// allow 10% or at least 1
int tolerance = Math.max(1, (int) Math.ceil(0.1 * exact));
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]