本文整理汇总了C#中Lucene.Net.Index.Term.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# Term.CompareTo方法的具体用法?C# Term.CompareTo怎么用?C# Term.CompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Index.Term
的用法示例。
在下文中一共展示了Term.CompareTo方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SkipTo
public virtual bool SkipTo(Term target)
{
do
{
if (!Next())
return false;
}
while (target.CompareTo(Term()) > 0);
return true;
}
示例2: Add
/// <summary>Adds a new <Term, TermInfo> pair to the set.
/// Term must be lexicographically greater than all previous Terms added.
/// TermInfo pointers must be positive and greater than all previous.
/// </summary>
/*internal*/
public void Add(Term term, TermInfo ti)
{
if (!isIndex && term.CompareTo(lastTerm) <= 0)
{
throw new System.IO.IOException("term out of order (\"" + term + "\".compareTo(\"" + lastTerm + "\") <= 0)");
}
if (ti.freqPointer < lastTi.freqPointer)
throw new System.IO.IOException("freqPointer out of order (" + ti.freqPointer + " < " + lastTi.freqPointer + ")");
if (ti.proxPointer < lastTi.proxPointer)
throw new System.IO.IOException("proxPointer out of order (" + ti.proxPointer + " < " + lastTi.proxPointer + ")");
if (!isIndex && size % indexInterval == 0)
other.Add(lastTerm, lastTi); // add an index term
WriteTerm(term); // write term
output.WriteVInt(ti.docFreq); // write doc freq
output.WriteVLong(ti.freqPointer - lastTi.freqPointer); // write pointers
output.WriteVLong(ti.proxPointer - lastTi.proxPointer);
if (ti.docFreq >= skipInterval)
{
output.WriteVInt(ti.skipOffset);
}
if (isIndex)
{
output.WriteVLong(other.output.GetFilePointer() - lastIndexPointer);
lastIndexPointer = other.output.GetFilePointer(); // write pointer
}
lastTi.Set(ti);
size++;
}
示例3: Next
public override bool Next()
{
SegmentMergeInfo top = (SegmentMergeInfo) queue.Top();
if (top == null)
{
term = null;
return false;
}
term = top.term;
docFreq = 0;
while (top != null && term.CompareTo(top.term) == 0)
{
queue.Pop();
docFreq += top.termEnum.DocFreq(); // increment freq
if (top.Next())
queue.Put(top);
// restore queue
else
top.Close(); // done with a segment
top = (SegmentMergeInfo) queue.Top();
}
return true;
}
示例4: CheckDeleteTerm
// used only by assert
private bool CheckDeleteTerm(Term term)
{
if (term != null) {
System.Diagnostics.Debug.Assert(lastDeleteTerm == null || term.CompareTo(lastDeleteTerm) > 0, "lastTerm=" + lastDeleteTerm + " vs term=" + term);
}
lastDeleteTerm = term;
return true;
}
示例5: GetPosition
/// <summary>Returns the position of a Term in the set or -1. </summary>
internal long GetPosition(Term term)
{
if (size == 0)
return - 1;
EnsureIndexIsRead();
int indexOffset = GetIndexOffset(term);
SegmentTermEnum enumerator = GetThreadResources().termEnum;
SeekEnum(enumerator, indexOffset);
while (term.CompareTo(enumerator.Term) > 0 && enumerator.Next())
{
}
if (term.CompareTo(enumerator.Term) == 0)
return enumerator.position;
else
return - 1;
}
示例6: Next
public override bool Next()
{
foreach (SegmentMergeInfo smi in matchingSegments)
{
if (smi == null)
break;
if (smi.Next())
queue.Add(smi);
else
smi.Dispose(); // done with segment
}
int numMatchingSegments = 0;
matchingSegments[0] = null;
SegmentMergeInfo top = queue.Top();
if (top == null)
{
term = null;
return false;
}
term = top.term;
docFreq = 0;
while (top != null && term.CompareTo(top.term) == 0)
{
matchingSegments[numMatchingSegments++] = top;
queue.Pop();
docFreq += top.termEnum.DocFreq(); // increment freq
top = queue.Top();
}
matchingSegments[numMatchingSegments] = null;
return true;
}
示例7: Get
/// <summary>Returns the TermInfo for a Term in the set, or null. </summary>
private TermInfo Get(Term term, bool useCache)
{
if (size == 0)
return null;
EnsureIndexIsRead();
TermInfo ti;
ThreadResources resources = GetThreadResources();
Cache<Term, TermInfo> cache = null;
if (useCache)
{
cache = resources.termInfoCache;
// check the cache first if the term was recently looked up
ti = cache.Get(term);
if (ti != null)
{
return ti;
}
}
// optimize sequential access: first try scanning cached enum w/o seeking
SegmentTermEnum enumerator = resources.termEnum;
if (enumerator.Term != null && ((enumerator.Prev() != null && term.CompareTo(enumerator.Prev()) > 0) || term.CompareTo(enumerator.Term) >= 0))
{
int enumOffset = (int) (enumerator.position / totalIndexInterval) + 1;
if (indexTerms.Length == enumOffset || term.CompareTo(indexTerms[enumOffset]) < 0)
{
// no need to seek
int numScans = enumerator.ScanTo(term);
if (enumerator.Term != null && term.CompareTo(enumerator.Term) == 0)
{
ti = enumerator.TermInfo();
if (cache != null && numScans > 1)
{
// we only want to put this TermInfo into the cache if
// scanEnum skipped more than one dictionary entry.
// This prevents RangeQueries or WildcardQueries to
// wipe out the cache when they iterate over a large numbers
// of terms in order
cache.Put(term, ti);
}
}
else
{
ti = null;
}
return ti;
}
}
// random-access: must seek
SeekEnum(enumerator, GetIndexOffset(term));
enumerator.ScanTo(term);
if (enumerator.Term != null && term.CompareTo(enumerator.Term) == 0)
{
ti = enumerator.TermInfo();
if (cache != null)
{
cache.Put(term, ti);
}
}
else
{
ti = null;
}
return ti;
}
示例8: GetIndexOffset
/// <summary>Returns the offset of the greatest index entry which is less than or equal to term.</summary>
private int GetIndexOffset(Term term)
{
int lo = 0; // binary search indexTerms[]
int hi = indexTerms.Length - 1;
while (hi >= lo)
{
int mid = Number.URShift((lo + hi), 1);
int delta = term.CompareTo(indexTerms[mid]);
if (delta < 0)
hi = mid - 1;
else if (delta > 0)
lo = mid + 1;
else
return mid;
}
return hi;
}
示例9: ScanEnum
/// <summary>Scans within block for matching term. </summary>
private TermInfo ScanEnum(Term term)
{
SegmentTermEnum enumerator = GetEnum();
enumerator.ScanTo(term);
if (enumerator.Term() != null && term.CompareTo(enumerator.Term()) == 0)
return enumerator.TermInfo();
else
return null;
}
示例10: Get
/// <summary>Returns the TermInfo for a Term in the set, or null. </summary>
public /*internal*/ TermInfo Get(Term term)
{
if (size == 0)
return null;
EnsureIndexIsRead();
// optimize sequential access: first try scanning cached enum w/o seeking
SegmentTermEnum enumerator = GetEnum();
if (enumerator.Term() != null && ((enumerator.Prev() != null && term.CompareTo(enumerator.Prev()) > 0) || term.CompareTo(enumerator.Term()) >= 0))
{
int enumOffset = (int) (enumerator.position / enumerator.indexInterval) + 1;
if (indexTerms.Length == enumOffset || term.CompareTo(indexTerms[enumOffset]) < 0)
return ScanEnum(term); // no need to seek
}
// random-access: must seek
SeekEnum(GetIndexOffset(term));
return ScanEnum(term);
}
示例11: Next
public override bool Next()
{
for (int i = 0; i < matchingSegments.Length; i++)
{
SegmentMergeInfo smi = matchingSegments[i];
if (smi == null)
break;
if (smi.Next())
queue.Put(smi);
else
smi.Close(); // done with segment
}
int numMatchingSegments = 0;
matchingSegments[0] = null;
SegmentMergeInfo top = (SegmentMergeInfo) queue.Top();
if (top == null)
{
term = null;
return false;
}
term = top.term;
docFreq = 0;
while (top != null && term.CompareTo(top.term) == 0)
{
matchingSegments[numMatchingSegments++] = top;
queue.Pop();
docFreq += top.termEnum.DocFreq(); // increment freq
top = (SegmentMergeInfo) queue.Top();
}
matchingSegments[numMatchingSegments] = null;
return true;
}