public R visit(FunctionExpression functionExpression) { @SuppressWarnings("unchecked") final List<Node> parameterList = functionExpression.parameterList; R r0 = Expressions.acceptNodes(parameterList, this); return functionExpression.body.accept(this); }
BlockStatement(List<Statement> statements, Type type) { super(ExpressionType.Block, type); assert statements != null : "statements should not be null"; this.statements = statements; assert distinctVariables(true); }
public MemberDeclaration visit(MethodDeclaration methodDeclaration, BlockStatement body) { return body.equals(methodDeclaration.body) ? methodDeclaration : Expressions.methodDecl(methodDeclaration.modifier, methodDeclaration.resultType, methodDeclaration.name, methodDeclaration.parameters, body); }
private static <P0, R> Type functionResultType( FunctionExpression<Function1<P0, R>> selector) { return selector.body.getType(); }
@Override public Void visitProject(Project project, List<Void> inputStreams) throws Exception { beginStage(project); List<RexNode> childExps = project.getChildExps(); RelDataType inputRowType = project.getInput(0).getRowType(); int outputCount = project.getRowType().getFieldCount(); pw.print("Context context = new StreamlineContext(Processor.dataContext);\n"); pw.print("context.values = _data.toArray();\n"); pw.print(String.format("Object[] outputValues = new Object[%d];\n", outputCount)); pw.write(rexCompiler.compileToBlock(childExps, inputRowType).toString()); pw.print(" ctx.emit(new CorrelatedValues(_data.getCorrelated(), outputValues));\n"); endStage(); return null; }
/** * Creates a BlockExpression that contains the given expressions, * has no variables and has specific result type. */ public static BlockStatement block(Type type, Iterable<? extends Statement> expressions) { List<Statement> list = toList(expressions); if (type == null) { if (list.size() > 0) { type = list.get(list.size() - 1).getType(); } else { type = Void.TYPE; } } return new BlockStatement(list, type); }
/** * Creates a LambdaExpression by first constructing a delegate * type. */ public static <F extends Function<?>> FunctionExpression<F> lambda( BlockStatement body, Iterable<? extends ParameterExpression> parameters) { final List<ParameterExpression> parameterList = toList(parameters); @SuppressWarnings("unchecked") Class<F> type = deduceType(parameterList, body.getType()); return new FunctionExpression<>(type, body, parameterList); }
@Override public Void visitFilter(Filter filter, List<Void> inputStreams) throws Exception { beginStage(filter); List<RexNode> childExps = filter.getChildExps(); RelDataType inputRowType = filter.getInput(0).getRowType(); pw.print("Context context = new StreamlineContext(Processor.dataContext);\n"); pw.print("context.values = _data.toArray();\n"); pw.print("Object[] outputValues = new Object[1];\n"); pw.write(rexCompiler.compileToBlock(childExps, inputRowType).toString()); String r = "((Boolean) outputValues[0])"; if (filter.getCondition().getType().isNullable()) { pw.print(String.format(" if (%s != null && %s) { ctx.emit(_data); }\n", r, r)); } else { pw.print(String.format(" if (%s) { ctx.emit(_data); }\n", r, r)); } endStage(); return null; }
public R visit(ConstructorDeclaration constructorDeclaration) { R r0 = Expressions.acceptNodes(constructorDeclaration.parameters, this); return constructorDeclaration.body.accept(this); }
public Expression visit(FunctionExpression functionExpression, BlockStatement body) { return functionExpression.body.equals(body) ? functionExpression : Expressions.lambda(body, functionExpression.parameterList); }
public R visit(MethodDeclaration methodDeclaration) { R r0 = Expressions.acceptNodes(methodDeclaration.parameters, this); return methodDeclaration.body.accept(this); }
public MemberDeclaration visit(ConstructorDeclaration constructorDeclaration, BlockStatement body) { return body.equals(constructorDeclaration.body) ? constructorDeclaration : Expressions.constructorDecl(constructorDeclaration.modifier, constructorDeclaration.resultType, constructorDeclaration.parameters, body); } }
public void go(EnumerableRel.Result result) { final Set<Type> types = new LinkedHashSet<>(); result.block.accept(new TypeFinder(types)); types.add(result.physType.getJavaRowType()); for (Type type : types) { register(type); } } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ConstructorDeclaration that = (ConstructorDeclaration) o; if (modifier != that.modifier) { return false; } if (!body.equals(that.body)) { return false; } if (!parameters.equals(that.parameters)) { return false; } if (!resultType.equals(that.resultType)) { return false; } return true; }
@Override public MemberDeclaration accept(Shuttle shuttle) { shuttle = shuttle.preVisit(this); // do not visit parameters final BlockStatement body = this.body.accept(shuttle); return shuttle.visit(this, body); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } MethodDeclaration that = (MethodDeclaration) o; if (modifier != that.modifier) { return false; } if (!body.equals(that.body)) { return false; } if (!name.equals(that.name)) { return false; } if (!parameters.equals(that.parameters)) { return false; } if (!resultType.equals(that.resultType)) { return false; } return true; }
public void go(EnumerableRel.Result result) { final Set<Type> types = new LinkedHashSet<>(); result.block.accept(new TypeFinder(types)); types.add(result.physType.getJavaRowType()); for (Type type : types) { register(type); } } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } FunctionExpression that = (FunctionExpression) o; if (body != null ? !body.equals(that.body) : that.body != null) { return false; } if (function != null ? !function.equals(that.function) : that.function != null) { return false; } if (!parameterList.equals(that.parameterList)) { return false; } return true; }
@Override public MemberDeclaration accept(Shuttle shuttle) { shuttle = shuttle.preVisit(this); // do not visit parameters final BlockStatement body = this.body.accept(shuttle); return shuttle.visit(this, body); }