public static Object groupedPartialAggregation(BiFunction<Object, Object, Boolean> isEqual, InternalAggregationFunction function, Page... pages) { // execute with args in positions: arg0, arg1, arg2 Object aggregation = groupedPartialAggregation(function, createArgs(function), pages); // execute with args in reverse order: arg2, arg1, arg0 if (function.getParameterTypes().size() > 1) { Object aggregationWithOffset = groupedPartialAggregation(function, reverseArgs(function), reverseColumns(pages)); assertFunctionEquals(isEqual, "Consistent results with reversed channels", aggregationWithOffset, aggregation); } // execute with args at an offset (and possibly reversed): null, null, null, arg2, arg1, arg0 Object aggregationWithOffset = groupedPartialAggregation(function, offsetArgs(function, 3), offsetColumns(pages, 3)); assertFunctionEquals(isEqual, "Consistent results with channel offset", aggregationWithOffset, aggregation); return aggregation; }
private static void assertAggregationInternal(InternalAggregationFunction function, BiFunction<Object, Object, Boolean> isEqual, String testDescription, Object expectedValue, Page... pages) { // This assertAggregation does not try to split up the page to test the correctness of combine function. // Do not use this directly. Always use the other assertAggregation. assertFunctionEquals(isEqual, testDescription, aggregation(function, pages), expectedValue); assertFunctionEquals(isEqual, testDescription, partialAggregation(function, pages), expectedValue); if (pages.length > 0) { assertFunctionEquals(isEqual, testDescription, groupedAggregation(isEqual, function, pages), expectedValue); assertFunctionEquals(isEqual, testDescription, groupedPartialAggregation(isEqual, function, pages), expectedValue); assertFunctionEquals(isEqual, testDescription, distinctAggregation(function, pages), expectedValue); } }
public static Object groupedPartialAggregation(InternalAggregationFunction function, double confidence, Page... pages) { // execute with args in positions: arg0, arg1, arg2 Object aggregation = groupedPartialAggregation(function, confidence, createArgs(function), pages); // execute with args in reverse order: arg2, arg1, arg0 if (function.getParameterTypes().size() > 1) { Object aggregationWithOffset = groupedPartialAggregation(function, confidence, reverseArgs(function), reverseColumns(pages)); assertEquals(aggregationWithOffset, aggregation, "Inconsistent results with reversed channels"); } // execute with args at an offset (and possibly reversed): null, null, null, arg2, arg1, arg0 Object aggregationWithOffset = groupedPartialAggregation(function, confidence, offsetArgs(function, 3), offsetColumns(pages, 3)); assertEquals(aggregationWithOffset, aggregation, "Inconsistent results with channel offset"); return aggregation; }
private static void assertAggregation(InternalAggregationFunction function, double confidence, Object expectedValue, Page... pages) { BiConsumer<Object, Object> equalAssertion = (actual, expected) -> { assertEquals(actual, expected); }; if (isFloatingNumber(expectedValue) && !isNan(expectedValue)) { equalAssertion = (actual, expected) -> { assertEquals((double) actual, (double) expected, 1e-10); }; } // This assertAggregation does not try to split up the page to test the correctness of combine function. // Do not use this directly. Always use the other assertAggregation. equalAssertion.accept(aggregation(function, confidence, pages), expectedValue); equalAssertion.accept(partialAggregation(function, confidence, pages), expectedValue); if (pages.length > 0) { equalAssertion.accept(groupedAggregation(function, confidence, pages), expectedValue); equalAssertion.accept(groupedPartialAggregation(function, confidence, pages), expectedValue); equalAssertion.accept(distinctAggregation(function, confidence, pages), expectedValue); } }