List of usage examples for org.apache.lucene.search DocIdSetIterator DocIdSetIterator
DocIdSetIterator
From source file:proj.zoie.api.impl.util.ArrayDocIdSet.java
License:Apache License
@Override public DocIdSetIterator iterator() { return new DocIdSetIterator() { int doc = -1; int current = -1; int largest = _lengthminusone; @Override//from w w w . ja v a2s .c o m public int docID() { return doc; } @Override public int nextDoc() throws IOException { if (current < _lengthminusone) { current++; doc = _docids[current]; return doc; } return DocIdSetIterator.NO_MORE_DOCS; } @Override public int advance(int target) throws IOException { int idx = current < 0 ? binarySearch(_docids, target) : binarySearch(_docids, target, current, largest); // int idx = Arrays.binarySearch(_docids,target); if (idx < 0) { idx = -(idx + 1); if (idx >= _docids.length) return DocIdSetIterator.NO_MORE_DOCS; } current = idx; doc = _docids[current]; return doc; } }; }
From source file:proj.zoie.api.UIDDocIdSet.java
License:Apache License
@Override public DocIdSetIterator iterator() { return new DocIdSetIterator() { int doc = -1; int current = -1; @Override//from w ww . j a v a 2 s .com public int docID() { return doc; } @Override public int nextDoc() throws IOException { if (current < _sorted.length - 1) { current++; doc = _sorted[current]; return doc; } return DocIdSetIterator.NO_MORE_DOCS; } @Override public int advance(int target) throws IOException { int idx = Arrays.binarySearch(_sorted, target); if (idx < 0) { idx = -(idx + 1); if (idx >= _sorted.length) return DocIdSetIterator.NO_MORE_DOCS; } current = idx; doc = _sorted[current]; return doc; } }; }