@Override public Map<PlanNodeId, SplitSource> visitLimit(LimitNode node, Void context) { return node.getSource().accept(this, context); }
@Override public Void visitLimit(LimitNode node, Set<Symbol> boundSymbols) { PlanNode source = node.getSource(); source.accept(this, boundSymbols); // visit child return null; }
@Override public Expression visitLimit(LimitNode node, Void context) { return node.getSource().accept(this, context); }
@Override public Expression visitLimit(LimitNode node, Void context) { return node.getSource().accept(this, context); }
@Override public Void visitLimit(LimitNode node, Set<Symbol> boundSymbols) { PlanNode source = node.getSource(); source.accept(this, boundSymbols); // visit child return null; }
@Override public Map<PlanNodeId, SplitSource> visitLimit(LimitNode node, Void context) { return node.getSource().accept(this, context); }
@Override public Void visitLimit(LimitNode node, Void context) { printNode(node, format("Limit[%s]", node.getCount()), NODE_COLORS.get(NodeType.LIMIT)); return node.getSource().accept(this, context); }
@Override public Void visitLimit(LimitNode node, Void context) { printNode(node, format("Limit[%s]", node.getCount()), NODE_COLORS.get(NodeType.LIMIT)); return node.getSource().accept(this, context); }
@Override public Range<Long> visitLimit(LimitNode node, Void context) { Range<Long> sourceCardinalityRange = node.getSource().accept(this, null); long upper = node.getCount(); if (sourceCardinalityRange.hasUpperBound()) { upper = min(sourceCardinalityRange.upperEndpoint(), node.getCount()); } long lower = min(upper, sourceCardinalityRange.lowerEndpoint()); return Range.closed(lower, upper); } }
@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(), node.isPartial()); }
@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(), node.isPartial()); }
@Override public Range<Long> visitLimit(LimitNode node, Void context) { Range<Long> sourceCardinalityRange = node.getSource().accept(this, null); long upper = node.getCount(); if (sourceCardinalityRange.hasUpperBound()) { upper = min(sourceCardinalityRange.upperEndpoint(), node.getCount()); } long lower = min(upper, sourceCardinalityRange.lowerEndpoint()); return Range.closed(lower, upper); } }
@Override protected Optional<PlanNodeStatsEstimate> doCalculate(LimitNode node, StatsProvider statsProvider, Lookup lookup, Session session, TypeProvider types) { PlanNodeStatsEstimate sourceStats = statsProvider.getStats(node.getSource()); if (sourceStats.getOutputRowCount() <= node.getCount()) { return Optional.of(sourceStats); } // LIMIT actually limits (or when there was no row count estimated for source) return Optional.of(PlanNodeStatsEstimate.buildFrom(sourceStats) .setOutputRowCount(node.getCount()) .build()); } }
@Override protected Optional<PlanNodeStatsEstimate> doCalculate(LimitNode node, StatsProvider statsProvider, Lookup lookup, Session session, TypeProvider types) { PlanNodeStatsEstimate sourceStats = statsProvider.getStats(node.getSource()); if (sourceStats.getOutputRowCount() <= node.getCount()) { return Optional.of(sourceStats); } // LIMIT actually limits (or when there was no row count estimated for source) return Optional.of(PlanNodeStatsEstimate.buildFrom(sourceStats) .setOutputRowCount(node.getCount()) .build()); } }
@Override public Result apply(LimitNode parent, Captures captures, Context context) { LimitNode child = captures.get(CHILD); return Result.ofPlanNode( new LimitNode( parent.getId(), child.getSource(), Math.min(parent.getCount(), child.getCount()), parent.isPartial())); } }
@Override public Result apply(LimitNode parent, Captures captures, Context context) { LimitNode child = captures.get(CHILD); return Result.ofPlanNode( new LimitNode( parent.getId(), child.getSource(), Math.min(parent.getCount(), child.getCount()), parent.isPartial())); } }
@Override public PlanNode visitLimit(LimitNode node, RewriteContext<LimitContext> context) { long count = node.getCount(); if (context.get() != null) { count = Math.min(count, context.get().getCount()); } // return empty ValuesNode in case of limit 0 if (count == 0) { return new ValuesNode(idAllocator.getNextId(), node.getOutputSymbols(), ImmutableList.of()); } // default visitPlan logic will insert the limit node return context.rewrite(node.getSource(), new LimitContext(count, false)); }
@Override public PlanNode visitLimit(LimitNode node, RewriteContext<LimitContext> context) { long count = node.getCount(); if (context.get() != null) { count = Math.min(count, context.get().getCount()); } // return empty ValuesNode in case of limit 0 if (count == 0) { return new ValuesNode(idAllocator.getNextId(), node.getOutputSymbols(), ImmutableList.of()); } // default visitPlan logic will insert the limit node return context.rewrite(node.getSource(), new LimitContext(count, false)); }
@Override public PhysicalOperation visitLimit(LimitNode node, LocalExecutionPlanContext context) { PhysicalOperation source = node.getSource().accept(this, context); OperatorFactory operatorFactory = new LimitOperatorFactory(context.getNextOperatorId(), node.getId(), node.getCount()); return new PhysicalOperation(operatorFactory, source.getLayout(), context, source); }
@Override public PhysicalOperation visitLimit(LimitNode node, LocalExecutionPlanContext context) { PhysicalOperation source = node.getSource().accept(this, context); OperatorFactory operatorFactory = new LimitOperatorFactory(context.getNextOperatorId(), node.getId(), node.getCount()); return new PhysicalOperation(operatorFactory, source.getLayout(), context, source); }