StringHelper

Methods for manipulating strings.

Properties

Link copied to clipboard

Pass this as the seed to .murmurhash3_x86_32.

Link copied to clipboard
const val ID_LENGTH: Int = 16

length in bytes of an ID

Functions

Link copied to clipboard
fun bytesDifference(priorTerm: BytesRef, currentTerm: BytesRef?): Int

Compares two BytesRef, element by element, and returns the number of elements common to both arrays (from the start of each). This method assumes currentTerm comes after priorTerm.

Link copied to clipboard
fun endsWith(ref: BytesRef, suffix: BytesRef): Boolean

Returns true iff the ref ends with the given suffix. Otherwise false.

Link copied to clipboard

Helper method to render an ID as a string, for debugging

Link copied to clipboard

Just converts each int in the incoming IntsRef to each byte in the returned [ ], throwing IllegalArgumentException if any int value is out of bounds for a byte.

Link copied to clipboard
fun murmurhash3_x64_128(data: ByteArray, offset: Int, length: Int, seed: Int): LongArray

Generates 128-bit hash from the byte array with the given offset, length and seed.

Link copied to clipboard
fun murmurhash3_x86_32(bytes: BytesRef, seed: Int): Int

fun murmurhash3_x86_32(data: ByteArray, offset: Int, len: Int, seed: Int): Int

Returns the MurmurHash3_x86_32 hash. Original source/tests at https://github.com/yonik/java_util/

Link copied to clipboard

Generates a non-cryptographic globally unique id.

Link copied to clipboard
fun sortKeyLength(priorTerm: BytesRef, currentTerm: BytesRef): Int

Returns the length of currentTerm needed for use as a sort key. so that still returns the same result. This method assumes currentTerm comes after priorTerm.

Link copied to clipboard
fun startsWith(ref: ByteArray, prefix: BytesRef): Boolean
fun startsWith(ref: BytesRef, prefix: BytesRef): Boolean

Returns true iff the ref starts with the given prefix. Otherwise false * .