/* Create a new merge policy instance with default settings for noCFSRatio and maxCFSSegmentSize. This ctor should be used by subclasses using different defaults than the MergePolicy. */ func newMergePolicyImpl(self MergeSpecifier, defaultNoCFSRatio, defaultMaxCFSSegmentSize float64) *MergePolicyImpl { ans := &MergePolicyImpl{ self: self, writer: util.NewSetOnce(), noCFSRatio: defaultNoCFSRatio, maxCFSSegmentSize: defaultMaxCFSSegmentSize, } ans.Size = func(info *SegmentInfoPerCommit) (n int64, err error) { byteSize, err := info.SizeInBytes() if err != nil { return 0, err } docCount := info.info.DocCount() if docCount <= 0 { return byteSize, nil } delCount := ans.writer.Get().(*IndexWriter).readerPool.numDeletedDocs(info) delRatio := float32(delCount) / float32(docCount) assert(delRatio <= 1) return int64(float32(byteSize) * (1 - delRatio)), nil } return ans }
/* Creates a new config that with defaults that match the specified Version as well as the default Analyzer. If matchVersion is >= 3.2, TieredMergePolicy is used for merging; else LogByteSizeMergePolicy. Note that TieredMergePolicy is free to select non-contiguous merges, which means docIDs may not remain monotonic over time. If this is a problem, you should switch to LogByteSizeMergePolicy or LogDocMergePolicy. */ func NewIndexWriterConfig(matchVersion util.Version, analyzer analysis.Analyzer) *IndexWriterConfig { return &IndexWriterConfig{ LiveIndexWriterConfigImpl: newLiveIndexWriterConfig(analyzer, matchVersion), writer: util.NewSetOnce(), } }
func (mp *MergePolicyImpl) clone() *MergePolicyImpl { clone := *mp clone.writer = util.NewSetOnce() return &clone }