public abstract class CachingCollector extends FilterCollector
isCached()
. If
this returns true, you can use replay(Collector)
against a new collector. If it returns false, this means
too much RAM was required and you must instead re-run the
original search.
NOTE: this class consumes 4 (or 8 bytes, if scoring is cached) per collected document. If the result set is large this can easily be a very substantial amount of RAM!
See the Lucene modules/grouping module for more details including a full code example.
in
Modifier and Type | Method and Description |
---|---|
static CachingCollector |
create(boolean cacheScores,
double maxRAMMB)
Creates a
CachingCollector which does not wrap another collector. |
static CachingCollector |
create(Collector other,
boolean cacheScores,
double maxRAMMB)
Create a new
CachingCollector that wraps the given collector and
caches documents and scores up to the specified RAM threshold. |
static CachingCollector |
create(Collector other,
boolean cacheScores,
int maxDocsToCache)
Create a new
CachingCollector that wraps the given collector and
caches documents and scores up to the specified max docs threshold. |
boolean |
isCached()
Return true is this collector is able to replay collection.
|
abstract void |
replay(Collector other)
Replays the cached doc IDs (and scores) to the given Collector.
|
getLeafCollector, scoreMode, toString
public static CachingCollector create(boolean cacheScores, double maxRAMMB)
CachingCollector
which does not wrap another collector.
The cached documents and scores can later be replayed
.public static CachingCollector create(Collector other, boolean cacheScores, double maxRAMMB)
CachingCollector
that wraps the given collector and
caches documents and scores up to the specified RAM threshold.other
- the Collector to wrap and delegate calls to.cacheScores
- whether to cache scores in addition to document IDs. Note that
this increases the RAM consumed per docmaxRAMMB
- the maximum RAM in MB to consume for caching the documents and
scores. If the collector exceeds the threshold, no documents and
scores are cached.public static CachingCollector create(Collector other, boolean cacheScores, int maxDocsToCache)
CachingCollector
that wraps the given collector and
caches documents and scores up to the specified max docs threshold.other
- the Collector to wrap and delegate calls to.cacheScores
- whether to cache scores in addition to document IDs. Note that
this increases the RAM consumed per docmaxDocsToCache
- the maximum number of documents for caching the documents and
possible the scores. If the collector exceeds the threshold,
no documents and scores are cached.public final boolean isCached()
public abstract void replay(Collector other) throws IOException
other.setScorer
as well as scores are not replayed.IllegalStateException
- if this collector is not cached (i.e., if the RAM limits were too
low for the number of documents + scores to cache).IllegalArgumentException
- if the given Collect's does not support out-of-order collection,
while the collector passed to the ctor does.IOException
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.