本文整理汇总了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;
}
示例2: WriteIndexVersion
private static void WriteIndexVersion(Lucene.Net.Store.Directory directory)
{
using(var indexOutput = directory.CreateOutput("index.version"))
{
indexOutput.WriteString(IndexVersion);
indexOutput.Flush();
}
}
示例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();
}
}
示例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();
}
}