UTF8StringUtil { public static int hash(byte[] bytes, int start, int coefficient, int r) { return hash(bytes, start, false, false, coefficient, r); }  static char charAt(byte[] b, int s); static int charSize(byte[] b, int s); static int getModifiedUTF8Len(char c); static int writeCharAsModifiedUTF8(char c, DataOutput dos); static int writeCharAsModifiedUTF8(char c, OutputStream dos); static int getStringLength(byte[] b, int s); static int getUTFLength(byte[] b, int s); static int getNumBytesToStoreLength(int strlen); static int UTF8ToCodePoint(byte[] b, int s); static int codePointToUTF8(int c, byte[] outputUTF8); static int normalize(byte[] bytes, int start); static int compareTo(byte[] thisBytes, int thisStart, byte[] thatBytes, int thatStart); static int rawByteCompareTo(byte[] thisBytes, int thisStart, byte[] thatBytes, int thatStart); static int lowerCaseCompareTo(byte[] thisBytes, int thisStart, byte[] thatBytes, int thatStart); static int hash(byte[] bytes, int start, int coefficient, int r); static int hash(byte[] bytes, int start); static int rawBytehash(byte[] bytes, int start); static int lowerCaseHash(byte[] bytes, int start); static StringBuilder toString(StringBuilder builder, byte[] bytes, int start); static void printUTF8StringWithQuotes(byte[] b, int s, int l, OutputStream os); static void printUTF8StringNoQuotes(byte[] b, int s, int l, OutputStream os); static void printUTF8StringWithQuotes(String str, OutputStream os); static void printUTF8StringNoQuotes(String str, OutputStream os); static int encodeUTF8Length(int length, byte[] bytes, int start); static int writeUTF8Length(int length, byte[] bytes, DataOutput out); static byte[] writeStringToBytes(String string); static String readUTF8(DataInput in); static String readUTF8(DataInput in, UTF8StringReader reader); static void writeUTF8(CharSequence str, DataOutput out); static void writeUTF8(CharSequence str, DataOutput out, UTF8StringWriter writer);  }
@Test public void testHash() throws IOException { byte[] buffer = writeStringToBytes(STRING_UTF8_MIX_LOWERCASE); int lowerHash = hash(buffer, 0); buffer = writeStringToBytes(STRING_UTF8_MIX_LOWERCASE); int upperHash = lowerCaseHash(buffer, 0); assertEquals(lowerHash, upperHash); int familyOne = hash(buffer, 0, 7, 297); int familyTwo = hash(buffer, 0, 8, 297); assertTrue(familyOne != familyTwo); }