Пример #1
0
        /// <summary> Remove the CommitPoints in the commitsToDelete List by
        /// DecRef'ing all files from each SegmentInfos.
        /// </summary>
        private void  DeleteCommits()
        {
            int size = commitsToDelete.Count;

            if (size > 0)
            {
                // First decref all files that had been referred to by
                // the now-deleted commits:
                for (int i = 0; i < size; i++)
                {
                    CommitPoint commit = (CommitPoint)commitsToDelete[i];
                    if (infoStream != null)
                    {
                        Message("deleteCommits: now remove commit \"" + commit.GetSegmentsFileName() + "\"");
                    }
                    int size2 = commit.files.Count;
                    for (int j = 0; j < size2; j++)
                    {
                        DecRef((System.String)commit.files[j]);
                    }
                }
                commitsToDelete.Clear();

                // Now compact commits to remove deleted ones (preserving the sort):
                size = commits.Count;
                int readFrom = 0;
                int writeTo  = 0;
                while (readFrom < size)
                {
                    CommitPoint commit = (CommitPoint)commits[readFrom];
                    if (!commit.deleted)
                    {
                        if (writeTo != readFrom)
                        {
                            commits[writeTo] = commits[readFrom];
                        }
                        writeTo++;
                    }
                    readFrom++;
                }

                while (size > writeTo)
                {
                    commits.RemoveAt(size - 1);
                    size--;
                }
            }
        }
Пример #2
0
        /// <summary> Remove the CommitPoints in the commitsToDelete List by
        /// DecRef'ing all files from each SegmentInfos.
        /// </summary>
        private void  DeleteCommits()
        {
            int size = commitsToDelete.Count;

            if (size > 0)
            {
                // First decref all files that had been referred to by
                // the now-deleted commits:
                for (int i = 0; i < size; i++)
                {
                    CommitPoint commit = (CommitPoint)commitsToDelete[i];
                    if (infoStream != null)
                    {
                        Message("deleteCommits: now decRef commit \"" + commit.GetSegmentsFileName() + "\"");
                    }
                    System.Collections.Generic.IEnumerator <string> it = commit.files.GetEnumerator();
                    while (it.MoveNext())
                    {
                        DecRef(it.Current);
                    }
                }
                commitsToDelete.Clear();

                // Now compact commits to remove deleted ones (preserving the sort):
                size = commits.Count;
                int readFrom = 0;
                int writeTo  = 0;
                while (readFrom < size)
                {
                    CommitPoint commit = (CommitPoint)commits[readFrom];
                    if (!commit.deleted)
                    {
                        if (writeTo != readFrom)
                        {
                            commits[writeTo] = commits[readFrom];
                        }
                        writeTo++;
                    }
                    readFrom++;
                }

                while (size > writeTo)
                {
                    commits.RemoveAt(size - 1);
                    size--;
                }
            }
        }