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); }
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); }
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); }
public Object Get(IndexReader reader, object coreKey, object delCoreKey) { lock (this) { object value; if (cache == null) { cache = new SupportClass.WeakHashTable(); } if (deletesMode == DeletesMode.IGNORE) { // key on core value = cache[coreKey]; } else if (deletesMode == DeletesMode.RECACHE) { // key on deletes, if any, else core value = cache[delCoreKey]; } else { System.Diagnostics.Debug.Assert(deletesMode == DeletesMode.DYNAMIC); // first try for exact match value = cache[delCoreKey]; if (value == null) { // now for core match, but dynamically AND NOT // deletions value = cache[coreKey]; if (value != null && reader.HasDeletions()) { value = MergeDeletes(reader, value); } } } return(value); } }
/// <summary>this DocIdSet is cacheable, if it works solely with FieldCache and no TermDocs </summary> public override bool IsCacheable() { return(!(mayUseTermDocs && reader.HasDeletions())); }
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; }
public Object Get(IndexReader reader, object coreKey, object delCoreKey) { lock (this) { object value; if (cache == null) { cache = new SupportClass.WeakHashTable(); } if (deletesMode == DeletesMode.IGNORE) { // key on core value = cache[coreKey]; } else if (deletesMode == DeletesMode.RECACHE) { // key on deletes, if any, else core value = cache[delCoreKey]; } else { System.Diagnostics.Debug.Assert(deletesMode == DeletesMode.DYNAMIC); // first try for exact match value = cache[delCoreKey]; if (value == null) { // now for core match, but dynamically AND NOT // deletions value = cache[coreKey]; if (value != null && reader.HasDeletions()) { value = MergeDeletes(reader, value); } } } return value; } }
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; }
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; }