C# Class Lucene.Net.Search.CachingCollector

Caches all docs, and optionally also scores, coming from a search, and is then able to replay them to another collector. You specify the max RAM this class may use. Once the collection is done, call #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!

NOTE: this class caches at least 128 documents before checking RAM limits.

See the Lucene modules/grouping module for more details including a full code example.

@lucene.experimental
Inheritance: Collector
Datei anzeigen Open project: apache/lucenenet

Protected Properties

Property Type Description
@base int
CachedDocs IList
CurDocs int[]
LastDocBase int
MaxDocsToCache int
Other Collector
Upto int

Public Methods

Method Description
AcceptsDocsOutOfOrder ( ) : bool
Create ( Collector other, bool cacheScores, double maxRAMMB ) : CachingCollector

Create a new CachingCollector that wraps the given collector and caches documents and scores up to the specified RAM threshold.

Create ( Collector other, bool cacheScores, int maxDocsToCache ) : CachingCollector

Create a new CachingCollector that wraps the given collector and caches documents and scores up to the specified max docs threshold.

Create ( bool acceptDocsOutOfOrder, bool cacheScores, double maxRAMMB ) : CachingCollector

Creates a CachingCollector which does not wrap another collector. The cached documents and scores can later be {@link #replay(Collector) replayed}.

Replay ( Collector other ) : void

Replays the cached doc IDs (and scores) to the given Collector. If this instance does not cache scores, then Scorer is not set on {@code other.setScorer} as well as scores are not replayed.

Private Methods

Method Description
CachingCollector ( Collector other, double maxRAMMB, bool cacheScores ) : System.Collections.Generic
CachingCollector ( Collector other, int maxDocsToCache ) : System.Collections.Generic
ReplayInit ( Collector other ) : void

Reused by the specialized inner classes.

Method Details

AcceptsDocsOutOfOrder() public method

public AcceptsDocsOutOfOrder ( ) : bool
return bool

Create() public static method

Create a new CachingCollector that wraps the given collector and caches documents and scores up to the specified RAM threshold.
public static Create ( Collector other, bool cacheScores, double maxRAMMB ) : CachingCollector
other Collector /// the Collector to wrap and delegate calls to.
cacheScores bool /// whether to cache scores in addition to document IDs. Note that /// this increases the RAM consumed per doc
maxRAMMB double /// 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.
return CachingCollector

Create() public static method

Create a new CachingCollector that wraps the given collector and caches documents and scores up to the specified max docs threshold.
public static Create ( Collector other, bool cacheScores, int maxDocsToCache ) : CachingCollector
other Collector /// the Collector to wrap and delegate calls to.
cacheScores bool /// whether to cache scores in addition to document IDs. Note that /// this increases the RAM consumed per doc
maxDocsToCache int /// 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.
return CachingCollector

Create() public static method

Creates a CachingCollector which does not wrap another collector. The cached documents and scores can later be {@link #replay(Collector) replayed}.
public static Create ( bool acceptDocsOutOfOrder, bool cacheScores, double maxRAMMB ) : CachingCollector
acceptDocsOutOfOrder bool /// whether documents are allowed to be collected out-of-order
cacheScores bool
maxRAMMB double
return CachingCollector

Replay() public abstract method

Replays the cached doc IDs (and scores) to the given Collector. If this instance does not cache scores, then Scorer is not set on {@code other.setScorer} as well as scores are not replayed.
/// if this collector is not cached (i.e., if the RAM limits were too /// low for the number of documents + scores to cache). /// if the given Collect's does not support out-of-order collection, /// while the collector passed to the ctor does.
public abstract Replay ( Collector other ) : void
other Collector
return void

Property Details

@base protected_oe property

protected int @base
return int

CachedDocs protected_oe property

protected IList CachedDocs
return IList

CurDocs protected_oe property

protected int[] CurDocs
return int[]

LastDocBase protected_oe property

protected int LastDocBase
return int

MaxDocsToCache protected_oe property

protected int MaxDocsToCache
return int

Other protected_oe property

protected Collector,Lucene.Net.Search Other
return Collector

Upto protected_oe property

protected int Upto
return int