Package org.apache.lucene.index
Class FrozenBufferedUpdates
- java.lang.Object
-
- org.apache.lucene.index.FrozenBufferedUpdates
-
final class FrozenBufferedUpdates extends java.lang.Object
Holds buffered deletes and updates by term or query, once pushed. Pushed deletes/updates are write-once, so we shift to more memory efficient data structure to hold them. We don't hold docIDs because these are applied on flush.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
FrozenBufferedUpdates.TermDocsIterator
This class helps iterating a term dictionary and consuming all the docs for each terms.
-
Field Summary
Fields Modifier and Type Field Description java.util.concurrent.CountDownLatch
applied
Counts down once all deletes/updates have been appliedprivate java.util.concurrent.locks.ReentrantLock
applyLock
(package private) static int
BYTES_PER_DEL_QUERY
(package private) int
bytesUsed
(package private) Query[]
deleteQueries
(package private) int[]
deleteQueryLimits
(package private) PrefixCodedTerms
deleteTerms
private long
delGen
private java.util.Map<java.lang.String,FieldUpdatesBuffer>
fieldUpdates
private int
fieldUpdatesCount
private InfoStream
infoStream
(package private) int
numTermDeletes
(package private) SegmentCommitInfo
privateSegment
long
totalDelCount
How many total documents were deleted/updated.
-
Constructor Summary
Constructors Constructor Description FrozenBufferedUpdates(InfoStream infoStream, BufferedUpdates updates, SegmentCommitInfo privateSegment)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) boolean
any()
private long
apply(BufferedUpdatesStream.SegmentState[] segStates)
Applies pending delete-by-term, delete-by-query and doc values updates to all segments in the index, returning the number of new deleted or updated documents.private long
applyDocValuesUpdates(BufferedUpdatesStream.SegmentState[] segStates)
private static long
applyDocValuesUpdates(BufferedUpdatesStream.SegmentState segState, java.util.Map<java.lang.String,FieldUpdatesBuffer> updates, long delGen, boolean segmentPrivateDeletes)
private long
applyQueryDeletes(BufferedUpdatesStream.SegmentState[] segStates)
private long
applyTermDeletes(BufferedUpdatesStream.SegmentState[] segStates)
static BufferedUpdatesStream.ApplyDeletesResult
closeSegmentStates(IndexWriter writer, BufferedUpdatesStream.SegmentState[] segStates, boolean success)
Close segment states previously opened with openSegmentStates.long
delGen()
private void
finishApply(IndexWriter writer, BufferedUpdatesStream.SegmentState[] segStates, boolean success, java.util.Set<java.lang.String> delFiles)
(package private) void
forceApply(IndexWriter writer)
Translates a frozen packet of delete term/query, or doc values updates, into their actual docIDs in the index, and applies the change.private java.util.List<SegmentCommitInfo>
getInfosToApply(IndexWriter writer)
Returns theSegmentCommitInfo
that this packet is supposed to apply its deletes to, or null if the private segment was already merged away.private static BufferedUpdatesStream.SegmentState[]
openSegmentStates(IndexWriter writer, java.util.List<SegmentCommitInfo> infos, java.util.Set<SegmentCommitInfo> alreadySeenSegments, long delGen)
Opens SegmentReader and inits SegmentState for each segment.void
setDelGen(long delGen)
java.lang.String
toString()
(package private) boolean
tryApply(IndexWriter writer)
Translates a frozen packet of delete term/query, or doc values updates, into their actual docIDs in the index, and applies the change.
-
-
-
Field Detail
-
BYTES_PER_DEL_QUERY
static final int BYTES_PER_DEL_QUERY
-
deleteTerms
final PrefixCodedTerms deleteTerms
-
deleteQueries
final Query[] deleteQueries
-
deleteQueryLimits
final int[] deleteQueryLimits
-
applied
public final java.util.concurrent.CountDownLatch applied
Counts down once all deletes/updates have been applied
-
applyLock
private final java.util.concurrent.locks.ReentrantLock applyLock
-
fieldUpdates
private final java.util.Map<java.lang.String,FieldUpdatesBuffer> fieldUpdates
-
totalDelCount
public long totalDelCount
How many total documents were deleted/updated.
-
fieldUpdatesCount
private final int fieldUpdatesCount
-
bytesUsed
final int bytesUsed
-
numTermDeletes
final int numTermDeletes
-
delGen
private long delGen
-
privateSegment
final SegmentCommitInfo privateSegment
-
infoStream
private final InfoStream infoStream
-
-
Constructor Detail
-
FrozenBufferedUpdates
public FrozenBufferedUpdates(InfoStream infoStream, BufferedUpdates updates, SegmentCommitInfo privateSegment)
-
-
Method Detail
-
getInfosToApply
private java.util.List<SegmentCommitInfo> getInfosToApply(IndexWriter writer)
Returns theSegmentCommitInfo
that this packet is supposed to apply its deletes to, or null if the private segment was already merged away.
-
tryApply
boolean tryApply(IndexWriter writer) throws java.io.IOException
Translates a frozen packet of delete term/query, or doc values updates, into their actual docIDs in the index, and applies the change. This is a heavy operation and is done concurrently by incoming indexing threads. This method will return immediately without blocking if another thread is currently applying the package. In order to ensure the packet has been applied,forceApply(IndexWriter)
must be called.- Throws:
java.io.IOException
-
forceApply
void forceApply(IndexWriter writer) throws java.io.IOException
Translates a frozen packet of delete term/query, or doc values updates, into their actual docIDs in the index, and applies the change. This is a heavy operation and is done concurrently by incoming indexing threads.- Throws:
java.io.IOException
-
openSegmentStates
private static BufferedUpdatesStream.SegmentState[] openSegmentStates(IndexWriter writer, java.util.List<SegmentCommitInfo> infos, java.util.Set<SegmentCommitInfo> alreadySeenSegments, long delGen) throws java.io.IOException
Opens SegmentReader and inits SegmentState for each segment.- Throws:
java.io.IOException
-
closeSegmentStates
public static BufferedUpdatesStream.ApplyDeletesResult closeSegmentStates(IndexWriter writer, BufferedUpdatesStream.SegmentState[] segStates, boolean success) throws java.io.IOException
Close segment states previously opened with openSegmentStates.- Throws:
java.io.IOException
-
finishApply
private void finishApply(IndexWriter writer, BufferedUpdatesStream.SegmentState[] segStates, boolean success, java.util.Set<java.lang.String> delFiles) throws java.io.IOException
- Throws:
java.io.IOException
-
apply
private long apply(BufferedUpdatesStream.SegmentState[] segStates) throws java.io.IOException
Applies pending delete-by-term, delete-by-query and doc values updates to all segments in the index, returning the number of new deleted or updated documents.- Throws:
java.io.IOException
-
applyDocValuesUpdates
private long applyDocValuesUpdates(BufferedUpdatesStream.SegmentState[] segStates) throws java.io.IOException
- Throws:
java.io.IOException
-
applyDocValuesUpdates
private static long applyDocValuesUpdates(BufferedUpdatesStream.SegmentState segState, java.util.Map<java.lang.String,FieldUpdatesBuffer> updates, long delGen, boolean segmentPrivateDeletes) throws java.io.IOException
- Throws:
java.io.IOException
-
applyQueryDeletes
private long applyQueryDeletes(BufferedUpdatesStream.SegmentState[] segStates) throws java.io.IOException
- Throws:
java.io.IOException
-
applyTermDeletes
private long applyTermDeletes(BufferedUpdatesStream.SegmentState[] segStates) throws java.io.IOException
- Throws:
java.io.IOException
-
setDelGen
public void setDelGen(long delGen)
-
delGen
public long delGen()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
any
boolean any()
-
-