presto-main/src/main/java/io/prestosql/sql/planner/iterative/rule/MergeLimitWithSort.java/MergeLimitWithSort/apply
class MergeLimitWithSort:    @Override
    public Result apply(LimitNode parent, Captures captures, Context context)
    {
        SortNode child = captures.get(CHILD);

        return Result.ofPlanNode(
                new TopNNode(
                        parent.getId(),
                        child.getSource(),
                        parent.getCount(),
                        child.getOrderingScheme(),
                        parent.isPartial() ? TopNNode.Step.PARTIAL : TopNNode.Step.SINGLE));
    }