java.lang.Object
org.apache.lucene.index.DocumentsWriterPerThread
- All Implemented Interfaces:
Lock,Accountable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate Throwable(package private) final Codecprivate int[](package private) final DocumentsWriterDeleteQueueprivate final DocumentsWriterDeleteQueue.DeleteSlice(package private) final TrackingDirectoryWrapperprivate final booleanprivate final FieldInfos.Builderprivate final IndexingChainprivate final LiveIndexWriterConfigprivate static final booleanprivate final InfoStreamprivate longprivate final ReentrantLockprivate final NumberFormatprivate intprivate intprivate final IndexingChain.ReservedField<NumericDocValuesField> private final AtomicLongprivate final BufferedUpdatesprivate final SegmentInfoFields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE -
Constructor Summary
ConstructorsConstructorDescriptionDocumentsWriterPerThread(int indexMajorVersionCreated, String segmentName, Directory directoryOrig, Directory directory, LiveIndexWriterConfig indexWriterConfig, DocumentsWriterDeleteQueue deleteQueue, FieldInfos.Builder fieldInfos, AtomicLong pendingNumDocs, boolean enableTestPoints) -
Method Summary
Modifier and TypeMethodDescription(package private) voidabort()Called if we hit an exception at a bad time (when updating the index files) and must discard all currently buffered docs.private Iterable<? extends IndexableField> addParentField(Iterable<? extends IndexableField> doc, IndexableField parentField) (package private) voidcommitLastBytesUsed(long delta) Commits the currentramBytesUsed()and stores it's value for later reuse.private voiddeleteLastDocs(int docCount) private longfinishDocuments(DocumentsWriterDeleteQueue.Node<?> deleteNode, int docIdUpTo) (package private) DocumentsWriterPerThread.FlushedSegmentflush(DocumentsWriter.FlushNotifications flushNotifications) Flush all pending docs to a new segmentReturns nested resources of this class.(package private) longCalculates the delta between the last committed bytes used and the currently used ram.(package private) longReturns the last committed bytes for this DWPT.intReturns the number of RAM resident documents in thisDocumentsWriterPerThread(package private) SegmentInfoGet current segment info we are writing.(package private) booleanReturnstrueiff this DWPT has been flushed(package private) final boolean(package private) booleanReturns true iff this DWPT is marked as flush pending(package private) booleanReturns true if the DWPT's lock is held by the current threadvoidlock()voidprivate voidmaybeAbort(String location, DocumentsWriter.FlushNotifications flushNotifications) private voidonAbortingException(Throwable throwable) (package private) FrozenBufferedUpdatesPrepares this DWPT for flushing.longReturn the memory usage of this object in bytes.private voidAnything that will add N docs to the index should reserve first to make sure it's allowed.(package private) voidsealFlushedSegment(DocumentsWriterPerThread.FlushedSegment flushedSegment, Sorter.DocMap sortMap, DocumentsWriter.FlushNotifications flushNotifications) Seals theSegmentInfofor the new flushed segment and persists the deleted documentsFixedBitSet.(package private) voidSets this DWPT as flush pending.private FixedBitSetsortLiveDocs(Bits liveDocs, Sorter.DocMap sortMap) (package private) final voidtoString()booleantryLock()booleanvoidunlock()(package private) longupdateDocuments(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 -
parentField
-
filesToDelete
-
-
Constructor Details
-
DocumentsWriterPerThread
DocumentsWriterPerThread(int indexMajorVersionCreated, 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
-
addParentField
private Iterable<? extends IndexableField> addParentField(Iterable<? extends IndexableField> doc, IndexableField parentField) -
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 theDocumentsWriterDeleteQueues 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 theSegmentInfofor 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:AccountableReturn the memory usage of this object in bytes. Negative values are illegal.- Specified by:
ramBytesUsedin interfaceAccountable
-
getChildResources
Description copied from interface:AccountableReturns nested resources of this class. The result should be a point-in-time snapshot (to avoid race conditions).- Specified by:
getChildResourcesin 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
public void lock() -
lockInterruptibly
- Specified by:
lockInterruptiblyin interfaceLock- Throws:
InterruptedException
-
tryLock
public boolean tryLock() -
tryLock
- Specified by:
tryLockin interfaceLock- Throws:
InterruptedException
-
isHeldByCurrentThread
boolean isHeldByCurrentThread()Returns true if the DWPT's lock is held by the current thread- See Also:
-
unlock
public void unlock() -
newCondition
- Specified by:
newConditionin interfaceLock
-
hasFlushed
boolean hasFlushed()Returnstrueiff this DWPT has been flushed
-