本文整理汇总了C#中Lucene.Net.Store.MockRAMDirectory.OpenInput方法的典型用法代码示例。如果您正苦于以下问题:C# Lucene.Net.Store.MockRAMDirectory.OpenInput方法的具体用法?C# Lucene.Net.Store.MockRAMDirectory.OpenInput怎么用?C# Lucene.Net.Store.MockRAMDirectory.OpenInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Store.MockRAMDirectory
的用法示例。
在下文中一共展示了Lucene.Net.Store.MockRAMDirectory.OpenInput方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestSegmentsChecksumError
public virtual void TestSegmentsChecksumError()
{
Directory dir = new MockRAMDirectory();
IndexWriter writer = null;
writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
// add 100 documents
for (int i = 0; i < 100; i++)
{
AddDoc(writer);
}
// close
writer.Close();
long gen = SegmentInfos.GetCurrentSegmentGeneration(dir);
Assert.IsTrue(gen > 1, "segment generation should be > 1 but got " + gen);
System.String segmentsFileName = SegmentInfos.GetCurrentSegmentFileName(dir);
IndexInput in_Renamed = dir.OpenInput(segmentsFileName);
IndexOutput out_Renamed = dir.CreateOutput(IndexFileNames.FileNameFromGeneration(IndexFileNames.SEGMENTS, "", 1 + gen));
out_Renamed.CopyBytes(in_Renamed, in_Renamed.Length() - 1);
byte b = in_Renamed.ReadByte();
out_Renamed.WriteByte((byte) (1 + b));
out_Renamed.Close();
in_Renamed.Close();
IndexReader reader = null;
try
{
reader = IndexReader.Open(dir);
}
catch (System.IO.IOException e)
{
System.Console.Out.WriteLine(e.StackTrace);
Assert.Fail("segmentInfos failed to retry fallback to correct segments_N file");
}
reader.Close();
}