public class

BalancedSegmentMergePolicy

extends LogByteSizeMergePolicy
java.lang.Object
   ↳ org.apache.lucene.index.MergePolicy
     ↳ org.apache.lucene.index.LogMergePolicy
       ↳ org.apache.lucene.index.LogByteSizeMergePolicy
         ↳ org.apache.lucene.index.BalancedSegmentMergePolicy

Class Overview

Merge policy that tries to balance not doing large segment merges with not accumulating too many segments in the index, to provide for better performance in near real-time setting.

This is based on code from zoie, described in more detail at http://code.google.com/p/zoie/wiki/ZoieMergePolicy.

Summary

Nested Classes
class BalancedSegmentMergePolicy.MergePolicyParams  
Constants
int DEFAULT_NUM_LARGE_SEGMENTS
[Expand]
Inherited Constants
From class org.apache.lucene.index.LogByteSizeMergePolicy
From class org.apache.lucene.index.LogMergePolicy
[Expand]
Inherited Fields
From class org.apache.lucene.index.LogMergePolicy
From class org.apache.lucene.index.MergePolicy
Public Constructors
BalancedSegmentMergePolicy()
Public Methods
MergePolicy.MergeSpecification findMerges(SegmentInfos infos)
Checks if any merges are now necessary and returns a MergePolicy.MergeSpecification if so.
MergePolicy.MergeSpecification findMergesForOptimize(SegmentInfos infos, int maxNumSegments, Set<SegmentInfo> segmentsToOptimize)
Returns the merges necessary to optimize the index.
MergePolicy.MergeSpecification findMergesToExpungeDeletes(SegmentInfos infos)
Finds merges necessary to expunge all deletes from the index.
int getMaxSmallSegments()
int getNumLargeSegments()
boolean getPartialExpunge()
void setMaxSmallSegments(int maxSmallSegments)
void setMergeFactor(int mergeFactor)
Determines how often segment indices are merged by addDocument().
void setMergePolicyParams(BalancedSegmentMergePolicy.MergePolicyParams params)
void setNumLargeSegments(int numLargeSegments)
void setPartialExpunge(boolean doPartialExpunge)
Protected Methods
long size(SegmentInfo info)
[Expand]
Inherited Methods
From class org.apache.lucene.index.LogByteSizeMergePolicy
From class org.apache.lucene.index.LogMergePolicy
From class org.apache.lucene.index.MergePolicy
From class java.lang.Object
From interface java.io.Closeable

Constants

public static final int DEFAULT_NUM_LARGE_SEGMENTS

Constant Value: 10 (0x0000000a)

Public Constructors

public BalancedSegmentMergePolicy ()

Public Methods

public MergePolicy.MergeSpecification findMerges (SegmentInfos infos)

Checks if any merges are now necessary and returns a MergePolicy.MergeSpecification if so. A merge is necessary when there are more than setMergeFactor(int) segments at a given level. When multiple levels have too many segments, this method will return multiple merges, allowing the MergeScheduler to use concurrency.

Parameters
infos the total set of segments in the index
Throws
IOException

public MergePolicy.MergeSpecification findMergesForOptimize (SegmentInfos infos, int maxNumSegments, Set<SegmentInfo> segmentsToOptimize)

Returns the merges necessary to optimize the index. This merge policy defines "optimized" to mean only the requested number of segments is left in the index, and respects the maxMergeSizeForOptimize setting. By default, and assuming maxNumSegments=1, only one segment will be left in the index, where that segment has no deletions pending nor separate norms, and it is in compound file format if the current useCompoundFile setting is true. This method returns multiple merges (mergeFactor at a time) so the MergeScheduler in use may make use of concurrency.

Parameters
infos the total set of segments in the index
maxNumSegments requested maximum number of segments in the index (currently this is always 1)
segmentsToOptimize contains the specific SegmentInfo instances that must be merged away. This may be a subset of all SegmentInfos.
Throws
IOException

public MergePolicy.MergeSpecification findMergesToExpungeDeletes (SegmentInfos infos)

Finds merges necessary to expunge all deletes from the index. We simply merge adjacent segments that have deletes, up to mergeFactor at a time.

Parameters
infos the total set of segments in the index

public int getMaxSmallSegments ()

public int getNumLargeSegments ()

public boolean getPartialExpunge ()

public void setMaxSmallSegments (int maxSmallSegments)

public void setMergeFactor (int mergeFactor)

Determines how often segment indices are merged by addDocument(). With smaller values, less RAM is used while indexing, and searches on unoptimized indices are faster, but indexing speed is slower. With larger values, more RAM is used during indexing, and while searches on unoptimized indices are slower, indexing is faster. Thus larger values (> 10) are best for batch index creation, and smaller values (

public void setMergePolicyParams (BalancedSegmentMergePolicy.MergePolicyParams params)

public void setNumLargeSegments (int numLargeSegments)

public void setPartialExpunge (boolean doPartialExpunge)

Protected Methods

protected long size (SegmentInfo info)

Throws
IOException