Lucene.Net.Search.CachingCollector.Create C# (CSharp) Method

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
        public static CachingCollector Create(Collector other, bool cacheScores, double maxRAMMB)
        {
            return cacheScores ? (CachingCollector)new ScoreCachingCollector(other, maxRAMMB) : new NoScoreCachingCollector(other, maxRAMMB);
        }

Same methods

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

Usage Example

Beispiel #1
0
        public virtual void TestIllegalCollectorOnReplay()
        {
            // tests that the Collector passed to replay() has an out-of-order mode that
            // is valid with the Collector passed to the ctor

            // 'src' Collector does not support out-of-order
            CachingCollector cc = CachingCollector.Create(new NoOpCollector(false), true, 50 * ONE_BYTE);

            cc.SetScorer(new MockScorer());
            for (int i = 0; i < 10; i++)
            {
                cc.Collect(i);
            }
            cc.Replay(new NoOpCollector(true));  // this call should not fail
            cc.Replay(new NoOpCollector(false)); // this call should not fail

            // 'src' Collector supports out-of-order
            cc = CachingCollector.Create(new NoOpCollector(true), true, 50 * ONE_BYTE);
            cc.SetScorer(new MockScorer());
            for (int i = 0; i < 10; i++)
            {
                cc.Collect(i);
            }
            cc.Replay(new NoOpCollector(true)); // this call should not fail
            try
            {
                cc.Replay(new NoOpCollector(false)); // this call should fail
                Assert.Fail("should have failed if an in-order Collector was given to replay(), " + "while CachingCollector was initialized with out-of-order collection");
            }
            catch (Exception e) when(e.IsIllegalArgumentException())
            {
                // ok
            }
        }
All Usage Examples Of Lucene.Net.Search.CachingCollector::Create