public void postOrder(LogicalNodeVisitor visitor) { child.postOrder(visitor); visitor.visit(this); } }
public void postOrder(LogicalNodeVisitor visitor) { child.postOrder(visitor); visitor.visit(this); } }
@Override public void postOrder(LogicalNodeVisitor visitor) { visitor.visit(this); getChild().postOrder(visitor); }
/** * Find the all logical node matched to type from the given node * * @param node start node * @param type to find * @return a found logical node */ public static LogicalNode[] findAllNodes(LogicalNode node, NodeType... type) { Preconditions.checkNotNull(node); Preconditions.checkNotNull(type); LogicalNodeFinder finder = new LogicalNodeFinder(type); node.postOrder(finder); if (finder.getFoundNodes().size() == 0) { return new LogicalNode[]{}; } List<LogicalNode> founds = finder.getFoundNodes(); return founds.toArray(new LogicalNode[founds.size()]); }
@Override public void postOrder(LogicalNodeVisitor visitor) { visitor.visit(this); getChild().postOrder(visitor); }
/** * Find the all logical node matched to type from the given node * * @param node start node * @param type to find * @return a found logical node */ public static LogicalNode[] findAllNodes(LogicalNode node, NodeType... type) { Preconditions.checkNotNull(node); Preconditions.checkNotNull(type); LogicalNodeFinder finder = new LogicalNodeFinder(type); node.postOrder(finder); if (finder.getFoundNodes().size() == 0) { return new LogicalNode[]{}; } List<LogicalNode> founds = finder.getFoundNodes(); return founds.toArray(new LogicalNode[founds.size()]); }
@Test public final void testVisitor() throws TajoException { QueryContext qc = createQueryContext(); // two relations Expr expr = sqlAnalyzer.parse(QUERIES[1]); LogicalNode plan = planner.createPlan(qc, expr).getRootBlock().getRoot(); TestVisitor vis = new TestVisitor(); plan.postOrder(vis); assertEquals(NodeType.ROOT, vis.stack.pop().getType()); assertEquals(NodeType.PROJECTION, vis.stack.pop().getType()); assertEquals(NodeType.JOIN, vis.stack.pop().getType()); assertEquals(NodeType.SCAN, vis.stack.pop().getType()); assertEquals(NodeType.SCAN, vis.stack.pop().getType()); }