Search in sources :

Example 1 with InputPageProjection

use of com.facebook.presto.operator.project.InputPageProjection in project presto by prestodb.

the class PageFunctionCompiler method compileProjection.

private Supplier<PageProjection> compileProjection(SqlFunctionProperties sqlFunctionProperties, Map<SqlFunctionId, SqlInvokedFunction> sessionFunctions, RowExpression projection, Optional<String> classNameSuffix) {
    if (projection instanceof InputReferenceExpression) {
        InputReferenceExpression input = (InputReferenceExpression) projection;
        InputPageProjection projectionFunction = new InputPageProjection(input.getField());
        return () -> projectionFunction;
    }
    if (projection instanceof ConstantExpression) {
        ConstantExpression constant = (ConstantExpression) projection;
        ConstantPageProjection projectionFunction = new ConstantPageProjection(constant.getValue(), constant.getType());
        return () -> projectionFunction;
    }
    return compileProjectionCached(sqlFunctionProperties, sessionFunctions, ImmutableList.of(projection), false, classNameSuffix);
}
Also used : InputReferenceExpression(com.facebook.presto.spi.relation.InputReferenceExpression) InputPageProjection(com.facebook.presto.operator.project.InputPageProjection) ConstantPageProjection(com.facebook.presto.operator.project.ConstantPageProjection) ConstantExpression(com.facebook.presto.spi.relation.ConstantExpression)

Example 2 with InputPageProjection

use of com.facebook.presto.operator.project.InputPageProjection in project presto by prestodb.

the class AbstractOperatorBenchmark method createHashProjectOperator.

protected final OperatorFactory createHashProjectOperator(int operatorId, PlanNodeId planNodeId, List<Type> types) {
    ImmutableList.Builder<VariableReferenceExpression> variables = ImmutableList.builder();
    ImmutableMap.Builder<VariableReferenceExpression, Integer> variableToInputMapping = ImmutableMap.builder();
    ImmutableList.Builder<PageProjectionWithOutputs> projections = ImmutableList.builder();
    for (int channel = 0; channel < types.size(); channel++) {
        VariableReferenceExpression variable = new VariableReferenceExpression(Optional.empty(), "h" + channel, types.get(channel));
        variables.add(variable);
        variableToInputMapping.put(variable, channel);
        projections.add(new PageProjectionWithOutputs(new InputPageProjection(channel), new int[] { channel }));
    }
    Optional<RowExpression> hashExpression = HashGenerationOptimizer.getHashExpression(localQueryRunner.getMetadata().getFunctionAndTypeManager(), variables.build());
    verify(hashExpression.isPresent());
    RowExpression translatedHashExpression = translate(hashExpression.get(), variableToInputMapping.build());
    PageFunctionCompiler functionCompiler = new PageFunctionCompiler(localQueryRunner.getMetadata(), 0);
    projections.add(new PageProjectionWithOutputs(functionCompiler.compileProjection(session.getSqlFunctionProperties(), translatedHashExpression, Optional.empty()).get(), new int[] { types.size() }));
    return new FilterAndProjectOperator.FilterAndProjectOperatorFactory(operatorId, planNodeId, () -> new PageProcessor(Optional.empty(), projections.build()), ImmutableList.copyOf(Iterables.concat(types, ImmutableList.of(BIGINT))), getFilterAndProjectMinOutputPageSize(session), getFilterAndProjectMinOutputPageRowCount(session));
}
Also used : PageFunctionCompiler(com.facebook.presto.sql.gen.PageFunctionCompiler) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ImmutableList(com.google.common.collect.ImmutableList) RowExpression(com.facebook.presto.spi.relation.RowExpression) PageProjectionWithOutputs(com.facebook.presto.operator.project.PageProjectionWithOutputs) ImmutableMap(com.google.common.collect.ImmutableMap) InputPageProjection(com.facebook.presto.operator.project.InputPageProjection) PageProcessor(com.facebook.presto.operator.project.PageProcessor) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression)

Aggregations

InputPageProjection (com.facebook.presto.operator.project.InputPageProjection)2 ConstantPageProjection (com.facebook.presto.operator.project.ConstantPageProjection)1 PageProcessor (com.facebook.presto.operator.project.PageProcessor)1 PageProjectionWithOutputs (com.facebook.presto.operator.project.PageProjectionWithOutputs)1 ConstantExpression (com.facebook.presto.spi.relation.ConstantExpression)1 InputReferenceExpression (com.facebook.presto.spi.relation.InputReferenceExpression)1 RowExpression (com.facebook.presto.spi.relation.RowExpression)1 VariableReferenceExpression (com.facebook.presto.spi.relation.VariableReferenceExpression)1 PageFunctionCompiler (com.facebook.presto.sql.gen.PageFunctionCompiler)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1