@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; }
private FixedBitSet sortLiveDocs(Bits liveDocs, Sorter.DocMap sortMap) throws IOException { assert liveDocs != null && sortMap != null; FixedBitSet sortedLiveDocs = new FixedBitSet(liveDocs.length()); sortedLiveDocs.set(0, liveDocs.length()); for (int i = 0; i < liveDocs.length(); i++) { if (liveDocs.get(i) == false) { sortedLiveDocs.clear(sortMap.oldToNew(i)); } } return sortedLiveDocs; }
/** * 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.clear(doc);
static void writeBitSet(DocIdSetIterator it, IndexOutput out) throws IOException { int i = 0; final FixedBitSet buffer = new FixedBitSet(1<<16); int prevBlock = -1; for (int doc = it.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = it.nextDoc()) { final int block = doc >>> 16; if (prevBlock != -1 && block != prevBlock) { flush(prevBlock, buffer, i, out); buffer.clear(0, buffer.length()); prevBlock = block; i = 0; } buffer.set(doc & 0xFFFF); i++; prevBlock = block; } if (i > 0) { flush(prevBlock, buffer, i, out); buffer.clear(0, buffer.length()); } // NO_MORE_DOCS is stored explicitly buffer.set(DocIdSetIterator.NO_MORE_DOCS & 0xFFFF); flush(DocIdSetIterator.NO_MORE_DOCS >>> 16, buffer, 1, out); }
/** * 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; }
/** * Make a copy of the given bits. */ public static FixedBitSet copyOf(Bits bits) { if (bits instanceof FixedBits) { // restore the original FixedBitSet FixedBits fixedBits = (FixedBits) bits; bits = new FixedBitSet(fixedBits.bits, fixedBits.length); } if (bits instanceof FixedBitSet) { return ((FixedBitSet)bits).clone(); } else { int length = bits.length(); FixedBitSet bitSet = new FixedBitSet(length); bitSet.set(0, length); for (int i = 0; i < length; ++i) { if (bits.get(i) == false) { bitSet.clear(i); } } return bitSet; } }
docsSeen.clear(0, docsSeen.length());
@Override public void visit(int docID) { result.clear(docID); cost[0]--; }
flushState.liveDocs.set(0, numDocsInRAM); for(int delDocID : pendingUpdates.deleteDocIDs) { flushState.liveDocs.clear(delDocID);
bits.clear(pp2.rptInd);
bits.clear(pp2.rptInd);
@Override public void visit(int docID, byte[] packedTriangle) { if (query.queryMatches(packedTriangle, scratchTriangle) == false) { result.clear(docID); cost[0]--; } }
@Override public void visit(int docID) { result.clear(docID); cost[0]--; }
public void deleteDocument(int n) { liveDocs.clear(n); }
public void deleteDocument(int n) { liveDocs.clear(n); }
@Override public void visit(int docID, byte[] packedTriangle) { if (query.queryMatches(packedTriangle) == false) { result.clear(docID); cost[0]--; } }
/** * Clears 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 clear */ public void clear(final int index) { this.underlying.clear(index + this.getStart()); }
/** * Clears the bit at the given position. * @param index the position to clear. */ public void clear(final int index) { int i = 0; int offset = index; while (offset >= this.underlying[i].length()) { offset -= this.underlying[i].length(); i++; } this.underlying[i].clear(offset); }
private FixedBitSet sortLiveDocs(Bits liveDocs, Sorter.DocMap sortMap) throws IOException { assert liveDocs != null && sortMap != null; FixedBitSet sortedLiveDocs = new FixedBitSet(liveDocs.length()); sortedLiveDocs.set(0, liveDocs.length()); for (int i = 0; i < liveDocs.length(); i++) { if (liveDocs.get(i) == false) { sortedLiveDocs.clear(sortMap.oldToNew(i)); } } return sortedLiveDocs; }