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


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

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


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

示例1: RollbackCommit

        public void RollbackCommit(Directory dir)
        {
            if (pendingOutput != null)
            {
                try
                {
                    pendingOutput.Close();
                }
                catch (System.Exception)
                {
                    // Suppress so we keep throwing the original exception
                    // in our caller
                }

                // Must carefully compute fileName from "generation"
                // since lastGeneration isn't incremented:
                try
                {
                    String segmentFileName = IndexFileNames.FileNameFromGeneration(IndexFileNames.SEGMENTS, "", generation);
                    dir.DeleteFile(segmentFileName);
                }
                catch (System.Exception)
                {
                    // Suppress so we keep throwing the original exception
                    // in our caller
                }
                pendingOutput = null;
            }
        }
开发者ID:cqm0609,项目名称:lucene-file-finder,代码行数:29,代码来源:SegmentInfos.cs

示例2: Write

        private void Write(Directory directory)
        {
            System.String segmentFileName = GetNextSegmentFileName();

            // Always advance the generation on write:
            if (generation == -1)
            {
                generation = 1;
            }
            else
            {
                generation++;
            }

            ChecksumIndexOutput output = new ChecksumIndexOutput(directory.CreateOutput(segmentFileName));

            bool success = false;

            try
            {
                output.WriteInt(CURRENT_FORMAT); // write FORMAT
                output.WriteLong(++version); // every write changes
                // the index
                output.WriteInt(counter); // write counter
                output.WriteInt(Count); // write infos
                for (int i = 0; i < Count; i++)
                {
                    Info(i).Write(output);
                }
                output.PrepareCommit();
                success = true;
                pendingOutput = output;
            }
            finally
            {
                if (!success)
                {
                    // we hit an exception above; try to close the file but suppress any exception:
                    try
                    {
                        output.Close();
                    }
                    catch (System.Exception)
                    {
                        // suppress so we keep throwing the original exception
                    }
                    try
                    {
                        // try not to leave a truncated segments_N file int the index
                        directory.DeleteFile(segmentFileName);
                    }
                    catch (System.Exception)
                    {
                        // suppress so we keep throwing the original exception
                    }
                }
            }
        }
开发者ID:cqm0609,项目名称:lucene-file-finder,代码行数:58,代码来源:SegmentInfos.cs

示例3: Write

		public void  Write(Directory directory)
		{
			
			System.String segmentFileName = GetNextSegmentFileName();
			
			// Always advance the generation on write:
			if (generation == - 1)
			{
				generation = 1;
			}
			else
			{
				generation++;
			}
			
			IndexOutput output = directory.CreateOutput(segmentFileName);
			
			bool success = false;
			
			try
			{
				output.WriteInt(CURRENT_FORMAT); // write FORMAT
				output.WriteLong(++version); // every write changes
				// the index
				output.WriteInt(counter); // write counter
				output.WriteInt(Count); // write infos
				for (int i = 0; i < Count; i++)
				{
					Info(i).Write(output);
				}
			}
			finally
			{
				try
				{
					output.Close();
					success = true;
				}
				finally
				{
					if (!success)
					{
						// Try not to leave a truncated segments_N file in
						// the index:
						directory.DeleteFile(segmentFileName);
					}
				}
			}
			
			try
			{
				output = directory.CreateOutput(IndexFileNames.SEGMENTS_GEN);
				try
				{
					output.WriteInt(FORMAT_LOCKLESS);
					output.WriteLong(generation);
					output.WriteLong(generation);
				}
				finally
				{
					output.Close();
				}
			}
			catch (System.IO.IOException e)
			{
				// It's OK if we fail to write this file since it's
				// used only as one of the retry fallbacks.
			}
			
			lastGeneration = generation;
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:71,代码来源:SegmentInfos.cs

示例4: 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

示例5: FieldsWriter

		internal FieldsWriter(Directory d, System.String segment, FieldInfos fn)
		{
			fieldInfos = fn;
			
			bool success = false;
			System.String fieldsName = segment + "." + IndexFileNames.FIELDS_EXTENSION;
			try
			{
				fieldsStream = d.CreateOutput(fieldsName);
				fieldsStream.WriteInt(FORMAT_CURRENT);
				success = true;
			}
			finally
			{
				if (!success)
				{
					try
					{
						Close();
					}
					catch (System.Exception t)
					{
						// Suppress so we keep throwing the original exception
					}
					try
					{
						d.DeleteFile(fieldsName);
					}
					catch (System.Exception t)
					{
						// Suppress so we keep throwing the original exception
					}
				}
			}
			
			success = false;
			System.String indexName = segment + "." + IndexFileNames.FIELDS_INDEX_EXTENSION;
			try
			{
				indexStream = d.CreateOutput(indexName);
				indexStream.WriteInt(FORMAT_CURRENT);
				success = true;
			}
			finally
			{
				if (!success)
				{
					try
					{
						Close();
					}
					catch (System.IO.IOException ioe)
					{
					}
					try
					{
						d.DeleteFile(fieldsName);
					}
					catch (System.Exception t)
					{
						// Suppress so we keep throwing the original exception
					}
					try
					{
						d.DeleteFile(indexName);
					}
					catch (System.Exception t)
					{
						// Suppress so we keep throwing the original exception
					}
				}
			}
			
			doClose = true;
		}
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:75,代码来源:FieldsWriter.cs

示例6: Optimize

		public void Optimize(Directory directory)
		{
			string[] files = directory.List();

			System.Collections.ArrayList segment_names = new System.Collections.ArrayList();
			foreach (SegmentInfo si in this)
				segment_names.Add (si.name);

			foreach (string file in files) {
				string basename = System.IO.Path.GetFileNameWithoutExtension (file);
				if (segment_names.Contains (basename))
					continue;

				if (basename == IndexFileNames.DELETABLE || basename == IndexFileNames.SEGMENTS)
					continue;

				Console.WriteLine ("WARNING! Deleting stale data {0}", file);
				directory.DeleteFile (file);
			}
		}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:20,代码来源:SegmentInfos.cs

示例7: Initialize

        private void Initialize(Directory directory, string segment, FieldInfos fis, int interval, bool isi)
        {
            IndexInterval = interval;
            FieldInfos = fis;
            IsIndex = isi;
            Output = directory.CreateOutput(IndexFileNames.SegmentFileName(segment, "", (IsIndex ? Lucene3xPostingsFormat.TERMS_INDEX_EXTENSION : Lucene3xPostingsFormat.TERMS_EXTENSION)), IOContext.DEFAULT);
            bool success = false;
            try
            {
                Output.WriteInt(FORMAT_CURRENT); // write format
                Output.WriteLong(0); // leave space for size
                Output.WriteInt(IndexInterval); // write indexInterval
                Output.WriteInt(SkipInterval); // write skipInterval
                Output.WriteInt(MaxSkipLevels); // write maxSkipLevels
                Debug.Assert(InitUTF16Results());
                success = true;
            }
            finally
            {
                if (!success)
                {
                    IOUtils.CloseWhileHandlingException(Output);

                    try
                    {
                        directory.DeleteFile(IndexFileNames.SegmentFileName(segment, "", (IsIndex ? Lucene3xPostingsFormat.TERMS_INDEX_EXTENSION : Lucene3xPostingsFormat.TERMS_EXTENSION)));
                    }
                    catch (IOException ignored)
                    {
                    }
                }
            }
        }
开发者ID:WakeflyCBass,项目名称:lucenenet,代码行数:33,代码来源:TermInfosWriter.cs

示例8: TermInfosWriter

        internal TermInfosWriter(Directory directory, string segment, FieldInfos fis, int interval)
        {
            Initialize(directory, segment, fis, interval, false);
            bool success = false;
            try
            {
                Other = new TermInfosWriter(directory, segment, fis, interval, true);
                Other.Other = this;
                success = true;
            }
            finally
            {
                if (!success)
                {
                    IOUtils.CloseWhileHandlingException(Output);

                    try
                    {
                        directory.DeleteFile(IndexFileNames.SegmentFileName(segment, "", (IsIndex ? Lucene3xPostingsFormat.TERMS_INDEX_EXTENSION : Lucene3xPostingsFormat.TERMS_EXTENSION)));
                    }
                    catch (IOException ignored)
                    {
                    }
                }
            }
        }
开发者ID:WakeflyCBass,项目名称:lucenenet,代码行数:26,代码来源:TermInfosWriter.cs

示例9: DeleteFiles

		private void  DeleteFiles(System.Collections.ArrayList files, Directory directory)
		{
			for (int i = 0; i < files.Count; i++)
				directory.DeleteFile((System.String) files[i]);
		}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:5,代码来源:IndexWriter.cs

示例10: CreateCompoundFile

        /// <summary>
        /// NOTE: this method creates a compound file for all files returned by
        /// info.files(). While, generally, this may include separate norms and
        /// deletion files, this SegmentInfo must not reference such files when this
        /// method is called, because they are not allowed within a compound file.
        /// </summary>
        public static ICollection<string> CreateCompoundFile(InfoStream infoStream, Directory directory, CheckAbort checkAbort, SegmentInfo info, IOContext context)
        {
            string fileName = Index.IndexFileNames.SegmentFileName(info.Name, "", Lucene.Net.Index.IndexFileNames.COMPOUND_FILE_EXTENSION);
            if (infoStream.IsEnabled("IW"))
            {
                infoStream.Message("IW", "create compound file " + fileName);
            }
            Debug.Assert(Lucene3xSegmentInfoFormat.GetDocStoreOffset(info) == -1);
            // Now merge all added files
            ICollection<string> files = info.Files;
            CompoundFileDirectory cfsDir = new CompoundFileDirectory(directory, fileName, context, true);
            IOException prior = null;
            try
            {
                foreach (string file in files)
                {
                    directory.Copy(cfsDir, file, file, context);
                    checkAbort.Work(directory.FileLength(file));
                }
            }
            catch (System.IO.IOException ex)
            {
                prior = ex;
            }
            finally
            {
                bool success = false;
                try
                {
                    IOUtils.CloseWhileHandlingException(prior, cfsDir);
                    success = true;
                }
                finally
                {
                    if (!success)
                    {
                        try
                        {
                            directory.DeleteFile(fileName);
                        }
                        catch (Exception)
                        {
                        }
                        try
                        {
                            directory.DeleteFile(Lucene.Net.Index.IndexFileNames.SegmentFileName(info.Name, "", Lucene.Net.Index.IndexFileNames.COMPOUND_FILE_ENTRIES_EXTENSION));
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }

            // Replace all previous files with the CFS/CFE files:
            HashSet<string> siFiles = new HashSet<string>();
            siFiles.Add(fileName);
            siFiles.Add(Lucene.Net.Index.IndexFileNames.SegmentFileName(info.Name, "", Lucene.Net.Index.IndexFileNames.COMPOUND_FILE_ENTRIES_EXTENSION));
            info.Files = siFiles;

            return files;
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:68,代码来源:IndexWriter.cs

示例11: Optimize

		public void Optimize(Directory directory)
		{
			string[] files = directory.List();

			System.Collections.ArrayList segment_names = new System.Collections.ArrayList();

			foreach (SegmentInfo si in this)
				segment_names.Add (si.name);

			foreach (string file in files) {
				string basename = System.IO.Path.GetFileNameWithoutExtension (file);
				if (segment_names.Contains (basename))
					continue;

				// Allowed files deletable, segments, segments.gen, segments_N
				if (basename == IndexFileNames.DELETABLE || basename.StartsWith (IndexFileNames.SEGMENTS))
					continue;

				Console.WriteLine ("WARNING! Deleting stale data {0}", file);
				try {
					directory.DeleteFile (file);
				} catch { /* Could be already deleted. */ }
			}
		}
开发者ID:zweib730,项目名称:beagrep,代码行数:24,代码来源:SegmentInfos.cs


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