@Override public Boolean visitLambda(LambdaDefinitionExpression lambda, Void context) { return lambda.getBody().accept(this, context); }
@Override public Void visitCall(CallExpression call, Void context) { builder.add(call); for (RowExpression argument : call.getArguments()) { argument.accept(this, context); } return null; }
@Override public Void visitLambda(LambdaDefinitionExpression lambda, Void context) { builder.add(lambda); lambda.getBody().accept(this, context); return null; }
private static RowExpression changeType(RowExpression value, Type targetType) { ChangeTypeVisitor visitor = new ChangeTypeVisitor(targetType); return value.accept(visitor, null); }
@Override public Void visitCall(CallExpression call, Context context) { for (RowExpression rowExpression : call.getArguments()) { rowExpression.accept(this, context); } return null; }
public RowExpression optimize(RowExpression expression) { return expression.accept(new Visitor(), null); }
public boolean isDeterministic(RowExpression expression) { return expression.accept(new Visitor(registry), null); }
expression.accept(new RowExpressionVisitor<Void, Void>()
@Override public Void visitLambda(LambdaDefinitionExpression lambda, Context context) { lambda.getBody().accept(this, new Context(true)); lambdaExpressions.add(lambda); return null; }
public boolean areExpressionsEquivalent(Session session, Expression leftExpression, Expression rightExpression, TypeProvider types) { Map<Symbol, Integer> symbolInput = new HashMap<>(); Map<Integer, Type> inputTypes = new HashMap<>(); int inputId = 0; for (Entry<Symbol, Type> entry : types.allTypes().entrySet()) { symbolInput.put(entry.getKey(), inputId); inputTypes.put(inputId, entry.getValue()); inputId++; } RowExpression leftRowExpression = toRowExpression(session, leftExpression, symbolInput, inputTypes); RowExpression rightRowExpression = toRowExpression(session, rightExpression, symbolInput, inputTypes); RowExpression canonicalizedLeft = leftRowExpression.accept(CANONICALIZATION_VISITOR, null); RowExpression canonicalizedRight = rightRowExpression.accept(CANONICALIZATION_VISITOR, null); return canonicalizedLeft.equals(canonicalizedRight); }
public static List<LambdaDefinitionExpression> extractLambdaExpressions(RowExpression expression) { Visitor visitor = new Visitor(); expression.accept(visitor, new Context(false)); return visitor.getLambdaExpressionsPostOrder(); }
public BytecodeNode compile(RowExpression rowExpression, Scope scope, Optional<Variable> outputBlockVariable, Optional<Class> lambdaInterface) { return rowExpression.accept(new Visitor(), new Context(scope, outputBlockVariable, lambdaInterface)); }
@Override public RowExpression visitCall(CallExpression call, Void context) { return new CallExpression( call.getSignature(), call.getType(), call.getArguments().stream() .map(expression -> expression.accept(this, context)) .collect(toImmutableList())); }
@Override public Boolean visitCall(CallExpression call, Void context) { Signature signature = call.getSignature(); if (registry.isRegistered(signature) && !registry.getScalarFunctionImplementation(signature).isDeterministic()) { return false; } return call.getArguments().stream() .allMatch(expression -> expression.accept(this, context)); }
@Override public RowExpression visitLambda(LambdaDefinitionExpression lambda, Void context) { return new LambdaDefinitionExpression(lambda.getArgumentTypes(), lambda.getArguments(), lambda.getBody().accept(this, context)); }
public static Result rewritePageFieldsToInputParameters(RowExpression expression) { Visitor visitor = new Visitor(); RowExpression rewrittenProjection = expression.accept(visitor, null); InputChannels inputChannels = new InputChannels(visitor.getInputChannels()); return new Result(rewrittenProjection, inputChannels); }
@Override public RowExpression visitLambda(LambdaDefinitionExpression lambda, Void context) { return new LambdaDefinitionExpression( lambda.getArgumentTypes(), lambda.getArguments(), lambda.getBody().accept(this, context)); }
@Override public RowExpression visitLambda(LambdaDefinitionExpression lambda, Void context) { return new LambdaDefinitionExpression(lambda.getArgumentTypes(), lambda.getArguments(), lambda.getBody().accept(this, context)); }
RowExpression optimizedOperand = call.getArguments().get(0).accept(this, context); if (optimizedOperand instanceof ConstantExpression) { ConstantExpression constantOperand = (ConstantExpression) optimizedOperand; checkState(constantOperand.getType().equals(BOOLEAN), "Operand of IF function should be BOOLEAN type. Get type " + constantOperand.getType().getDisplayName()); if (Boolean.TRUE.equals(constantOperand.getValue())) { return call.getArguments().get(1).accept(this, context); return call.getArguments().get(2).accept(this, context); .map(argument -> argument.accept(this, null)) .collect(toImmutableList()); return call(signature, call.getType(), arguments); ImmutableList.Builder<RowExpression> optimizedArgumentsBuilder = ImmutableList.builder(); for (RowExpression argument : call.getArguments()) { RowExpression optimizedArgument = argument.accept(this, context); if (!(optimizedArgument instanceof ConstantExpression)) { allConstantExpression = false; case ROW_CONSTRUCTOR: { List<RowExpression> arguments = call.getArguments().stream() .map(argument -> argument.accept(this, null)) .collect(toImmutableList()); return call(signature, call.getType(), arguments); .map(argument -> argument.accept(this, context)) .collect(toImmutableList());
call.getType(), call.getArguments().stream() .map(expression -> expression.accept(this, context)) .collect(toImmutableList()));