本文整理汇总了C#中Lucene.Net.Index.SegmentReader.MaxDoc方法的典型用法代码示例。如果您正苦于以下问题:C# SegmentReader.MaxDoc方法的具体用法?C# SegmentReader.MaxDoc怎么用?C# SegmentReader.MaxDoc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Index.SegmentReader
的用法示例。
在下文中一共展示了SegmentReader.MaxDoc方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AllTermDocs
protected internal AllTermDocs(SegmentReader parent) : base(parent.MaxDoc())
{
lock (parent)
{
this.deletedDocs = parent.deletedDocs;
}
}
示例2: TestTermIndex
/// <summary> Test the term index.</summary>
private Status.TermIndexStatus TestTermIndex(SegmentInfo info, SegmentReader reader)
{
Status.TermIndexStatus status = new Status.TermIndexStatus();
try
{
if (infoStream != null)
{
infoStream.Write(" test: terms, freq, prox...");
}
TermEnum termEnum = reader.Terms();
TermPositions termPositions = reader.TermPositions();
// Used only to count up # deleted docs for this term
MySegmentTermDocs myTermDocs = new MySegmentTermDocs(reader);
int maxDoc = reader.MaxDoc();
while (termEnum.Next())
{
status.termCount++;
Term term = termEnum.Term();
int docFreq = termEnum.DocFreq();
termPositions.Seek(term);
int lastDoc = - 1;
int freq0 = 0;
status.totFreq += docFreq;
while (termPositions.Next())
{
freq0++;
int doc = termPositions.Doc();
int freq = termPositions.Freq();
if (doc <= lastDoc)
{
throw new System.SystemException("term " + term + ": doc " + doc + " <= lastDoc " + lastDoc);
}
if (doc >= maxDoc)
{
throw new System.SystemException("term " + term + ": doc " + doc + " >= maxDoc " + maxDoc);
}
lastDoc = doc;
if (freq <= 0)
{
throw new System.SystemException("term " + term + ": doc " + doc + ": freq " + freq + " is out of bounds");
}
int lastPos = - 1;
status.totPos += freq;
for (int j = 0; j < freq; j++)
{
int pos = termPositions.NextPosition();
if (pos < - 1)
{
throw new System.SystemException("term " + term + ": doc " + doc + ": pos " + pos + " is out of bounds");
}
if (pos < lastPos)
{
throw new System.SystemException("term " + term + ": doc " + doc + ": pos " + pos + " < lastPos " + lastPos);
}
}
}
// Now count how many deleted docs occurred in
// this term:
int delCount;
if (reader.HasDeletions())
{
myTermDocs.Seek(term);
while (myTermDocs.Next())
{
}
delCount = myTermDocs.delCount;
}
else
{
delCount = 0;
}
if (freq0 + delCount != docFreq)
{
throw new System.SystemException("term " + term + " docFreq=" + docFreq + " != num docs seen " + freq0 + " + num docs deleted " + delCount);
}
}
Msg("OK [" + status.termCount + " terms; " + status.totFreq + " terms/docs pairs; " + status.totPos + " tokens]");
}
catch (System.Exception e)
{
Msg("ERROR [" + System.Convert.ToString(e.Message) + "]");
status.error = e;
if (infoStream != null)
{
infoStream.WriteLine(e.StackTrace);
}
}
return status;
//.........这里部分代码省略.........
示例3: TestFieldNorms
/// <summary> Test field norms.</summary>
private Status.FieldNormStatus TestFieldNorms(System.Collections.Generic.ICollection<string> fieldNames, SegmentReader reader)
{
Status.FieldNormStatus status = new Status.FieldNormStatus();
try
{
// Test Field Norms
if (infoStream != null)
{
infoStream.Write(" test: field norms.........");
}
System.Collections.IEnumerator it = fieldNames.GetEnumerator();
byte[] b = new byte[reader.MaxDoc()];
while (it.MoveNext())
{
System.String fieldName = (System.String) it.Current;
reader.Norms(fieldName, b, 0);
++status.totFields;
}
Msg("OK [" + status.totFields + " fields]");
}
catch (System.Exception e)
{
Msg("ERROR [" + System.Convert.ToString(e.Message) + "]");
status.error = e;
if (infoStream != null)
{
infoStream.WriteLine(e.StackTrace);
}
}
return status;
}
示例4: 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();
BinaryDocValuesFieldUpdates.Iterator 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;
}
}
}
}
示例5: 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 ?? default(long);
}
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 default(long);
}
}
}
}
示例6: TestFieldNorms
/// <summary> Test field norms.</summary>
private Status.FieldNormStatus TestFieldNorms(ICollection<string> fieldNames, SegmentReader reader)
{
Status.FieldNormStatus status = new Status.FieldNormStatus();
try
{
// Test Field Norms
if (infoStream != null)
{
infoStream.Write(" test: field norms.........");
}
byte[] b = new byte[reader.MaxDoc()];
foreach(string fieldName in fieldNames)
{
if (reader.HasNorms(fieldName))
{
reader.Norms(fieldName, b, 0);
++status.totFields;
}
}
Msg("OK [" + status.totFields + " fields]");
}
catch (System.Exception e)
{
Msg("ERROR [" + System.Convert.ToString(e.Message) + "]");
status.error = e;
if (infoStream != null)
{
infoStream.WriteLine(e.StackTrace);
}
}
return status;
}