public abstract class StringHelper extends Object
Modifier and Type | Field and Description |
---|---|
static int |
GOOD_FAST_HASH_SEED
Pass this as the seed to
murmurhash3_x86_32(byte[], int, int, int) . |
static int |
ID_LENGTH
length in bytes of an ID
|
Modifier and Type | Method and Description |
---|---|
static int |
bytesDifference(BytesRef priorTerm,
BytesRef currentTerm)
Compares two
BytesRef , element by element, and returns the
number of elements common to both arrays (from the start of each). |
static int |
compare(int count,
byte[] a,
int aOffset,
byte[] b,
int bOffset)
Deprecated.
Use FutureArrays.compareUnsigned instead.
|
static boolean |
endsWith(BytesRef ref,
BytesRef suffix)
Returns
true iff the ref ends with the given suffix. |
static String |
idToString(byte[] id)
Helper method to render an ID as a string, for debugging
|
static BytesRef |
intsRefToBytesRef(IntsRef ints)
|
static int |
murmurhash3_x86_32(byte[] data,
int offset,
int len,
int seed)
Returns the MurmurHash3_x86_32 hash.
|
static int |
murmurhash3_x86_32(BytesRef bytes,
int seed) |
static byte[] |
randomId()
Generates a non-cryptographic globally unique id.
|
static int |
sortKeyLength(BytesRef priorTerm,
BytesRef currentTerm)
Returns the length of
currentTerm needed for use as a sort key. |
static boolean |
startsWith(byte[] ref,
BytesRef prefix)
Returns
true iff the ref starts with the given prefix. |
static boolean |
startsWith(BytesRef ref,
BytesRef prefix)
Returns
true iff the ref starts with the given prefix. |
public static final int GOOD_FAST_HASH_SEED
murmurhash3_x86_32(byte[], int, int, int)
.public static final int ID_LENGTH
public static int bytesDifference(BytesRef priorTerm, BytesRef currentTerm)
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.public static int sortKeyLength(BytesRef priorTerm, BytesRef currentTerm)
currentTerm
needed for use as a sort key.
so that BytesRef.compareTo(BytesRef)
still returns the same result.
This method assumes currentTerm comes after priorTerm.public static boolean startsWith(byte[] ref, BytesRef prefix)
true
iff the ref starts with the given prefix.
Otherwise false
.ref
- the byte[]
to testprefix
- the expected prefixtrue
iff the ref starts with the given prefix.
Otherwise false
.public static boolean startsWith(BytesRef ref, BytesRef prefix)
true
iff the ref starts with the given prefix.
Otherwise false
.ref
- the BytesRef
to testprefix
- the expected prefixtrue
iff the ref starts with the given prefix.
Otherwise false
.public static boolean endsWith(BytesRef ref, BytesRef suffix)
true
iff the ref ends with the given suffix. Otherwise
false
.ref
- the BytesRef
to testsuffix
- the expected suffixtrue
iff the ref ends with the given suffix.
Otherwise false
.public static int murmurhash3_x86_32(byte[] data, int offset, int len, int seed)
public static int murmurhash3_x86_32(BytesRef bytes, int seed)
public static byte[] randomId()
public static String idToString(byte[] id)
Returns the string (null)
if the id is null.
Otherwise, returns a string representation for debugging.
Never throws an exception. The returned string may
indicate if the id is definitely invalid.
@Deprecated public static int compare(int count, byte[] a, int aOffset, byte[] b, int bOffset)
Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.