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
コード例 #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
            }
        }
コード例 #2
0
        public virtual void TestIllegalStateOnReplay()
        {
            CachingCollector cc = CachingCollector.Create(new NoOpCollector(false), true, 50 * ONE_BYTE);

            cc.SetScorer(new MockScorer());

            // collect 130 docs, this should be enough for triggering cache abort.
            for (int i = 0; i < 130; i++)
            {
                cc.Collect(i);
            }

            Assert.IsFalse(cc.IsCached, "CachingCollector should not be cached due to low memory limit");

            try
            {
                cc.Replay(new NoOpCollector(false));
                Assert.Fail("replay should fail if CachingCollector is not cached");
            }
#pragma warning disable 168
            catch (InvalidOperationException e)
#pragma warning restore 168
            {
                // expected
            }
        }
コード例 #3
0
        public virtual void TestNoWrappedCollector()
        {
            foreach (bool cacheScores in new bool[] { false, true })
            {
                // create w/ null wrapped collector, and test that the methods work
                CachingCollector cc = CachingCollector.Create(true, cacheScores, 50 * ONE_BYTE);
                cc.SetNextReader(null);
                cc.SetScorer(new MockScorer());
                cc.Collect(0);

                Assert.IsTrue(cc.IsCached);
                cc.Replay(new NoOpCollector(true));
            }
        }
コード例 #4
0
        public virtual void TestBasic()
        {
            foreach (bool cacheScores in new bool[] { false, true })
            {
                CachingCollector cc = CachingCollector.Create(new NoOpCollector(false), cacheScores, 1.0);
                cc.SetScorer(new MockScorer());

                // collect 1000 docs
                for (int i = 0; i < 1000; i++)
                {
                    cc.Collect(i);
                }

                // now replay them
                cc.Replay(new CollectorAnonymousClass(this));
            }
        }