Class SortedInputEnumerator
This wrapper buffers incoming elements and makes sure they are sorted based on given comparer.
Note
This API is experimental and might change in incompatible ways in the next release.
Inherited Members
Namespace: Lucene.Net.Search.Suggest
Assembly: Lucene.Net.Suggest.dll
Syntax
public class SortedInputEnumerator : IInputEnumerator, IBytesRefEnumerator
Constructors
SortedInputEnumerator(IInputEnumerator)
Creates a new sorted wrapper, using Lucene.Net.Util.BytesRef.UTF8SortedAsUnicodeComparer for sorting.
Declaration
public SortedInputEnumerator(IInputEnumerator source)
Parameters
| Type | Name | Description |
|---|---|---|
| IInputEnumerator | source |
SortedInputEnumerator(IInputEnumerator, IComparer<BytesRef>)
Creates a new sorted wrapper, sorting by BytesRef (ascending) then cost (ascending).
Declaration
public SortedInputEnumerator(IInputEnumerator source, IComparer<BytesRef> comparer)
Parameters
| Type | Name | Description |
|---|---|---|
| IInputEnumerator | source | |
| IComparer<BytesRef> | comparer |
Properties
Comparer
Return the Lucene.Net.Util.BytesRef Comparer used to sort terms provided by the
iterator. This may return null if there are no items or the iterator is not
sorted. Callers may invoke this method many times, so it's best to cache a
single instance & reuse it.
Declaration
public virtual IComparer<BytesRef> Comparer { get; }
Property Value
| Type | Description |
|---|---|
| IComparer<BytesRef> |
Contexts
A term's contexts context can be used to filter suggestions. May return null, if suggest entries do not have any context
Declaration
public virtual ICollection<BytesRef> Contexts { get; }
Property Value
| Type | Description |
|---|---|
| ICollection<BytesRef> |
Current
Gets the Lucene.Net.Util.BytesRef for the current iteration. The returned Lucene.Net.Util.BytesRef may be reused across calls to Lucene.Net.Util.IBytesRefEnumerator.MoveNext().
Declaration
public virtual BytesRef Current { get; }
Property Value
| Type | Description |
|---|---|
| BytesRef |
HasContexts
Returns true if the iterator has contexts
Declaration
public virtual bool HasContexts { get; }
Property Value
| Type | Description |
|---|---|
| bool |
HasPayloads
Returns true if the iterator has payloads
Declaration
public virtual bool HasPayloads { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Payload
An arbitrary byte[] to record per suggestion. See Payload to retrieve the payload for each suggestion.
Declaration
public virtual BytesRef Payload { get; }
Property Value
| Type | Description |
|---|---|
| BytesRef |
Weight
A term's weight, higher numbers mean better suggestions.
Declaration
public virtual long Weight { get; }
Property Value
| Type | Description |
|---|---|
| long |
Methods
Decode(BytesRef, ByteArrayDataInput)
decodes the weight at the current position
Declaration
protected virtual long Decode(BytesRef scratch, ByteArrayDataInput tmpInput)
Parameters
| Type | Name | Description |
|---|---|---|
| BytesRef | scratch | |
| ByteArrayDataInput | tmpInput |
Returns
| Type | Description |
|---|---|
| long |
DecodeContexts(BytesRef, ByteArrayDataInput)
decodes the contexts at the current position
Declaration
protected virtual ISet<BytesRef> DecodeContexts(BytesRef scratch, ByteArrayDataInput tmpInput)
Parameters
| Type | Name | Description |
|---|---|---|
| BytesRef | scratch | |
| ByteArrayDataInput | tmpInput |
Returns
| Type | Description |
|---|---|
| ISet<BytesRef> |
DecodePayload(BytesRef, ByteArrayDataInput)
decodes the payload at the current position
Declaration
protected virtual BytesRef DecodePayload(BytesRef scratch, ByteArrayDataInput tmpInput)
Parameters
| Type | Name | Description |
|---|---|---|
| BytesRef | scratch | |
| ByteArrayDataInput | tmpInput |
Returns
| Type | Description |
|---|---|
| BytesRef |
Encode(ByteSequencesWriter, ByteArrayDataOutput, byte[], BytesRef, BytesRef, ICollection<BytesRef>, long)
encodes an entry (bytes+(contexts)+(payload)+weight) to the provided writer
Declaration
protected virtual void Encode(OfflineSorter.ByteSequencesWriter writer, ByteArrayDataOutput output, byte[] buffer, BytesRef spare, BytesRef payload, ICollection<BytesRef> contexts, long weight)
Parameters
| Type | Name | Description |
|---|---|---|
| OfflineSorter.ByteSequencesWriter | writer | |
| ByteArrayDataOutput | output | |
| byte[] | buffer | |
| BytesRef | spare | |
| BytesRef | payload | |
| ICollection<BytesRef> | contexts | |
| long | weight |
MoveNext()
Increments the iteration to the next Lucene.Net.Util.BytesRef in the enumerator.
Declaration
public virtual bool MoveNext()
Returns
| Type | Description |
|---|---|
| bool |
|
Exceptions
| Type | Condition |
|---|---|
| IOException | If there is a low-level I/O error. |