small optimization for global facet with facet filter, by removing the double check on the facet filter

This commit is contained in:
Shay Banon 2012-08-21 19:32:55 +02:00
parent f03ff2976a
commit c33ca2921d
2 changed files with 9 additions and 1 deletions

View File

@ -48,6 +48,12 @@ public abstract class AbstractFacetCollector extends FacetCollector {
return this.filter;
}
public Filter getAndClearFilter() {
Filter filter = this.filter;
this.filter = null;
return filter;
}
@Override
public void setFilter(Filter filter) {
if (this.filter == null) {

View File

@ -103,7 +103,9 @@ public class FacetPhase implements SearchPhase {
if (collector instanceof AbstractFacetCollector) {
AbstractFacetCollector facetCollector = (AbstractFacetCollector) collector;
if (facetCollector.getFilter() != null) {
filter = facetCollector.getFilter();
// we can clear the filter, since we are anyhow going to iterate over it
// so no need to double check it...
filter = facetCollector.getAndClearFilter();
}
}
List<Collector> list = filtersByCollector.get(filter);