public LazyAccumulatorFactoryBinder(AggregationMetadata metadata, DynamicClassLoader classLoader) { binder = Suppliers.memoize(() -> AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader)); }
public static GenericAccumulatorFactoryBinder generateAccumulatorFactoryBinder(AggregationMetadata metadata, DynamicClassLoader classLoader) { Class<? extends Accumulator> accumulatorClass = generateAccumulatorClass( Accumulator.class, metadata, classLoader); Class<? extends GroupedAccumulator> groupedAccumulatorClass = generateAccumulatorClass( GroupedAccumulator.class, metadata, classLoader); return new GenericAccumulatorFactoryBinder( metadata.getAccumulatorStateDescriptors(), accumulatorClass, groupedAccumulatorClass); }
generateConstructor( definition, stateFieldAndDescriptors, generateAddInput( definition, stateFileds, callSiteBinder, grouped); generateAddInputWindowIndex( definition, stateFileds, metadata.getInputFunction(), callSiteBinder); generateGetEstimatedSize(definition, stateFileds); generateGetIntermediateType( definition, callSiteBinder, generateGetFinalType(definition, callSiteBinder, metadata.getOutputType()); generateAddIntermediateAsCombine( definition, stateFieldAndDescriptors, generateGroupedEvaluateIntermediate(definition, stateFieldAndDescriptors);
generateConstructor( definition, stateSerializerField, generateAddInput(definition, stateField, inputChannelsField, maskChannelField, sampleWeightChannelField, metadata.getInputMetadata(), metadata.getInputFunction(), callSiteBinder, grouped); generateGetEstimatedSize(definition, stateField); generateGetIntermediateType(definition, callSiteBinder, stateSerializer.getSerializedType()); generateGetFinalType(definition, callSiteBinder, metadata.getOutputType()); generateAddIntermediateAsCombine(definition, stateField, stateSerializerField, stateFactoryField, metadata.getCombineFunction(), stateFactory.getSingleStateClass(), callSiteBinder, grouped); generateAddIntermediateAsIntermediateInput(definition, stateField, metadata.getIntermediateInputMetadata(), metadata.getIntermediateInputFunction(), callSiteBinder, grouped); generateGroupedEvaluateIntermediate(definition, stateSerializerField, stateField); generateEvaluateIntermediate(definition, stateSerializerField, stateField); generateGroupedEvaluateFinal(definition, confidenceField, stateField, metadata.getOutputFunction(), metadata.isApproximate(), callSiteBinder); generateEvaluateFinal(definition, confidenceField, stateField, metadata.getOutputFunction(), metadata.isApproximate(), callSiteBinder);
public LazyAccumulatorFactoryBinder(AggregationMetadata metadata, DynamicClassLoader classLoader) { binder = Suppliers.memoize(() -> new AccumulatorCompiler().generateAccumulatorFactoryBinder(metadata, classLoader)); }
boolean grouped) MethodDefinition method = declareAddIntermediate(definition, grouped); Scope scope = method.getScope(); BytecodeBlock body = method.getBody(); generateEnsureCapacity(scope, stateFields, body); body.append(generateBlockNonNullPositionForLoop(scope, position, loopBody)) .ret();
private static void generateAddIntermediateAsIntermediateInput( ClassDefinition definition, FieldDefinition stateField, List<ParameterMetadata> parameterMetadatas, MethodHandle intermediateInputFunction, CallSiteBinder callSiteBinder, boolean grouped) { MethodDefinition method = declareAddIntermediate(definition, grouped); Scope scope = method.getScope(); BytecodeBlock body = method.getBody(); if (grouped) { generateEnsureCapacity(scope, stateField, body); } Variable positionVariable = scope.declareVariable(int.class, "position"); BytecodeBlock loopBody = generateInvokeInputFunction(scope, stateField, positionVariable, null, ImmutableList.of(scope.getVariable("block")), parameterMetadatas, intermediateInputFunction, callSiteBinder, grouped); if (grouped) { // skip rows with null group id IfStatement ifStatement = new IfStatement("if (!groupIdsBlock.isNull(position))") .condition(not(scope.getVariable("groupIdsBlock").invoke("isNull", boolean.class, positionVariable))) .ifTrue(loopBody); loopBody = new BytecodeBlock().append(ifStatement); } body.append(generateBlockNonNullPositionForLoop(scope, positionVariable, loopBody)) .ret(); }
generateEnsureCapacity(scope, stateField, body); .putVariable(parameterVariables.get(i)); BytecodeBlock block = generateInputForLoop( stateField, parameterMetadatas,
private static InternalAggregationFunction generateAggregation(Type type) { DynamicClassLoader classLoader = new DynamicClassLoader(CountColumn.class.getClassLoader()); AccumulatorStateSerializer<LongState> stateSerializer = new StateCompiler().generateStateSerializer(LongState.class, classLoader); AccumulatorStateFactory<LongState> stateFactory = new StateCompiler().generateStateFactory(LongState.class, classLoader); Type intermediateType = stateSerializer.getSerializedType(); List<Type> inputTypes = ImmutableList.of(type); AggregationMetadata metadata = new AggregationMetadata( generateAggregationName(NAME, BIGINT, inputTypes), createInputParameterMetadata(type), INPUT_FUNCTION, null, null, COMBINE_FUNCTION, OUTPUT_FUNCTION, LongState.class, stateSerializer, stateFactory, BIGINT, false); GenericAccumulatorFactoryBinder factory = new AccumulatorCompiler().generateAccumulatorFactoryBinder(metadata, classLoader); return new InternalAggregationFunction(NAME, inputTypes, intermediateType, BIGINT, true, false, factory); }
boolean grouped) MethodDefinition method = declareAddIntermediate(definition, grouped); Scope scope = method.getScope(); BytecodeBlock body = method.getBody(); generateEnsureCapacity(scope, stateField, body); body.append(generateBlockNonNullPositionForLoop(scope, position, loopBody)) .ret();
generateEnsureCapacity(scope, stateField, body); .putVariable(parameterVariables.get(i)); BytecodeBlock block = generateInputForLoop(stateField, parameterMetadatas, inputFunction, scope, parameterVariables, masksBlock, sampleWeightsBlock, callSiteBinder, grouped);
private static InternalAggregationFunction generateAggregation(Type type) { DynamicClassLoader classLoader = new DynamicClassLoader(ChecksumAggregationFunction.class.getClassLoader()); List<Type> inputTypes = ImmutableList.of(type); AggregationMetadata metadata = new AggregationMetadata( generateAggregationName(NAME, type, inputTypes), createInputParameterMetadata(type), INPUT_FUNCTION.bindTo(type), null, null, COMBINE_FUNCTION, OUTPUT_FUNCTION, NullableLongState.class, new StateCompiler().generateStateSerializer(NullableLongState.class, classLoader), new StateCompiler().generateStateFactory(NullableLongState.class, classLoader), VARBINARY, false); GenericAccumulatorFactoryBinder factory = new AccumulatorCompiler().generateAccumulatorFactoryBinder(metadata, classLoader); return new InternalAggregationFunction(NAME, inputTypes, BIGINT, VARBINARY, true, false, factory); }
private static InternalAggregationFunction generateAggregation(Type type) { DynamicClassLoader classLoader = new DynamicClassLoader(ChecksumAggregationFunction.class.getClassLoader()); List<Type> inputTypes = ImmutableList.of(type); AggregationMetadata metadata = new AggregationMetadata( generateAggregationName(NAME, type.getTypeSignature(), inputTypes.stream().map(Type::getTypeSignature).collect(toImmutableList())), createInputParameterMetadata(type), INPUT_FUNCTION.bindTo(type), COMBINE_FUNCTION, OUTPUT_FUNCTION, ImmutableList.of(new AccumulatorStateDescriptor( NullableLongState.class, StateCompiler.generateStateSerializer(NullableLongState.class, classLoader), StateCompiler.generateStateFactory(NullableLongState.class, classLoader))), VARBINARY); GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader); return new InternalAggregationFunction(NAME, inputTypes, ImmutableList.of(BIGINT), VARBINARY, true, false, factory); }
public GenericAccumulatorFactoryBinder generateAccumulatorFactoryBinder(AggregationMetadata metadata, DynamicClassLoader classLoader) { Class<? extends Accumulator> accumulatorClass = generateAccumulatorClass( Accumulator.class, metadata, classLoader); Class<? extends GroupedAccumulator> groupedAccumulatorClass = generateAccumulatorClass( GroupedAccumulator.class, metadata, classLoader); return new GenericAccumulatorFactoryBinder( metadata.getStateSerializer(), metadata.getStateFactory(), accumulatorClass, groupedAccumulatorClass, metadata.isApproximate()); }
private static InternalAggregationFunction generateAggregation(Type keyType, Type valueType) { DynamicClassLoader classLoader = new DynamicClassLoader(MapAggregationFunction.class.getClassLoader()); List<Type> inputTypes = ImmutableList.of(keyType, valueType); Type outputType = new MapType(keyType, valueType); KeyValuePairStateSerializer stateSerializer = new KeyValuePairStateSerializer(keyType, valueType, false); Type intermediateType = stateSerializer.getSerializedType(); AggregationMetadata metadata = new AggregationMetadata( generateAggregationName(NAME, outputType, inputTypes), createInputParameterMetadata(keyType, valueType), INPUT_FUNCTION.bindTo(keyType).bindTo(valueType), null, null, COMBINE_FUNCTION, OUTPUT_FUNCTION, KeyValuePairsState.class, stateSerializer, new KeyValuePairsStateFactory(keyType, valueType), outputType, false); GenericAccumulatorFactoryBinder factory = new AccumulatorCompiler().generateAccumulatorFactoryBinder(metadata, classLoader); return new InternalAggregationFunction(NAME, inputTypes, intermediateType, outputType, true, false, factory); }
private static InternalAggregationFunction generateAggregation(Type type) { DynamicClassLoader classLoader = new DynamicClassLoader(CountColumn.class.getClassLoader()); AccumulatorStateSerializer<LongState> stateSerializer = StateCompiler.generateStateSerializer(LongState.class, classLoader); AccumulatorStateFactory<LongState> stateFactory = StateCompiler.generateStateFactory(LongState.class, classLoader); Type intermediateType = stateSerializer.getSerializedType(); List<Type> inputTypes = ImmutableList.of(type); AggregationMetadata metadata = new AggregationMetadata( generateAggregationName(NAME, BIGINT.getTypeSignature(), inputTypes.stream().map(Type::getTypeSignature).collect(toImmutableList())), createInputParameterMetadata(type), INPUT_FUNCTION, COMBINE_FUNCTION, OUTPUT_FUNCTION, ImmutableList.of(new AccumulatorStateDescriptor( LongState.class, stateSerializer, stateFactory)), BIGINT); GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader); return new InternalAggregationFunction(NAME, inputTypes, ImmutableList.of(intermediateType), BIGINT, true, false, factory); }
private static InternalAggregationFunction generateAggregation(Type keyType, Type valueType) { DynamicClassLoader classLoader = new DynamicClassLoader(MultimapAggregationFunction.class.getClassLoader()); List<Type> inputTypes = ImmutableList.of(keyType, valueType); Type outputType = new MapType(keyType, new ArrayType(valueType)); KeyValuePairStateSerializer stateSerializer = new KeyValuePairStateSerializer(keyType, valueType, true); Type intermediateType = stateSerializer.getSerializedType(); AggregationMetadata metadata = new AggregationMetadata( generateAggregationName(NAME, outputType, inputTypes), createInputParameterMetadata(keyType, valueType), INPUT_FUNCTION, null, null, COMBINE_FUNCTION, OUTPUT_FUNCTION, KeyValuePairsState.class, stateSerializer, new KeyValuePairsStateFactory(keyType, valueType), outputType, false); GenericAccumulatorFactoryBinder factory = new AccumulatorCompiler().generateAccumulatorFactoryBinder(metadata, classLoader); return new InternalAggregationFunction(NAME, inputTypes, intermediateType, outputType, true, false, factory); }
private InternalAggregationFunction generateAggregation(Type keyType, Type valueType, Type outputType) { DynamicClassLoader classLoader = new DynamicClassLoader(MultimapAggregationFunction.class.getClassLoader()); List<Type> inputTypes = ImmutableList.of(keyType, valueType); MultimapAggregationStateSerializer stateSerializer = new MultimapAggregationStateSerializer(keyType, valueType); Type intermediateType = stateSerializer.getSerializedType(); AggregationMetadata metadata = new AggregationMetadata( generateAggregationName(NAME, outputType.getTypeSignature(), inputTypes.stream().map(Type::getTypeSignature).collect(toImmutableList())), createInputParameterMetadata(keyType, valueType), INPUT_FUNCTION, COMBINE_FUNCTION, OUTPUT_FUNCTION.bindTo(keyType).bindTo(valueType), ImmutableList.of(new AccumulatorStateDescriptor( MultimapAggregationState.class, stateSerializer, new MultimapAggregationStateFactory(keyType, valueType, groupMode))), outputType); GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader); return new InternalAggregationFunction(NAME, inputTypes, ImmutableList.of(intermediateType), outputType, true, true, factory); }
private static InternalAggregationFunction generateAggregation(Type keyType, Type valueType) { DynamicClassLoader classLoader = new DynamicClassLoader(Histogram.class.getClassLoader()); List<Type> inputTypes = ImmutableList.of(keyType); Type outputType = new MapType(keyType, valueType); HistogramStateSerializer stateSerializer = new HistogramStateSerializer(keyType); Type intermediateType = stateSerializer.getSerializedType(); MethodHandle inputFunction = INPUT_FUNCTION.bindTo(keyType); MethodHandle outputFunction = OUTPUT_FUNCTION.bindTo(outputType); AggregationMetadata metadata = new AggregationMetadata( generateAggregationName(NAME, outputType, inputTypes), createInputParameterMetadata(keyType), inputFunction, null, null, COMBINE_FUNCTION, outputFunction, HistogramState.class, stateSerializer, new HistogramStateFactory(), outputType, false); GenericAccumulatorFactoryBinder factory = new AccumulatorCompiler().generateAccumulatorFactoryBinder(metadata, classLoader); return new InternalAggregationFunction(NAME, inputTypes, intermediateType, outputType, true, false, factory); }
private static InternalAggregationFunction generateAggregation(Type keyType, Type valueType, MapType outputType) { DynamicClassLoader classLoader = new DynamicClassLoader(MapUnionAggregation.class.getClassLoader()); List<Type> inputTypes = ImmutableList.of(outputType); KeyValuePairStateSerializer stateSerializer = new KeyValuePairStateSerializer(outputType); Type intermediateType = stateSerializer.getSerializedType(); AggregationMetadata metadata = new AggregationMetadata( generateAggregationName(NAME, outputType.getTypeSignature(), inputTypes.stream().map(Type::getTypeSignature).collect(toImmutableList())), createInputParameterMetadata(outputType), INPUT_FUNCTION.bindTo(keyType).bindTo(valueType), COMBINE_FUNCTION, OUTPUT_FUNCTION, ImmutableList.of(new AccumulatorStateDescriptor( KeyValuePairsState.class, stateSerializer, new KeyValuePairsStateFactory(keyType, valueType))), outputType); GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader); return new InternalAggregationFunction(NAME, inputTypes, ImmutableList.of(intermediateType), outputType, true, false, factory); }