use of org.apache.calcite.linq4j.tree.MethodDeclaration in project calcite by apache.
the class RexExecutorImpl method compile.
private String compile(RexBuilder rexBuilder, List<RexNode> constExps, RexToLixTranslator.InputGetter getter, RelDataType rowType) {
final RexProgramBuilder programBuilder = new RexProgramBuilder(rowType, rexBuilder);
for (RexNode node : constExps) {
programBuilder.addProject(node, "c" + programBuilder.getProjectList().size());
}
final JavaTypeFactoryImpl javaTypeFactory = new JavaTypeFactoryImpl(rexBuilder.getTypeFactory().getTypeSystem());
final BlockBuilder blockBuilder = new BlockBuilder();
final ParameterExpression root0_ = Expressions.parameter(Object.class, "root0");
final ParameterExpression root_ = DataContext.ROOT;
blockBuilder.add(Expressions.declare(Modifier.FINAL, root_, Expressions.convert_(root0_, DataContext.class)));
final List<Expression> expressions = RexToLixTranslator.translateProjects(programBuilder.getProgram(), javaTypeFactory, blockBuilder, null, root_, getter, null);
blockBuilder.add(Expressions.return_(null, Expressions.newArrayInit(Object[].class, expressions)));
final MethodDeclaration methodDecl = Expressions.methodDecl(Modifier.PUBLIC, Object[].class, BuiltInMethod.FUNCTION1_APPLY.method.getName(), ImmutableList.of(root0_), blockBuilder.toBlock());
String code = Expressions.toString(methodDecl);
if (CalcitePrepareImpl.DEBUG) {
Util.debugCode(System.out, code);
}
return code;
}
Aggregations