org.apache.lucene.index
Class BalancedSegmentMergePolicy

java.lang.Object
  extended by org.apache.lucene.index.MergePolicy
      extended by org.apache.lucene.index.LogMergePolicy
          extended by org.apache.lucene.index.LogByteSizeMergePolicy
              extended by 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_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, noCFSRatio
 
Fields inherited from class org.apache.lucene.index.MergePolicy
writer
 
Constructor Summary
BalancedSegmentMergePolicy(org.apache.lucene.index.IndexWriter writer)
           
 
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, Set<org.apache.lucene.index.SegmentInfo> 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, getMinMergeMB, setMaxMergeMB, setMinMergeMB
 
Methods inherited from class org.apache.lucene.index.LogMergePolicy
close, getCalibrateSizeByDeletes, getMaxMergeDocs, getMergeFactor, getNoCFSRatio, getUseCompoundDocStore, getUseCompoundFile, makeOneMerge, setCalibrateSizeByDeletes, setMaxMergeDocs, setNoCFSRatio, setUseCompoundDocStore, setUseCompoundFile, sizeBytes, sizeDocs, useCompoundDocStore, useCompoundFile, verbose
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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(org.apache.lucene.index.IndexWriter writer)
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,
                                                                                    Set<org.apache.lucene.index.SegmentInfo> 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-2010 Apache Software Foundation. All Rights Reserved.