class FlushByRamOrCountsPolicy extends FlushPolicy
FlushPolicy
implementation that flushes new segments based on
RAM used and document count depending on the IndexWriter's
IndexWriterConfig
. It also applies pending deletes based on the
number of buffered delete terms.
onDelete(DocumentsWriterFlushControl, DocumentsWriterPerThreadPool.ThreadState)
- applies pending delete operations based on the global number of buffered
delete terms if the consumed memory is greater than IndexWriterConfig.getRAMBufferSizeMB()
onInsert(DocumentsWriterFlushControl, DocumentsWriterPerThreadPool.ThreadState)
- flushes either on the number of documents per
DocumentsWriterPerThread
(
DocumentsWriterPerThread.getNumDocsInRAM()
) or on the global active
memory consumption in the current indexing session iff
IndexWriterConfig.getMaxBufferedDocs()
or
IndexWriterConfig.getRAMBufferSizeMB()
is enabled respectivelyFlushPolicy.onUpdate(DocumentsWriterFlushControl, DocumentsWriterPerThreadPool.ThreadState)
- calls
onInsert(DocumentsWriterFlushControl, DocumentsWriterPerThreadPool.ThreadState)
and
onDelete(DocumentsWriterFlushControl, DocumentsWriterPerThreadPool.ThreadState)
in orderIndexWriterConfig
settings are used to mark
DocumentsWriterPerThread
as flush pending during indexing with
respect to their live updates.
If IndexWriterConfig.setRAMBufferSizeMB(double)
is enabled, the
largest ram consuming DocumentsWriterPerThread
will be marked as
pending iff the global active RAM consumption is >=
the configured max RAM
buffer.
indexWriterConfig, infoStream
Constructor and Description |
---|
FlushByRamOrCountsPolicy() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
flushOnDocCount()
Returns
true if this FlushPolicy flushes on
IndexWriterConfig.getMaxBufferedDocs() , otherwise
false . |
protected boolean |
flushOnRAM()
Returns
true if this FlushPolicy flushes on
IndexWriterConfig.getRAMBufferSizeMB() , otherwise
false . |
protected void |
markLargestWriterPending(DocumentsWriterFlushControl control,
DocumentsWriterPerThreadPool.ThreadState perThreadState,
long currentBytesPerThread)
Marks the most ram consuming active
DocumentsWriterPerThread flush
pending |
void |
onDelete(DocumentsWriterFlushControl control,
DocumentsWriterPerThreadPool.ThreadState state)
Called for each delete term.
|
void |
onInsert(DocumentsWriterFlushControl control,
DocumentsWriterPerThreadPool.ThreadState state)
Called for each document addition on the given
DocumentsWriterPerThreadPool.ThreadState s
DocumentsWriterPerThread . |
findLargestNonPendingWriter, init, onUpdate
public void onDelete(DocumentsWriterFlushControl control, DocumentsWriterPerThreadPool.ThreadState state)
FlushPolicy
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
onDelete
in class FlushPolicy
public void onInsert(DocumentsWriterFlushControl control, DocumentsWriterPerThreadPool.ThreadState state)
FlushPolicy
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
onInsert
in class FlushPolicy
protected void markLargestWriterPending(DocumentsWriterFlushControl control, DocumentsWriterPerThreadPool.ThreadState perThreadState, long currentBytesPerThread)
DocumentsWriterPerThread
flush
pendingprotected boolean flushOnDocCount()
true
if this FlushPolicy
flushes on
IndexWriterConfig.getMaxBufferedDocs()
, otherwise
false
.protected boolean flushOnRAM()
true
if this FlushPolicy
flushes on
IndexWriterConfig.getRAMBufferSizeMB()
, otherwise
false
.