Class MergeLimits
- java.lang.Object
-
- io.prestosql.sql.planner.iterative.rule.MergeLimits
-
public class MergeLimits extends Object implements Rule<LimitNode>
This rule handles both LimitNode with ties and LimitNode without ties. The parent LimitNode is without ties.If the child LimitNode is without ties, both nodes are merged into a single LimitNode with row count being the minimum of their row counts:
- Limit (3) - Limit (5)
is transformed into:- Limit (3)
If the child LimitNode is with ties, the rule's behavior depends on both nodes' row count. If parent row count is lower or equal to child row count, child node is removed from the plan:
- Limit (3) - Limit (5, withTies)
is transformed into:- Limit (3)
If parent row count is greater than child row count, both nodes remain in the plan, but they are rearranged in the way that the LimitNode with ties is the root:
- Limit (5) - Limit (3, withTies)
is transformed into:- Limit (3, withTies) - Limit (5)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.prestosql.sql.planner.iterative.Rule
Rule.Context, Rule.Result
-
-
Constructor Summary
Constructors Constructor Description MergeLimits()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Rule.Result
apply(LimitNode parent, Captures captures, Rule.Context context)
Pattern<LimitNode>
getPattern()
Returns a pattern to which plan nodes this rule applies.
-
-
-
Method Detail
-
getPattern
public Pattern<LimitNode> getPattern()
Description copied from interface:Rule
Returns a pattern to which plan nodes this rule applies.- Specified by:
getPattern
in interfaceRule<LimitNode>
-
apply
public Rule.Result apply(LimitNode parent, Captures captures, Rule.Context context)
-
-