private static List<Integer> createArgs(InternalAggregationFunction function) { ImmutableList.Builder<Integer> list = ImmutableList.builder(); for (int i = 0; i < function.getParameterTypes().size(); i++) { list.add(i); } return list.build(); } }
public static int[] createArgs(InternalAggregationFunction function) { int[] args = new int[function.getParameterTypes().size()]; for (int i = 0; i < args.length; i++) { args[i] = i; } return args; } }
private static int[] createArgs(InternalAggregationFunction function) { int[] args = new int[function.getParameterTypes().size()]; for (int i = 0; i < args.length; i++) { args[i] = i; } return args; }
@Test public void testAllPositionsNull() { // if there are no parameters skip this test List<Type> parameterTypes = getFunction().getParameterTypes(); if (parameterTypes.isEmpty()) { return; } Block[] blocks = new Block[parameterTypes.size()]; for (int i = 0; i < parameterTypes.size(); i++) { blocks[i] = RunLengthEncodedBlock.create(parameterTypes.get(0), null, 10); } testAggregation(getExpectedValueIncludingNulls(0, 0, 10), blocks); }
@Test public void testMixedNullAndNonNullPositions() { // if there are no parameters skip this test List<Type> parameterTypes = getFunction().getParameterTypes(); if (parameterTypes.isEmpty()) { return; } Block[] alternatingNullsBlocks = createAlternatingNullsBlock(parameterTypes, getSequenceBlocks(0, 10)); testAggregation(getExpectedValueIncludingNulls(0, 10, 20), alternatingNullsBlocks); }
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; }
@Test @Override public void testMixedNullAndNonNullPositions() { assertAggregation(getFunction(), QDIGEST_EQUALITY, "test mixed null and nonnull position", new Page(createAlternatingNullsBlock(getFunction().getParameterTypes(), getSequenceBlocks(0, 10))), getExpectedValueIncludingNulls(0, 10, 20)); } }
null); assertEquals(specialized.getFinalType(), DoubleType.DOUBLE); assertTrue(specialized.getParameterTypes().equals(ImmutableList.of(DoubleType.DOUBLE))); assertTrue(specialized.isDecomposable()); assertEquals(specialized.name(), "simple_generic_implementations");
null); assertEquals(specialized.getFinalType(), DoubleType.DOUBLE); assertTrue(specialized.getParameterTypes().equals(ImmutableList.of(DoubleType.DOUBLE))); assertTrue(specialized.isDecomposable()); assertEquals(specialized.name(), "partially_fixed_type_parameter_injection");
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 List<Integer> createArgs(InternalAggregationFunction function) { ImmutableList.Builder<Integer> list = ImmutableList.builder(); for (int i = 0; i < function.getParameterTypes().size(); i++) { list.add(i); } return list.build(); } }
public InternalAggregationFunction generateAggregationFunction(Class<?> clazz, Type returnType, List<Type> argumentTypes) { requireNonNull(returnType, "returnType is null"); requireNonNull(argumentTypes, "argumentTypes is null"); for (InternalAggregationFunction aggregation : generateAggregationFunctions(clazz)) { if (aggregation.getFinalType().equals(returnType) && aggregation.getParameterTypes().equals(argumentTypes)) { return aggregation; } } throw new IllegalArgumentException(String.format("No method with return type %s and arguments %s", returnType, argumentTypes)); }
private static int[] createArgs(InternalAggregationFunction function) { int[] args = new int[function.getParameterTypes().size()]; for (int i = 0; i < args.length; i++) { args[i] = i; } return args; }
private void accumulate(int start, int end) { // TODO: add Accumulator method that does not require creating pages PageBuilder pageBuilder = new PageBuilder(function.getParameterTypes()); for (int position = start; position <= end; position++) { for (int i = 0; i < function.getParameterTypes().size(); i++) { windowIndex.appendTo(argumentChannels[i], position, pageBuilder.getBlockBuilder(i)); } pageBuilder.declarePosition(); } accumulator.addInput(pageBuilder.build()); }
@Test public void testMixedNullAndNonNullPositions() { // if there are no parameters skip this test List<Type> parameterTypes = getFunction().getParameterTypes(); if (parameterTypes.isEmpty()) { return; } Block[] alternatingNullsBlocks = createAlternatingNullsBlock(parameterTypes, getSequenceBlocks(0, 10)); testAggregation(getExpectedValueIncludingNulls(0, 10, 20), alternatingNullsBlocks); }
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; }