use of com.facebook.presto.sql.planner.plan.LimitNode in project presto by prestodb.
the class MergeLimitWithDistinct method apply.
@Override
public Optional<PlanNode> apply(PlanNode node, Lookup lookup, PlanNodeIdAllocator idAllocator, SymbolAllocator symbolAllocator) {
if (!(node instanceof LimitNode)) {
return Optional.empty();
}
LimitNode parent = (LimitNode) node;
PlanNode input = lookup.resolve(parent.getSource());
if (!(input instanceof AggregationNode)) {
return Optional.empty();
}
AggregationNode child = (AggregationNode) input;
if (isDistinct(child)) {
return Optional.empty();
}
return Optional.of(new DistinctLimitNode(parent.getId(), child.getSource(), parent.getCount(), false, child.getHashSymbol()));
}
use of com.facebook.presto.sql.planner.plan.LimitNode in project presto by prestodb.
the class MergeLimitWithSort method apply.
@Override
public Optional<PlanNode> apply(PlanNode node, Lookup lookup, PlanNodeIdAllocator idAllocator, SymbolAllocator symbolAllocator) {
if (!(node instanceof LimitNode)) {
return Optional.empty();
}
LimitNode parent = (LimitNode) node;
PlanNode source = lookup.resolve(parent.getSource());
if (!(source instanceof SortNode)) {
return Optional.empty();
}
SortNode child = (SortNode) source;
return Optional.of(new TopNNode(parent.getId(), child.getSource(), parent.getCount(), child.getOrderBy(), child.getOrderings(), parent.isPartial()));
}
use of com.facebook.presto.sql.planner.plan.LimitNode in project presto by prestodb.
the class MergeLimitWithTopN method apply.
@Override
public Optional<PlanNode> apply(PlanNode node, Lookup lookup, PlanNodeIdAllocator idAllocator, SymbolAllocator symbolAllocator) {
if (!(node instanceof LimitNode)) {
return Optional.empty();
}
LimitNode parent = (LimitNode) node;
PlanNode source = lookup.resolve(parent.getSource());
if (!(source instanceof TopNNode)) {
return Optional.empty();
}
TopNNode child = (TopNNode) source;
return Optional.of(new TopNNode(parent.getId(), child.getSource(), Math.min(parent.getCount(), child.getCount()), child.getOrderBy(), child.getOrderings(), parent.isPartial()));
}
use of com.facebook.presto.sql.planner.plan.LimitNode in project presto by prestodb.
the class MergeLimits method apply.
@Override
public Optional<PlanNode> apply(PlanNode node, Lookup lookup, PlanNodeIdAllocator idAllocator, SymbolAllocator symbolAllocator) {
if (!(node instanceof LimitNode)) {
return Optional.empty();
}
LimitNode parent = (LimitNode) node;
PlanNode source = lookup.resolve(parent.getSource());
if (!(source instanceof LimitNode)) {
return Optional.empty();
}
LimitNode child = (LimitNode) source;
return Optional.of(new LimitNode(parent.getId(), child.getSource(), Math.min(parent.getCount(), child.getCount()), parent.isPartial()));
}
Aggregations