Java 类com.facebook.presto.sql.tree.DefaultTraversalVisitor 实例源码

项目:presto    文件:FunctionAssertions.java   
private static boolean needsBoundValue(Expression projectionExpression)
{
    final AtomicBoolean hasQualifiedNameReference = new AtomicBoolean();
    new DefaultTraversalVisitor<Void, Void>()
    {
        @Override
        protected Void visitQualifiedNameReference(QualifiedNameReference node, Void context)
        {
            hasQualifiedNameReference.set(true);
            return null;
        }
    }.process(projectionExpression, null);

    return hasQualifiedNameReference.get();
}
项目:presto    文件:TreeAssertions.java   
private static List<Node> linearizeTree(Node tree)
{
    ImmutableList.Builder<Node> nodes = ImmutableList.builder();
    new DefaultTraversalVisitor<Node, Void>()
    {
        @Override
        public Node process(Node node, @Nullable Void context)
        {
            Node result = super.process(node, context);
            nodes.add(node);
            return result;
        }
    }.process(tree, null);
    return nodes.build();
}
项目:rakam    文件:ExpressionCompiler.java   
private FilterContext analyze(Expression filterExpression, List<Map.Entry<String, Type>> columns) {
//        filterExpression = rewriteQualifiedNamesToSymbolReferences(filterExpression);
        // TODO
        List<Expression> projectionExpressions = new ArrayList<>();
        Map<Symbol, Integer> sourceLayout = new HashMap<>();
        Map<Integer, Type> sourceTypes = new HashMap<>();
        int[] projectionProxies = new int[columns.size()];
        new DefaultTraversalVisitor<Void, Void>() {
            @Override
            protected Void visitSymbolReference(SymbolReference node, Void context) {
                projectionExpressions.add(node);
                int idx = sourceLayout.size();
                sourceLayout.put(new Symbol(node.getName().toString()), idx);

                int index = 0;
                for (int i = 0; i < columns.size(); i++) {
                    Map.Entry<String, Type> entry = columns.get(i);
                    if (entry.getKey().equals(node.getName())) {
                        sourceTypes.put(index++, entry.getValue());
                        projectionProxies[idx] = i;
                        break;
                    }
                }

                return null;
            }
        }.process(filterExpression, null);

        // compiler uses inputs instead of symbols, so rewrite the expressions first
//        SymbolToInputRewriter symbolToInputRewriter = new SymbolToInputRewriter(sourceLayout);
//        Expression rewrittenFilter = ExpressionTreeRewriter.rewriteWith(symbolToInputRewriter, filterExpression);

//        List<Expression> rewrittenProjections = new ArrayList<>();
//        for (Expression projection : projectionExpressions) {
//            rewrittenProjections.add(ExpressionTreeRewriter.rewriteWith(symbolToInputRewriter, projection));
//        }

//        IdentityHashMap<Expression, Type> expressionTypes = getExpressionTypesFromInput(
//                session,
//                metadata,
//                sqlParser,
//                sourceTypes,
//                concat(singleton(rewrittenFilter), rewrittenProjections),
//                ImmutableList.of());

        FunctionRegistry functionRegistry = new FunctionRegistry(typeManager, serde, featuresConfig);
//        RowExpression filter = SqlToRowExpressionTranslator.translate(
//                rewrittenFilter, FunctionKind.SCALAR, expressionTypes, functionRegistry, typeManager, session, true);
//        filter = expressionOptimizer.optimize(filter);

//        return new FilterContext(sourceTypes, projectionProxies, compileRowExpression(filter));
        return null;
    }