コード例 #1
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");
            }
        }
コード例 #2
0
 /// <summary>Provide the DocIdSet to be cached, using the DocIdSet provided
 /// by the wrapped Filter.
 /// This implementation returns the given DocIdSet.
 /// </summary>
 protected internal virtual DocIdSet DocIdSetToCache(DocIdSet docIdSet, IndexReader reader)
 {
     if (docIdSet.IsCacheable())
     {
         return(docIdSet);
     }
     else
     {
         DocIdSetIterator it = docIdSet.Iterator();
         // null is allowed to be returned by iterator(),
         // in this case we wrap with the empty set,
         // which is cacheable.
         return((it == null) ? DocIdSet.EMPTY_DOCIDSET : new OpenBitSetDISI(it, reader.MaxDoc()));
     }
 }
コード例 #3
0
		/// <summary>Provide the DocIdSet to be cached, using the DocIdSet provided
		/// by the wrapped Filter.
		/// This implementation returns the given DocIdSet.
		/// </summary>
		protected internal virtual DocIdSet DocIdSetToCache(DocIdSet docIdSet, IndexReader reader)
		{
			if (docIdSet.IsCacheable())
			{
				return docIdSet;
			}
			else
			{
				DocIdSetIterator it = docIdSet.Iterator();
				// null is allowed to be returned by iterator(),
				// in this case we wrap with the empty set,
				// which is cacheable.
				return (it == null) ? DocIdSet.EMPTY_DOCIDSET : new OpenBitSetDISI(it, reader.MaxDoc());
			}
		}
コード例 #4
0
 /// <summary>This DocIdSet implementation is cacheable if the inner set is cacheable. </summary>
 public override bool IsCacheable()
 {
     return(_innerSet.IsCacheable());
 }