public override DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDocs) { var reader = context.AtomicReader; object key = reader.CoreCacheKey; if (_cache.TryGetValue(key, out DocIdSet docIdSet) && docIdSet != null) { hitCount++; } else { missCount++; docIdSet = DocIdSetToCache(_filter.GetDocIdSet(context, null), reader); if (Debugging.AssertsEnabled) { Debugging.Assert(docIdSet.IsCacheable); } #if FEATURE_CONDITIONALWEAKTABLE_ADDORUPDATE _cache.AddOrUpdate(key, docIdSet); #else _cache[key] = docIdSet; #endif } return(docIdSet == EMPTY_DOCIDSET ? null : BitsFilteredDocIdSet.Wrap(docIdSet, acceptDocs)); }
public override DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDocs) { IBits docsWithField = FieldCache.DEFAULT.GetDocsWithField(((AtomicReader)context.Reader), field); if (negate) { if (docsWithField is MatchAllBits) { return(null); } return(new FieldCacheDocIdSet(context.AtomicReader.MaxDoc, acceptDocs, (doc) => !docsWithField.Get(doc))); } else { if (docsWithField is MatchNoBits) { return(null); } if (docsWithField is DocIdSet docIdSetWithField) { // UweSays: this is always the case for our current impl - but who knows // :-) return(BitsFilteredDocIdSet.Wrap(docIdSetWithField, acceptDocs)); } return(new FieldCacheDocIdSet(context.AtomicReader.MaxDoc, acceptDocs, (doc) => docsWithField.Get(doc))); } }
public override DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDocs) { var reader = context.AtomicReader; object key = reader.CoreCacheKey; DocIdSet docIdSet = _cache[key]; if (docIdSet != null) { hitCount++; } else { missCount++; docIdSet = DocIdSetToCache(_filter.GetDocIdSet(context, null), reader); Debug.Assert(docIdSet.IsCacheable); _cache[key] = docIdSet; } return(docIdSet == EMPTY_DOCIDSET ? null : BitsFilteredDocIdSet.Wrap(docIdSet, acceptDocs)); }
public override DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDocs) { var reader = context.AtomicReader; object key = reader.CoreCacheKey; if (cache.TryGetValue(key, out DocIdSet docIdSet)) { hitCount++; } else { missCount++; docIdSet = DocIdSetToCache(filter.GetDocIdSet(context, null), reader); if (Debugging.AssertsEnabled) { Debugging.Assert(docIdSet.IsCacheable); } #if FEATURE_CONDITIONALWEAKTABLE_ENUMERATOR cache.AddOrUpdate(key, docIdSet); #else UninterruptableMonitor.Enter(cache); try { cache.AddOrUpdate(key, docIdSet); // LUCENENET specific - since .NET Standard 2.0 and .NET Framework don't have a CondtionalWeakTable enumerator, // we use a weak event to retrieve the DocIdSet instances reader.SubscribeToGetCacheKeysEvent(eventAggregator.GetEvent <Events.GetCacheKeysEvent>()); } finally { UninterruptableMonitor.Exit(cache); } #endif } return(docIdSet == EMPTY_DOCIDSET ? null : BitsFilteredDocIdSet.Wrap(docIdSet, acceptDocs)); }