only call terms lookup once and not per segment

This commit is contained in:
Shay Banon 2013-06-24 18:01:22 +02:00
parent e0846448e9
commit f3c068f637
1 changed files with 8 additions and 3 deletions

View File

@ -145,6 +145,8 @@ public class IndicesTermsFilterCache extends AbstractComponent {
private final TermsLookup lookup;
private final CacheKeyFilter.Key cacheKey;
private final IndicesTermsFilterCache cache;
boolean termsFilterCalled;
private Filter termsFilter;
LookupTermsFilter(TermsLookup lookup, CacheKeyFilter.Key cacheKey, IndicesTermsFilterCache cache) {
this.lookup = lookup;
@ -154,9 +156,12 @@ public class IndicesTermsFilterCache extends AbstractComponent {
@Override
public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptDocs) throws IOException {
Filter filter = cache.termsFilter(cacheKey, lookup);
if (filter == null) return null;
return filter.getDocIdSet(context, acceptDocs);
// only call the terms filter once per execution (across segments per single search request)
if (!termsFilterCalled) {
termsFilter = cache.termsFilter(cacheKey, lookup);
}
if (termsFilter == null) return null;
return termsFilter.getDocIdSet(context, acceptDocs);
}
@Override