@Override public Boolean visitLimit(LimitNode node, Void context) { return node.getCount() <= 1; }
@Override public Boolean visitLimit(LimitNode node, Void context) { return node.getCount() <= 1; }
@Override public boolean shapeMatches(PlanNode node) { if (!(node instanceof LimitNode)) { return false; } LimitNode limitNode = (LimitNode) node; return limitNode.getCount() == limit; }
@Override public boolean shapeMatches(PlanNode node) { if (!(node instanceof LimitNode)) { return false; } LimitNode limitNode = (LimitNode) node; return limitNode.getCount() == limit; }
@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 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 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 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 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 Result apply(LimitNode parent, Captures captures, Context context) { TopNNode child = captures.get(CHILD); return Result.ofPlanNode( new TopNNode( parent.getId(), child.getSource(), Math.min(parent.getCount(), child.getCount()), child.getOrderingScheme(), parent.isPartial() ? TopNNode.Step.PARTIAL : TopNNode.Step.SINGLE)); } }
@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); }
@Override public Void visitLimit(LimitNode node, Integer indent) { print(indent, "- Limit%s[%s] => [%s]", node.isPartial() ? "Partial" : "", node.getCount(), formatOutputs(node.getOutputSymbols())); printPlanNodesStatsAndCost(indent + 2, node); printStats(indent + 2, node.getId()); return processChildren(node, indent + 1); }
@Override public Void visitLimit(LimitNode node, Integer indent) { print(indent, "- Limit%s[%s] => [%s]", node.isPartial() ? "Partial" : "", node.getCount(), formatOutputs(node.getOutputSymbols())); printPlanNodesStatsAndCost(indent + 2, node); printStats(indent + 2, node.getId()); return processChildren(node, indent + 1); }
@Override public Result apply(LimitNode parent, Captures captures, Context context) { SortNode child = captures.get(CHILD); return Result.ofPlanNode( new TopNNode( parent.getId(), child.getSource(), parent.getCount(), child.getOrderingScheme(), parent.isPartial() ? TopNNode.Step.PARTIAL : TopNNode.Step.SINGLE)); } }