Package org.apache.lucene.util
Class StringHelper
java.lang.Object
org.apache.lucene.util.StringHelper
Methods for manipulating strings.
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intPass this as the seed tomurmurhash3_x86_32(byte[], int, int, int).static final intlength in bytes of an ID -
Method Summary
Modifier and TypeMethodDescriptionstatic intbytesDifference(BytesRef priorTerm, BytesRef currentTerm) Compares twoBytesRef, element by element, and returns the number of elements common to both arrays (from the start of each).static booleanReturnstrueiff the ref ends with the given suffix.static StringidToString(byte[] id) Helper method to render an ID as a string, for debuggingstatic BytesRefintsRefToBytesRef(IntsRef ints) static intmurmurhash3_x86_32(byte[] data, int offset, int len, int seed) Returns the MurmurHash3_x86_32 hash.static intmurmurhash3_x86_32(BytesRef bytes, int seed) static byte[]randomId()Generates a non-cryptographic globally unique id.static intsortKeyLength(BytesRef priorTerm, BytesRef currentTerm) Returns the length ofcurrentTermneeded for use as a sort key.static booleanstartsWith(byte[] ref, BytesRef prefix) Returnstrueiff the ref starts with the given prefix.static booleanstartsWith(BytesRef ref, BytesRef prefix) Returnstrueiff the ref starts with the given prefix.
-
Field Details
-
GOOD_FAST_HASH_SEED
public static final int GOOD_FAST_HASH_SEEDPass this as the seed tomurmurhash3_x86_32(byte[], int, int, int). -
ID_LENGTH
public static final int ID_LENGTHlength in bytes of an ID- See Also:
-
-
Method Details
-
bytesDifference
Compares twoBytesRef, 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. -
sortKeyLength
Returns the length ofcurrentTermneeded for use as a sort key. so thatBytesRef.compareTo(BytesRef)still returns the same result. This method assumes currentTerm comes after priorTerm. -
startsWith
Returnstrueiff the ref starts with the given prefix. Otherwisefalse.- Parameters:
ref- thebyte[]to testprefix- the expected prefix- Returns:
- Returns
trueiff the ref starts with the given prefix. Otherwisefalse.
-
startsWith
Returnstrueiff the ref starts with the given prefix. Otherwisefalse.- Parameters:
ref- theBytesRefto testprefix- the expected prefix- Returns:
- Returns
trueiff the ref starts with the given prefix. Otherwisefalse.
-
endsWith
Returnstrueiff the ref ends with the given suffix. Otherwisefalse.- Parameters:
ref- theBytesRefto testsuffix- the expected suffix- Returns:
- Returns
trueiff the ref ends with the given suffix. Otherwisefalse.
-
murmurhash3_x86_32
public static int murmurhash3_x86_32(byte[] data, int offset, int len, int seed) Returns the MurmurHash3_x86_32 hash. Original source/tests at https://github.com/yonik/java_util/ -
murmurhash3_x86_32
-
randomId
public static byte[] randomId()Generates a non-cryptographic globally unique id. -
idToString
Helper method to render an ID as a string, for debuggingReturns 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. -
intsRefToBytesRef
-