Search in sources :

Example 1 with PageFilter

use of io.prestosql.operator.project.PageFilter in project hetu-core by openlookeng.

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);
    };
}
Also used : PageFilter(io.prestosql.operator.project.PageFilter) ParameterizedType.type(io.airlift.bytecode.ParameterizedType.type) Nested(org.weakref.jmx.Nested) LoadingCache(com.google.common.cache.LoadingCache) BytecodeUtils.invoke(io.prestosql.sql.gen.BytecodeUtils.invoke) OptionalInt(java.util.OptionalInt) Supplier(java.util.function.Supplier) CompilerUtils.makeClassName(io.prestosql.util.CompilerUtils.makeClassName) Access.a(io.airlift.bytecode.Access.a) Inject(javax.inject.Inject) ImmutableList(com.google.common.collect.ImmutableList) Managed(org.weakref.jmx.Managed) CompilerUtils.defineClass(io.prestosql.util.CompilerUtils.defineClass) Objects.requireNonNull(java.util.Objects.requireNonNull) BOOLEAN(io.prestosql.spi.type.BooleanType.BOOLEAN) PageProjection(io.prestosql.operator.project.PageProjection) FINAL(io.airlift.bytecode.Access.FINAL) PrestoException(io.prestosql.spi.PrestoException) Expressions.constant(io.prestosql.sql.relational.Expressions.constant) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Metadata(io.prestosql.metadata.Metadata) CacheLoader(com.google.common.cache.CacheLoader) Objects(java.util.Objects) CompilationException(io.airlift.bytecode.CompilationException) PageProcessor(io.prestosql.operator.project.PageProcessor) List(java.util.List) PUBLIC(io.airlift.bytecode.Access.PUBLIC) RowExpression(io.prestosql.spi.relation.RowExpression) COMPILER_ERROR(io.prestosql.spi.StandardErrorCode.COMPILER_ERROR) Optional(java.util.Optional) VisibleForTesting(com.google.common.annotations.VisibleForTesting) CacheBuilder(com.google.common.cache.CacheBuilder) ClassDefinition(io.airlift.bytecode.ClassDefinition) CursorProcessor(io.prestosql.operator.project.CursorProcessor) MoreObjects.toStringHelper(com.google.common.base.MoreObjects.toStringHelper) PageProcessor(io.prestosql.operator.project.PageProcessor) Optional(java.util.Optional) Supplier(java.util.function.Supplier) ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) List(java.util.List)

Example 2 with PageFilter

use of io.prestosql.operator.project.PageFilter in project hetu-core by openlookeng.

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) {
        throw new PrestoException(COMPILER_ERROR, filter.toString(), e.getCause());
    }
    return () -> {
        try {
            return functionClass.getConstructor().newInstance();
        } catch (ReflectiveOperationException e) {
            throw new PrestoException(COMPILER_ERROR, e);
        }
    };
}
Also used : PageFieldsToInputParametersRewriter(io.prestosql.operator.project.PageFieldsToInputParametersRewriter) PageFilter(io.prestosql.operator.project.PageFilter) PrestoException(io.prestosql.spi.PrestoException) ClassDefinition(io.airlift.bytecode.ClassDefinition) PrestoException(io.prestosql.spi.PrestoException)

Aggregations

ClassDefinition (io.airlift.bytecode.ClassDefinition)2 PageFilter (io.prestosql.operator.project.PageFilter)2 PrestoException (io.prestosql.spi.PrestoException)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 MoreObjects.toStringHelper (com.google.common.base.MoreObjects.toStringHelper)1 CacheBuilder (com.google.common.cache.CacheBuilder)1 CacheLoader (com.google.common.cache.CacheLoader)1 LoadingCache (com.google.common.cache.LoadingCache)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 FINAL (io.airlift.bytecode.Access.FINAL)1 PUBLIC (io.airlift.bytecode.Access.PUBLIC)1 Access.a (io.airlift.bytecode.Access.a)1 CompilationException (io.airlift.bytecode.CompilationException)1 ParameterizedType.type (io.airlift.bytecode.ParameterizedType.type)1 Metadata (io.prestosql.metadata.Metadata)1 CursorProcessor (io.prestosql.operator.project.CursorProcessor)1 PageFieldsToInputParametersRewriter (io.prestosql.operator.project.PageFieldsToInputParametersRewriter)1 PageProcessor (io.prestosql.operator.project.PageProcessor)1 PageProjection (io.prestosql.operator.project.PageProjection)1