Skip to content

Commit

Permalink
HSEARCH-1191 EMPTY_DOCIDSET was removed, implement our own
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanne committed Feb 3, 2014
1 parent 211d0a0 commit 0371148
Showing 1 changed file with 22 additions and 2 deletions.
Expand Up @@ -29,6 +29,7 @@

import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.OpenBitSet;

import static java.lang.Math.max;
Expand Down Expand Up @@ -78,7 +79,7 @@ private synchronized DocIdSet buildBitSet() throws IOException {
DocIdSetIterator docIdSetIterator = andedDocIdSets.get( i ).iterator();
if ( docIdSetIterator == null ) {
// the Lucene API permits to return null on any iterator for empty matches
return DocIdSet.EMPTY_DOCIDSET;
return EMPTY_DOCIDSET;
}
iterators[i] = docIdSetIterator;
}
Expand All @@ -94,7 +95,7 @@ private DocIdSet makeDocIdSetOnAgreedBits(final DocIdSetIterator[] iterators) th
int targetPosition = findFirstTargetPosition( iterators, result );

if ( targetPosition == DocIdSetIterator.NO_MORE_DOCS ) {
return DocIdSet.EMPTY_DOCIDSET;
return EMPTY_DOCIDSET;
}

// Each iterator can vote "ok" for the current target to
Expand Down Expand Up @@ -165,4 +166,23 @@ private int findFirstTargetPosition(final DocIdSetIterator[] iterators, OpenBitS

return targetPosition;
}

private static final DocIdSet EMPTY_DOCIDSET = new DocIdSet() {

@Override
public DocIdSetIterator iterator() {
return DocIdSetIterator.empty();
}

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

@Override
public Bits bits() {
return null;
}
};

}

0 comments on commit 0371148

Please sign in to comment.