public class UsageTrackingQueryCachingPolicy extends Object implements QueryCachingPolicy
QueryCachingPolicy
that tracks usage statistics of recently-used
filters in order to decide on which filters are worth caching.Constructor and Description |
---|
UsageTrackingQueryCachingPolicy()
Create a new instance with an history size of 256.
|
UsageTrackingQueryCachingPolicy(int historySize)
Expert: Create a new instance with a configurable history size.
|
Modifier and Type | Method and Description |
---|---|
protected int |
minFrequencyToCache(Query query)
For a given filter, return how many times it should appear in the history
before being cached.
|
void |
onUse(Query query)
Callback that is called every time that a cached filter is used.
|
boolean |
shouldCache(Query query)
Whether the given
Query is worth caching. |
public UsageTrackingQueryCachingPolicy(int historySize)
minFrequencyToCache(org.apache.lucene.search.Query)
returns low values and this means some filters
that are rarely used will be cached, which would hurt performance. Or
minFrequencyToCache(org.apache.lucene.search.Query)
returns high values that are function of the
size of the history but then filters will be slow to make it to the cache.historySize
- the number of recently used filters to trackpublic UsageTrackingQueryCachingPolicy()
protected int minFrequencyToCache(Query query)
DocIdSetIterator
,
like MultiTermQuery
, point-based queries or TermInSetQuery
,
and 5 for other filters.public void onUse(Query query)
QueryCachingPolicy
onUse
in interface QueryCachingPolicy
public boolean shouldCache(Query query) throws IOException
QueryCachingPolicy
Query
is worth caching.
This method will be called by the QueryCache
to know whether to
cache. It will first attempt to load a DocIdSet
from the cache.
If it is not cached yet and this method returns true then a
cache entry will be generated. Otherwise an uncached scorer will be
returned.shouldCache
in interface QueryCachingPolicy
IOException
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.