presto-main/src/main/java/io/prestosql/operator/DistinctLimitOperator.java/DistinctLimitOperator/getOutput
class DistinctLimitOperator:    @Override
    public Page getOutput()
    {
        if (unfinishedWork != null && !processUnfinishedWork()) {
            return null;
        }

        if (groupByIds == null) {
            return null;
        }

        verifyNotNull(inputPage);
        int distinctCount = 0;
        int[] distinctPositions = new int[inputPage.getPositionCount()];
        for (int position = 0; position < groupByIds.getPositionCount(); position++) {
            if (groupByIds.getGroupId(position) == nextDistinctId) {
                distinctPositions[distinctCount] = position;
                distinctCount++;

                remainingLimit--;
                nextDistinctId++;
                if (remainingLimit == 0) {
                    break;
                }
            }
        }
        Page result = maskToDistinctOutputPositions(distinctCount, distinctPositions);

        groupByIds = null;
        inputPage = null;

        updateMemoryReservation();
        return result;
    }