From 7a8905ce15d0b3dff9547e5015845ded88216f8a Mon Sep 17 00:00:00 2001 From: Ido Berkovich Date: Mon, 23 Dec 2024 11:53:41 +0200 Subject: [PATCH] OPIK-287 PR comments --- .../resources/utils/BigDecimalCollectors.java | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/apps/opik-backend/src/test/java/com/comet/opik/api/resources/utils/BigDecimalCollectors.java b/apps/opik-backend/src/test/java/com/comet/opik/api/resources/utils/BigDecimalCollectors.java index 0de3476a8b..c34e7250e5 100644 --- a/apps/opik-backend/src/test/java/com/comet/opik/api/resources/utils/BigDecimalCollectors.java +++ b/apps/opik-backend/src/test/java/com/comet/opik/api/resources/utils/BigDecimalCollectors.java @@ -8,28 +8,6 @@ import java.util.stream.Collector; public class BigDecimalCollectors { - - public static Collector averagingBigDecimal() { - return Collector.of( - // Supplier: Create an array with two elements to hold total and count - () -> new BigDecimal[]{BigDecimal.ZERO, BigDecimal.ZERO}, - // Accumulator: Update total and count - (result, value) -> { - result[0] = result[0].add(value); // Accumulate total - result[1] = result[1].add(BigDecimal.ONE); // Increment count - }, - // Combiner: Merge two arrays (used for parallel streams) - (result1, result2) -> { - result1[0] = result1[0].add(result2[0]); // Combine totals - result1[1] = result1[1].add(result2[1]); // Combine counts - return result1; - }, - // Finisher: Compute the average (total / count) with rounding - result -> result[1].compareTo(BigDecimal.ZERO) == 0 - ? BigDecimal.ZERO // Avoid division by zero - : result[0].divide(result[1], ValidationUtils.SCALE, RoundingMode.HALF_UP)); - } - public static Collector averagingBigDecimal(Function mapper) { return Collector.of( () -> new BigDecimal[]{BigDecimal.ZERO, BigDecimal.ZERO}, @@ -49,5 +27,4 @@ public class BigDecimalCollectors { ? BigDecimal.ZERO : result[0].divide(result[1], ValidationUtils.SCALE, RoundingMode.HALF_UP)); } - }