protected override DocIdSet DocIdSetToCache(DocIdSet docIdSet, AtomicReader reader) { if (docIdSet == null) { return EMPTY_DOCIDSET; } if (docIdSet is FixedBitSet) { // this is different from CachingWrapperFilter: even when the DocIdSet is // cacheable, we convert it to a FixedBitSet since we require all the // cached filters to be FixedBitSets return docIdSet; } DocIdSetIterator it = docIdSet.GetIterator(); if (it == null) { return EMPTY_DOCIDSET; } FixedBitSet copy = new FixedBitSet(reader.MaxDoc); copy.Or(it); return copy; }
protected override DocIdSet CacheImpl(DocIdSetIterator iterator, AtomicReader reader) { FixedBitSet cached = new FixedBitSet(reader.MaxDoc); cached.Or(iterator); return cached; }
private FixedBitSet InitialResult(AtomicReaderContext context, int logic, int[] index) { AtomicReader reader = context.AtomicReader; FixedBitSet result = new FixedBitSet(reader.MaxDoc); if (logic == AND) { result.Or(GetDISI(chain[index[0]], context)); ++index[0]; } else if (logic == ANDNOT) { result.Or(GetDISI(chain[index[0]], context)); result.Flip(0, reader.MaxDoc); // NOTE: may set bits for deleted docs. ++index[0]; } return result; }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private void doChain(org.apache.lucene.util.FixedBitSet result, int logic, org.apache.lucene.search.DocIdSet dis) throws java.io.IOException private void doChain(FixedBitSet result, int logic, DocIdSet dis) { if (dis is FixedBitSet) { // optimized case for FixedBitSets switch (logic) { case OR: result.Or((FixedBitSet)dis); break; case AND: result.And((FixedBitSet)dis); break; case ANDNOT: result.AndNot((FixedBitSet)dis); break; case XOR: result.Xor((FixedBitSet)dis); break; default: doChain(result, DEFAULT, dis); break; } } else { DocIdSetIterator disi; if (dis == null) { disi = DocIdSetIterator.Empty(); } else { disi = dis.GetIterator() ?? DocIdSetIterator.Empty(); } switch (logic) { case OR: result.Or(disi); break; case AND: result.And(disi); break; case ANDNOT: result.AndNot(disi); break; case XOR: result.Xor(disi); break; default: doChain(result, DEFAULT, dis); break; } } }
public DocumentFilteredAtomicIndexReader(AtomicReaderContext context, Filter preserveFilter, bool negateFilter) : base(context.AtomicReader) { int maxDoc = @in.MaxDoc; FixedBitSet bits = new FixedBitSet(maxDoc); // ignore livedocs here, as we filter them later: DocIdSet docs = preserveFilter.GetDocIdSet(context, null); if (docs != null) { DocIdSetIterator it = docs.GetIterator(); if (it != null) { bits.Or(it); } } if (negateFilter) { bits.Flip(0, maxDoc); } if (@in.HasDeletions) { Bits oldLiveDocs = @in.LiveDocs; Debug.Assert(oldLiveDocs != null); DocIdSetIterator it = bits.GetIterator(); for (int i = it.NextDoc(); i < maxDoc; i = it.NextDoc()) { if (!oldLiveDocs.Get(i)) { // we can safely modify the current bit, as the iterator already stepped over it: bits.Clear(i); } } } this.liveDocs = bits; this.numDocs_Renamed = bits.Cardinality(); }