@Override public final int nextDoc() throws IOException { if (_queue.size() == 0) { return NO_MORE_DOCS; } // TODO: move this init into positions(): if the search // doesn't need the positions for this doc then don't // waste CPU merging them: _posList.clear(); _doc = _queue.top().docID(); // merge sort all positions together DocsAndPositionsEnum postings; do { postings = _queue.top(); final int freq = postings.freq(); for (int i = 0; i < freq; i++) { _posList.add(postings.nextPosition()); } if (postings.nextDoc() != NO_MORE_DOCS) { _queue.updateTop(); } else { _queue.pop(); } } while (_queue.size() > 0 && _queue.top().docID() == _doc); _posList.sort(); _freq = _posList.size(); return _doc; }
@Override public int nextPosition() { return _posList.next(); }