本文整理汇总了C#中Lucene.Net.Index.SegmentInfo.Attributes方法的典型用法代码示例。如果您正苦于以下问题:C# SegmentInfo.Attributes方法的具体用法?C# SegmentInfo.Attributes怎么用?C# SegmentInfo.Attributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Index.SegmentInfo
的用法示例。
在下文中一共展示了SegmentInfo.Attributes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Write3xInfo
public static string Write3xInfo(Directory dir, SegmentInfo si, IOContext context)
{
// NOTE: this is NOT how 3.x is really written...
string fileName = IndexFileNames.SegmentFileName(si.Name, "", Lucene3xSegmentInfoFormat.UPGRADED_SI_EXTENSION);
si.AddFile(fileName);
//System.out.println("UPGRADE write " + fileName);
bool success = false;
IndexOutput output = dir.CreateOutput(fileName, context);
try
{
// we are about to write this SI in 3.x format, dropping all codec information, etc.
// so it had better be a 3.x segment or you will get very confusing errors later.
if ((si.Codec is Lucene3xCodec) == false)
{
throw new InvalidOperationException("cannot write 3x SegmentInfo unless codec is Lucene3x (got: " + si.Codec + ")");
}
CodecUtil.WriteHeader(output, Lucene3xSegmentInfoFormat.UPGRADED_SI_CODEC_NAME, Lucene3xSegmentInfoFormat.UPGRADED_SI_VERSION_CURRENT);
// Write the Lucene version that created this segment, since 3.1
output.WriteString(si.Version);
output.WriteInt(si.DocCount);
output.WriteStringStringMap(si.Attributes());
output.WriteByte((byte)(sbyte)(si.UseCompoundFile ? SegmentInfo.YES : SegmentInfo.NO));
output.WriteStringStringMap(si.Diagnostics);
output.WriteStringSet(si.Files);
output.Dispose();
success = true;
}
finally
{
if (!success)
{
IOUtils.CloseWhileHandlingException(output);
try
{
si.Dir.DeleteFile(fileName);
}
catch (Exception)
{
// Suppress so we keep throwing the original exception
}
}
}
return fileName;
}