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;

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

            if (cached != null)
            {
                hitCount++;
                if (cached is DocIdSet)
                {
                    return((DocIdSet)cached);
                }
                else
                {
                    return(new DocIdBitSet((System.Collections.BitArray)cached));
                }
            }
            missCount++;
            // cache miss
            DocIdSet docIdSet = DocIdSetToCache(filter.GetDocIdSet(reader), reader);

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

            return(docIdSet);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
            /** Remove this reader from the cache, if present. */
            public void Purge(IndexReader r)
            {
                object readerKey = r.GetFieldCacheKey();

                lock (readerCache)
                {
                    readerCache.Remove(readerKey);
                }
            }
Exemplo n.º 5
0
            public virtual System.Object Get(IndexReader reader, Entry key)
            {
                IDictionary <Entry, Object> innerCache;

                System.Object value_Renamed;
                System.Object readerKey = reader.GetFieldCacheKey();
                lock (readerCache)
                {
                    innerCache = readerCache[readerKey];
                    if (innerCache == null)
                    {
                        innerCache             = new Support.Dictionary <Entry, Object>();
                        readerCache[readerKey] = innerCache;
                        value_Renamed          = null;
                    }
                    else
                    {
                        value_Renamed = innerCache[key];
                    }
                    if (value_Renamed == null)
                    {
                        value_Renamed   = new CreationPlaceholder();
                        innerCache[key] = value_Renamed;
                    }
                }
                if (value_Renamed is CreationPlaceholder)
                {
                    lock (value_Renamed)
                    {
                        CreationPlaceholder progress = (CreationPlaceholder)value_Renamed;
                        if (progress.value_Renamed == null)
                        {
                            progress.value_Renamed = CreateValue(reader, key);
                            lock (readerCache)
                            {
                                innerCache[key] = progress.value_Renamed;
                            }

                            // Only check if key.custom (the parser) is
                            // non-null; else, we check twice for a single
                            // call to FieldCache.getXXX
                            if (key.custom != null && wrapper != null)
                            {
                                System.IO.StreamWriter infoStream = wrapper.GetInfoStream();
                                if (infoStream != null)
                                {
                                    PrintNewInsanity(infoStream, progress.value_Renamed);
                                }
                            }
                        }
                        return(progress.value_Renamed);
                    }
                }
                return(value_Renamed);
            }
Exemplo n.º 6
0
        private SpanFilterResult GetCachedResult(IndexReader reader)
        {
            object coreKey    = reader.GetFieldCacheKey();
            object delCoreKey = reader.HasDeletions() ? reader.GetDeletesCacheKey() : coreKey;

            SpanFilterResult result = (SpanFilterResult)cache.Get(reader, coreKey, delCoreKey);

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

            missCount++;
            result = filter.BitSpans(reader);

            cache.Put(coreKey, delCoreKey, result);
            return(result);
        }
Exemplo n.º 7
0
            public virtual System.Object Get(IndexReader reader, Entry key)
            {
                System.Collections.IDictionary innerCache;
                System.Object value_Renamed;
                System.Object readerKey = reader.GetFieldCacheKey();
                lock (readerCache.SyncRoot)
                {
                    innerCache = (System.Collections.IDictionary) readerCache[readerKey];
                    if (innerCache == null)
                    {
                        innerCache = new System.Collections.Hashtable();
                        readerCache[readerKey] = innerCache;
                        value_Renamed = null;
                    }
                    else
                    {
                        value_Renamed = innerCache[key];
                    }
                    if (value_Renamed == null)
                    {
                        value_Renamed = new CreationPlaceholder();
                        innerCache[key] = value_Renamed;
                    }
                }
                if (value_Renamed is CreationPlaceholder)
                {
                    lock (value_Renamed)
                    {
                        CreationPlaceholder progress = (CreationPlaceholder) value_Renamed;
                        if (progress.value_Renamed == null)
                        {
                            progress.value_Renamed = CreateValue(reader, key);
                            lock (readerCache.SyncRoot)
                            {
                                innerCache[key] = progress.value_Renamed;
                            }

                            // Only check if key.custom (the parser) is
                            // non-null; else, we check twice for a single
                            // call to FieldCache.getXXX
                            if (key.custom != null && wrapper != null)
                            {
                                System.IO.StreamWriter infoStream = wrapper.GetInfoStream();
                                if (infoStream != null)
                                {
                                    PrintNewInsanity(infoStream, progress.value_Renamed);
                                }
                            }
                        }
                        return progress.value_Renamed;
                    }
                }
                return value_Renamed;
            }
		private SpanFilterResult GetCachedResult(IndexReader reader)
		{
            object coreKey = reader.GetFieldCacheKey();
            object delCoreKey = reader.HasDeletions() ? reader.GetDeletesCacheKey() : coreKey;

            SpanFilterResult result = (SpanFilterResult) cache.Get(reader, coreKey, delCoreKey);
            if (result != null) {
                hitCount++;
                return result;
            }

            missCount++;
            result = filter.BitSpans(reader);

            cache.Put(coreKey, delCoreKey, result);
            return result;
		}
Exemplo n.º 9
0
 /** Remove this reader from the cache, if present. */
 public void Purge(IndexReader r)
 {
     object readerKey = r.GetFieldCacheKey();
     lock (readerCache)
     {
         readerCache.Remove(readerKey);
     }
 }
Exemplo n.º 10
0
		public override DocIdSet GetDocIdSet(IndexReader reader)
		{
			object coreKey = reader.GetFieldCacheKey();
            object delCoreKey = reader.HasDeletions() ? reader.GetDeletesCacheKey() : coreKey;

            object cached = cache.Get(reader, coreKey, delCoreKey);
			
			if (cached != null)
			{
                hitCount++;
				if (cached is DocIdSet)
					return (DocIdSet) cached;
				else
					return new DocIdBitSet((System.Collections.BitArray) cached);
			}
            missCount++;
            // cache miss
			DocIdSet docIdSet = DocIdSetToCache(filter.GetDocIdSet(reader), reader);
			
			if (docIdSet != null)
			{
                cache.Put(coreKey, delCoreKey, docIdSet);
			}
			
			return docIdSet;
		}
Exemplo n.º 11
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;
		}