Exemplo n.º 1
0
 @Override
 public Row next() {
   PeekingRowIterator nextIter = queue.remove();
   Row next = nextIter.next();
   if (nextIter.hasNext()) {
     queue.add(nextIter);
   } else {
     leastExhausted = true;
   }
   return next;
 }
Exemplo n.º 2
0
 public RowMergingIterator merge(List<Iterator<Row>> iterators) {
   for (Iterator<Row> rowIterator : iterators) {
     if (rowIterator.hasNext()) {
       queue.add(peekingIterator(rowIterator));
     }
   }
   leastExhausted = false;
   return this;
 }
Exemplo n.º 3
0
    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));
        }
      }
    }
Exemplo n.º 4
0
 @Override
 public boolean hasNext() {
   return !queue.isEmpty();
 }