lucene/src/main/java/com/twitter/elephantbird/mapreduce/input/LuceneIndexCollectAllRecordReader.java
@Override
  protected Iterator<T> search(final IndexSearcher searcher, final Query query) throws IOException {
    // grow the bit set if needed
    docIds.set(searcher.getIndexReader().maxDoc());
    // clear it
    docIds.clear();
    searcher.search(query, new Collector() {
      private int docBase;

      @Override
      public void setScorer(Scorer scorer) {
      }

      @Override
      public boolean acceptsDocsOutOfOrder() {
        return true;
      }

      @Override
      public void collect(int doc) {
        docIds.set(doc + docBase);
      }

      public void setNextReader(AtomicReaderContext context) {
        this.docBase = context.docBase;
      }
    });

    return new AbstractIterator<T>() {
      private int doc = docIds.nextSetBit(0);

      @Override
      protected T computeNext() {
        ((Progressable)context).progress(); // casting to avoid Hadoop 2 incompatibility
        if (doc < 0) {
          return endOfData();
        }
        try {
          T ret = docToValue(searcher.doc(doc));
          doc = docIds.nextSetBit(doc + 1);
          return  ret;
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
    };
  }
@Override
  protected Iterator<T> search(final IndexSearcher searcher, final Query query) throws IOException {
    // grow the bit set if needed
    docIds.set(searcher.getIndexReader().maxDoc());
    // clear it
    docIds.clear();
    searcher.search(query, new Collector() {
      private int docBase;

      @Override
      public void setScorer(Scorer scorer) {
      }

      @Override
      public boolean acceptsDocsOutOfOrder() {
        return true;
      }

      @Override
      public void collect(int doc) {
        docIds.set(doc + docBase);
      }

      public void setNextReader(AtomicReaderContext context) {
        this.docBase = context.docBase;
      }
    });

    return new AbstractIterator<T>() {
      private int doc = docIds.nextSetBit(0);

      @Override
      protected T computeNext() {
        ((Progressable)context).progress(); // casting to avoid Hadoop 2 incompatibility
        if (doc < 0) {
          return endOfData();
        }
        try {
          T ret = docToValue(searcher.doc(doc));
          doc = docIds.nextSetBit(doc + 1);
          return  ret;
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
    };
  }
Applies {@link #docToValue(Document)} to every document
found by executing query over searcher

@param searcher the index searcher to query
@param query the query to run
@return a list of values to be emitted as records (one by one) by this record reader
@throws IOException