@Override public PlanNode visitLimit(LimitNode node, RewriteContext<Set<Symbol>> context) { ImmutableSet.Builder<Symbol> expectedInputs = ImmutableSet.<Symbol>builder().addAll(context.get()); PlanNode source = context.rewrite(node.getSource(), expectedInputs.build()); return new LimitNode(node.getId(), source, node.getCount()); }
@Override public SubPlanBuilder visitLimit(LimitNode node, Void context) { SubPlanBuilder current = node.getSource().accept(this, context); current.setRoot( new LimitNode(node.getId(), current.getRoot(), node.getCount(), node.getSampleWeight())); if (current.isDistributed()) { current.setRoot( new SinkNode( idAllocator.getNextId(), current.getRoot(), current.getRoot().getOutputSymbols())); // create merge plan fragment PlanNode source = new ExchangeNode( idAllocator.getNextId(), current.getId(), current.getRoot().getOutputSymbols()); LimitNode merge = new LimitNode(idAllocator.getNextId(), source, node.getCount(), node.getSampleWeight()); current = createSingleNodePlan(merge).addChild(current.build()); } return current; }