Class ReadersAndUpdates


  • final class ReadersAndUpdates
    extends java.lang.Object
    • Field Detail

      • refCount

        private final java.util.concurrent.atomic.AtomicInteger refCount
      • indexCreatedVersionMajor

        private final int indexCreatedVersionMajor
      • isMerging

        private boolean isMerging
      • pendingDVUpdates

        private final java.util.Map<java.lang.String,​java.util.List<DocValuesFieldUpdates>> pendingDVUpdates
      • mergingDVUpdates

        private final java.util.Map<java.lang.String,​java.util.List<DocValuesFieldUpdates>> mergingDVUpdates
      • ramBytesUsed

        final java.util.concurrent.atomic.AtomicLong ramBytesUsed
    • Constructor Detail

      • ReadersAndUpdates

        ReadersAndUpdates​(int indexCreatedVersionMajor,
                          SegmentReader reader,
                          PendingDeletes pendingDeletes)
                   throws java.io.IOException
        Init from a previously opened SegmentReader.

        NOTE: steals incoming ref from reader.

        Throws:
        java.io.IOException
    • Method Detail

      • incRef

        public void incRef()
      • decRef

        public void decRef()
      • refCount

        public int refCount()
      • getDelCount

        public int getDelCount()
      • addDVUpdate

        public void addDVUpdate​(DocValuesFieldUpdates update)
                         throws java.io.IOException
        Adds a new resolved (meaning it maps docIDs to new values) doc values packet. We buffer these in RAM and write to disk when too much RAM is used or when a merge needs to kick off, or a commit/refresh.
        Throws:
        java.io.IOException
      • getNumDVUpdates

        public long getNumDVUpdates()
      • release

        public void release​(SegmentReader sr)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • delete

        public boolean delete​(int docID)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • dropReaders

        public void dropReaders()
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • getReadOnlyClone

        public SegmentReader getReadOnlyClone​(IOContext context)
                                       throws java.io.IOException
        Returns a ref to a clone. NOTE: you should decRef() the reader when you're done (ie do not call close()).
        Throws:
        java.io.IOException
      • numDeletesToMerge

        int numDeletesToMerge​(MergePolicy policy)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • getLatestReader

        private CodecReader getLatestReader()
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • getLiveDocs

        public Bits getLiveDocs()
        Returns a snapshot of the live docs.
      • getHardLiveDocs

        public Bits getHardLiveDocs()
        Returns the live-docs bits excluding documents that are not live due to soft-deletes
      • dropChanges

        public void dropChanges()
      • writeLiveDocs

        public boolean writeLiveDocs​(Directory dir)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • handleDVUpdates

        private void handleDVUpdates​(FieldInfos infos,
                                     Directory dir,
                                     DocValuesFormat dvFormat,
                                     SegmentReader reader,
                                     java.util.Map<java.lang.Integer,​java.util.Set<java.lang.String>> fieldFiles,
                                     long maxDelGen,
                                     InfoStream infoStream)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • writeFieldInfosGen

        private java.util.Set<java.lang.String> writeFieldInfosGen​(FieldInfos fieldInfos,
                                                                   Directory dir,
                                                                   FieldInfosFormat infosFormat)
                                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • createNewReaderWithLatestLiveDocs

        private SegmentReader createNewReaderWithLatestLiveDocs​(SegmentReader reader)
                                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • swapNewReaderWithLatestLiveDocs

        private void swapNewReaderWithLatestLiveDocs()
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • setIsMerging

        void setIsMerging()
      • isMerging

        boolean isMerging()
      • dropMergingUpdates

        public void dropMergingUpdates()
        Drops all merging updates. Called from IndexWriter after this segment finished merging (whether successfully or not).
      • getMergingDVUpdates

        public java.util.Map<java.lang.String,​java.util.List<DocValuesFieldUpdates>> getMergingDVUpdates()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isFullyDeleted

        public boolean isFullyDeleted()
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • keepFullyDeletedSegment

        boolean keepFullyDeletedSegment​(MergePolicy mergePolicy)
                                 throws java.io.IOException
        Throws:
        java.io.IOException