Search in sources :

Example 86 with Variable

use of com.facebook.presto.bytecode.Variable in project presto by prestodb.

the class JoinProbeCompiler method generateGetCurrentJoinPosition.

private static void generateGetCurrentJoinPosition(ClassDefinition classDefinition, CallSiteBinder callSiteBinder, FieldDefinition lookupSourceField, FieldDefinition probePageField, FieldDefinition pageField, Optional<Integer> probeHashChannel, FieldDefinition probeHashBlockField, FieldDefinition positionField) {
    MethodDefinition method = classDefinition.declareMethod(a(PUBLIC), "getCurrentJoinPosition", type(long.class));
    Variable thisVariable = method.getThis();
    BytecodeBlock body = method.getBody().append(new IfStatement().condition(thisVariable.invoke("currentRowContainsNull", boolean.class)).ifTrue(constantLong(-1).ret()));
    BytecodeExpression position = thisVariable.getField(positionField);
    BytecodeExpression hashChannelsPage = thisVariable.getField(probePageField);
    BytecodeExpression allChannelsPage = thisVariable.getField(pageField);
    BytecodeExpression probeHashBlock = thisVariable.getField(probeHashBlockField);
    if (probeHashChannel.isPresent()) {
        body.append(thisVariable.getField(lookupSourceField).invoke("getJoinPosition", long.class, position, hashChannelsPage, allChannelsPage, constantType(callSiteBinder, BigintType.BIGINT).invoke("getLong", long.class, probeHashBlock, position))).retLong();
    } else {
        body.append(thisVariable.getField(lookupSourceField).invoke("getJoinPosition", long.class, position, hashChannelsPage, allChannelsPage)).retLong();
    }
}
Also used : IfStatement(com.facebook.presto.bytecode.control.IfStatement) Variable(com.facebook.presto.bytecode.Variable) MethodDefinition(com.facebook.presto.bytecode.MethodDefinition) BytecodeBlock(com.facebook.presto.bytecode.BytecodeBlock) BytecodeExpression(com.facebook.presto.bytecode.expression.BytecodeExpression)

Example 87 with Variable

use of com.facebook.presto.bytecode.Variable in project presto by prestodb.

the class JoinProbeCompiler method generateGetPage.

private static void generateGetPage(ClassDefinition classDefinition, FieldDefinition pageField) {
    // dummy implementation for now
    // compiled class is used only in usecase case when result of this method is ignored.
    MethodDefinition method = classDefinition.declareMethod(a(PUBLIC), "getPage", type(Page.class));
    Variable thisVariable = method.getThis();
    method.getBody().append(thisVariable.getField(pageField)).ret(Page.class);
}
Also used : Variable(com.facebook.presto.bytecode.Variable) MethodDefinition(com.facebook.presto.bytecode.MethodDefinition) Page(com.facebook.presto.spi.Page)

Example 88 with Variable

use of com.facebook.presto.bytecode.Variable in project presto by prestodb.

the class AccumulatorCompiler method generateSetGroupIdFromGroupIdsBlock.

private static void generateSetGroupIdFromGroupIdsBlock(Scope scope, FieldDefinition stateField, BytecodeBlock block) {
    Variable groupIdsBlock = scope.getVariable("groupIdsBlock");
    Variable position = scope.getVariable("position");
    BytecodeExpression state = scope.getThis().getField(stateField);
    block.append(state.invoke("setGroupId", void.class, groupIdsBlock.invoke("getGroupId", long.class, position)));
}
Also used : Variable(com.facebook.presto.bytecode.Variable) BytecodeExpression(com.facebook.presto.bytecode.expression.BytecodeExpression)

Example 89 with Variable

use of com.facebook.presto.bytecode.Variable in project presto by prestodb.

the class AccumulatorCompiler method generateEvaluateIntermediate.

private static void generateEvaluateIntermediate(ClassDefinition definition, FieldDefinition stateSerializerField, FieldDefinition stateField) {
    Parameter out = arg("out", BlockBuilder.class);
    MethodDefinition method = definition.declareMethod(a(PUBLIC), "evaluateIntermediate", type(void.class), out);
    Variable thisVariable = method.getThis();
    BytecodeExpression stateSerializer = thisVariable.getField(stateSerializerField);
    BytecodeExpression state = thisVariable.getField(stateField);
    method.getBody().append(stateSerializer.invoke("serialize", void.class, state.cast(Object.class), out)).ret();
}
Also used : Variable(com.facebook.presto.bytecode.Variable) MethodDefinition(com.facebook.presto.bytecode.MethodDefinition) Parameter(com.facebook.presto.bytecode.Parameter) BytecodeExpression(com.facebook.presto.bytecode.expression.BytecodeExpression)

Example 90 with Variable

use of com.facebook.presto.bytecode.Variable in project presto by prestodb.

the class AccumulatorCompiler method generateGroupedEvaluateIntermediate.

private static void generateGroupedEvaluateIntermediate(ClassDefinition definition, FieldDefinition stateSerializerField, FieldDefinition stateField) {
    Parameter groupId = arg("groupId", int.class);
    Parameter out = arg("out", BlockBuilder.class);
    MethodDefinition method = definition.declareMethod(a(PUBLIC), "evaluateIntermediate", type(void.class), groupId, out);
    Variable thisVariable = method.getThis();
    BytecodeExpression state = thisVariable.getField(stateField);
    BytecodeExpression stateSerializer = thisVariable.getField(stateSerializerField);
    method.getBody().append(state.invoke("setGroupId", void.class, groupId.cast(long.class))).append(stateSerializer.invoke("serialize", void.class, state.cast(Object.class), out)).ret();
}
Also used : Variable(com.facebook.presto.bytecode.Variable) MethodDefinition(com.facebook.presto.bytecode.MethodDefinition) Parameter(com.facebook.presto.bytecode.Parameter) BytecodeExpression(com.facebook.presto.bytecode.expression.BytecodeExpression)

Aggregations

Variable (com.facebook.presto.bytecode.Variable)131 BytecodeBlock (com.facebook.presto.bytecode.BytecodeBlock)104 MethodDefinition (com.facebook.presto.bytecode.MethodDefinition)91 Parameter (com.facebook.presto.bytecode.Parameter)75 Scope (com.facebook.presto.bytecode.Scope)68 IfStatement (com.facebook.presto.bytecode.control.IfStatement)68 BytecodeExpression (com.facebook.presto.bytecode.expression.BytecodeExpression)40 BytecodeNode (com.facebook.presto.bytecode.BytecodeNode)36 ImmutableList (com.google.common.collect.ImmutableList)30 LabelNode (com.facebook.presto.bytecode.instruction.LabelNode)28 ClassDefinition (com.facebook.presto.bytecode.ClassDefinition)21 ForLoop (com.facebook.presto.bytecode.control.ForLoop)21 Block (com.facebook.presto.spi.block.Block)19 Block (com.facebook.presto.common.block.Block)18 List (java.util.List)17 CallSiteBinder (com.facebook.presto.bytecode.CallSiteBinder)16 FieldDefinition (com.facebook.presto.bytecode.FieldDefinition)15 Type (com.facebook.presto.common.type.Type)15 RowExpression (com.facebook.presto.spi.relation.RowExpression)15 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)14