Exemplo n.º 1
0
        public override System.Collections.BitArray Bits(IndexReader reader)
        {
            object coreKey    = reader.GetFieldCacheKey();
            object delCoreKey = reader.HasDeletions() ? reader.GetDeletesCacheKey() : coreKey;

            object cached = cache.Get(reader, coreKey, delCoreKey);

            if (cached != null)
            {
                if (cached is System.Collections.BitArray)
                {
                    return((System.Collections.BitArray)cached);
                }
                else if (cached is DocIdBitSet)
                {
                    return(((DocIdBitSet)cached).GetBitSet());
                }
                // It would be nice to handle the DocIdSet case, but that's not really possible
            }

            System.Collections.BitArray bits = filter.Bits(reader);

            if (bits != null)
            {
                cache.Put(coreKey, delCoreKey, bits);
            }

            return(bits);
        }
Exemplo n.º 2
0
        public override DocIdSet GetDocIdSet(IndexReader reader)
        {
            object coreKey    = reader.GetFieldCacheKey();
            object delCoreKey = reader.HasDeletions() ? reader.GetDeletesCacheKey() : coreKey;

            DocIdSet docIdSet = cache.Get(reader, coreKey, delCoreKey);

            if (docIdSet != null)
            {
                hitCount++;
                return(docIdSet);
            }

            missCount++;

            // cache miss
            docIdSet = DocIdSetToCache(filter.GetDocIdSet(reader), reader);

            if (docIdSet != null)
            {
                cache.Put(coreKey, delCoreKey, docIdSet);
            }

            return(docIdSet);
        }