本文整理汇总了C#中Lucene.Net.Index.ParallelReader类的典型用法代码示例。如果您正苦于以下问题:C# ParallelReader类的具体用法?C# ParallelReader怎么用?C# ParallelReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParallelReader类属于Lucene.Net.Index命名空间,在下文中一共展示了ParallelReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestFieldNames
public virtual void TestFieldNames()
{
Directory dir1 = GetDir1();
Directory dir2 = GetDir2();
ParallelReader pr = new ParallelReader();
pr.Add(IndexReader.Open(dir1));
pr.Add(IndexReader.Open(dir2));
System.Collections.Generic.ICollection<string> fieldNames = pr.GetFieldNames(IndexReader.FieldOption.ALL);
Assert.AreEqual(4, fieldNames.Count);
Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "f1"));
Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "f2"));
Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "f3"));
Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "f4"));
}
示例2: Parallel
// Fields 1 & 2 in one index, 3 & 4 in other, with ParallelReader:
private Searcher Parallel()
{
Directory dir1 = GetDir1();
Directory dir2 = GetDir2();
ParallelReader pr = new ParallelReader();
pr.Add(IndexReader.Open(dir1));
pr.Add(IndexReader.Open(dir2));
return new IndexSearcher(pr);
}
示例3: OpenReader
protected internal override IndexReader OpenReader()
{
ParallelReader pr = new ParallelReader();
pr.Add(IndexReader.Open(dir3));
pr.Add(IndexReader.Open(dir4));
pr.Add(new FilterIndexReader(IndexReader.Open(dir3)));
return pr;
}
示例4: InitBlock
private void InitBlock(ParallelReader enclosingInstance)
{
this.enclosingInstance = enclosingInstance;
}
示例5: ParallelTermDocs
public ParallelTermDocs(ParallelReader enclosingInstance)
{
InitBlock(enclosingInstance);
}
示例6: ParallelTermEnum
public ParallelTermEnum(ParallelReader enclosingInstance)
{
InitBlock(enclosingInstance);
try
{
field = ((System.String) Enclosing_Instance.fieldToReader.GetKey(0));
}
catch (ArgumentOutOfRangeException e)
{
// No fields, so keep field == null, termEnum == null
return;
}
if (field != null)
termEnum = ((IndexReader) Enclosing_Instance.fieldToReader[field]).Terms();
}
示例7: Test1
public virtual void Test1()
{
ParallelReader pr = new ParallelReader();
pr.Add(ir1);
pr.Add(ir2);
TermDocs td = pr.TermDocs();
TermEnum te = pr.Terms();
Assert.IsTrue(te.Next());
Assert.AreEqual("field1:brown", te.Term.ToString());
td.Seek(te.Term);
Assert.IsTrue(td.Next());
Assert.AreEqual(0, td.Doc);
Assert.IsFalse(td.Next());
Assert.IsTrue(te.Next());
Assert.AreEqual("field1:fox", te.Term.ToString());
td.Seek(te.Term);
Assert.IsTrue(td.Next());
Assert.AreEqual(0, td.Doc);
Assert.IsFalse(td.Next());
Assert.IsTrue(te.Next());
Assert.AreEqual("field1:jumps", te.Term.ToString());
td.Seek(te.Term);
Assert.IsTrue(td.Next());
Assert.AreEqual(0, td.Doc);
Assert.IsFalse(td.Next());
Assert.IsTrue(te.Next());
Assert.AreEqual("field1:quick", te.Term.ToString());
td.Seek(te.Term);
Assert.IsTrue(td.Next());
Assert.AreEqual(0, td.Doc);
Assert.IsFalse(td.Next());
Assert.IsTrue(te.Next());
Assert.AreEqual("field1:the", te.Term.ToString());
td.Seek(te.Term);
Assert.IsTrue(td.Next());
Assert.AreEqual(0, td.Doc);
Assert.IsFalse(td.Next());
Assert.IsTrue(te.Next());
Assert.AreEqual("field2:brown", te.Term.ToString());
td.Seek(te.Term);
Assert.IsTrue(td.Next());
Assert.AreEqual(0, td.Doc);
Assert.IsFalse(td.Next());
Assert.IsTrue(te.Next());
Assert.AreEqual("field2:fox", te.Term.ToString());
td.Seek(te.Term);
Assert.IsTrue(td.Next());
Assert.AreEqual(0, td.Doc);
Assert.IsFalse(td.Next());
Assert.IsTrue(te.Next());
Assert.AreEqual("field2:jumps", te.Term.ToString());
td.Seek(te.Term);
Assert.IsTrue(td.Next());
Assert.AreEqual(0, td.Doc);
Assert.IsFalse(td.Next());
Assert.IsTrue(te.Next());
Assert.AreEqual("field2:quick", te.Term.ToString());
td.Seek(te.Term);
Assert.IsTrue(td.Next());
Assert.AreEqual(0, td.Doc);
Assert.IsFalse(td.Next());
Assert.IsTrue(te.Next());
Assert.AreEqual("field2:the", te.Term.ToString());
td.Seek(te.Term);
Assert.IsTrue(td.Next());
Assert.AreEqual(0, td.Doc);
Assert.IsFalse(td.Next());
Assert.IsTrue(te.Next());
Assert.AreEqual("field3:dog", te.Term.ToString());
td.Seek(te.Term);
Assert.IsTrue(td.Next());
Assert.AreEqual(0, td.Doc);
Assert.IsFalse(td.Next());
Assert.IsTrue(te.Next());
Assert.AreEqual("field3:fox", te.Term.ToString());
td.Seek(te.Term);
Assert.IsTrue(td.Next());
Assert.AreEqual(0, td.Doc);
Assert.IsFalse(td.Next());
Assert.IsTrue(te.Next());
Assert.AreEqual("field3:jumps", te.Term.ToString());
td.Seek(te.Term);
Assert.IsTrue(td.Next());
Assert.AreEqual(0, td.Doc);
Assert.IsFalse(td.Next());
Assert.IsTrue(te.Next());
Assert.AreEqual("field3:lazy", te.Term.ToString());
td.Seek(te.Term);
Assert.IsTrue(td.Next());
Assert.AreEqual(0, td.Doc);
Assert.IsFalse(td.Next());
Assert.IsTrue(te.Next());
Assert.AreEqual("field3:over", te.Term.ToString());
td.Seek(te.Term);
Assert.IsTrue(td.Next());
Assert.AreEqual(0, td.Doc);
Assert.IsFalse(td.Next());
Assert.IsTrue(te.Next());
//.........这里部分代码省略.........
示例8: ParallelTermEnum
public ParallelTermEnum(ParallelReader enclosingInstance)
{
InitBlock(enclosingInstance);
try
{
field = Enclosing_Instance.fieldToReader.Keys.First();
}
catch (ArgumentOutOfRangeException)
{
// No fields, so keep field == null, termEnum == null
return;
}
if (field != null)
termEnum = Enclosing_Instance.fieldToReader[field].Terms();
}
示例9: ParallelTermDocs
public ParallelTermDocs(ParallelReader enclosingInstance, Term term)
{
InitBlock(enclosingInstance);
Seek(term);
}
示例10: ParallelTermEnum
public ParallelTermEnum(ParallelReader enclosingInstance, Term term)
{
InitBlock(enclosingInstance);
field = term.Field();
termEnum = ((IndexReader) Enclosing_Instance.fieldToReader[field]).Terms(term);
}
示例11: TestIncompatibleIndexes
public virtual void TestIncompatibleIndexes()
{
// two documents:
Directory dir1 = GetDir1();
// one document only:
Directory dir2 = new MockRAMDirectory();
IndexWriter w2 = new IndexWriter(dir2, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
Document d3 = new Document();
d3.Add(new Field("f3", "v1", Field.Store.YES, Field.Index.ANALYZED));
w2.AddDocument(d3);
w2.Close();
ParallelReader pr = new ParallelReader();
pr.Add(IndexReader.Open(dir1, false));
Assert.Throws<ArgumentException>(() => pr.Add(IndexReader.Open(dir2, false)),
"didn't get exptected exception: indexes don't have same number of documents");
}
示例12: TestDocument
public virtual void TestDocument()
{
Directory dir1 = GetDir1();
Directory dir2 = GetDir2();
ParallelReader pr = new ParallelReader();
pr.Add(IndexReader.Open(dir1));
pr.Add(IndexReader.Open(dir2));
Document doc11 = pr.Document(0, new MapFieldSelector(new System.String[]{"f1"}));
Document doc24 = pr.Document(1, new MapFieldSelector(new System.Collections.ArrayList(new System.String[]{"f4"})));
Document doc223 = pr.Document(1, new MapFieldSelector(new System.String[]{"f2", "f3"}));
Assert.AreEqual(1, doc11.GetFields().Count);
Assert.AreEqual(1, doc24.GetFields().Count);
Assert.AreEqual(2, doc223.GetFields().Count);
Assert.AreEqual("v1", doc11.Get("f1"));
Assert.AreEqual("v2", doc24.Get("f4"));
Assert.AreEqual("v2", doc223.Get("f2"));
Assert.AreEqual("v2", doc223.Get("f3"));
}
示例13: TestReferenceCountingParallelReader
public virtual void TestReferenceCountingParallelReader()
{
for (int mode = 0; mode <= 1; mode++)
{
Directory dir1 = new MockRAMDirectory();
CreateIndex(dir1, false);
Directory dir2 = new MockRAMDirectory();
CreateIndex(dir2, true);
IndexReader reader1 = IndexReader.Open(dir1);
AssertRefCountEquals(1, reader1);
ParallelReader parallelReader1 = new ParallelReader(mode == 0);
parallelReader1.Add(reader1);
IndexReader initReader2 = IndexReader.Open(dir2);
parallelReader1.Add(initReader2);
ModifyIndex(1, dir2);
AssertRefCountEquals(1 + mode, reader1);
IndexReader parallelReader2 = parallelReader1.Reopen();
// index1 hasn't changed, so parallelReader2 should share reader1 now with multiReader1
AssertRefCountEquals(2 + mode, reader1);
ModifyIndex(0, dir1);
ModifyIndex(0, dir2);
IndexReader reader2 = reader1.Reopen();
AssertRefCountEquals(2 + mode, reader1);
if (mode == 1)
{
initReader2.Close();
}
ModifyIndex(4, dir1);
IndexReader reader3 = reader2.Reopen();
AssertRefCountEquals(2 + mode, reader1);
AssertRefCountEquals(1, reader2);
parallelReader1.Close();
AssertRefCountEquals(1 + mode, reader1);
parallelReader1.Close();
AssertRefCountEquals(1 + mode, reader1);
if (mode == 1)
{
initReader2.Close();
}
reader1.Close();
AssertRefCountEquals(1, reader1);
parallelReader2.Close();
AssertRefCountEquals(0, reader1);
parallelReader2.Close();
AssertRefCountEquals(0, reader1);
reader3.Close();
AssertRefCountEquals(0, reader1);
AssertReaderClosed(reader1, true, false);
reader2.Close();
AssertRefCountEquals(0, reader1);
AssertReaderClosed(reader1, true, false);
reader2.Close();
AssertRefCountEquals(0, reader1);
reader3.Close();
AssertRefCountEquals(0, reader1);
AssertReaderClosed(reader1, true, true);
dir1.Close();
dir2.Close();
}
}
示例14: TestParallelReader
public virtual void TestParallelReader()
{
Directory dir1 = new MockRAMDirectory();
TestIndexReaderReopen.CreateIndex(dir1, true);
Directory dir2 = new MockRAMDirectory();
TestIndexReaderReopen.CreateIndex(dir2, true);
IndexReader r1 = IndexReader.Open(dir1, false);
IndexReader r2 = IndexReader.Open(dir2, false);
ParallelReader pr1 = new ParallelReader();
pr1.Add(r1);
pr1.Add(r2);
PerformDefaultTests(pr1);
pr1.Close();
dir1.Close();
dir2.Close();
}
示例15: TestIncompatibleIndexes
public virtual void TestIncompatibleIndexes()
{
// two documents:
Directory dir1 = GetDir1();
// one document only:
Directory dir2 = new MockRAMDirectory();
IndexWriter w2 = new IndexWriter(dir2, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
Document d3 = new Document();
d3.Add(new Field("f3", "v1", Field.Store.YES, Field.Index.ANALYZED));
w2.AddDocument(d3);
w2.Close();
ParallelReader pr = new ParallelReader();
pr.Add(IndexReader.Open(dir1));
try
{
pr.Add(IndexReader.Open(dir2));
Assert.Fail("didn't get exptected exception: indexes don't have same number of documents");
}
catch (System.ArgumentException e)
{
// expected exception
}
}