本文整理汇总了C#中Lucene.Net.Index.SegmentReader.GetDocsWithField方法的典型用法代码示例。如果您正苦于以下问题:C# SegmentReader.GetDocsWithField方法的具体用法?C# SegmentReader.GetDocsWithField怎么用?C# SegmentReader.GetDocsWithField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Index.SegmentReader
的用法示例。
在下文中一共展示了SegmentReader.GetDocsWithField方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBytesRefEnumerable
private IEnumerable<BytesRef> GetBytesRefEnumerable(SegmentReader reader, string field, BinaryDocValuesFieldUpdates fieldUpdates)
{
BinaryDocValues currentValues = reader.GetBinaryDocValues(field);
Bits DocsWithField = reader.GetDocsWithField(field);
int maxDoc = reader.MaxDoc;
var iter = (BinaryDocValuesFieldUpdates.Iterator)fieldUpdates.GetIterator();
BytesRef scratch = new BytesRef();
int updateDoc = iter.NextDoc();
for (int curDoc = 0; curDoc < maxDoc; ++curDoc)
{
if (curDoc == updateDoc) //document has an updated value
{
BytesRef value = (BytesRef)iter.Value(); // either null or updated
updateDoc = iter.NextDoc(); //prepare for next round
yield return value;
}
else
{ // no update for this document
if (currentValues != null && DocsWithField.Get(curDoc))
{
// only read the current value if the document had a value before
currentValues.Get(curDoc, scratch);
yield return scratch;
}
else
{
yield return null;
}
}
}
}
示例2: GetLongEnumerable
private IEnumerable<long?> GetLongEnumerable(SegmentReader reader, string field, NumericDocValuesFieldUpdates fieldUpdates)
{
int maxDoc = reader.MaxDoc;
Bits DocsWithField = reader.GetDocsWithField(field);
NumericDocValues currentValues = reader.GetNumericDocValues(field);
NumericDocValuesFieldUpdates.Iterator iter = (NumericDocValuesFieldUpdates.Iterator)fieldUpdates.GetIterator();
int updateDoc = iter.NextDoc();
for (int curDoc = 0; curDoc < maxDoc; ++curDoc)
{
if (curDoc == updateDoc) //document has an updated value
{
long? value = (long?)iter.Value(); // either null or updated
updateDoc = iter.NextDoc(); //prepare for next round
yield return value;
}
else
{ // no update for this document
if (currentValues != null && DocsWithField.Get(curDoc))
{
// only read the current value if the document had a value before
yield return currentValues.Get(curDoc);
}
else
{
yield return null;
}
}
}
}