Class PendingDeletes

java.lang.Object
org.apache.lucene.index.PendingDeletes
Direct Known Subclasses:
PendingSoftDeletes

class PendingDeletes extends Object
This class handles accounting and applying pending deletes for live segment readers
  • Field Details

    • info

      protected final SegmentCommitInfo info
    • liveDocs

      private Bits liveDocs
    • writeableLiveDocs

      private FixedBitSet writeableLiveDocs
    • pendingDeleteCount

      protected int pendingDeleteCount
    • liveDocsInitialized

      boolean liveDocsInitialized
  • Constructor Details

  • Method Details

    • getMutableBits

      protected FixedBitSet getMutableBits()
    • delete

      boolean delete(int docID) throws IOException
      Marks a document as deleted in this segment and return true if a document got actually deleted or if the document was already deleted.
      Throws:
      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 IOException
      Called once a new reader is opened for this segment ie. when deletes or updates are applied.
      Throws:
      IOException
    • assertCheckLiveDocs

      private boolean assertCheckLiveDocs(Bits bits, int expectedLength, int expectedDeleteCount)
    • dropChanges

      void dropChanges()
      Resets the pending docs
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • writeLiveDocs

      boolean writeLiveDocs(Directory dir) throws IOException
      Writes the live docs to disk and returns true if any new docs were written.
      Throws:
      IOException
    • isFullyDeleted

      boolean isFullyDeleted(IOSupplier<CodecReader> readerIOSupplier) throws IOException
      Returns true iff the segment represented by this PendingDeletes is fully deleted
      Throws:
      IOException
    • onDocValuesUpdate

      void onDocValuesUpdate(FieldInfo info, DocValuesFieldUpdates.Iterator iterator) throws IOException
      Called for every field update for the given field at flush time
      Parameters:
      info - the field info of the field that's updated
      iterator - the values to apply
      Throws:
      IOException
    • numDeletesToMerge

      int numDeletesToMerge(MergePolicy policy, IOSupplier<CodecReader> readerIOSupplier) throws IOException
      Throws:
      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()
      Returns true if we have to initialize this PendingDeletes before delete(int); otherwise this PendingDeletes is ready to accept deletes. A PendingDeletes can be initialized by providing it a reader via onNewReader(CodecReader, SegmentCommitInfo).