Class DocumentsWriterPerThread

  • All Implemented Interfaces:
    java.util.concurrent.locks.Lock, Accountable

    final class DocumentsWriterPerThread
    extends java.lang.Object
    implements Accountable, java.util.concurrent.locks.Lock
    • Field Detail

      • abortingException

        private java.lang.Throwable abortingException
      • codec

        final Codec codec
      • aborted

        private boolean aborted
      • flushPending

        private SetOnce<java.lang.Boolean> flushPending
      • lastCommittedBytesUsed

        private volatile long lastCommittedBytesUsed
      • hasFlushed

        private SetOnce<java.lang.Boolean> hasFlushed
      • numDocsInRAM

        private int numDocsInRAM
      • nf

        private final java.text.NumberFormat nf
      • pendingNumDocs

        private final java.util.concurrent.atomic.AtomicLong pendingNumDocs
      • enableTestPoints

        private final boolean enableTestPoints
      • lock

        private final java.util.concurrent.locks.ReentrantLock lock
      • deleteDocIDs

        private int[] deleteDocIDs
      • numDeletedDocIds

        private int numDeletedDocIds
      • filesToDelete

        private final java.util.Set<java.lang.String> filesToDelete
    • Method Detail

      • onAbortingException

        private void onAbortingException​(java.lang.Throwable throwable)
      • isAborted

        final boolean isAborted()
      • abort

        void abort()
            throws java.io.IOException
        Called if we hit an exception at a bad time (when updating the index files) and must discard all currently buffered docs. This resets our state, discarding any docs added since last flush.
        Throws:
        java.io.IOException
      • testPoint

        final void testPoint​(java.lang.String message)
      • reserveOneDoc

        private void reserveOneDoc()
        Anything that will add N docs to the index should reserve first to make sure it's allowed.
      • deleteLastDocs

        private void deleteLastDocs​(int docCount)
      • getNumDocsInRAM

        public int getNumDocsInRAM()
        Returns the number of RAM resident documents in this DocumentsWriterPerThread
      • maybeAbort

        private void maybeAbort​(java.lang.String location,
                                DocumentsWriter.FlushNotifications flushNotifications)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • pendingFilesToDelete

        java.util.Set<java.lang.String> pendingFilesToDelete()
      • getSegmentInfo

        SegmentInfo getSegmentInfo()
        Get current segment info we are writing.
      • ramBytesUsed

        public long ramBytesUsed()
        Description copied from interface: Accountable
        Return the memory usage of this object in bytes. Negative values are illegal.
        Specified by:
        ramBytesUsed in interface Accountable
      • getChildResources

        public java.util.Collection<Accountable> getChildResources()
        Description copied from interface: Accountable
        Returns nested resources of this class. The result should be a point-in-time snapshot (to avoid race conditions).
        Specified by:
        getChildResources in interface Accountable
        See Also:
        Accountables
      • toString

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

        boolean isFlushPending()
        Returns true iff this DWPT is marked as flush pending
      • setFlushPending

        void setFlushPending()
        Sets this DWPT as flush pending. This can only be set once.
      • getLastCommittedBytesUsed

        long getLastCommittedBytesUsed()
        Returns the last committed bytes for this DWPT. This method can be called without acquiring the DWPTs lock.
      • commitLastBytesUsed

        void commitLastBytesUsed​(long delta)
        Commits the current ramBytesUsed() and stores it's value for later reuse. The last committed bytes used can be retrieved via getLastCommittedBytesUsed()
      • lock

        public void lock()
        Specified by:
        lock in interface java.util.concurrent.locks.Lock
      • lockInterruptibly

        public void lockInterruptibly()
                               throws java.lang.InterruptedException
        Specified by:
        lockInterruptibly in interface java.util.concurrent.locks.Lock
        Throws:
        java.lang.InterruptedException
      • tryLock

        public boolean tryLock()
        Specified by:
        tryLock in interface java.util.concurrent.locks.Lock
      • tryLock

        public boolean tryLock​(long time,
                               java.util.concurrent.TimeUnit unit)
                        throws java.lang.InterruptedException
        Specified by:
        tryLock in interface java.util.concurrent.locks.Lock
        Throws:
        java.lang.InterruptedException
      • isHeldByCurrentThread

        boolean isHeldByCurrentThread()
        Returns true if the DWPT's lock is held by the current thread
        See Also:
        ReentrantLock.isHeldByCurrentThread()
      • unlock

        public void unlock()
        Specified by:
        unlock in interface java.util.concurrent.locks.Lock
      • newCondition

        public java.util.concurrent.locks.Condition newCondition()
        Specified by:
        newCondition in interface java.util.concurrent.locks.Lock
      • hasFlushed

        boolean hasFlushed()
        Returns true iff this DWPT has been flushed