Class LogMergePolicy
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 MergeFactor.
This class is abstract and requires a subclass to
define the Size(SegmentCommitInfo) method which specifies how a
segment's size is determined. LogDocMergePolicy
is one subclass that measures size by document count in
the segment. LogByteSizeMergePolicy is another
subclass that measures size as the total byte size of the
file(s) for the segment.
Inheritance
System.Object
LogMergePolicy
Implements
System.IDisposable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Assembly: Lucene.Net.dll
Syntax
public abstract class LogMergePolicy : MergePolicy, IDisposable
Constructors
|
Improve this Doc
View Source
LogMergePolicy()
Sole constructor. (For invocation by subclass
constructors, typically implicit.)
Declaration
protected LogMergePolicy()
Fields
|
Improve this Doc
View Source
DEFAULT_MAX_MERGE_DOCS
Default maximum segment size. A segment of this size
or larger will never be merged.
Declaration
public static readonly int DEFAULT_MAX_MERGE_DOCS
Field Value
Type |
Description |
System.Int32 |
|
See Also
|
Improve this Doc
View Source
DEFAULT_MERGE_FACTOR
Default merge factor, which is how many segments are
merged at a time
Declaration
public static readonly int DEFAULT_MERGE_FACTOR
Field Value
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
DEFAULT_NO_CFS_RATIO
Default noCFSRatio. If a merge's size is >= 10% of
the index, then we disable compound file for it.
Declaration
public static readonly double DEFAULT_NO_CFS_RATIO
Field Value
Type |
Description |
System.Double |
|
See Also
|
Improve this Doc
View Source
LEVEL_LOG_SPAN
Defines the allowed range of log(size) for each
level. A level is computed by taking the max segment
log size, minus LEVEL_LOG_SPAN, and finding all
segments falling within that range.
Declaration
public static readonly double LEVEL_LOG_SPAN
Field Value
Type |
Description |
System.Double |
|
|
Improve this Doc
View Source
m_calibrateSizeByDeletes
If true, we pro-rate a segment's size by the
percentage of non-deleted documents.
Declaration
protected bool m_calibrateSizeByDeletes
Field Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
m_maxMergeDocs
If a segment has more than this many documents then it
will never be merged.
Declaration
protected int m_maxMergeDocs
Field Value
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
m_maxMergeSize
If the size of a segment exceeds this value then it
will never be merged.
Declaration
protected long m_maxMergeSize
Field Value
Type |
Description |
System.Int64 |
|
|
Improve this Doc
View Source
m_maxMergeSizeForForcedMerge
If the size of a segment exceeds this value then it
will never be merged during ForceMerge(Int32).
Declaration
protected long m_maxMergeSizeForForcedMerge
Field Value
Type |
Description |
System.Int64 |
|
|
Improve this Doc
View Source
m_mergeFactor
How many segments to merge at a time.
Declaration
protected int m_mergeFactor
Field Value
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
m_minMergeSize
Any segments whose size is smaller than this value
will be rounded up to this value. This ensures that
tiny segments are aggressively merged.
Declaration
protected long m_minMergeSize
Field Value
Type |
Description |
System.Int64 |
|
Properties
|
Improve this Doc
View Source
CalibrateSizeByDeletes
Gets or Sets whether the segment size should be calibrated by
the number of deletes when choosing segments for merge.
Declaration
public virtual bool CalibrateSizeByDeletes { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
IsVerbose
Returns true if LogMergePolicy is enabled in Lucene.Net.Index.IndexWriter.infoStream.
Declaration
protected virtual bool IsVerbose { get; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
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.
The default value is System.Int32.MaxValue.
The default merge policy
(LogByteSizeMergePolicy) also allows you to set this
limit by net size (in MB) of the segment, using
MaxMergeMB.
Declaration
public virtual int MaxMergeDocs { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
MergeFactor
Gets or Sets the number of segments that are merged at
once and also controls the total number of segments
allowed to accumulate in the index.
This determines how often segment indices are merged by
AddDocument(IEnumerable<IIndexableField>). 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.
Declaration
public virtual int MergeFactor { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
Methods
|
Improve this Doc
View Source
Dispose(Boolean)
Declaration
protected override void Dispose(bool disposing)
Parameters
Type |
Name |
Description |
System.Boolean |
disposing |
|
Overrides
|
Improve this Doc
View Source
FindForcedDeletesMerges(SegmentInfos)
Finds merges necessary to force-merge all deletes from the
index. We simply merge adjacent segments that have
deletes, up to mergeFactor at a time.
Declaration
public override MergePolicy.MergeSpecification FindForcedDeletesMerges(SegmentInfos segmentInfos)
Parameters
Returns
Overrides
|
Improve this Doc
View Source
FindForcedMerges(SegmentInfos, Int32, IDictionary<SegmentCommitInfo, Nullable<Boolean>>)
Returns the merges necessary to merge the index down
to a specified number of segments.
this respects the m_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.
Declaration
public override MergePolicy.MergeSpecification FindForcedMerges(SegmentInfos infos, int maxNumSegments, IDictionary<SegmentCommitInfo, bool?> segmentsToMerge)
Parameters
Type |
Name |
Description |
SegmentInfos |
infos |
|
System.Int32 |
maxNumSegments |
|
System.Collections.Generic.IDictionary<SegmentCommitInfo, System.Nullable<System.Boolean>> |
segmentsToMerge |
|
Returns
Overrides
|
Improve this Doc
View Source
FindMerges(MergeTrigger, SegmentInfos)
Checks if any merges are now necessary and returns a
MergePolicy.MergeSpecification if so. A merge
is necessary when there are more than
MergeFactor segments at a given level. When
multiple levels have too many segments, this method
will return multiple merges, allowing the
MergeScheduler to use concurrency.
Declaration
public override MergePolicy.MergeSpecification FindMerges(MergeTrigger mergeTrigger, SegmentInfos infos)
Parameters
Returns
Overrides
|
Improve this Doc
View Source
IsMerged(SegmentInfos, Int32, IDictionary<SegmentCommitInfo, Nullable<Boolean>>)
Returns true
if the number of segments eligible for
merging is less than or equal to the specified
maxNumSegments
.
Declaration
protected virtual bool IsMerged(SegmentInfos infos, int maxNumSegments, IDictionary<SegmentCommitInfo, bool?> segmentsToMerge)
Parameters
Type |
Name |
Description |
SegmentInfos |
infos |
|
System.Int32 |
maxNumSegments |
|
System.Collections.Generic.IDictionary<SegmentCommitInfo, System.Nullable<System.Boolean>> |
segmentsToMerge |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
Message(String)
Print a debug message to Lucene.Net.Index.IndexWriter.infoStream.
Declaration
protected virtual void Message(string message)
Parameters
Type |
Name |
Description |
System.String |
message |
|
|
Improve this Doc
View Source
SizeBytes(SegmentCommitInfo)
Declaration
protected virtual long SizeBytes(SegmentCommitInfo info)
Parameters
Returns
Type |
Description |
System.Int64 |
|
|
Improve this Doc
View Source
SizeDocs(SegmentCommitInfo)
Declaration
protected virtual long SizeDocs(SegmentCommitInfo info)
Parameters
Returns
Type |
Description |
System.Int64 |
|
|
Improve this Doc
View Source
ToString()
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Overrides
System.Object.ToString()
Implements
System.IDisposable