private Supplier<PageFilter> compileFilterInternal(RowExpression filter, Optional<String> classNameSuffix) { requireNonNull(filter, "filter is null"); PageFieldsToInputParametersRewriter.Result result = rewritePageFieldsToInputParameters(filter); CallSiteBinder callSiteBinder = new CallSiteBinder(); ClassDefinition classDefinition = defineFilterClass(result.getRewrittenExpression(), result.getInputChannels(), callSiteBinder, classNameSuffix); Class<? extends PageFilter> functionClass; try { functionClass = defineClass(classDefinition, PageFilter.class, callSiteBinder.getBindings(), getClass().getClassLoader()); } catch (Exception e) { throw new PrestoException(COMPILER_ERROR, filter.toString(), e.getCause()); } return () -> { try { return functionClass.getConstructor().newInstance(); } catch (ReflectiveOperationException e) { throw new PrestoException(COMPILER_ERROR, e); } }; }
private <T> Class<? extends T> compileProcessor( RowExpression filter, List<RowExpression> projections, BodyCompiler bodyCompiler, Class<? extends T> superType) { ClassDefinition classDefinition = new ClassDefinition( a(PUBLIC, FINAL), makeClassName(superType.getSimpleName()), type(Object.class), type(superType)); CallSiteBinder callSiteBinder = new CallSiteBinder(); bodyCompiler.generateMethods(classDefinition, callSiteBinder, filter, projections); // // toString method // generateToString( classDefinition, callSiteBinder, toStringHelper(classDefinition.getType().getJavaClassName()) .add("filter", filter) .add("projections", projections) .toString()); return defineClass(classDefinition, superType, callSiteBinder.getBindings(), getClass().getClassLoader()); }
private Class<? extends InternalJoinFilterFunction> compileInternalJoinFilterFunction(RowExpression filterExpression, int leftBlocksSize) { ClassDefinition classDefinition = new ClassDefinition( a(PUBLIC, FINAL), makeClassName("JoinFilterFunction"), type(Object.class), type(InternalJoinFilterFunction.class)); CallSiteBinder callSiteBinder = new CallSiteBinder(); new JoinFilterFunctionCompiler(metadata).generateMethods(classDefinition, callSiteBinder, filterExpression, leftBlocksSize); // // toString method // generateToString( classDefinition, callSiteBinder, toStringHelper(classDefinition.getType().getJavaClassName()) .add("filter", filterExpression) .add("leftBlocksSize", leftBlocksSize) .toString()); return defineClass(classDefinition, InternalJoinFilterFunction.class, callSiteBinder.getBindings(), getClass().getClassLoader()); }
private Class<? extends PageWithPositionComparator> generatePageWithPositionComparatorClass(List<Type> sortTypes, List<Integer> sortChannels, List<SortOrder> sortOrders) { CallSiteBinder callSiteBinder = new CallSiteBinder(); ClassDefinition classDefinition = new ClassDefinition( a(PUBLIC, FINAL), makeClassName("PageWithPositionComparator"), type(Object.class), type(PageWithPositionComparator.class)); classDefinition.declareDefaultConstructor(a(PUBLIC)); generateMergeSortCompareTo(classDefinition, callSiteBinder, sortTypes, sortChannels, sortOrders); return defineClass(classDefinition, PageWithPositionComparator.class, callSiteBinder.getBindings(), getClass().getClassLoader()); }
private Class<? extends PagesIndexComparator> compilePagesIndexComparator( List<Type> sortTypes, List<Integer> sortChannels, List<SortOrder> sortOrders) { CallSiteBinder callSiteBinder = new CallSiteBinder(); ClassDefinition classDefinition = new ClassDefinition( a(PUBLIC, FINAL), makeClassName("PagesIndexComparator"), type(Object.class), type(PagesIndexComparator.class)); classDefinition.declareDefaultConstructor(a(PUBLIC)); generatePageIndexCompareTo(classDefinition, callSiteBinder, sortTypes, sortChannels, sortOrders); return defineClass(classDefinition, PagesIndexComparator.class, callSiteBinder.getBindings(), getClass().getClassLoader()); }
type(AccumulatorStateSerializer.class)); CallSiteBinder callSiteBinder = new CallSiteBinder();
CallSiteBinder callSiteBinder = new CallSiteBinder();
checkArgument(methodType.parameterList().equals(ImmutableList.of(Object.class, javaArrayType)), "parameter types do not match"); CallSiteBinder callSiteBinder = new CallSiteBinder(); ClassDefinition classDefinition = new ClassDefinition(a(PUBLIC, FINAL), makeClassName("VarArgsToListAdapter"), type(Object.class)); classDefinition.declareDefaultConstructor(a(PRIVATE));
BytecodeBlock body = method.getBody(); CallSiteBinder binder = new CallSiteBinder();
CallSiteBinder binder = new CallSiteBinder();
private Class<? extends PagesHashStrategy> internalCompileHashStrategy(List<Type> types, List<Integer> outputChannels, List<Integer> joinChannels, Optional<Integer> sortChannel) CallSiteBinder callSiteBinder = new CallSiteBinder();
private Supplier<PageProjection> compileProjectionInternal(RowExpression projection, Optional<String> classNameSuffix) { requireNonNull(projection, "projection is null"); if (projection instanceof InputReferenceExpression) { InputReferenceExpression input = (InputReferenceExpression) projection; InputPageProjection projectionFunction = new InputPageProjection(input.getField(), input.getType()); return () -> projectionFunction; } if (projection instanceof ConstantExpression) { ConstantExpression constant = (ConstantExpression) projection; ConstantPageProjection projectionFunction = new ConstantPageProjection(constant.getValue(), constant.getType()); return () -> projectionFunction; } PageFieldsToInputParametersRewriter.Result result = rewritePageFieldsToInputParameters(projection); CallSiteBinder callSiteBinder = new CallSiteBinder(); // generate Work ClassDefinition pageProjectionWorkDefinition = definePageProjectWorkClass(result.getRewrittenExpression(), callSiteBinder, classNameSuffix); Class<? extends Work> pageProjectionWorkClass; try { pageProjectionWorkClass = defineClass(pageProjectionWorkDefinition, Work.class, callSiteBinder.getBindings(), getClass().getClassLoader()); } catch (Exception e) { throw new PrestoException(COMPILER_ERROR, e); } return () -> new GeneratedPageProjection( result.getRewrittenExpression(), determinismEvaluator.isDeterministic(result.getRewrittenExpression()), result.getInputChannels(), constructorMethodHandle(pageProjectionWorkClass, BlockBuilder.class, ConnectorSession.class, Page.class, SelectedPositions.class)); }
CallSiteBinder binder = new CallSiteBinder(); OperatorType operator = min ? LESS_THAN : GREATER_THAN; MethodHandle compareMethod = functionRegistry.getScalarFunctionImplementation(functionRegistry.resolveOperator(operator, ImmutableList.of(keyType, keyType))).getMethodHandle();
type(accumulatorInterface)); CallSiteBinder callSiteBinder = new CallSiteBinder();
List<Type> fromTypes = fromType.getTypeParameters(); CallSiteBinder binder = new CallSiteBinder();
private static Class<?> generateArrayCast(TypeManager typeManager, Signature elementCastSignature, ScalarFunctionImplementation elementCast) CallSiteBinder binder = new CallSiteBinder();
CallSiteBinder callSiteBinder = new CallSiteBinder(); CachedInstanceBinder cachedInstanceBinder = new CachedInstanceBinder(lambdaProviderClassDefinition, callSiteBinder);
private static Class<?> generateIndeterminate(Type type, FunctionRegistry functionRegistry) CallSiteBinder binder = new CallSiteBinder();
private static Class<?> generateTransform(Type inputType, Type outputType) CallSiteBinder binder = new CallSiteBinder(); Class<?> inputJavaType = Primitives.wrap(inputType.getJavaType()); Class<?> outputJavaType = Primitives.wrap(outputType.getJavaType());
private static MethodHandle generateFilter(MapType mapType) CallSiteBinder binder = new CallSiteBinder(); Type keyType = mapType.getKeyType(); Type valueType = mapType.getValueType();