@Override public Result apply(LimitNode limit, Captures captures, Context context) { return Result.ofPlanNode(new ValuesNode(limit.getId(), limit.getOutputSymbols(), ImmutableList.of())); } }
@Override public Result apply(LimitNode limit, Captures captures, Context context) { return Result.ofPlanNode(new ValuesNode(limit.getId(), limit.getOutputSymbols(), ImmutableList.of())); } }
@Override public PlanNodeCostEstimate visitLimit(LimitNode node, Void context) { // This is just a wild guess. First of all, LimitNode is rather rare except as a top node of a query plan, // so proper cost estimation is not that important. Second, since LimitNode can lead to incomplete evaluation // of the source, true cost estimation should be implemented as a "constraint" enforced on a sub-tree and // evaluated in context of actual source node type (and their sources). return cpuCost(getStats(node).getOutputSizeInBytes(node.getOutputSymbols(), types)); }
@Override public PlanNodeCostEstimate visitLimit(LimitNode node, Void context) { // This is just a wild guess. First of all, LimitNode is rather rare except as a top node of a query plan, // so proper cost estimation is not that important. Second, since LimitNode can lead to incomplete evaluation // of the source, true cost estimation should be implemented as a "constraint" enforced on a sub-tree and // evaluated in context of actual source node type (and their sources). return cpuCost(getStats(node).getOutputSizeInBytes(node.getOutputSymbols(), types)); }
@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 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 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 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); }