java.lang.Object
org.apache.lucene.index.DocumentsWriterPerThread
- All Implemented Interfaces:
Accountable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private Throwable
(package private) final Codec
private int[]
(package private) final DocumentsWriterDeleteQueue
private final DocumentsWriterDeleteQueue.DeleteSlice
(package private) final TrackingDirectoryWrapper
private final boolean
private final FieldInfos.Builder
private final IndexingChain
private final LiveIndexWriterConfig
private static final boolean
private final InfoStream
private long
private final ReentrantLock
private final NumberFormat
private int
private int
private final AtomicLong
private final BufferedUpdates
private final SegmentInfo
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE
-
Constructor Summary
ConstructorsConstructorDescriptionDocumentsWriterPerThread
(int indexVersionCreated, String segmentName, Directory directoryOrig, Directory directory, LiveIndexWriterConfig indexWriterConfig, DocumentsWriterDeleteQueue deleteQueue, FieldInfos.Builder fieldInfos, AtomicLong pendingNumDocs, boolean enableTestPoints) -
Method Summary
Modifier and TypeMethodDescription(package private) void
abort()
Called if we hit an exception at a bad time (when updating the index files) and must discard all currently buffered docs.(package private) void
commitLastBytesUsed
(long delta) Commits the currentramBytesUsed()
and stores it's value for later reuse.private void
deleteLastDocs
(int docCount) private long
finishDocuments
(DocumentsWriterDeleteQueue.Node<?> deleteNode, int docIdUpTo) (package private) DocumentsWriterPerThread.FlushedSegment
flush
(DocumentsWriter.FlushNotifications flushNotifications) Flush all pending docs to a new segmentReturns nested resources of this class.(package private) long
Calculates the delta between the last committed bytes used and the currently used ram.(package private) long
Returns the last committed bytes for this DWPT.int
Returns the number of RAM resident documents in thisDocumentsWriterPerThread
(package private) SegmentInfo
Get current segment info we are writing.(package private) boolean
Returnstrue
iff this DWPT has been flushed(package private) final boolean
(package private) boolean
Returns true iff this DWPT is marked as flush pending(package private) boolean
Returns true if the DWPT's lock is held by the current thread(package private) void
lock()
Locks this DWPT for exclusive access.private void
maybeAbort
(String location, DocumentsWriter.FlushNotifications flushNotifications) private void
onAbortingException
(Throwable throwable) (package private) FrozenBufferedUpdates
Prepares this DWPT for flushing.long
Return the memory usage of this object in bytes.private void
Anything that will add N docs to the index should reserve first to make sure it's allowed.(package private) void
sealFlushedSegment
(DocumentsWriterPerThread.FlushedSegment flushedSegment, Sorter.DocMap sortMap, DocumentsWriter.FlushNotifications flushNotifications) Seals theSegmentInfo
for the new flushed segment and persists the deleted documentsFixedBitSet
.(package private) void
Sets this DWPT as flush pending.private FixedBitSet
sortLiveDocs
(Bits liveDocs, Sorter.DocMap sortMap) (package private) final void
toString()
(package private) boolean
tryLock()
Acquires the DWPT's lock only if it is not held by another thread at the time of invocation.(package private) void
unlock()
Unlocks the DWPT's lock(package private) long
updateDocuments
(Iterable<? extends Iterable<? extends IndexableField>> docs, DocumentsWriterDeleteQueue.Node<?> deleteNode, DocumentsWriter.FlushNotifications flushNotifications, Runnable onNewDocOnRAM)
-
Field Details
-
abortingException
-
INFO_VERBOSE
private static final boolean INFO_VERBOSE- See Also:
-
codec
-
directory
-
indexingChain
-
pendingUpdates
-
segmentInfo
-
aborted
private boolean aborted -
flushPending
-
lastCommittedBytesUsed
private volatile long lastCommittedBytesUsed -
hasFlushed
-
fieldInfos
-
infoStream
-
numDocsInRAM
private int numDocsInRAM -
deleteQueue
-
deleteSlice
-
nf
-
pendingNumDocs
-
indexWriterConfig
-
enableTestPoints
private final boolean enableTestPoints -
lock
-
deleteDocIDs
private int[] deleteDocIDs -
numDeletedDocIds
private int numDeletedDocIds -
filesToDelete
-
-
Constructor Details
-
DocumentsWriterPerThread
DocumentsWriterPerThread(int indexVersionCreated, String segmentName, Directory directoryOrig, Directory directory, LiveIndexWriterConfig indexWriterConfig, DocumentsWriterDeleteQueue deleteQueue, FieldInfos.Builder fieldInfos, AtomicLong pendingNumDocs, boolean enableTestPoints)
-
-
Method Details
-
onAbortingException
-
isAborted
final boolean isAborted() -
abort
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:
IOException
-
testPoint
-
reserveOneDoc
private void reserveOneDoc()Anything that will add N docs to the index should reserve first to make sure it's allowed. -
updateDocuments
long updateDocuments(Iterable<? extends Iterable<? extends IndexableField>> docs, DocumentsWriterDeleteQueue.Node<?> deleteNode, DocumentsWriter.FlushNotifications flushNotifications, Runnable onNewDocOnRAM) throws IOException - Throws:
IOException
-
finishDocuments
-
deleteLastDocs
private void deleteLastDocs(int docCount) -
getNumDocsInRAM
public int getNumDocsInRAM()Returns the number of RAM resident documents in thisDocumentsWriterPerThread
-
prepareFlush
FrozenBufferedUpdates prepareFlush()Prepares this DWPT for flushing. This method will freeze and return theDocumentsWriterDeleteQueue
s global buffer and apply all pending deletes to this DWPT. -
flush
DocumentsWriterPerThread.FlushedSegment flush(DocumentsWriter.FlushNotifications flushNotifications) throws IOException Flush all pending docs to a new segment- Throws:
IOException
-
maybeAbort
private void maybeAbort(String location, DocumentsWriter.FlushNotifications flushNotifications) throws IOException - Throws:
IOException
-
pendingFilesToDelete
-
sortLiveDocs
-
sealFlushedSegment
void sealFlushedSegment(DocumentsWriterPerThread.FlushedSegment flushedSegment, Sorter.DocMap sortMap, DocumentsWriter.FlushNotifications flushNotifications) throws IOException Seals theSegmentInfo
for the new flushed segment and persists the deleted documentsFixedBitSet
.- Throws:
IOException
-
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 interfaceAccountable
-
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 interfaceAccountable
- See Also:
-
toString
-
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 currentramBytesUsed()
and stores it's value for later reuse. The last committed bytes used can be retrieved viagetLastCommittedBytesUsed()
-
getCommitLastBytesUsedDelta
long getCommitLastBytesUsedDelta()Calculates the delta between the last committed bytes used and the currently used ram.- Returns:
- the delta between the current
ramBytesUsed()
and the currentgetLastCommittedBytesUsed()
- See Also:
-
lock
void lock()Locks this DWPT for exclusive access.- See Also:
-
tryLock
boolean tryLock()Acquires the DWPT's lock only if it is not held by another thread at the time of invocation.- Returns:
- true if the lock was acquired.
- See Also:
-
isHeldByCurrentThread
boolean isHeldByCurrentThread()Returns true if the DWPT's lock is held by the current thread- See Also:
-
unlock
void unlock()Unlocks the DWPT's lock- See Also:
-
hasFlushed
boolean hasFlushed()Returnstrue
iff this DWPT has been flushed
-