Show / Hide Table of Contents

    Class BytesRef

    Represents byte[], as a slice (offset + length) into an existing byte[]. The Bytes property should never be null; use EMPTY_BYTES if necessary.

    Important note: Unless otherwise noted, Lucene uses this class to represent terms that are encoded as UTF8 bytes in the index. To convert them to a .NET (which is UTF16), use Utf8ToString(). Using code like new String(bytes, offset, length) to do this is wrong, as it does not respect the correct character set and may return wrong results (depending on the platform's defaults)!

    Inheritance
    System.Object
    BytesRef
    Implements
    IComparable
    Namespace: Lucene.Net.Util
    Assembly: Lucene.Net.dll
    Syntax
    public sealed class BytesRef : IComparable<BytesRef>, IComparable

    Constructors

    | Improve this Doc View Source

    BytesRef()

    Create a BytesRef with EMPTY_BYTES

    Declaration
    public BytesRef()
    | Improve this Doc View Source

    BytesRef(ICharSequence)

    Initialize the byte[] from the UTF8 bytes for the provided ICharSequence.

    Declaration
    public BytesRef(ICharSequence text)
    Parameters
    Type Name Description
    ICharSequence text

    This must be well-formed unicode text, with no unpaired surrogates.

    | Improve this Doc View Source

    BytesRef(Byte[])

    This instance will directly reference bytes w/o making a copy. bytes should not be null.

    Declaration
    public BytesRef(byte[] bytes)
    Parameters
    Type Name Description
    System.Byte[] bytes
    | Improve this Doc View Source

    BytesRef(Byte[], Int32, Int32)

    This instance will directly reference bytes w/o making a copy. bytes should not be null.

    Declaration
    public BytesRef(byte[] bytes, int offset, int length)
    Parameters
    Type Name Description
    System.Byte[] bytes
    System.Int32 offset
    System.Int32 length
    | Improve this Doc View Source

    BytesRef(Int32)

    Create a BytesRef pointing to a new array of size capacity. Offset and length will both be zero.

    Declaration
    public BytesRef(int capacity)
    Parameters
    Type Name Description
    System.Int32 capacity
    | Improve this Doc View Source

    BytesRef(String)

    Initialize the byte[] from the UTF8 bytes for the provided .

    Declaration
    public BytesRef(string text)
    Parameters
    Type Name Description
    System.String text

    This must be well-formed unicode text, with no unpaired surrogates.

    Fields

    | Improve this Doc View Source

    EMPTY_BYTES

    An empty byte array for convenience

    Declaration
    public static readonly byte[] EMPTY_BYTES
    Field Value
    Type Description
    System.Byte[]

    Properties

    | Improve this Doc View Source

    Bytes

    The contents of the BytesRef. Should never be null.

    Declaration
    public byte[] Bytes { get; set; }
    Property Value
    Type Description
    System.Byte[]
    | Improve this Doc View Source

    Length

    Length of used bytes.

    Declaration
    public int Length { get; set; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    Offset

    Offset of first valid byte.

    Declaration
    public int Offset { get; set; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    UTF8SortedAsUnicodeComparer

    Declaration
    public static IComparer<BytesRef> UTF8SortedAsUnicodeComparer { get; }
    Property Value
    Type Description
    IComparer<BytesRef>
    | Improve this Doc View Source

    UTF8SortedAsUTF16Comparer

    Declaration
    public static IComparer<BytesRef> UTF8SortedAsUTF16Comparer { get; }
    Property Value
    Type Description
    IComparer<BytesRef>

    Methods

    | Improve this Doc View Source

    Append(BytesRef)

    Appends the bytes from the given BytesRef

    NOTE: if this would exceed the array size, this method creates a new reference array.

    Declaration
    public void Append(BytesRef other)
    Parameters
    Type Name Description
    BytesRef other
    | Improve this Doc View Source

    BytesEquals(BytesRef)

    Expert: Compares the bytes against another BytesRef, returning true if the bytes are equal.

    This is a Lucene.NET INTERNAL API, use at your own risk
    Declaration
    public bool BytesEquals(BytesRef other)
    Parameters
    Type Name Description
    BytesRef other

    Another BytesRef, should not be null.

    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Clone()

    Returns a shallow clone of this instance (the underlying bytes are not copied and will be shared by both the returned object and this object.

    Declaration
    public object Clone()
    Returns
    Type Description
    System.Object
    See Also
    DeepCopyOf(BytesRef)
    | Improve this Doc View Source

    CompareTo(BytesRef)

    Unsigned byte order comparison

    Declaration
    public int CompareTo(BytesRef other)
    Parameters
    Type Name Description
    BytesRef other
    Returns
    Type Description
    System.Int32
    | Improve this Doc View Source

    CompareTo(Object)

    Unsigned byte order comparison

    Declaration
    public int CompareTo(object other)
    Parameters
    Type Name Description
    System.Object other
    Returns
    Type Description
    System.Int32
    | Improve this Doc View Source

    CopyBytes(BytesRef)

    Copies the bytes from the given BytesRef

    NOTE: if this would exceed the array size, this method creates a new reference array.

    Declaration
    public void CopyBytes(BytesRef other)
    Parameters
    Type Name Description
    BytesRef other
    | Improve this Doc View Source

    CopyChars(ICharSequence)

    Copies the UTF8 bytes for this ICharSequence.

    Declaration
    public void CopyChars(ICharSequence text)
    Parameters
    Type Name Description
    ICharSequence text

    Must be well-formed unicode text, with no unpaired surrogates or invalid UTF16 code units.

    | Improve this Doc View Source

    CopyChars(String)

    Copies the UTF8 bytes for this .

    Declaration
    public void CopyChars(string text)
    Parameters
    Type Name Description
    System.String text

    Must be well-formed unicode text, with no unpaired surrogates or invalid UTF16 code units.

    | Improve this Doc View Source

    DeepCopyOf(BytesRef)

    Creates a new BytesRef that points to a copy of the bytes from other.

    The returned BytesRef will have a length of other.Length and an offset of zero.

    Declaration
    public static BytesRef DeepCopyOf(BytesRef other)
    Parameters
    Type Name Description
    BytesRef other
    Returns
    Type Description
    BytesRef
    | Improve this Doc View Source

    Equals(Object)

    Declaration
    public override bool Equals(object other)
    Parameters
    Type Name Description
    System.Object other
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    GetHashCode()

    Calculates the hash code as required by Lucene.Net.Index.TermsHash during indexing.

    This is currently implemented as MurmurHash3 (32 bit), using the seed from GOOD_FAST_HASH_SEED, but is subject to change from release to release.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    System.Int32
    | Improve this Doc View Source

    Grow(Int32)

    Used to grow the reference array.

    In general this should not be used as it does not take the offset into account.

    This is a Lucene.NET INTERNAL API, use at your own risk
    Declaration
    public void Grow(int newLength)
    Parameters
    Type Name Description
    System.Int32 newLength
    | Improve this Doc View Source

    IsValid()

    Performs internal consistency checks. Always returns true (or throws )

    Declaration
    public bool IsValid()
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    ToString()

    Returns hex encoded bytes, eg [0x6c 0x75 0x63 0x65 0x6e 0x65]

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    Utf8ToString()

    Interprets stored bytes as UTF8 bytes, returning the resulting .

    Declaration
    public string Utf8ToString()
    Returns
    Type Description
    System.String

    Implements

    IComparable
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)