@Test public void testPairWithSameStartAndEnd() { SortedDocIdSet sortedDocIdSet = new SortedDocIdSet(Collections.singletonList(new Pairs.IntPair(1, 1))); BlockDocIdIterator iterator = sortedDocIdSet.iterator(); List<Integer> result = new ArrayList<>(); int docId; while ((docId = iterator.next()) != Constants.EOF) { result.add(docId); } assertEquals(result, Collections.singletonList(1)); }
@Override public int next() { IntPair currentRange = _docIdRanges.get(_currentRangeId); if (_nextDocId <= currentRange.getRight()) { return _nextDocId++; } if (_currentRangeId < _numRanges - 1) { _currentRangeId++; _nextDocId = _docIdRanges.get(_currentRangeId).getLeft(); return _nextDocId++; } else { return Constants.EOF; } }
SortedDocIdIterator implements BlockDocIdIterator { @Override public int next() { IntPair currentRange = _docIdRanges.get(_currentRangeId); if (_nextDocId <= currentRange.getRight()) { return _nextDocId++; } if (_currentRangeId < _numRanges - 1) { _currentRangeId++; _nextDocId = _docIdRanges.get(_currentRangeId).getLeft(); return _nextDocId++; } else { return Constants.EOF; } } }
SortedDocIdIterator implements BlockDocIdIterator { @Override public int next() { IntPair currentRange = _docIdRanges.get(_currentRangeId); if (_nextDocId <= currentRange.getRight()) { return _nextDocId++; } if (_currentRangeId < _numRanges - 1) { _currentRangeId++; _nextDocId = _docIdRanges.get(_currentRangeId).getLeft(); return _nextDocId++; } else { return Constants.EOF; } } SortedDocIdIterator(List<IntPair> docIdRanges); }
SortedDocIdIterator implements BlockDocIdIterator { @Override public int next() { IntPair currentRange = _docIdRanges.get(_currentRangeId); if (_nextDocId <= currentRange.getRight()) { return _nextDocId++; } if (_currentRangeId < _numRanges - 1) { _currentRangeId++; _nextDocId = _docIdRanges.get(_currentRangeId).getLeft(); return _nextDocId++; } else { return Constants.EOF; } } SortedDocIdIterator(List<IntPair> docIdRanges); List<IntPair> getDocIdRanges(); @Override int next(); @Override int advance(int targetDocId); }
SortedDocIdIterator implements BlockDocIdIterator { @Override public int next() { IntPair currentRange = _docIdRanges.get(_currentRangeId); if (_nextDocId <= currentRange.getRight()) { return _nextDocId++; } if (_currentRangeId < _numRanges - 1) { _currentRangeId++; _nextDocId = _docIdRanges.get(_currentRangeId).getLeft(); return _nextDocId++; } else { return Constants.EOF; } } SortedDocIdIterator(List<IntPair> docIdRanges); List<IntPair> getDocIdRanges(); @Override int next(); @Override int advance(int targetDocId);  }