Class FlushPolicy
- java.lang.Object
-
- org.apache.lucene.index.FlushPolicy
-
- Direct Known Subclasses:
FlushByRamOrCountsPolicy
abstract class FlushPolicy extends java.lang.Object
FlushPolicy
controls when segments are flushed from a RAM resident internal data-structure to theIndexWriter
sDirectory
.Segments are traditionally flushed by:
- RAM consumption - configured via
IndexWriterConfig.setRAMBufferSizeMB(double)
- Number of RAM resident documents - configured via
IndexWriterConfig.setMaxBufferedDocs(int)
IndexWriter
consults the providedFlushPolicy
to control the flushing process. The policy is informed for each added or updated document as well as for each delete term. Based on theFlushPolicy
, the information provided viaDocumentsWriterPerThreadPool.ThreadState
andDocumentsWriterFlushControl
, theFlushPolicy
decides if aDocumentsWriterPerThread
needs flushing and mark it as flush-pending viaDocumentsWriterFlushControl.setFlushPending(org.apache.lucene.index.DocumentsWriterPerThreadPool.ThreadState)
, or if deletes need to be applied.
-
-
Field Summary
Fields Modifier and Type Field Description protected LiveIndexWriterConfig
indexWriterConfig
protected InfoStream
infoStream
-
Constructor Summary
Constructors Constructor Description FlushPolicy()
-
Method Summary
-
-
-
Field Detail
-
indexWriterConfig
protected LiveIndexWriterConfig indexWriterConfig
-
infoStream
protected InfoStream infoStream
-
-
Method Detail
-
onDelete
public abstract void onDelete(DocumentsWriterFlushControl control, DocumentsWriterPerThreadPool.ThreadState state)
Called for each delete term. If this is a delete triggered due to an update the givenDocumentsWriterPerThreadPool.ThreadState
is non-null.Note: This method is called synchronized on the given
DocumentsWriterFlushControl
and it is guaranteed that the calling thread holds the lock on the givenDocumentsWriterPerThreadPool.ThreadState
-
onUpdate
public void onUpdate(DocumentsWriterFlushControl control, DocumentsWriterPerThreadPool.ThreadState state)
Called for each document update on the givenDocumentsWriterPerThreadPool.ThreadState
'sDocumentsWriterPerThread
.Note: This method is called synchronized on the given
DocumentsWriterFlushControl
and it is guaranteed that the calling thread holds the lock on the givenDocumentsWriterPerThreadPool.ThreadState
-
onInsert
public abstract void onInsert(DocumentsWriterFlushControl control, DocumentsWriterPerThreadPool.ThreadState state)
Called for each document addition on the givenDocumentsWriterPerThreadPool.ThreadState
sDocumentsWriterPerThread
.Note: This method is synchronized by the given
DocumentsWriterFlushControl
and it is guaranteed that the calling thread holds the lock on the givenDocumentsWriterPerThreadPool.ThreadState
-
init
protected void init(LiveIndexWriterConfig indexWriterConfig)
Called by DocumentsWriter to initialize the FlushPolicy
-
findLargestNonPendingWriter
protected DocumentsWriterPerThreadPool.ThreadState findLargestNonPendingWriter(DocumentsWriterFlushControl control, DocumentsWriterPerThreadPool.ThreadState perThreadState)
Returns the current most RAM consuming non-pendingDocumentsWriterPerThreadPool.ThreadState
with at least one indexed document.This method will never return
null
-
assertMessage
private boolean assertMessage(java.lang.String s)
-
-