This class implements a MergePolicy that tries
to merge segments into levels of exponentially
increasing size, where each level has fewer segments than
the value of the merge factor. Whenever extra segments
(beyond the merge factor upper bound) are encountered,
all segments within the level are merged. You can get or
set the merge factor using getMergeFactor() and
setMergeFactor(int) respectively.

Constructor Detail

LogMergePolicy

Method Detail

verbose

getNoCFSRatio

setNoCFSRatio

public void setNoCFSRatio(double noCFSRatio)

If a merged segment will be more than this percentage
of the total size of the index, leave the segment as
non-compound file even if compound file is enabled.
Set to 1.0 to always use CFS regardless of merge
size.

message

getMergeFactor

Returns the number of segments that are merged at
once and also controls the total number of segments
allowed to accumulate in the index.

setMergeFactor

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 are
faster, but indexing speed is slower. With larger
values, more RAM is used during indexing, and while
searches is slower, indexing is
faster. Thus larger values (> 10) are best for batch
index creation, and smaller values (< 10) for indices
that are interactively maintained.

findForcedMerges

Returns the merges necessary to merge the index down
to a specified number of segments.
This respects the maxMergeSizeForForcedMerge 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.

maxNumSegments - requested maximum number of segments in the index (currently this
is always 1)

segmentsToMerge - contains the specific SegmentInfo instances that must be merged
away. This may be a subset of all
SegmentInfos. If the value is True for a
given SegmentInfo, that means this segment was
an original segment present in the
to-be-merged index; else, it was a segment
produced by a cascaded merge.

findMerges

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.

setMaxMergeDocs

public void setMaxMergeDocs(int maxMergeDocs)

Determines the largest segment (measured by
document count) that may be merged with other segments.
Small values (e.g., less than 10,000) are best for
interactive indexing, as this limits the length of
pauses while indexing to a few seconds. Larger values
are best for batched indexing and speedier
searches.