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 String, use utf8ToString.

BytesRef implements Comparable. The underlying byte arrays are sorted lexicographically, numerically treating elements as unsigned.

Constructors

Link copied to clipboard
constructor()

Create a BytesRef with EMPTY_BYTES

constructor(bytes: ByteArray, offset: Int, length: Int)

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

constructor(bytes: ByteArray)

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

constructor(capacity: Int)

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

constructor(text: CharSequence)

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

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The contents of the BytesRef. Should never be null.

Link copied to clipboard
var length: Int

Length of used bytes.

Link copied to clipboard
var offset: Int

Offset of first valid byte.

Functions

Link copied to clipboard

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

Link copied to clipboard

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.

Link copied to clipboard
open operator override fun compareTo(other: BytesRef): Int

Unsigned byte order comparison

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int

Calculates the hash code.

Link copied to clipboard

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

Link copied to clipboard
open override fun toString(): String

Returns hex encoded bytes, e.g. "6c 75 63 65 6e 65"

Link copied to clipboard

Interprets stored bytes as UTF-8 bytes, returning the resulting string.