use of io.airlift.bytecode.DynamicClassLoader in project hetu-core by openlookeng.
the class JoinCompiler method internalCompileLookupSourceFactory.
private LookupSourceSupplierFactory internalCompileLookupSourceFactory(List<Type> types, List<Integer> outputChannels, List<Integer> joinChannels, Optional<Integer> sortChannel) {
Class<? extends PagesHashStrategy> pagesHashStrategyClass = internalCompileHashStrategy(types, outputChannels, joinChannels, sortChannel);
Class<? extends LookupSourceSupplier> joinHashSupplierClass = IsolatedClass.isolateClass(new DynamicClassLoader(getClass().getClassLoader()), LookupSourceSupplier.class, JoinHashSupplier.class, JoinHash.class, PagesHash.class);
return new LookupSourceSupplierFactory(joinHashSupplierClass, new PagesHashStrategyFactory(pagesHashStrategyClass));
}
use of io.airlift.bytecode.DynamicClassLoader in project hetu-core by openlookeng.
the class Bootstrap method bootstrap.
public static CallSite bootstrap(MethodHandles.Lookup callerLookup, String name, MethodType type, long bindingId) {
ClassLoader classLoader = callerLookup.lookupClass().getClassLoader();
checkArgument(classLoader instanceof DynamicClassLoader, "Expected %s's classloader to be of type %s", callerLookup.lookupClass().getName(), DynamicClassLoader.class.getName());
DynamicClassLoader dynamicClassLoader = (DynamicClassLoader) classLoader;
MethodHandle target = dynamicClassLoader.getCallSiteBindings().get(bindingId);
checkArgument(target != null, "Binding %s for function %s%s not found", bindingId, name, type.parameterList());
return new ConstantCallSite(target);
}
use of io.airlift.bytecode.DynamicClassLoader in project hetu-core by openlookeng.
the class ArbitraryAggregationFunction method generateAggregation.
private static InternalAggregationFunction generateAggregation(Type type) {
DynamicClassLoader classLoader = new DynamicClassLoader(ArbitraryAggregationFunction.class.getClassLoader());
List<Type> inputTypes = ImmutableList.of(type);
MethodHandle inputFunction;
MethodHandle combineFunction;
MethodHandle outputFunction;
Class<? extends AccumulatorState> stateInterface;
AccumulatorStateSerializer<?> stateSerializer;
if (type.getJavaType() == long.class) {
stateInterface = NullableLongState.class;
stateSerializer = StateCompiler.generateStateSerializer(stateInterface, classLoader);
inputFunction = LONG_INPUT_FUNCTION;
combineFunction = LONG_COMBINE_FUNCTION;
outputFunction = LONG_OUTPUT_FUNCTION;
} else if (type.getJavaType() == double.class) {
stateInterface = NullableDoubleState.class;
stateSerializer = StateCompiler.generateStateSerializer(stateInterface, classLoader);
inputFunction = DOUBLE_INPUT_FUNCTION;
combineFunction = DOUBLE_COMBINE_FUNCTION;
outputFunction = DOUBLE_OUTPUT_FUNCTION;
} else if (type.getJavaType() == boolean.class) {
stateInterface = NullableBooleanState.class;
stateSerializer = StateCompiler.generateStateSerializer(stateInterface, classLoader);
inputFunction = BOOLEAN_INPUT_FUNCTION;
combineFunction = BOOLEAN_COMBINE_FUNCTION;
outputFunction = BOOLEAN_OUTPUT_FUNCTION;
} else {
// native container type is Slice or Block
stateInterface = BlockPositionState.class;
stateSerializer = new BlockPositionStateSerializer(type);
inputFunction = BLOCK_POSITION_INPUT_FUNCTION;
combineFunction = BLOCK_POSITION_COMBINE_FUNCTION;
outputFunction = BLOCK_POSITION_OUTPUT_FUNCTION;
}
inputFunction = inputFunction.bindTo(type);
Type intermediateType = stateSerializer.getSerializedType();
List<ParameterMetadata> inputParameterMetadata = createInputParameterMetadata(type);
AggregationMetadata metadata = new AggregationMetadata(generateAggregationName(NAME, type.getTypeSignature(), inputTypes.stream().map(Type::getTypeSignature).collect(toImmutableList())), inputParameterMetadata, inputFunction, combineFunction, outputFunction.bindTo(type), ImmutableList.of(new AccumulatorStateDescriptor(stateInterface, stateSerializer, StateCompiler.generateStateFactory(stateInterface, classLoader))), type);
GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader);
return new InternalAggregationFunction(NAME, inputTypes, ImmutableList.of(intermediateType), type, true, false, factory);
}
use of io.airlift.bytecode.DynamicClassLoader in project hetu-core by openlookeng.
the class MergeQuantileDigestFunction method generateAggregation.
private static InternalAggregationFunction generateAggregation(Type valueType, QuantileDigestType type) {
DynamicClassLoader classLoader = new DynamicClassLoader(MapAggregationFunction.class.getClassLoader());
QuantileDigestStateSerializer stateSerializer = new QuantileDigestStateSerializer(valueType);
Type intermediateType = stateSerializer.getSerializedType();
AggregationMetadata metadata = new AggregationMetadata(generateAggregationName(NAME, type.getTypeSignature(), ImmutableList.of(type.getTypeSignature())), createInputParameterMetadata(type), INPUT_FUNCTION.bindTo(type), COMBINE_FUNCTION, OUTPUT_FUNCTION.bindTo(stateSerializer), ImmutableList.of(new AccumulatorStateDescriptor(QuantileDigestState.class, stateSerializer, new QuantileDigestStateFactory())), type);
GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader);
return new InternalAggregationFunction(NAME, ImmutableList.of(type), ImmutableList.of(intermediateType), type, true, true, factory);
}
use of io.airlift.bytecode.DynamicClassLoader in project hetu-core by openlookeng.
the class MapUnionAggregation method generateAggregation.
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);
}
Aggregations