class BufferedUpdatesStream extends java.lang.Object implements Accountable
FrozenBufferedUpdates
.
When DocumentsWriterPerThread flushes, its buffered
deletes and updates are appended to this stream and immediately
resolved (to actual docIDs, per segment) using the indexing
thread that triggered the flush for concurrency. When a
merge kicks off, we sync to ensure all resolving packets
complete. We also apply to all segments when NRT reader is pulled,
commit/close is called, or when too many deletes or updates are
buffered and must be flushed (by RAM usage or by count).
Each packet is assigned a generation, and each flushed or
merged segment is also assigned a generation, so we can
track which BufferedDeletes packets to apply to any given
segment.Modifier and Type | Class and Description |
---|---|
static class |
BufferedUpdatesStream.ApplyDeletesResult |
private static class |
BufferedUpdatesStream.FinishedSegments
Tracks the contiguous range of packets that have finished resolving.
|
static class |
BufferedUpdatesStream.SegmentState
Holds all per-segment internal state used while resolving deletions.
|
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.atomic.AtomicLong |
bytesUsed |
private boolean |
closed |
private BufferedUpdatesStream.FinishedSegments |
finishedSegments |
private InfoStream |
infoStream |
private long |
nextGen |
private java.util.concurrent.atomic.AtomicInteger |
numTerms |
private java.util.Set<FrozenBufferedUpdates> |
updates |
private IndexWriter |
writer |
Constructor and Description |
---|
BufferedUpdatesStream(IndexWriter writer) |
Modifier and Type | Method and Description |
---|---|
boolean |
any() |
private boolean |
checkDeleteStats() |
void |
clear()
Only used by IW.rollback
|
BufferedUpdatesStream.ApplyDeletesResult |
closeSegmentStates(IndexWriter.ReaderPool pool,
BufferedUpdatesStream.SegmentState[] segStates,
boolean success)
Close segment states previously opened with openSegmentStates.
|
private void |
ensureOpen() |
void |
finished(FrozenBufferedUpdates packet)
Called by indexing threads once they are fully done resolving all deletes for the provided
delGen.
|
void |
finishedSegment(long delGen) |
long |
getCompletedDelGen()
All frozen packets up to and including this del gen are guaranteed to be finished.
|
(package private) long |
getNextGen() |
int |
getPendingUpdatesCount() |
int |
numTerms() |
BufferedUpdatesStream.SegmentState[] |
openSegmentStates(IndexWriter.ReaderPool pool,
java.util.List<SegmentCommitInfo> infos,
java.util.Set<SegmentCommitInfo> alreadySeenSegments,
long delGen)
Opens SegmentReader and inits SegmentState for each segment.
|
long |
push(FrozenBufferedUpdates packet) |
long |
ramBytesUsed()
Return the memory usage of this object in bytes.
|
boolean |
stillRunning(long delGen)
Returns true if this delGen is still running.
|
private void |
waitApply(java.util.Set<FrozenBufferedUpdates> waitFor) |
void |
waitApplyAll()
Waits for all in-flight packets, which are already being resolved concurrently
by indexing threads, to finish.
|
void |
waitApplyForMerge(java.util.List<SegmentCommitInfo> mergeInfos)
Waits only for those in-flight packets that apply to these merge segments.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getChildResources
private final java.util.Set<FrozenBufferedUpdates> updates
private long nextGen
private final BufferedUpdatesStream.FinishedSegments finishedSegments
private final InfoStream infoStream
private final java.util.concurrent.atomic.AtomicLong bytesUsed
private final java.util.concurrent.atomic.AtomicInteger numTerms
private final IndexWriter writer
private boolean closed
public BufferedUpdatesStream(IndexWriter writer)
public long push(FrozenBufferedUpdates packet)
public int getPendingUpdatesCount()
public void clear()
public boolean any()
public int numTerms()
public long ramBytesUsed()
Accountable
ramBytesUsed
in interface Accountable
private void ensureOpen()
public void waitApplyAll() throws java.io.IOException
java.io.IOException
public boolean stillRunning(long delGen)
public void finishedSegment(long delGen)
public void finished(FrozenBufferedUpdates packet)
public long getCompletedDelGen()
public void waitApplyForMerge(java.util.List<SegmentCommitInfo> mergeInfos) throws java.io.IOException
java.io.IOException
private void waitApply(java.util.Set<FrozenBufferedUpdates> waitFor) throws java.io.IOException
java.io.IOException
long getNextGen()
public BufferedUpdatesStream.SegmentState[] openSegmentStates(IndexWriter.ReaderPool pool, java.util.List<SegmentCommitInfo> infos, java.util.Set<SegmentCommitInfo> alreadySeenSegments, long delGen) throws java.io.IOException
java.io.IOException
public BufferedUpdatesStream.ApplyDeletesResult closeSegmentStates(IndexWriter.ReaderPool pool, BufferedUpdatesStream.SegmentState[] segStates, boolean success) throws java.io.IOException
java.io.IOException
private boolean checkDeleteStats()