- Direct Known Subclasses:
FlushByRamOrCountsPolicy
FlushPolicy
controls when segments are flushed from a RAM resident internal
data-structure to the IndexWriter
s Directory
.
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 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 DocumentsWriterPerThread
and
DocumentsWriterFlushControl
, the FlushPolicy
decides if a DocumentsWriterPerThread
needs flushing and mark it as flush-pending via DocumentsWriterFlushControl.setFlushPending(org.apache.lucene.index.DocumentsWriterPerThread)
, or if deletes need to be applied.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
protected DocumentsWriterPerThread
findLargestNonPendingWriter
(DocumentsWriterFlushControl control, DocumentsWriterPerThread perThread) Returns the current most RAM consuming non-pendingDocumentsWriterPerThread
with at least one indexed document.protected void
init
(LiveIndexWriterConfig indexWriterConfig) Called by DocumentsWriter to initialize the FlushPolicyabstract void
onDelete
(DocumentsWriterFlushControl control, DocumentsWriterPerThread perThread) Called for each delete term.abstract void
onInsert
(DocumentsWriterFlushControl control, DocumentsWriterPerThread perThread) Called for each document addition on the givenDocumentsWriterPerThread
sDocumentsWriterPerThread
.void
onUpdate
(DocumentsWriterFlushControl control, DocumentsWriterPerThread perThread) Called for each document update on the givenDocumentsWriterPerThread
'sDocumentsWriterPerThread
.
-
Field Details
-
indexWriterConfig
-
infoStream
-
-
Constructor Details
-
FlushPolicy
FlushPolicy()
-
-
Method Details
-
onDelete
public abstract void onDelete(DocumentsWriterFlushControl control, DocumentsWriterPerThread perThread) Called for each delete term. If this is a delete triggered due to an update the givenDocumentsWriterPerThread
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 givenDocumentsWriterPerThread
-
onUpdate
Called for each document update on the givenDocumentsWriterPerThread
'sDocumentsWriterPerThread
.Note: This method is called synchronized on the given
DocumentsWriterFlushControl
and it is guaranteed that the calling thread holds the lock on the givenDocumentsWriterPerThread
-
onInsert
public abstract void onInsert(DocumentsWriterFlushControl control, DocumentsWriterPerThread perThread) Called for each document addition on the givenDocumentsWriterPerThread
sDocumentsWriterPerThread
.Note: This method is synchronized by the given
DocumentsWriterFlushControl
and it is guaranteed that the calling thread holds the lock on the givenDocumentsWriterPerThread
-
init
Called by DocumentsWriter to initialize the FlushPolicy -
findLargestNonPendingWriter
protected DocumentsWriterPerThread findLargestNonPendingWriter(DocumentsWriterFlushControl control, DocumentsWriterPerThread perThread) Returns the current most RAM consuming non-pendingDocumentsWriterPerThread
with at least one indexed document.This method will never return
null
-
assertMessage
-