## org.apache.lucene.index
Class BalancedSegmentMergePolicy

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

All Implemented Interfaces:
  Closeable

    public class BalancedSegmentMergePolicy

extends org.apache.lucene.index.LogByteSizeMergePolicy

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.

Nested Class Summary
`static class` `BalancedSegmentMergePolicy.MergePolicyParams`

Nested classes/interfaces inherited from class org.apache.lucene.index.MergePolicy
`org.apache.lucene.index.MergePolicy.MergeAbortedException, org.apache.lucene.index.MergePolicy.MergeException, org.apache.lucene.index.MergePolicy.MergeSpecification, org.apache.lucene.index.MergePolicy.OneMerge`

Field Summary
`static int` `DEFAULT_NUM_LARGE_SEGMENTS`

Fields inherited from class org.apache.lucene.index.LogByteSizeMergePolicy
`DEFAULT_MAX_MERGE_MB, DEFAULT_MAX_MERGE_MB_FOR_OPTIMIZE, DEFAULT_MIN_MERGE_MB`

Fields inherited from class org.apache.lucene.index.LogMergePolicy
`calibrateSizeByDeletes, DEFAULT_MAX_MERGE_DOCS, DEFAULT_MERGE_FACTOR, DEFAULT_NO_CFS_RATIO, LEVEL_LOG_SPAN, maxMergeDocs, maxMergeSize, maxMergeSizeForOptimize, mergeFactor, minMergeSize, noCFSRatio, useCompoundFile`

Fields inherited from class org.apache.lucene.index.MergePolicy
`writer`

Constructor Summary
`BalancedSegmentMergePolicy()`

Method Summary
`org.apache.lucene.index.MergePolicy.MergeSpecification` `findMerges(org.apache.lucene.index.SegmentInfos infos)`
`org.apache.lucene.index.MergePolicy.MergeSpecification` `findMergesForOptimize(org.apache.lucene.index.SegmentInfos infos, int maxNumSegments, Map<org.apache.lucene.index.SegmentInfo,Boolean> segmentsToOptimize)`
`org.apache.lucene.index.MergePolicy.MergeSpecification` `findMergesToExpungeDeletes(org.apache.lucene.index.SegmentInfos infos)`
`int` `getMaxSmallSegments()`
`int` `getNumLargeSegments()`
`boolean` `getPartialExpunge()`
`void` `setMaxSmallSegments(int maxSmallSegments)`
`void` `setMergeFactor(int mergeFactor)`
`void` `setMergePolicyParams(BalancedSegmentMergePolicy.MergePolicyParams params)`
`void` `setNumLargeSegments(int numLargeSegments)`
`void` `setPartialExpunge(boolean doPartialExpunge)`
`protected long` `size(org.apache.lucene.index.SegmentInfo info)`

Methods inherited from class org.apache.lucene.index.LogByteSizeMergePolicy
`getMaxMergeMB, getMaxMergeMBForOptimize, getMinMergeMB, setMaxMergeMB, setMaxMergeMBForOptimize, setMinMergeMB`

Methods inherited from class org.apache.lucene.index.LogMergePolicy
`close, getCalibrateSizeByDeletes, getMaxMergeDocs, getMergeFactor, getNoCFSRatio, getUseCompoundFile, isOptimized, isOptimized, message, setCalibrateSizeByDeletes, setMaxMergeDocs, setNoCFSRatio, setUseCompoundFile, sizeBytes, sizeDocs, toString, useCompoundFile, verbose`

Methods inherited from class org.apache.lucene.index.MergePolicy
`setIndexWriter`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### DEFAULT_NUM_LARGE_SEGMENTS

    public static final int DEFAULT_NUM_LARGE_SEGMENTS

See Also:
  Constant Field Values

Constructor Detail

### BalancedSegmentMergePolicy

    public BalancedSegmentMergePolicy()

Method Detail

### setMergePolicyParams

    public void setMergePolicyParams(BalancedSegmentMergePolicy.MergePolicyParams params)

### size

    protected long size(org.apache.lucene.index.SegmentInfo info)
                 throws IOException

  Overrides:
    `size` in class `org.apache.lucene.index.LogByteSizeMergePolicy`
  Throws:
    `IOException`

### setPartialExpunge

    public void setPartialExpunge(boolean doPartialExpunge)

### getPartialExpunge

    public boolean getPartialExpunge()

### setNumLargeSegments

    public void setNumLargeSegments(int numLargeSegments)

### getNumLargeSegments

    public int getNumLargeSegments()

### setMaxSmallSegments

    public void setMaxSmallSegments(int maxSmallSegments)

### getMaxSmallSegments

    public int getMaxSmallSegments()

### setMergeFactor

    public void setMergeFactor(int mergeFactor)

  Overrides:
    `setMergeFactor` in class `org.apache.lucene.index.LogMergePolicy`

### findMergesForOptimize

    public org.apache.lucene.index.MergePolicy.MergeSpecification findMergesForOptimize(org.apache.lucene.index.SegmentInfos infos,
                                                                                        int maxNumSegments,
                                                                                        Map<org.apache.lucene.index.SegmentInfo,Boolean> segmentsToOptimize)
                                                                                 throws IOException

  Overrides:
    `findMergesForOptimize` in class `org.apache.lucene.index.LogMergePolicy`
  Throws:
    `IOException`

### findMergesToExpungeDeletes

    public org.apache.lucene.index.MergePolicy.MergeSpecification findMergesToExpungeDeletes(org.apache.lucene.index.SegmentInfos infos)
                                                                                      throws org.apache.lucene.index.CorruptIndexException,
                                                                                             IOException

  Overrides:
    `findMergesToExpungeDeletes` in class `org.apache.lucene.index.LogMergePolicy`
  Throws:
    `org.apache.lucene.index.CorruptIndexException`
    `IOException`

### findMerges

    public org.apache.lucene.index.MergePolicy.MergeSpecification findMerges(org.apache.lucene.index.SegmentInfos infos)
                                                                      throws IOException

  Overrides:
    `findMerges` in class `org.apache.lucene.index.LogMergePolicy`
  Throws:
    `IOException`

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.