本文整理汇总了C#中Lucene.Net.Index.SegmentReader类的典型用法代码示例。如果您正苦于以下问题:C# SegmentReader类的具体用法?C# SegmentReader怎么用?C# SegmentReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SegmentReader类属于Lucene.Net.Index命名空间,在下文中一共展示了SegmentReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public override void SetUp()
{
base.SetUp();
DocHelper.SetupDoc(testDoc);
SegmentInfo info = DocHelper.WriteDoc(dir, testDoc);
reader = SegmentReader.Get(info);
}
示例2: TestBadSeek
public virtual void TestBadSeek()
{
try
{
//After adding the document, we should be able to read it back in
SegmentReader reader = new SegmentReader(new SegmentInfo("test", 3, dir));
Assert.IsTrue(reader != null);
SegmentTermDocs segTermDocs = new SegmentTermDocs(reader);
Assert.IsTrue(segTermDocs != null);
segTermDocs.Seek(new Term("textField2", "bad"));
Assert.IsTrue(segTermDocs.Next() == false);
reader.Close();
}
catch (System.IO.IOException e)
{
Assert.IsTrue(false);
}
try
{
//After adding the document, we should be able to read it back in
SegmentReader reader = new SegmentReader(new SegmentInfo("test", 3, dir));
Assert.IsTrue(reader != null);
SegmentTermDocs segTermDocs = new SegmentTermDocs(reader);
Assert.IsTrue(segTermDocs != null);
segTermDocs.Seek(new Term("junk", "bad"));
Assert.IsTrue(segTermDocs.Next() == false);
reader.Close();
}
catch (System.IO.IOException e)
{
Assert.IsTrue(false);
}
}
示例3: DoBody
protected internal override object DoBody(string segmentFileName)
{
var sis = new SegmentInfos();
sis.Read(directory, segmentFileName);
var readers = new SegmentReader[sis.Size()];
for (int i = sis.Size() - 1; i >= 0; i--)
{
System.IO.IOException prior = null;
bool success = false;
try
{
readers[i] = new SegmentReader(sis.Info(i), termInfosIndexDivisor, IOContext.READ);
success = true;
}
catch (System.IO.IOException ex)
{
prior = ex;
}
finally
{
if (!success)
{
IOUtils.CloseWhileHandlingException(prior, readers);
}
}
}
return new StandardDirectoryReader(directory, readers, null, sis, termInfosIndexDivisor, false);
}
示例4: Norm
public Norm(SegmentReader enclosingInstance, IndexInput in_Renamed, int number, long normSeek)
{
InitBlock(enclosingInstance);
this.in_Renamed = in_Renamed;
this.number = number;
this.normSeek = normSeek;
}
示例5: CreateOpenBitSets
static void CreateOpenBitSets(SegmentReader reader, IDictionary<string, HashSet<string>> feeds, IDictionary<string, IDictionary<string, OpenBitSet>> bitSetLookup)
{
for (int n = 0; n < reader.MaxDoc; n++)
{
if (reader.IsDeleted(n))
{
continue;
}
Document document = reader.Document(n);
string id = document.Get("Id");
if (id == null)
{
continue;
}
foreach (var feed in feeds)
{
if (feed.Value.Contains(id))
{
bitSetLookup[feed.Key][reader.SegmentName].Set(n);
}
}
}
}
示例6: AllTermDocs
protected internal AllTermDocs(SegmentReader parent) : base(parent.MaxDoc)
{
lock (parent)
{
this.deletedDocs = parent.deletedDocs;
}
}
示例7: SegmentTermDocs
public SegmentTermDocs(SegmentReader parent)
{
this.parent = parent;
this.freqStream = (IndexInput) parent.freqStream.Clone();
this.deletedDocs = parent.deletedDocs;
this.skipInterval = parent.tis.GetSkipInterval();
}
示例8: TestDocument
public virtual void TestDocument()
{
SegmentReader[] readers = new SegmentReader[2];
Directory dir = NewDirectory();
Document doc1 = new Document();
Document doc2 = new Document();
DocHelper.SetupDoc(doc1);
DocHelper.SetupDoc(doc2);
DocHelper.WriteDoc(Random(), dir, doc1);
DocHelper.WriteDoc(Random(), dir, doc2);
DirectoryReader reader = DirectoryReader.Open(dir);
Assert.IsTrue(reader != null);
Assert.IsTrue(reader is StandardDirectoryReader);
Document newDoc1 = reader.Document(0);
Assert.IsTrue(newDoc1 != null);
Assert.IsTrue(DocHelper.NumFields(newDoc1) == DocHelper.NumFields(doc1) - DocHelper.Unstored.Count);
Document newDoc2 = reader.Document(1);
Assert.IsTrue(newDoc2 != null);
Assert.IsTrue(DocHelper.NumFields(newDoc2) == DocHelper.NumFields(doc2) - DocHelper.Unstored.Count);
Terms vector = reader.GetTermVectors(0).Terms(DocHelper.TEXT_FIELD_2_KEY);
Assert.IsNotNull(vector);
reader.Dispose();
if (readers[0] != null)
{
readers[0].Dispose();
}
if (readers[1] != null)
{
readers[1].Dispose();
}
dir.Dispose();
}
示例9: SetUp
public override void SetUp()
{
base.SetUp();
DocHelper.SetupDoc(testDoc);
SegmentInfo info = DocHelper.WriteDoc(dir, testDoc);
reader = SegmentReader.Get(true, info, IndexReader.DEFAULT_TERMS_INDEX_DIVISOR);
}
示例10: MultiSegmentReader
private int[] starts; // 1st docno for each segment
#endregion Fields
#region Constructors
/// <summary>Construct reading the named set of readers. </summary>
internal MultiSegmentReader(Directory directory, SegmentInfos sis, bool closeDirectory, bool readOnly)
: base(directory, sis, closeDirectory, readOnly)
{
// To reduce the chance of hitting FileNotFound
// (and having to retry), we open segments in
// reverse because IndexWriter merges & deletes
// the newest segments first.
SegmentReader[] readers = new SegmentReader[sis.Count];
for (int i = sis.Count - 1; i >= 0; i--)
{
try
{
readers[i] = SegmentReader.Get(readOnly, sis.Info(i));
}
catch (System.IO.IOException e)
{
// Close all readers we had opened:
for (i++; i < sis.Count; i++)
{
try
{
readers[i].Close();
}
catch (System.IO.IOException)
{
// keep going - we want to clean up as much as possible
}
}
throw e;
}
}
Initialize(readers);
}
示例11: AllTermDocs
protected internal AllTermDocs(SegmentReader parent)
{
lock (parent)
{
this.deletedDocs = parent.deletedDocs;
}
this.maxDoc = parent.MaxDoc();
}
示例12: SetUp
public override void SetUp()
{
base.SetUp();
Dir = NewDirectory();
DocHelper.SetupDoc(TestDoc);
SegmentCommitInfo info = DocHelper.WriteDoc(Random(), Dir, TestDoc);
Reader = new SegmentReader(info, DirectoryReader.DEFAULT_TERMS_INDEX_DIVISOR, IOContext.READ);
}
示例13: SetUp
public override void SetUp()
{
base.SetUp();
DocHelper.SetupDoc(doc1);
SegmentInfo info1 = DocHelper.WriteDoc(merge1Dir, doc1);
DocHelper.SetupDoc(doc2);
SegmentInfo info2 = DocHelper.WriteDoc(merge2Dir, doc2);
reader1 = SegmentReader.Get(info1);
reader2 = SegmentReader.Get(info2);
}
示例14: SetUp
public override void SetUp()
{
base.SetUp();
DocHelper.SetupDoc(doc1);
SegmentInfo info1 = DocHelper.WriteDoc(merge1Dir, doc1);
DocHelper.SetupDoc(doc2);
SegmentInfo info2 = DocHelper.WriteDoc(merge2Dir, doc2);
reader1 = SegmentReader.Get(true, info1, IndexReader.DEFAULT_TERMS_INDEX_DIVISOR);
reader2 = SegmentReader.Get(true, info2, IndexReader.DEFAULT_TERMS_INDEX_DIVISOR);
}
示例15: SegmentTermDocs
public /*protected internal*/ SegmentTermDocs(SegmentReader parent)
{
this.parent = parent;
this.freqStream = (IndexInput) parent.core.freqStream.Clone();
lock (parent)
{
this.deletedDocs = parent.deletedDocs;
}
this.skipInterval = parent.core.GetTermsReader().GetSkipInterval();
this.maxSkipLevels = parent.core.GetTermsReader().GetMaxSkipLevels();
}