本文整理汇总了C#中Lucene.Net.Index.IndexReader.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# IndexReader.Clone方法的具体用法?C# IndexReader.Clone怎么用?C# IndexReader.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Index.IndexReader
的用法示例。
在下文中一共展示了IndexReader.Clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PerformDefaultTests
/// <summary> 1. Get a norm from the original reader 2. Clone the original reader 3.
/// Delete a document and set the norm of the cloned reader 4. Verify the norms
/// are not the same on each reader 5. Verify the doc deleted is only in the
/// cloned reader 6. Try to delete a document in the original reader, an
/// exception should be thrown
///
/// </summary>
/// <param name="r1">IndexReader to perform tests on
/// </param>
/// <throws> Exception </throws>
private void PerformDefaultTests(IndexReader r1)
{
float norm1 = Similarity.DecodeNorm(r1.Norms("field1")[4]);
IndexReader pr1Clone = (IndexReader) r1.Clone();
pr1Clone.DeleteDocument(10);
pr1Clone.SetNorm(4, "field1", 0.5f);
Assert.IsTrue(Similarity.DecodeNorm(r1.Norms("field1")[4]) == norm1);
Assert.IsTrue(Similarity.DecodeNorm(pr1Clone.Norms("field1")[4]) != norm1);
Assert.IsTrue(!r1.IsDeleted(10));
Assert.IsTrue(pr1Clone.IsDeleted(10));
// try to update the original reader, which should throw an exception
try
{
r1.DeleteDocument(11);
Assert.Fail("Tried to delete doc 11 and an exception should have been thrown");
}
catch (System.Exception exception)
{
// expectted
}
pr1Clone.Close();
}
示例2: PerformDefaultTests
/// <summary> 1. Get a norm from the original reader 2. Clone the original reader 3.
/// Delete a document and set the norm of the cloned reader 4. Verify the norms
/// are not the same on each reader 5. Verify the doc deleted is only in the
/// cloned reader 6. Try to delete a document in the original reader, an
/// exception should be thrown
///
/// </summary>
/// <param name="r1">IndexReader to perform tests on
/// </param>
/// <throws> Exception </throws>
private void PerformDefaultTests(IndexReader r1)
{
float norm1 = Similarity.DecodeNorm(r1.Norms("field1")[4]);
IndexReader pr1Clone = (IndexReader) r1.Clone();
pr1Clone.DeleteDocument(10);
pr1Clone.SetNorm(4, "field1", 0.5f);
Assert.IsTrue(Similarity.DecodeNorm(r1.Norms("field1")[4]) == norm1);
Assert.IsTrue(Similarity.DecodeNorm(pr1Clone.Norms("field1")[4]) != norm1);
Assert.IsTrue(!r1.IsDeleted(10));
Assert.IsTrue(pr1Clone.IsDeleted(10));
// try to update the original reader, which should throw an exception
Assert.Throws<LockObtainFailedException>(() => r1.DeleteDocument(11),
"Tried to delete doc 11 and an exception should have been thrown");
pr1Clone.Close();
}
示例3: Initialize
private void Initialize(IndexReader[] subReaders, bool closeSubReaders)
{
this.subReaders = (IndexReader[]) subReaders.Clone();
starts = new int[subReaders.Length + 1]; // build starts array
decrefOnClose = new bool[subReaders.Length];
for (int i = 0; i < subReaders.Length; i++)
{
starts[i] = maxDoc;
maxDoc += subReaders[i].MaxDoc(); // compute maxDocs
if (!closeSubReaders)
{
subReaders[i].IncRef();
decrefOnClose[i] = true;
}
else
{
decrefOnClose[i] = false;
}
if (subReaders[i].HasDeletions())
hasDeletions = true;
}
starts[subReaders.Length] = maxDoc;
}