presto-main/src/main/java/io/prestosql/sql/planner/optimizations/QueryCardinalityUtil.java/CardinalityExtractorPlanVisitor/visitLimit
class CardinalityExtractorPlanVisitor:        @Override
        public Range<Long> visitLimit(LimitNode node, Void context)
        {
            if (node.isWithTies()) {
                Range<Long> sourceCardinalityRange = node.getSource().accept(this, null);
                long lower = min(node.getCount(), sourceCardinalityRange.lowerEndpoint());
                if (sourceCardinalityRange.hasUpperBound()) {
                    return Range.closed(lower, sourceCardinalityRange.upperEndpoint());
                }
                else {
                    return Range.atLeast(lower);
                }
            }

            return applyLimit(node.getSource(), node.getCount());
        }