Package org.apache.lucene.index

# Class LogByteSizeMergePolicy

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

public class LogByteSizeMergePolicy extends LogMergePolicy
This is a `LogMergePolicy` that measures size of a segment as the total byte size of the segment's files.

## Nested Class Summary

## Nested classes/interfaces inherited from class org.apache.lucene.index.MergePolicy

`MergePolicy.MergeAbortedException, MergePolicy.MergeContext, MergePolicy.MergeException, MergePolicy.MergeSpecification, MergePolicy.OneMerge, MergePolicy.OneMergeProgress`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final double`
`DEFAULT_MAX_MERGE_MB`
Default maximum segment size.
`static final double`
`DEFAULT_MAX_MERGE_MB_FOR_FORCED_MERGE`
Default maximum segment size.
`static final double`
`DEFAULT_MIN_MERGE_MB`
Default minimum segment size.

### 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, maxMergeSizeForForcedMerge, mergeFactor, minMergeSize, targetSearchConcurrency`

### Fields inherited from class org.apache.lucene.index.MergePolicy

`DEFAULT_MAX_CFS_SEGMENT_SIZE, maxCFSSegmentSize, noCFSRatio`

## Constructor Summary

Constructors
Constructor
Description
`LogByteSizeMergePolicy()`
Sole constructor, setting all settings to their defaults.

## Method Summary

Modifier and Type
Method
Description
`double`
`getMaxMergeMB()`
Returns the largest segment (measured by total byte size of the segment's files, in MB) that may be merged with other segments.
`double`
`getMaxMergeMBForForcedMerge()`
Returns the largest segment (measured by total byte size of the segment's files, in MB) that may be merged with other segments during forceMerge.
`double`
`getMinMergeMB()`
Get the minimum size for a segment to remain un-merged.
`void`
`setMaxMergeMB(double mb)`
Determines the largest segment (measured by total byte size of the segment's files, in MB) that may be merged with other segments.
`void`
`setMaxMergeMBForForcedMerge(double mb)`
Determines the largest segment (measured by total byte size of the segment's files, in MB) that may be merged with other segments during forceMerge.
`void`
`setMinMergeMB(double mb)`
Sets the minimum size for the lowest level segments.
`protected long`
`size(SegmentCommitInfo info, MergePolicy.MergeContext mergeContext)`
Return the byte size of the provided `SegmentCommitInfo`, prorated by percentage of non-deleted documents is set.

### Methods inherited from class org.apache.lucene.index.LogMergePolicy

`findForcedDeletesMerges, findForcedMerges, findMerges, getCalibrateSizeByDeletes, getMaxMergeDocs, getMergeFactor, getTargetSearchConcurrency, isMerged, maxFullFlushMergeSize, setCalibrateSizeByDeletes, setMaxMergeDocs, setMergeFactor, setTargetSearchConcurrency, sizeBytes, sizeDocs, toString`

### Methods inherited from class org.apache.lucene.index.MergePolicy

`assertDelCount, findFullFlushMerges, findMerges, getMaxCFSSegmentSizeMB, getNoCFSRatio, isMerged, keepFullyDeletedSegment, message, numDeletesToMerge, segString, setMaxCFSSegmentSizeMB, setNoCFSRatio, useCompoundFile, verbose`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### DEFAULT_MIN_MERGE_MB

public static final double DEFAULT_MIN_MERGE_MB
Default minimum segment size. @see setMinMergeMB

See Also:
  - Constant Field Values

### DEFAULT_MAX_MERGE_MB

public static final double DEFAULT_MAX_MERGE_MB
Default maximum segment size. A segment of this size or larger will never be merged. @see setMaxMergeMB

See Also:
  - Constant Field Values

### DEFAULT_MAX_MERGE_MB_FOR_FORCED_MERGE

public static final double DEFAULT_MAX_MERGE_MB_FOR_FORCED_MERGE
Default maximum segment size. A segment of this size or larger will never be merged during forceMerge. @see setMaxMergeMBForForceMerge

See Also:
  - Constant Field Values

## Constructor Details

### LogByteSizeMergePolicy

public LogByteSizeMergePolicy()
Sole constructor, setting all settings to their defaults.

## Method Details

### size

protected long size(SegmentCommitInfo info, MergePolicy.MergeContext mergeContext) throws IOException
Description copied from class: `MergePolicy`
Return the byte size of the provided `SegmentCommitInfo`, prorated by percentage of non-deleted documents is set.

Overrides:
  `size` in class `MergePolicy`
Throws:
  `IOException`

### setMaxMergeMB

public void setMaxMergeMB(double mb)
Determines the largest segment (measured by total byte size of the segment's files, in MB) that may be merged with other segments. Small values (e.g., less than 50 MB) 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.

Note that `LogMergePolicy.setMaxMergeDocs(int)` is also used to check whether a segment is too large for merging (it's either or).

### getMaxMergeMB

public double getMaxMergeMB()
Returns the largest segment (measured by total byte size of the segment's files, in MB) that may be merged with other segments.

See Also:
  - `setMaxMergeMB(double)`

### setMaxMergeMBForForcedMerge

public void setMaxMergeMBForForcedMerge(double mb)
Determines the largest segment (measured by total byte size of the segment's files, in MB) that may be merged with other segments during forceMerge. Setting it low will leave the index with more than 1 segment, even if `IndexWriter.forceMerge(int)` is called.

### getMaxMergeMBForForcedMerge

public double getMaxMergeMBForForcedMerge()
Returns the largest segment (measured by total byte size of the segment's files, in MB) that may be merged with other segments during forceMerge.

See Also:
  - `setMaxMergeMBForForcedMerge(double)`

### setMinMergeMB

public void setMinMergeMB(double mb)
Sets the minimum size for the lowest level segments. Any segments below this size are candidates for full-flush merges and be merged more aggressively in order to avoid having a long tail of small segments. Large values of this parameter increase the merging cost during indexing if you flush small segments.

### getMinMergeMB

public double getMinMergeMB()
Get the minimum size for a segment to remain un-merged.

See Also:
  - `*`