fix seen readers counter

since clear can be called on percolator as well, we need to make sure we inc the counter even for non segment readers
This commit is contained in:
Shay Banon 2013-04-02 13:25:56 +02:00
parent 31d1e6cfe7
commit 10a76ad5d8
1 changed files with 5 additions and 2 deletions

View File

@ -162,9 +162,12 @@ public class WeightedFilterCache extends AbstractIndexComponent implements Filte
if (cacheValue == null) {
if (!cache.seenReaders.containsKey(context.reader().getCoreCacheKey())) {
Boolean previous = cache.seenReaders.putIfAbsent(context.reader().getCoreCacheKey(), Boolean.TRUE);
if (previous == null && (context.reader() instanceof SegmentReader)) {
((SegmentReader) context.reader()).addCoreClosedListener(cache);
if (previous == null) {
cache.seenReadersCount.inc();
// we add a core closed listener only, for non core IndexReaders we rely on clear being called (percolator for example)
if (context.reader() instanceof SegmentReader) {
((SegmentReader) context.reader()).addCoreClosedListener(cache);
}
}
}