Class MergeLimits

  • All Implemented Interfaces:
    Rule<LimitNode>

    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)