当前位置: 首页>>代码示例>>C#>>正文


C# SegmentInfos.PrepareCommit方法代码示例

本文整理汇总了C#中Lucene.Net.Index.SegmentInfos.PrepareCommit方法的典型用法代码示例。如果您正苦于以下问题:C# SegmentInfos.PrepareCommit方法的具体用法?C# SegmentInfos.PrepareCommit怎么用?C# SegmentInfos.PrepareCommit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lucene.Net.Index.SegmentInfos的用法示例。


在下文中一共展示了SegmentInfos.PrepareCommit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StartCommit

        /// <summary>
        /// Walk through all files referenced by the current
        ///  segmentInfos and ask the Directory to sync each file,
        ///  if it wasn't already.  If that succeeds, then we
        ///  prepare a new segments_N file but do not fully commit
        ///  it.
        /// </summary>
        private void StartCommit(SegmentInfos toSync)
        {
            Debug.Assert(TestPoint("startStartCommit"));
            Debug.Assert(PendingCommit == null);

            if (HitOOM)
            {
                throw new InvalidOperationException("this writer hit an OutOfMemoryError; cannot commit");
            }

            try
            {
                if (infoStream.IsEnabled("IW"))
                {
                    infoStream.Message("IW", "startCommit(): start");
                }

                lock (this)
                {
                    Debug.Assert(LastCommitChangeCount <= ChangeCount, "lastCommitChangeCount=" + LastCommitChangeCount + " changeCount=" + ChangeCount);

                    if (PendingCommitChangeCount == LastCommitChangeCount)
                    {
                        if (infoStream.IsEnabled("IW"))
                        {
                            infoStream.Message("IW", "  skip startCommit(): no changes pending");
                        }
                        Deleter.DecRef(FilesToCommit);
                        FilesToCommit = null;
                        return;
                    }

                    if (infoStream.IsEnabled("IW"))
                    {
                        infoStream.Message("IW", "startCommit index=" + SegString(ToLiveInfos(toSync).Segments) + " changeCount=" + ChangeCount);
                    }

                    Debug.Assert(FilesExist(toSync));
                }

                Debug.Assert(TestPoint("midStartCommit"));

                bool pendingCommitSet = false;

                try
                {
                    Debug.Assert(TestPoint("midStartCommit2"));

                    lock (this)
                    {
                        Debug.Assert(PendingCommit == null);

                        Debug.Assert(segmentInfos.Generation == toSync.Generation);

                        // Exception here means nothing is prepared
                        // (this method unwinds everything it did on
                        // an exception)
                        toSync.PrepareCommit(directory);
                        //System.out.println("DONE prepareCommit");

                        pendingCommitSet = true;
                        PendingCommit = toSync;
                    }

                    // this call can take a long time -- 10s of seconds
                    // or more.  We do it without syncing on this:
                    bool success = false;
                    ICollection<string> filesToSync;
                    try
                    {
                        filesToSync = toSync.Files(directory, false);
                        directory.Sync(filesToSync);
                        success = true;
                    }
                    finally
                    {
                        if (!success)
                        {
                            pendingCommitSet = false;
                            PendingCommit = null;
                            toSync.RollbackCommit(directory);
                        }
                    }

                    if (infoStream.IsEnabled("IW"))
                    {
                        infoStream.Message("IW", "done all syncs: " + filesToSync);
                    }

                    Debug.Assert(TestPoint("midStartCommitSuccess"));
                }
                finally
                {
//.........这里部分代码省略.........
开发者ID:joyanta,项目名称:lucene.net,代码行数:101,代码来源:IndexWriter.cs


注:本文中的Lucene.Net.Index.SegmentInfos.PrepareCommit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。