Class FlushPolicy
- java.lang.Object
-
- org.apache.lucene.index.FlushPolicy
-
- Direct Known Subclasses:
FlushByRamOrCountsPolicy
abstract class FlushPolicy extends java.lang.ObjectFlushPolicycontrols when segments are flushed from a RAM resident internal data-structure to theIndexWritersDirectory.Segments are traditionally flushed by:
- RAM consumption - configured via
IndexWriterConfig.setRAMBufferSizeMB(double) - Number of RAM resident documents - configured via
IndexWriterConfig.setMaxBufferedDocs(int)
IndexWriterconsults the providedFlushPolicyto 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 viaDocumentsWriterPerThreadandDocumentsWriterFlushControl, theFlushPolicydecides if aDocumentsWriterPerThreadneeds flushing and mark it as flush-pending viaDocumentsWriterFlushControl.setFlushPending(org.apache.lucene.index.DocumentsWriterPerThread), or if deletes need to be applied.
-
-
Field Summary
Fields Modifier and Type Field Description protected LiveIndexWriterConfigindexWriterConfigprotected InfoStreaminfoStream
-
Constructor Summary
Constructors Constructor Description FlushPolicy()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private booleanassertMessage(java.lang.String s)protected DocumentsWriterPerThreadfindLargestNonPendingWriter(DocumentsWriterFlushControl control, DocumentsWriterPerThread perThread)Returns the current most RAM consuming non-pendingDocumentsWriterPerThreadwith at least one indexed document.protected voidinit(LiveIndexWriterConfig indexWriterConfig)Called by DocumentsWriter to initialize the FlushPolicyabstract voidonDelete(DocumentsWriterFlushControl control, DocumentsWriterPerThread perThread)Called for each delete term.abstract voidonInsert(DocumentsWriterFlushControl control, DocumentsWriterPerThread perThread)Called for each document addition on the givenDocumentsWriterPerThreadsDocumentsWriterPerThread.voidonUpdate(DocumentsWriterFlushControl control, DocumentsWriterPerThread perThread)Called for each document update on the givenDocumentsWriterPerThread'sDocumentsWriterPerThread.
-
-
-
Field Detail
-
indexWriterConfig
protected LiveIndexWriterConfig indexWriterConfig
-
infoStream
protected InfoStream infoStream
-
-
Method Detail
-
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 givenDocumentsWriterPerThreadis non-null.Note: This method is called synchronized on the given
DocumentsWriterFlushControland it is guaranteed that the calling thread holds the lock on the givenDocumentsWriterPerThread
-
onUpdate
public void onUpdate(DocumentsWriterFlushControl control, DocumentsWriterPerThread perThread)
Called for each document update on the givenDocumentsWriterPerThread'sDocumentsWriterPerThread.Note: This method is called synchronized on the given
DocumentsWriterFlushControland 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 givenDocumentsWriterPerThreadsDocumentsWriterPerThread.Note: This method is synchronized by the given
DocumentsWriterFlushControland it is guaranteed that the calling thread holds the lock on the givenDocumentsWriterPerThread
-
init
protected void init(LiveIndexWriterConfig indexWriterConfig)
Called by DocumentsWriter to initialize the FlushPolicy
-
findLargestNonPendingWriter
protected DocumentsWriterPerThread findLargestNonPendingWriter(DocumentsWriterFlushControl control, DocumentsWriterPerThread perThread)
Returns the current most RAM consuming non-pendingDocumentsWriterPerThreadwith at least one indexed document.This method will never return
null
-
assertMessage
private boolean assertMessage(java.lang.String s)
-
-