abstract class FlushPolicy
extends java.lang.Object
FlushPolicy
controls when segments are flushed from a RAM resident
internal data-structure to the IndexWriter
s Directory
.
Segments are traditionally flushed by:
IndexWriterConfig.setRAMBufferSizeMB(double)
IndexWriterConfig.setMaxBufferedDocs(int)
IndexWriter
consults the provided FlushPolicy
to control the
flushing process. The policy is informed for each added or updated document
as well as for each delete term. Based on the FlushPolicy
, the
information provided via DocumentsWriterPerThreadPool.ThreadState
and
DocumentsWriterFlushControl
, the FlushPolicy
decides if a
DocumentsWriterPerThread
needs flushing and mark it as flush-pending
via DocumentsWriterFlushControl.setFlushPending(org.apache.lucene.index.DocumentsWriterPerThreadPool.ThreadState)
, or if deletes need
to be applied.
Modifier and Type | Field and Description |
---|---|
protected LiveIndexWriterConfig |
indexWriterConfig |
protected InfoStream |
infoStream |
Constructor and Description |
---|
FlushPolicy() |
protected LiveIndexWriterConfig indexWriterConfig
protected InfoStream infoStream
public abstract void onDelete(DocumentsWriterFlushControl control, DocumentsWriterPerThreadPool.ThreadState state)
DocumentsWriterPerThreadPool.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 given DocumentsWriterPerThreadPool.ThreadState
public void onUpdate(DocumentsWriterFlushControl control, DocumentsWriterPerThreadPool.ThreadState state)
DocumentsWriterPerThreadPool.ThreadState
's
DocumentsWriterPerThread
.
Note: This method is called synchronized on the given
DocumentsWriterFlushControl
and it is guaranteed that the calling
thread holds the lock on the given DocumentsWriterPerThreadPool.ThreadState
public abstract void onInsert(DocumentsWriterFlushControl control, DocumentsWriterPerThreadPool.ThreadState state)
DocumentsWriterPerThreadPool.ThreadState
s
DocumentsWriterPerThread
.
Note: This method is synchronized by the given
DocumentsWriterFlushControl
and it is guaranteed that the calling
thread holds the lock on the given DocumentsWriterPerThreadPool.ThreadState
protected void init(LiveIndexWriterConfig indexWriterConfig)
protected DocumentsWriterPerThreadPool.ThreadState findLargestNonPendingWriter(DocumentsWriterFlushControl control, DocumentsWriterPerThreadPool.ThreadState perThreadState)
DocumentsWriterPerThreadPool.ThreadState
with
at least one indexed document.
This method will never return null
private boolean assertMessage(java.lang.String s)