Search in sources :

Example 6 with CompiledLambda

use of io.trino.sql.gen.LambdaBytecodeGenerator.CompiledLambda in project trino by trinodb.

the class JoinFilterFunctionCompiler method generateMethodsForLambda.

private Map<LambdaDefinitionExpression, CompiledLambda> generateMethodsForLambda(ClassDefinition containerClassDefinition, CallSiteBinder callSiteBinder, CachedInstanceBinder cachedInstanceBinder, RowExpression filter) {
    Set<LambdaDefinitionExpression> lambdaExpressions = ImmutableSet.copyOf(extractLambdaExpressions(filter));
    ImmutableMap.Builder<LambdaDefinitionExpression, CompiledLambda> compiledLambdaMap = ImmutableMap.builder();
    int counter = 0;
    for (LambdaDefinitionExpression lambdaExpression : lambdaExpressions) {
        CompiledLambda compiledLambda = LambdaBytecodeGenerator.preGenerateLambdaExpression(lambdaExpression, "lambda_" + counter, containerClassDefinition, compiledLambdaMap.buildOrThrow(), callSiteBinder, cachedInstanceBinder, functionManager);
        compiledLambdaMap.put(lambdaExpression, compiledLambda);
        counter++;
    }
    return compiledLambdaMap.buildOrThrow();
}
Also used : CompiledLambda(io.trino.sql.gen.LambdaBytecodeGenerator.CompiledLambda) ImmutableMap(com.google.common.collect.ImmutableMap) LambdaDefinitionExpression(io.trino.sql.relational.LambdaDefinitionExpression)

Example 7 with CompiledLambda

use of io.trino.sql.gen.LambdaBytecodeGenerator.CompiledLambda in project trino by trinodb.

the class JoinFilterFunctionCompiler method generateMethods.

private void generateMethods(ClassDefinition classDefinition, CallSiteBinder callSiteBinder, RowExpression filter, int leftBlocksSize) {
    CachedInstanceBinder cachedInstanceBinder = new CachedInstanceBinder(classDefinition, callSiteBinder);
    FieldDefinition sessionField = classDefinition.declareField(a(PRIVATE, FINAL), "session", ConnectorSession.class);
    Map<LambdaDefinitionExpression, CompiledLambda> compiledLambdaMap = generateMethodsForLambda(classDefinition, callSiteBinder, cachedInstanceBinder, filter);
    generateFilterMethod(classDefinition, callSiteBinder, cachedInstanceBinder, compiledLambdaMap, filter, leftBlocksSize, sessionField);
    generateConstructor(classDefinition, sessionField, cachedInstanceBinder);
}
Also used : CompiledLambda(io.trino.sql.gen.LambdaBytecodeGenerator.CompiledLambda) FieldDefinition(io.airlift.bytecode.FieldDefinition) LambdaDefinitionExpression(io.trino.sql.relational.LambdaDefinitionExpression)

Aggregations

CompiledLambda (io.trino.sql.gen.LambdaBytecodeGenerator.CompiledLambda)7 LambdaDefinitionExpression (io.trino.sql.relational.LambdaDefinitionExpression)7 ImmutableMap (com.google.common.collect.ImmutableMap)3 FieldDefinition (io.airlift.bytecode.FieldDefinition)3 Variable (io.airlift.bytecode.Variable)3 BytecodeBlock (io.airlift.bytecode.BytecodeBlock)2 ClassDefinition (io.airlift.bytecode.ClassDefinition)2 MethodDefinition (io.airlift.bytecode.MethodDefinition)2 Parameter (io.airlift.bytecode.Parameter)1 Work (io.trino.operator.Work)1 InputChannels (io.trino.operator.project.InputChannels)1 PageFilter (io.trino.operator.project.PageFilter)1