コード例 #1
0
        private static void AssertDocIdSetCacheable(IndexReader reader, Filter filter, bool shouldCacheable)
        {
            Assert.IsTrue(reader.Context is AtomicReaderContext);
            AtomicReaderContext  context     = (AtomicReaderContext)reader.Context;
            CachingWrapperFilter cacher      = new CachingWrapperFilter(filter);
            DocIdSet             originalSet = filter.GetDocIdSet(context, (context.AtomicReader).LiveDocs);
            DocIdSet             cachedSet   = cacher.GetDocIdSet(context, (context.AtomicReader).LiveDocs);

            if (originalSet == null)
            {
                Assert.IsNull(cachedSet);
            }
            if (cachedSet == null)
            {
                Assert.IsTrue(originalSet == null || originalSet.GetIterator() == null);
            }
            else
            {
                Assert.IsTrue(cachedSet.IsCacheable);
                Assert.AreEqual(shouldCacheable, originalSet.IsCacheable);
                //System.out.println("Original: "+originalSet.getClass().getName()+" -- cached: "+cachedSet.getClass().getName());
                if (originalSet.IsCacheable)
                {
                    Assert.AreEqual(originalSet.GetType(), cachedSet.GetType(), "Cached DocIdSet must be of same class like uncached, if cacheable");
                }
                else
                {
                    Assert.IsTrue(cachedSet is FixedBitSet || cachedSet == null, "Cached DocIdSet must be an FixedBitSet if the original one was not cacheable");
                }
            }
        }
コード例 #2
0
        private static void assertDocIdSetCacheable(IndexReader reader, Filter filter, bool shouldCacheable)
        {
            CachingWrapperFilter cacher      = new CachingWrapperFilter(filter);
            DocIdSet             originalSet = filter.GetDocIdSet(reader);
            DocIdSet             cachedSet   = cacher.GetDocIdSet(reader);

            Assert.IsTrue(cachedSet.IsCacheable);
            Assert.AreEqual(shouldCacheable, originalSet.IsCacheable);
            //System.out.println("Original: "+originalSet.getClass().getName()+" -- cached: "+cachedSet.getClass().getName());
            if (originalSet.IsCacheable)
            {
                Assert.AreEqual(originalSet.GetType(), cachedSet.GetType(), "Cached DocIdSet must be of same class like uncached, if cacheable");
            }
            else
            {
                Assert.IsTrue(cachedSet is OpenBitSetDISI, "Cached DocIdSet must be an OpenBitSet if the original one was not cacheable");
            }
        }