@Override
 public Row next() {
   PeekingRowIterator nextIter = queue.remove();
   Row next = nextIter.next();
   if (nextIter.hasNext()) {
     queue.add(nextIter);
   } else {
     leastExhausted = true;
   }
   return next;
 }
 public RowMergingIterator merge(List<Iterator<Row>> iterators) {
   for (Iterator<Row> rowIterator : iterators) {
     if (rowIterator.hasNext()) {
       queue.add(peekingIterator(rowIterator));
     }
   }
   leastExhausted = false;
   return this;
 }
    public RowMergingIterator(
        Iterable<? extends Iterator<? extends Row>> iterators,
        final Comparator<? super Row> itemComparator) {
      Comparator<PeekingRowIterator> heapComparator =
          new Comparator<PeekingRowIterator>() {
            @Override
            public int compare(PeekingRowIterator o1, PeekingRowIterator o2) {
              return itemComparator.compare(o1.peek(), o2.peek());
            }
          };
      queue = new PriorityQueue<>(2, heapComparator);

      for (Iterator<? extends Row> iterator : iterators) {
        if (iterator.hasNext()) {
          queue.add(peekingIterator(iterator));
        }
      }
    }
 @Override
 public boolean hasNext() {
   return !queue.isEmpty();
 }