use of io.trino.operator.project.PageFilter in project trino by trinodb.
the class PageFunctionCompiler method compileFilterInternal.
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) {
if (Throwables.getRootCause(e) instanceof MethodTooLargeException) {
throw new TrinoException(COMPILER_ERROR, "Query exceeded maximum filters. Please reduce the number of filters referenced and re-run the query.", e);
}
throw new TrinoException(COMPILER_ERROR, filter.toString(), e.getCause());
}
return () -> {
try {
return functionClass.getConstructor().newInstance();
} catch (ReflectiveOperationException e) {
throw new TrinoException(COMPILER_ERROR, e);
}
};
}
use of io.trino.operator.project.PageFilter in project trino by trinodb.
the class ExpressionCompiler method compilePageProcessor.
private Supplier<PageProcessor> compilePageProcessor(Optional<RowExpression> filter, List<? extends RowExpression> projections, Optional<String> classNameSuffix, OptionalInt initialBatchSize) {
Optional<Supplier<PageFilter>> filterFunctionSupplier = filter.map(expression -> pageFunctionCompiler.compileFilter(expression, classNameSuffix));
List<Supplier<PageProjection>> pageProjectionSuppliers = projections.stream().map(projection -> pageFunctionCompiler.compileProjection(projection, classNameSuffix)).collect(toImmutableList());
return () -> {
Optional<PageFilter> filterFunction = filterFunctionSupplier.map(Supplier::get);
List<PageProjection> pageProjections = pageProjectionSuppliers.stream().map(Supplier::get).collect(toImmutableList());
return new PageProcessor(filterFunction, pageProjections, initialBatchSize);
};
}
Aggregations