Пример #1
0
        /// <summary>Merges all segments together into a single segment, optimizing an index
        /// for search.
        /// </summary>
        public virtual void  Optimize()
        {
            lock (this)
            {
                FlushRamSegments();
                while (segmentInfos.Count > 1 || (segmentInfos.Count == 1 && (SegmentReader.HasDeletions(segmentInfos.Info(0)) || segmentInfos.Info(0).dir != directory || (useCompoundFile && (!SegmentReader.UsesCompoundFile(segmentInfos.Info(0)) || SegmentReader.HasSeparateNorms(segmentInfos.Info(0)))))))
                {
                    int minSegment = segmentInfos.Count - mergeFactor;
                    MergeSegments(minSegment < 0?0:minSegment);
                }

                segmentInfos.Optimize(directory);
            }
        }