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


C# Lucene.Net.Store.Directory.Sync方法代码示例

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


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

示例1: FinishCommit

        public void FinishCommit(Directory dir)
        {
            if (pendingOutput == null)
                throw new System.Exception("prepareCommit was not called");
            bool success = false;
            try
            {
                pendingOutput.FinishCommit();
                pendingOutput.Close();
                pendingOutput = null;
                success = true;
            }
            finally
            {
                if (!success)
                    RollbackCommit(dir);
            }

            // NOTE: if we crash here, we have left a segments_N
            // file in the directory in a possibly corrupt state (if
            // some bytes made it to stable storage and others
            // didn't).  But, the segments_N file includes checksum
            // at the end, which should catch this case.  So when a
            // reader tries to read it, it will throw a
            // CorruptIndexException, which should cause the retry
            // logic in SegmentInfos to kick in and load the last
            // good (previous) segments_N-1 file.

            String fileName = IndexFileNames.FileNameFromGeneration(IndexFileNames.SEGMENTS, "", generation);
            success = false;
            try
            {
                dir.Sync(fileName);
                success = true;
            }
            finally
            {
                if (!success)
                {
                    try
                    {
                        dir.DeleteFile(fileName);
                    }
                    catch (System.Exception)
                    {
                        // Suppress so we keep throwing the original exception
                    }
                }
            }

            lastGeneration = generation;

            try
            {
                IndexOutput genOutput = dir.CreateOutput(IndexFileNames.SEGMENTS_GEN);
                try
                {
                    genOutput.WriteInt(FORMAT_LOCKLESS);
                    genOutput.WriteLong(generation);
                    genOutput.WriteLong(generation);
                }
                finally
                {
                    genOutput.Close();
                }
            }
            catch (System.Exception)
            {
                // It's OK if we fail to write this file since it's
                // used only as one of the retry fallbacks.
            }
        }
开发者ID:cqm0609,项目名称:lucene-file-finder,代码行数:72,代码来源:SegmentInfos.cs


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