presto-hive/src/main/java/io/prestosql/plugin/hive/util/MergingPageIterator.java/MergingPageIterator/MergingPageIterator
class MergingPageIterator:    public MergingPageIterator(
            Collection<Iterator<Page>> iterators,
            List<Type> types,
            List<Integer> sortFields,
            List<SortOrder> sortOrders)
    {
        requireNonNull(sortFields, "sortFields is null");
        requireNonNull(sortOrders, "sortOrders is null");
        checkArgument(sortFields.size() == sortOrders.size(), "sortFields and sortOrders size must match");

        this.types = ImmutableList.copyOf(requireNonNull(types, "types is null"));
        this.sortFields = ImmutableList.copyOf(sortFields);
        this.sortOrders = ImmutableList.copyOf(sortOrders);
        this.pageBuilder = new PageBuilder(types);
        this.pagePositions = mergeSorted(
                iterators.stream()
                        .map(pages -> concat(transform(pages, PagePositionIterator::new)))
                        .collect(toList()),
                naturalOrder());
    }