Class FieldComparer.TermValComparer
Sorts by field's natural Term sort order. All comparisons are done using CompareTo(BytesRef), which is slow for medium to large result sets but possibly very fast for very small results sets.
Inherited Members
Namespace: Lucene.Net.Search
Assembly: Lucene.Net.dll
Syntax
public sealed class FieldComparer.TermValComparer : FieldComparer<BytesRef>
Properties
this[int]
Return the actual value in the slot. LUCENENET NOTE: This was value(int) in Lucene.
Declaration
public override BytesRef this[int slot] { get; }
Parameters
Type | Name | Description |
---|---|---|
int | slot | The value |
Property Value
Type | Description |
---|---|
BytesRef | Value in this slot |
Overrides
Methods
Compare(int, int)
Compare hit at slot1
with hit at slot2
.
Declaration
public override int Compare(int slot1, int slot2)
Parameters
Type | Name | Description |
---|---|---|
int | slot1 | first slot to compare |
int | slot2 | second slot to compare |
Returns
Type | Description |
---|---|
int | any N < 0 if |
Overrides
CompareBottom(int)
Compare the bottom of the queue with this doc. This will only invoked after SetBottom(int) has been called. This should return the same result as Compare(int, int) as if bottom were slot1 and the new document were slot 2.
For a search that hits many results, this method will be the hotspot (invoked by far the most frequently).
Declaration
public override int CompareBottom(int doc)
Parameters
Type | Name | Description |
---|---|---|
int | doc | Doc that was hit |
Returns
Type | Description |
---|---|
int | Any N < 0 if the doc's value is sorted after the bottom entry (not competitive), any N > 0 if the doc's value is sorted before the bottom entry and 0 if they are equal. |
Overrides
CompareTop(int)
Compare the top value with this doc. This will only invoked after SetTopValue(T) has been called. This should return the same result as Compare(int, int) as if topValue were slot1 and the new document were slot 2. This is only called for searches that use SearchAfter (deep paging).
Declaration
public override int CompareTop(int doc)
Parameters
Type | Name | Description |
---|---|---|
int | doc | Doc that was hit |
Returns
Type | Description |
---|---|
int | Any N < 0 if the doc's value is sorted after the bottom entry (not competitive), any N > 0 if the doc's value is sorted before the bottom entry and 0 if they are equal. |
Overrides
CompareValues(BytesRef, BytesRef)
Returns -1 if first is less than second. Default
implementation to assume the type implements IComparable<T> and
invoke CompareTo(T); be sure to override this method if
your FieldComparer<T>'s type isn't a IComparable<T> or
if you need special null
handling.
Declaration
public override int CompareValues(BytesRef val1, BytesRef val2)
Parameters
Type | Name | Description |
---|---|---|
BytesRef | val1 | |
BytesRef | val2 |
Returns
Type | Description |
---|---|
int |
Overrides
Copy(int, int)
This method is called when a new hit is competitive. You should copy any state associated with this document that will be required for future comparisons, into the specified slot.
Declaration
public override void Copy(int slot, int doc)
Parameters
Type | Name | Description |
---|---|---|
int | slot | Which slot to copy the hit to |
int | doc | DocID relative to current reader |
Overrides
SetBottom(int)
Set the bottom slot, ie the "weakest" (sorted last) entry in the queue. When CompareBottom(int) is called, you should compare against this slot. This will always be called before CompareBottom(int).
Declaration
public override void SetBottom(int slot)
Parameters
Type | Name | Description |
---|---|---|
int | slot | the currently weakest (sorted last) slot in the queue |
Overrides
SetNextReader(AtomicReaderContext)
Set a new AtomicReaderContext. All subsequent docIDs are relative to the current reader (you must add docBase if you need to map it to a top-level docID).
Declaration
public override FieldComparer SetNextReader(AtomicReaderContext context)
Parameters
Type | Name | Description |
---|---|---|
AtomicReaderContext | context | Current reader context |
Returns
Type | Description |
---|---|
FieldComparer | The comparer to use for this segment; most comparers can just return "this" to reuse the same comparer across segments |
Overrides
Exceptions
Type | Condition |
---|---|
IOException | If there is a low-level IO error |
SetTopValue(BytesRef)
Record the top value, for future calls to CompareTop(int). This is only called for searches that use SearchAfter (deep paging), and is called before any calls to SetNextReader(AtomicReaderContext).
Declaration
public override void SetTopValue(BytesRef value)
Parameters
Type | Name | Description |
---|---|---|
BytesRef | value |