NumDeletedDocs() public method

Obtain the number of deleted docs for a pooled reader. If the reader isn't being pooled, the segmentInfo's delCount is returned.
public NumDeletedDocs ( SegmentInfo info ) : int
info SegmentInfo
return int
示例#1
0
        /// <summary>
        /// Returns true if this single info is already fully merged (has no
        ///  pending deletes, is in the same dir as the
        ///  writer, and matches the current compound file setting
        /// </summary>
        protected internal bool IsMerged(SegmentInfos infos, SegmentCommitInfo info)
        {
            IndexWriter w = Writer.Get();

            Debug.Assert(w != null);
            bool hasDeletions = w.NumDeletedDocs(info) > 0;

            return(!hasDeletions && !info.Info.HasSeparateNorms() && info.Info.Dir == w.Directory && UseCompoundFile(infos, info) == info.Info.UseCompoundFile);
        }
示例#2
0
        /// <summary>
        /// Returns <c>true</c> if this single info is already fully merged (has no
        /// pending deletes, is in the same dir as the
        /// writer, and matches the current compound file setting
        /// </summary>
        protected bool IsMerged(SegmentInfos infos, SegmentCommitInfo info)
        {
            IndexWriter w = m_writer.Get();

            Debug.Assert(w != null);
            bool hasDeletions = w.NumDeletedDocs(info) > 0;

            return(!hasDeletions
#pragma warning disable 612, 618
                   && !info.Info.HasSeparateNorms
#pragma warning restore 612, 618
                   && info.Info.Dir == w.Directory &&
                   UseCompoundFile(infos, info) == info.Info.UseCompoundFile);
        }
示例#3
0
        /// <summary>
        /// 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.
        /// </summary>
        public override MergeSpecification FindForcedDeletesMerges(SegmentInfos segmentInfos)
        {
            var segments    = segmentInfos.AsList();
            int numSegments = segments.Count;

            if (IsVerbose)
            {
                Message("findForcedDeleteMerges: " + numSegments + " segments");
            }

            var         spec = new MergeSpecification();
            int         firstSegmentWithDeletions = -1;
            IndexWriter w = m_writer.Get();

            Debug.Assert(w != null);
            for (int i = 0; i < numSegments; i++)
            {
                SegmentCommitInfo info = segmentInfos.Info(i);
                int delCount           = w.NumDeletedDocs(info);
                if (delCount > 0)
                {
                    if (IsVerbose)
                    {
                        Message("  segment " + info.Info.Name + " has deletions");
                    }
                    if (firstSegmentWithDeletions == -1)
                    {
                        firstSegmentWithDeletions = i;
                    }
                    else if (i - firstSegmentWithDeletions == m_mergeFactor)
                    {
                        // We've seen mergeFactor segments in a row with
                        // deletions, so force a merge now:
                        if (IsVerbose)
                        {
                            Message("  add merge " + firstSegmentWithDeletions + " to " + (i - 1) + " inclusive");
                        }
                        spec.Add(new OneMerge(segments.SubList(firstSegmentWithDeletions, i)));
                        firstSegmentWithDeletions = i;
                    }
                }
                else if (firstSegmentWithDeletions != -1)
                {
                    // End of a sequence of segments with deletions, so,
                    // merge those past segments even if it's fewer than
                    // mergeFactor segments
                    if (IsVerbose)
                    {
                        Message("  add merge " + firstSegmentWithDeletions + " to " + (i - 1) + " inclusive");
                    }
                    spec.Add(new OneMerge(segments.SubList(firstSegmentWithDeletions, i)));
                    firstSegmentWithDeletions = -1;
                }
            }

            if (firstSegmentWithDeletions != -1)
            {
                if (IsVerbose)
                {
                    Message("  add merge " + firstSegmentWithDeletions + " to " + (numSegments - 1) + " inclusive");
                }
                spec.Add(new OneMerge(segments.SubList(firstSegmentWithDeletions, numSegments)));
            }

            return(spec);
        }