Package org.apache.lucene.index
Class MergePolicy.OneMerge
- java.lang.Object
-
- org.apache.lucene.index.MergePolicy.OneMerge
-
- Enclosing class:
- MergePolicy
public static class MergePolicy.OneMerge extends java.lang.Object
OneMerge provides the information necessary to perform an individual primitive merge operation, resulting in a single new segment. The merge spec includes the subset of segments to be merged as well as whether the new segment should use the compound file format.
-
-
Field Summary
Fields Modifier and Type Field Description long
estimatedMergeBytes
Estimated size in bytes of the merged segment.java.util.List<SegmentCommitInfo>
segments
Segments to be merged.int
totalDocCount
Number of documents in the merged segment.
-
Constructor Summary
Constructors Constructor Description OneMerge(java.util.List<SegmentCommitInfo> segments)
Sole constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkAborted(Directory dir)
Called periodically byIndexWriter
while merging to see if the merge is aborted.MergePolicy.DocMap
getDocMap(MergeState mergeState)
Expert: IfgetMergeReaders()
reorders document IDs, this method must be overridden to return a mapping from the natural doc ID (the doc ID that would result from a natural merge) to the actual doc ID.MergeInfo
getMergeInfo()
ReturnMergeInfo
describing this merge.java.util.List<AtomicReader>
getMergeReaders()
Expert: Get the list of readers to merge.boolean
getPause()
Returns true if this merge is paused.java.lang.String
segString(Directory dir)
Returns a readable description of the current merge state.void
setInfo(SegmentCommitInfo info)
Expert: Sets theSegmentCommitInfo
of thisMergePolicy.OneMerge
.void
setPause(boolean paused)
Set or clear whether this merge is paused paused (for exampleConcurrentMergeScheduler
will pause merges if too many are running).long
totalBytesSize()
Returns the total size in bytes of this merge.int
totalNumDocs()
Returns the total number of documents that are included with this merge.
-
-
-
Field Detail
-
estimatedMergeBytes
public volatile long estimatedMergeBytes
Estimated size in bytes of the merged segment.
-
segments
public final java.util.List<SegmentCommitInfo> segments
Segments to be merged.
-
totalDocCount
public final int totalDocCount
Number of documents in the merged segment.
-
-
Constructor Detail
-
OneMerge
public OneMerge(java.util.List<SegmentCommitInfo> segments)
Sole constructor.- Parameters:
segments
- List ofSegmentCommitInfo
s to be merged.
-
-
Method Detail
-
getMergeReaders
public java.util.List<AtomicReader> getMergeReaders() throws java.io.IOException
Expert: Get the list of readers to merge. Note that this list does not necessarily match the list of segments to merge and should only be used to feed SegmentMerger to initialize a merge. When aMergePolicy.OneMerge
reorders doc IDs, it must overridegetDocMap(org.apache.lucene.index.MergeState)
too so that deletes that happened during the merge can be applied to the newly merged segment.- Throws:
java.io.IOException
-
setInfo
public void setInfo(SegmentCommitInfo info)
Expert: Sets theSegmentCommitInfo
of thisMergePolicy.OneMerge
. Allows sub-classes to e.g. set diagnostics properties.
-
getDocMap
public MergePolicy.DocMap getDocMap(MergeState mergeState)
Expert: IfgetMergeReaders()
reorders document IDs, this method must be overridden to return a mapping from the natural doc ID (the doc ID that would result from a natural merge) to the actual doc ID. This mapping is used to apply deletions that happened during the merge to the new segment.
-
checkAborted
public void checkAborted(Directory dir) throws MergePolicy.MergeAbortedException
Called periodically byIndexWriter
while merging to see if the merge is aborted.
-
setPause
public void setPause(boolean paused)
Set or clear whether this merge is paused paused (for exampleConcurrentMergeScheduler
will pause merges if too many are running).
-
getPause
public boolean getPause()
Returns true if this merge is paused.- See Also:
setPause(boolean)
-
segString
public java.lang.String segString(Directory dir)
Returns a readable description of the current merge state.
-
totalBytesSize
public long totalBytesSize() throws java.io.IOException
Returns the total size in bytes of this merge. Note that this does not indicate the size of the merged segment, but the input total size. This is only set once the merge is initialized by IndexWriter.- Throws:
java.io.IOException
-
totalNumDocs
public int totalNumDocs() throws java.io.IOException
Returns the total number of documents that are included with this merge. Note that this does not indicate the number of documents after the merge.- Throws:
java.io.IOException
-
-