public final class UsageTrackingFilterCachingPolicy extends Object implements FilterCachingPolicy
FilterCachingPolicythat tracks usage statistics of recently-used filters in order to decide on which filters are worth caching. It also uses some heuristics on segments, filters and the doc id sets that they produce in order to cache more aggressively when the execution cost significantly outweighs the caching overhead.
|Constructor and Description|
Create a new instance with sensible defaults.
Create a new instance.
|Modifier and Type||Method and Description|
Callback that is called every time that a cached filter is used.
Whether the given
public UsageTrackingFilterCachingPolicy(float minSizeRatio, int historySize, int minFrequencyCostlyFilters, int minFrequencyCheapFilters, int minFrequencyOtherFilters)
minSizeRatio- the minimum size ratio for segments to be cached, see
historySize- the number of recently used filters to track
minFrequencyCostlyFilters- how many times filters whose
getDocIdSetmethod is expensive should have been seen before being cached
minFrequencyCheapFilters- how many times filters that produce
DocIdSets that are cheap to cached should have been seen before being cached
minFrequencyOtherFilters- how many times other filters should have been seen before being cached
public void onUse(Filter filter)
public boolean shouldCache(Filter filter, LeafReaderContext context, DocIdSet set) throws IOException
DocIdSetshould be cached on a given segment. This method will be called on each leaf context to know if the filter should be cached on this particular leaf. The filter cache will first attempt to load a
DocIdSetfrom the cache. If it is not cached yet and this method returns true then a cache entry will be generated. Otherwise an uncached set will be returned.
Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.