Skip to content

Instantly share code, notes, and snippets.

@martijnvg
Created January 15, 2013 11:13
Show Gist options
  • Save martijnvg/4537938 to your computer and use it in GitHub Desktop.
Save martijnvg/4537938 to your computer and use it in GitHub Desktop.
The RobinEngine#loadCurrentVersionFromIndex method. Tweaked the BloomFilteringPostingsFormat to make bloom filter accessible for other users.
private long loadCurrentVersionFromIndex(Term uid) {
Searcher searcher = searcher();
try {
List<AtomicReaderContext> readers = searcher.reader().leaves();
Map<String, Map<String, BloomFilter>> testje = BloomFilteringPostingsFormat.testje;
for (int i = 0; i < readers.size(); i++) {
AtomicReaderContext readerContext = readers.get(i);
BloomFilter bloomFilter = testje.get(((SegmentReader)readerContext.reader()).getSegmentName()).get(uid.field());
if (!bloomFilter.isPresent(uid.bytes())) {
continue;
}
long version = UidField.loadVersion(readerContext, uid);
// either -2 (its there, but no version associated), or an actual version
if (version != -1) {
return version;
}
}
return -1;
} finally {
searcher.release();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment