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


C# Lucene.CreateOutput方法代码示例

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


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

示例1: TryReusePreviousCommitPointsToRecoverIndex

		private bool TryReusePreviousCommitPointsToRecoverIndex(Lucene.Net.Store.Directory directory, IndexDefinition indexDefinition, string indexStoragePath, out IndexCommitPoint indexCommit, out string[] keysToDelete)
		{
			indexCommit = null;
			keysToDelete = null;

			if (indexDefinition.IsMapReduce)
				return false;

			var indexFullPath = Path.Combine(indexStoragePath, indexDefinition.IndexId.ToString());



			var allCommitPointsFullPath = IndexCommitPointDirectory.GetAllCommitPointsFullPath(indexFullPath);

			if (Directory.Exists(allCommitPointsFullPath) == false)
				return false;

			var filesInIndexDirectory = Directory.GetFiles(indexFullPath).Select(Path.GetFileName);

			var existingCommitPoints =
				IndexCommitPointDirectory.ScanAllCommitPointsDirectory(indexFullPath);

			Array.Reverse(existingCommitPoints); // start from the highest generation

			foreach (var commitPointDirectoryName in existingCommitPoints)
			{
				try
				{
					var commitPointDirectory = new IndexCommitPointDirectory(indexStoragePath, indexDefinition.IndexId.ToString(),
																				commitPointDirectoryName);

					if (TryGetCommitPoint(commitPointDirectory, out indexCommit) == false)
					{
						IOExtensions.DeleteDirectory(commitPointDirectory.FullPath);
						continue; // checksum is invalid, try another commit point
					}

					var missingFile =
						indexCommit.SegmentsInfo.ReferencedFiles.Any(
							referencedFile => filesInIndexDirectory.Contains(referencedFile) == false);

					if (missingFile)
					{
						IOExtensions.DeleteDirectory(commitPointDirectory.FullPath);
						continue; // there are some missing files, try another commit point
					}

					var storedSegmentsFile = indexCommit.SegmentsInfo.SegmentsFileName;

					// here there should be only one segments_N file, however remove all if there is more
					foreach (var currentSegmentsFile in Directory.GetFiles(commitPointDirectory.IndexFullPath, "segments_*"))
					{
						File.Delete(currentSegmentsFile);
					}

					// copy old segments_N file
					File.Copy(Path.Combine(commitPointDirectory.FullPath, storedSegmentsFile),
							  Path.Combine(commitPointDirectory.IndexFullPath, storedSegmentsFile), true);

					try
					{
						// update segments.gen file
						using (var genOutput = directory.CreateOutput(IndexFileNames.SEGMENTS_GEN))
						{
							genOutput.WriteInt(SegmentInfos.FORMAT_LOCKLESS);
							genOutput.WriteLong(indexCommit.SegmentsInfo.Generation);
							genOutput.WriteLong(indexCommit.SegmentsInfo.Generation);
						}
					}
					catch (Exception)
					{
						// here we can ignore, segments.gen is used only as fallback
					}

					if (File.Exists(commitPointDirectory.DeletedKeysFile))
						keysToDelete = File.ReadLines(commitPointDirectory.DeletedKeysFile).ToArray();

					return true;
				}
				catch (Exception ex)
				{
					startupLog.WarnException("Could not recover an index named '" + indexDefinition.IndexId +
									   "'from segments of the following generation " + commitPointDirectoryName, ex);
				}
			}

			return false;
		}
开发者ID:felipeleusin,项目名称:ravendb,代码行数:88,代码来源:IndexStorage.cs

示例2: WriteIndexVersion

		private static void WriteIndexVersion(Lucene.Net.Store.Directory directory)
		{
			using(var indexOutput = directory.CreateOutput("index.version"))
			{
				indexOutput.WriteString(IndexVersion);
				indexOutput.Flush();
			}
		}
开发者ID:synhershko,项目名称:ravendb,代码行数:8,代码来源:IndexStorage.cs

示例3: WriteIndexVersion

		public static void WriteIndexVersion(Lucene.Net.Store.Directory directory, IndexDefinition indexDefinition)
		{
			var version = IndexVersion;
			if (indexDefinition.IsMapReduce)
			{
				version = MapReduceIndexVersion;
			}
			using (var indexOutput = directory.CreateOutput(IndexVersionFileName(indexDefinition)))
			{
				indexOutput.WriteString(version);
				indexOutput.Flush();
			}
		}
开发者ID:felipeleusin,项目名称:ravendb,代码行数:13,代码来源:IndexStorage.cs

示例4: WriteIndexVersion

		private static void WriteIndexVersion(Lucene.Net.Store.Directory directory)
		{
			var indexOutput = directory.CreateOutput("index.version");
			try
			{
				indexOutput.WriteString(IndexVersion);
				indexOutput.Flush();
			}
			finally
			{
				indexOutput.Close();
			}
		}
开发者ID:configurator,项目名称:ravendb,代码行数:13,代码来源:IndexStorage.cs


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