use of com.facebook.presto.bytecode.MethodDefinition 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();
}
use of com.facebook.presto.bytecode.MethodDefinition 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();
}
use of com.facebook.presto.bytecode.MethodDefinition in project presto by prestodb.
the class AccumulatorCompiler method generateGetIntermediateType.
private static MethodDefinition generateGetIntermediateType(ClassDefinition definition, CallSiteBinder callSiteBinder, Type type) {
MethodDefinition methodDefinition = definition.declareMethod(a(PUBLIC), "getIntermediateType", type(Type.class));
methodDefinition.getBody().append(constantType(callSiteBinder, type)).retObject();
return methodDefinition;
}
use of com.facebook.presto.bytecode.MethodDefinition in project presto by prestodb.
the class AccumulatorCompiler method generateConstructor.
private static void generateConstructor(ClassDefinition definition, FieldDefinition stateSerializerField, FieldDefinition stateFactoryField, FieldDefinition inputChannelsField, FieldDefinition maskChannelField, FieldDefinition stateField, boolean grouped) {
Parameter stateSerializer = arg("stateSerializer", AccumulatorStateSerializer.class);
Parameter stateFactory = arg("stateFactory", AccumulatorStateFactory.class);
Parameter inputChannels = arg("inputChannels", type(List.class, Integer.class));
Parameter maskChannel = arg("maskChannel", type(Optional.class, Integer.class));
MethodDefinition method = definition.declareConstructor(a(PUBLIC), stateSerializer, stateFactory, inputChannels, maskChannel);
BytecodeBlock body = method.getBody();
Variable thisVariable = method.getThis();
body.comment("super();").append(thisVariable).invokeConstructor(Object.class);
body.append(thisVariable.setField(stateSerializerField, generateRequireNotNull(stateSerializer)));
body.append(thisVariable.setField(stateFactoryField, generateRequireNotNull(stateFactory)));
body.append(thisVariable.setField(inputChannelsField, generateRequireNotNull(inputChannels)));
body.append(thisVariable.setField(maskChannelField, generateRequireNotNull(maskChannel)));
String createState;
if (grouped) {
createState = "createGroupedState";
} else {
createState = "createSingleState";
}
body.append(thisVariable.setField(stateField, stateFactory.invoke(createState, Object.class).cast(stateField.getType())));
body.ret();
}
use of com.facebook.presto.bytecode.MethodDefinition in project presto by prestodb.
the class AccumulatorCompiler method generateGetEstimatedSize.
private static void generateGetEstimatedSize(ClassDefinition definition, FieldDefinition stateField) {
MethodDefinition method = definition.declareMethod(a(PUBLIC), "getEstimatedSize", type(long.class));
BytecodeExpression state = method.getThis().getField(stateField);
method.getBody().append(state.invoke("getEstimatedSize", long.class).ret());
}
Aggregations