Package org.apache.lucene.index
Class PendingDeletes
- java.lang.Object
-
- org.apache.lucene.index.PendingDeletes
-
- Direct Known Subclasses:
PendingSoftDeletes
class PendingDeletes extends java.lang.ObjectThis class handles accounting and applying pending deletes for live segment readers
-
-
Field Summary
Fields Modifier and Type Field Description protected SegmentCommitInfoinfoprivate BitsliveDocs(package private) booleanliveDocsInitializedprotected intpendingDeleteCountprivate FixedBitSetwriteableLiveDocs
-
Constructor Summary
Constructors Constructor Description PendingDeletes(SegmentCommitInfo info)PendingDeletes(SegmentCommitInfo info, Bits liveDocs, boolean liveDocsInitialized)PendingDeletes(SegmentReader reader, SegmentCommitInfo info)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleanassertCheckLiveDocs(Bits bits, int expectedLength, int expectedDeleteCount)(package private) booleandelete(int docID)Marks a document as deleted in this segment and return true if a document got actually deleted or if the document was already deleted.(package private) voiddropChanges()Resets the pending docs(package private) intgetDelCount()Returns the number of deleted docs in the segment.(package private) BitsgetHardLiveDocs()Returns a snapshot of the hard live docs.(package private) BitsgetLiveDocs()Returns a snapshot of the current live docs.protected FixedBitSetgetMutableBits()(package private) booleanisFullyDeleted(IOSupplier<CodecReader> readerIOSupplier)Returnstrueiff the segment represented by thisPendingDeletesis fully deleted(package private) booleanmustInitOnDelete()Returnstrueif we have to initialize this PendingDeletes beforedelete(int); otherwise this PendingDeletes is ready to accept deletes.(package private) booleanneedsRefresh(CodecReader reader)Returns true if the given reader needs to be refreshed in order to see the latest deletes(package private) intnumDeletesToMerge(MergePolicy policy, IOSupplier<CodecReader> readerIOSupplier)(package private) intnumDocs()Returns the number of live documents in this segmentprotected intnumPendingDeletes()Returns the number of pending deletes that are not written to disk.(package private) voidonDocValuesUpdate(FieldInfo info, DocValuesFieldUpdates.Iterator iterator)Called for every field update for the given field at flush time(package private) voidonNewReader(CodecReader reader, SegmentCommitInfo info)Called once a new reader is opened for this segment ie.java.lang.StringtoString()(package private) booleanverifyDocCounts(CodecReader reader)(package private) booleanwriteLiveDocs(Directory dir)Writes the live docs to disk and returnstrueif any new docs were written.
-
-
-
Field Detail
-
info
protected final SegmentCommitInfo info
-
liveDocs
private Bits liveDocs
-
writeableLiveDocs
private FixedBitSet writeableLiveDocs
-
pendingDeleteCount
protected int pendingDeleteCount
-
liveDocsInitialized
boolean liveDocsInitialized
-
-
Constructor Detail
-
PendingDeletes
PendingDeletes(SegmentReader reader, SegmentCommitInfo info)
-
PendingDeletes
PendingDeletes(SegmentCommitInfo info)
-
PendingDeletes
PendingDeletes(SegmentCommitInfo info, Bits liveDocs, boolean liveDocsInitialized)
-
-
Method Detail
-
getMutableBits
protected FixedBitSet getMutableBits()
-
delete
boolean delete(int docID) throws java.io.IOExceptionMarks a document as deleted in this segment and return true if a document got actually deleted or if the document was already deleted.- Throws:
java.io.IOException
-
getLiveDocs
Bits getLiveDocs()
Returns a snapshot of the current live docs.
-
getHardLiveDocs
Bits getHardLiveDocs()
Returns a snapshot of the hard live docs.
-
numPendingDeletes
protected int numPendingDeletes()
Returns the number of pending deletes that are not written to disk.
-
onNewReader
void onNewReader(CodecReader reader, SegmentCommitInfo info) throws java.io.IOException
Called once a new reader is opened for this segment ie. when deletes or updates are applied.- Throws:
java.io.IOException
-
assertCheckLiveDocs
private boolean assertCheckLiveDocs(Bits bits, int expectedLength, int expectedDeleteCount)
-
dropChanges
void dropChanges()
Resets the pending docs
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
writeLiveDocs
boolean writeLiveDocs(Directory dir) throws java.io.IOException
Writes the live docs to disk and returnstrueif any new docs were written.- Throws:
java.io.IOException
-
isFullyDeleted
boolean isFullyDeleted(IOSupplier<CodecReader> readerIOSupplier) throws java.io.IOException
Returnstrueiff the segment represented by thisPendingDeletesis fully deleted- Throws:
java.io.IOException
-
onDocValuesUpdate
void onDocValuesUpdate(FieldInfo info, DocValuesFieldUpdates.Iterator iterator) throws java.io.IOException
Called for every field update for the given field at flush time- Parameters:
info- the field info of the field that's updatediterator- the values to apply- Throws:
java.io.IOException
-
numDeletesToMerge
int numDeletesToMerge(MergePolicy policy, IOSupplier<CodecReader> readerIOSupplier) throws java.io.IOException
- Throws:
java.io.IOException
-
needsRefresh
final boolean needsRefresh(CodecReader reader)
Returns true if the given reader needs to be refreshed in order to see the latest deletes
-
getDelCount
final int getDelCount()
Returns the number of deleted docs in the segment.
-
numDocs
final int numDocs()
Returns the number of live documents in this segment
-
verifyDocCounts
boolean verifyDocCounts(CodecReader reader)
-
mustInitOnDelete
boolean mustInitOnDelete()
Returnstrueif we have to initialize this PendingDeletes beforedelete(int); otherwise this PendingDeletes is ready to accept deletes. A PendingDeletes can be initialized by providing it a reader viaonNewReader(CodecReader, SegmentCommitInfo).
-
-