/** * @param b bytes to hash * @return Runs {@link org.apache.hadoop.io.WritableComparator#hashBytes(byte[], int)} on the * passed in array. This method is what {@link org.apache.hadoop.io.Text} and * {@link org.apache.hadoop.hbase.io.ImmutableBytesWritable} use calculating hash code. */ public static int hashCode(final byte[] b) { return hashCode(b, b.length); }
/** * @param b bytes to hash * @param length length to hash * @return A hash of <code>b</code> as an Integer that can be used as key in * Maps. */ public static Integer mapKey(final byte[] b, final int length) { return hashCode(b, length); }
/** * @param b bytes to hash * @return A hash of <code>b</code> as an Integer that can be used as key in * Maps. */ public static Integer mapKey(final byte[] b) { return hashCode(b); }
@Override public int hashCode() { if (data == null) return 0; else return Bytes.hashCode(data, offset, length); }
/** Compute hash for binary data. */ public static int hashBytes(byte[] bytes, int offset, int length) { return hashCode(bytes, offset, length); }
@Override public int hashCode() { if (data == null) { return 0; } else { if (length <= Bytes.SIZEOF_LONG && length > 0) { // to avoid hash collision of byte arrays those are converted from nearby integers/longs, which is the case for kylin dictionary long value = BytesUtil.readLong(data, offset, length); return (int) (value ^ (value >>> 32)); } return Bytes.hashCode(data, offset, length); } }
/** * @param b bytes to hash * @param length length to hash * @return A hash of <code>b</code> as an Integer that can be used as key in * Maps. */ public static Integer mapKey(final byte[] b, final int length) { return hashCode(b, length); }
/** * @param b bytes to hash * @return A hash of <code>b</code> as an Integer that can be used as key in * Maps. */ public static Integer mapKey(final byte[] b) { return hashCode(b); }
@Override public int hashCode() { if (data == null) return 0; else return Bytes.hashCode(data, offset, length); }
/** * @param b bytes to hash * @param length length to hash * @return A hash of <code>b</code> as an Integer that can be used as key in * Maps. */ public static Integer mapKey(final byte[] b, final int length) { return hashCode(b, length); }
/** * @param b bytes to hash * @return Runs {@link org.apache.hadoop.io.WritableComparator#hashBytes(byte[], int)} on the * passed in array. This method is what {@link org.apache.hadoop.io.Text} and * {@link org.apache.hadoop.hbase.io.ImmutableBytesWritable} use calculating hash code. */ public static int hashCode(final byte[] b) { return hashCode(b, b.length); }
/** * @param b bytes to hash * @return Runs {@link org.apache.hadoop.io.WritableComparator#hashBytes(byte[], int)} on the * passed in array. This method is what {@link org.apache.hadoop.io.Text} and * {@link org.apache.hadoop.hbase.io.ImmutableBytesWritable} use calculating hash code. */ public static int hashCode(final byte[] b) { return hashCode(b, b.length); }
/** * @param b bytes to hash * @return A hash of <code>b</code> as an Integer that can be used as key in * Maps. */ public static Integer mapKey(final byte[] b) { return hashCode(b); }
/** Compute hash for binary data. */ public static int hashBytes(byte[] bytes, int offset, int length) { return hashCode(bytes, offset, length); }
@Override public int hashCode() { return Bytes.hashCode(data); }
@Override public int hashCode() { if (data == null) { return 0; } else { if (length <= Bytes.SIZEOF_LONG && length > 0) { // to avoid hash collision of byte arrays those are converted from nearby integers/longs, which is the case for kylin dictionary long value = BytesUtil.readLong(data, offset, length); return (int) (value ^ (value >>> 32)); } return Bytes.hashCode(data, offset, length); } }