This is an automated email from the ASF dual-hosted git repository. leerho pushed a commit to branch fix-test-failures in repository https://gitbox.apache.org/repos/asf/datasketches-java.git
commit 24e7b9367623d007fc74678eb5cdd1f4a8f2989b Author: Lee Rhodes <[email protected]> AuthorDate: Sat Sep 26 14:27:18 2026 -0700 Check TDigestDouble.merge weight overflow before touching min/max 9bf19ff6b moved the min/max update ahead of the Math.addExact check, so a merge that throws ArithmeticException still mutated the digest, failing weightOverflowDoesNotChangeDigest. Co-Authored-By: Claude Opus 5.5 <[email protected]> --- src/main/java/org/apache/datasketches/tdigest/TDigestDouble.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/datasketches/tdigest/TDigestDouble.java b/src/main/java/org/apache/datasketches/tdigest/TDigestDouble.java index 4cd4169e0..fa99c3d99 100644 --- a/src/main/java/org/apache/datasketches/tdigest/TDigestDouble.java +++ b/src/main/java/org/apache/datasketches/tdigest/TDigestDouble.java @@ -117,10 +117,10 @@ public final class TDigestDouble { */ public void merge(final TDigestDouble other) { if (other.isEmpty()) { return; } + Math.addExact(getTotalWeight(), other.getTotalWeight()); // Extreme centroid means are not the true min/max when those centroids have weight > 1. minValue_ = Math.min(minValue_, other.minValue_); maxValue_ = Math.max(maxValue_, other.maxValue_); - Math.addExact(getTotalWeight(), other.getTotalWeight()); final int num = numCentroids_ + numBuffered_ + other.numCentroids_ + other.numBuffered_; final double[] values = new double[num]; final long[] weights = new long[num]; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
