this implementation supplies a filtered DocIdSet, that excludes all docids which are not in a Bits instance. this is especially useful in Lucene.Net.Search.Filter to apply the {@code acceptDocs} passed to {@code getDocIdSet()} before returning the final DocIdSet.
Inheritance: FilteredDocIdSet
Example #1
0
        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));
        }
Example #2
0
        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 FieldCacheDocIdSetAnonymousInnerClassHelper(this, context.AtomicReader.MaxDoc, acceptDocs, docsWithField));
            }
            else
            {
                if (docsWithField is MatchNoBits)
                {
                    return(null);
                }
                if (docsWithField is DocIdSet)
                {
                    // UweSays: this is always the case for our current impl - but who knows
                    // :-)
                    return(BitsFilteredDocIdSet.Wrap((DocIdSet)docsWithField, acceptDocs));
                }
                return(new FieldCacheDocIdSetAnonymousInnerClassHelper2(this, context.AtomicReader.MaxDoc, acceptDocs, docsWithField));
            }
        }
Example #3
0
        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));
        }
Example #4
0
        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));
        }