public static int[] offsetArgs(InternalAggregationFunction function, int offset) { int[] args = createArgs(function); for (int i = 0; i < args.length; i++) { args[i] += offset; } return args; }
public static int[] reverseArgs(InternalAggregationFunction function) { int[] args = createArgs(function); Collections.reverse(Ints.asList(args)); return args; }
public static Object distinctAggregation(InternalAggregationFunction function, Page... pages) { Optional<Integer> maskChannel = Optional.of(pages[0].getChannelCount()); // Execute normally Object aggregation = aggregation(function, createArgs(function), maskChannel, maskPages(true, pages)); Page[] dupedPages = new Page[pages.length * 2]; // Create two copies of each page with one of them masked off System.arraycopy(maskPages(true, pages), 0, dupedPages, 0, pages.length); System.arraycopy(maskPages(false, pages), 0, dupedPages, pages.length, pages.length); // Execute with masked pages and assure equal to normal execution Object aggregationWithDupes = aggregation(function, createArgs(function), maskChannel, dupedPages); assertEquals(aggregationWithDupes, aggregation, "Inconsistent results with mask"); return aggregation; }
public static Object aggregation(InternalAggregationFunction function, Page... pages) { // execute with args in positions: arg0, arg1, arg2 Object aggregation = aggregation(function, createArgs(function), Optional.empty(), pages); // execute with args in reverse order: arg2, arg1, arg0 if (function.getParameterTypes().size() > 1) { Object aggregationWithOffset = aggregation(function, reverseArgs(function), Optional.empty(), 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 = aggregation(function, offsetArgs(function, 3), Optional.empty(), offsetColumns(pages, 3)); assertEquals(aggregationWithOffset, aggregation, "Inconsistent results with channel offset"); return aggregation; }
public static Object partialAggregation(InternalAggregationFunction function, Page... pages) { // execute with args in positions: arg0, arg1, arg2 Object aggregation = partialAggregation(function, createArgs(function), pages); // execute with args in reverse order: arg2, arg1, arg0 if (function.getParameterTypes().size() > 1) { Object aggregationWithOffset = partialAggregation(function, 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 = partialAggregation(function, offsetArgs(function, 3), offsetColumns(pages, 3)); assertEquals(aggregationWithOffset, aggregation, "Inconsistent results with channel offset"); return aggregation; }
public static Object groupedAggregation(BiFunction<Object, Object, Boolean> isEqual, InternalAggregationFunction function, Page... pages) { // execute with args in positions: arg0, arg1, arg2 Object aggregation = groupedAggregation(function, createArgs(function), pages); // execute with args in reverse order: arg2, arg1, arg0 if (function.getParameterTypes().size() > 1) { Object aggregationWithOffset = groupedAggregation(function, reverseArgs(function), reverseColumns(pages)); assertFunctionEquals(isEqual, "Inconsistent results with reversed channels", aggregationWithOffset, aggregation); } // execute with args at an offset (and possibly reversed): null, null, null, arg2, arg1, arg0 Object aggregationWithOffset = groupedAggregation(function, offsetArgs(function, 3), offsetColumns(pages, 3)); assertFunctionEquals(isEqual, "Consistent results with channel offset", aggregationWithOffset, aggregation); return aggregation; }
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 int[] offsetArgs(InternalAggregationFunction function, int offset) { int[] args = createArgs(function); for (int i = 0; i < args.length; i++) { args[i] += offset; } return args; }
private static int[] reverseArgs(InternalAggregationFunction function) { int[] args = createArgs(function); Collections.reverse(Ints.asList(args)); return args; }
public static Object distinctAggregation(InternalAggregationFunction function, double confidence, Page... pages) { Optional<Integer> maskChannel = Optional.of(pages[0].getChannelCount()); // Execute normally Object aggregation = aggregation(function, createArgs(function), maskChannel, confidence, maskPages(true, pages)); Page[] dupedPages = new Page[pages.length * 2]; // Create two copies of each page with one of them masked off System.arraycopy(maskPages(true, pages), 0, dupedPages, 0, pages.length); System.arraycopy(maskPages(false, pages), 0, dupedPages, pages.length, pages.length); // Execute with masked pages and assure equal to normal execution Object aggregationWithDupes = aggregation(function, createArgs(function), maskChannel, confidence, dupedPages); assertEquals(aggregationWithDupes, aggregation, "Inconsistent results with mask"); return aggregation; }
public static Object aggregation(InternalAggregationFunction function, double confidence, Page... pages) { // execute with args in positions: arg0, arg1, arg2 Object aggregation = aggregation(function, createArgs(function), Optional.empty(), confidence, pages); // execute with args in reverse order: arg2, arg1, arg0 if (function.getParameterTypes().size() > 1) { Object aggregationWithOffset = aggregation(function, reverseArgs(function), Optional.empty(), confidence, 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 = aggregation(function, offsetArgs(function, 3), Optional.empty(), confidence, offsetColumns(pages, 3)); assertEquals(aggregationWithOffset, aggregation, "Inconsistent results with channel offset"); return aggregation; }
public static Object groupedAggregation(InternalAggregationFunction function, double confidence, Page... pages) { // execute with args in positions: arg0, arg1, arg2 Object aggregation = groupedAggregation(function, confidence, createArgs(function), pages); // execute with args in reverse order: arg2, arg1, arg0 if (function.getParameterTypes().size() > 1) { Object aggregationWithOffset = groupedAggregation(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 = groupedAggregation(function, confidence, offsetArgs(function, 3), offsetColumns(pages, 3)); assertEquals(aggregationWithOffset, aggregation, "Inconsistent results with channel offset"); return aggregation; }
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; }
public static Object partialAggregation(InternalAggregationFunction function, double confidence, Page... pages) { // execute with args in positions: arg0, arg1, arg2 Object aggregation = partialAggregation(function, confidence, createArgs(function), pages); // execute with args in reverse order: arg2, arg1, arg0 if (function.getParameterTypes().size() > 1) { Object aggregationWithOffset = partialAggregation(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 = partialAggregation(function, confidence, offsetArgs(function, 3), offsetColumns(pages, 3)); assertEquals(aggregationWithOffset, aggregation, "Inconsistent results with channel offset"); return aggregation; }