/** * Clears all bits in the given bitset that are set and are also in the given DocIdSetIterator. * * @param iterator the doc ID set iterator for apply * @param bits the bit set to apply the deletes to * @return the number of bits changed by this function */ static int applySoftDeletes(DocIdSetIterator iterator, FixedBitSet bits) throws IOException { assert iterator != null; int newDeletes = 0; int docID; DocValuesFieldUpdates.Iterator hasValue = iterator instanceof DocValuesFieldUpdates.Iterator ? (DocValuesFieldUpdates.Iterator) iterator : null; while ((docID = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { if (hasValue == null || hasValue.hasValue()) { if (bits.get(docID)) { // doc is live - clear it bits.clear(docID); newDeletes++; // now that we know we deleted it and we fully control the hard deletes we can do correct accounting // below. } } else { if (bits.get(docID) == false) { bits.set(docID); newDeletes--; } } } return newDeletes; }
@Override boolean delete(int docID) throws IOException { FixedBitSet mutableBits = getMutableBits(); // we need to fetch this first it might be a shared instance with hardDeletes if (hardDeletes.delete(docID)) { if (mutableBits.get(docID)) { // delete it here too! mutableBits.clear(docID); assert hardDeletes.delete(docID) == false; } else { // if it was deleted subtract the delCount pendingDeleteCount--; assert assertPendingDeletes(); } return true; } return false; }
/** * Marks a document as deleted in this segment and return true if a document got actually deleted or * if the document was already deleted. */ boolean delete(int docID) throws IOException { assert info.info.maxDoc() > 0; FixedBitSet mutableBits = getMutableBits(); assert mutableBits != null; assert docID >= 0 && docID < mutableBits.length() : "out of bounds: docid=" + docID + " liveDocsLength=" + mutableBits.length() + " seg=" + info.info.name + " maxDoc=" + info.info.maxDoc(); final boolean didDelete = mutableBits.get(docID); if (didDelete) { mutableBits.clear(docID); pendingDeleteCount++; } return didDelete; }
state.liveDocs.set(0, state.segmentInfo.maxDoc()); if (state.liveDocs.get(doc)) { state.delCountOnFlush++; state.liveDocs.clear(doc);
if (pp2.rptGroup >= 0 && bits.get(pp2.rptInd)) { bits.clear(pp2.rptInd);
if (pp2.rptGroup >= 0 && bits.get(pp2.rptInd)) { bits.clear(pp2.rptInd);
public boolean get(int index) { assert 0 <= index && index < this.length(); assert bitset == null || onBits < bitset.length() : "Bitset should be released when all bits are set"; return bitset == null ? true : bitset.get(index); }
private GroupShardsIterator<SearchShardIterator> getIterator(BitSetSearchPhaseResults results, GroupShardsIterator<SearchShardIterator> shardsIts) { int cardinality = results.getNumPossibleMatches(); FixedBitSet possibleMatches = results.getPossibleMatches(); if (cardinality == 0) { // this is a special case where we have no hit but we need to get at least one search response in order // to produce a valid search result with all the aggs etc. possibleMatches.set(0); } int i = 0; for (SearchShardIterator iter : shardsIts) { if (possibleMatches.get(i++)) { iter.reset(); } else { iter.resetAndSkip(); } } return shardsIts; }
private ContainsResult mayContainValue(int positiveHash) { assert positiveHash >= 0; // Bloom sizes are always base 2 and so can be ANDed for a fast modulo int pos = positiveHash & bloomSize; if (filter.get(pos)) { // This term may be recorded in this index (but could be a collision) return ContainsResult.MAYBE; } // definitely NOT in this segment return ContainsResult.NO; }
@Override public boolean get(int index) { return bits.get(index); }
@Override public boolean isDeleted(int n) { return readerDels.get(n); }
@Override /** * Writes vector to a string of the form 010 etc. (no delimiters). * * No terminating newline or delimiter. */ public String writeToString() { StringBuilder builder = new StringBuilder(); for (int i = 0; i < dimension; ++i) { builder.append(this.bitSet.get(i) ? "1" : "0"); } return builder.toString(); }
/** * Gets the index-th bit of this slice, meaning the * (start + index)th bit of the underlying bitset. * @param index the index into the slice to get * @return whether the bit is set */ public boolean get(final int index) { return this.underlying.get(index + this.getStart()); }
@Override protected final boolean matchDoc(int doc) { int ord = fcsi.getOrd(doc); if (ord == -1) { // missing return false; } else { return bits.get(ord); } } };
IntConsumer bitSetConsumer = maybeWrapConsumer.apply(bitSet::set); findSplitDocs(IdFieldMapper.NAME, includeInShard, leafReader, docId -> { if (hasRoutingValue.get(docId) == false) { bitSetConsumer.accept(docId);
@Override public boolean next() throws IOException { boolean res; while ((res = super.next())) { if (!dels.get(doc())) { break; } } return res; } };
public boolean get(int index) { assert 0 <= index && index < this.length(); assert bitset == null || onBits < bitset.length() : "Bitset should be released when all bits are set"; return bitset == null ? true : bitset.get(index); }
@Override public boolean next() throws IOException { boolean res; while ((res = super.next())) { if (!readerDels.get(doc())) { break; } } return res; } };
@Override public boolean get(final int index) { int i = 0; int offset = index; while (offset > this.underlying[i].length()) { offset -= this.underlying[i].length(); i++; } return this.underlying[i].get(offset); }
public boolean get(int index) { assert 0 <= index && index < this.length(); assert bitset == null || onBits < bitset.length() : "Bitset should be released when all bits are set"; return bitset == null ? true : bitset.get(index); }