code: public <T> Iterator<T> limit(final Iterator<T> iter) {
          return new AbstractIterator<T>() {
              @Override
              protected T computeNext() {
                  if (_remaining > 0 && iter.hasNext()) {
                      _remaining--;
                      return iter.next();
                  }
                  return endOfData();
              }
          };
      }
docs: Similar to {@link Iterators#limit(Iterator, int)} except that it updates this limit counter object so other
  code can track how many items are remaining before the limit is reached.  This is useful when the underlying
  iterator queries in batch because it can adjust its batch sizes to avoid going too far past the limit.