@Override public long hashByte(byte input) { long hash = seed() + P5 + 1; hash ^= Primitives.unsignedByte(input) * P5; hash = Long.rotateLeft(hash, 11) * P1; return XxHash.finalize(hash); }
@Override public long hashLong(long input) { input = NATIVE_XX.toLittleEndian(input); long hash = seed() + P5 + 8; input *= P2; input = Long.rotateLeft(input, 31); input *= P1; hash ^= input; hash = Long.rotateLeft(hash, 27) * P1 + P4; return XxHash.finalize(hash); }
@Override public long hashShort(short input) { input = NATIVE_XX.toLittleEndian(input); long hash = seed() + P5 + 2; hash ^= Primitives.unsignedByte(input) * P5; hash = Long.rotateLeft(hash, 11) * P1; hash ^= Primitives.unsignedByte(input >> 8) * P5; hash = Long.rotateLeft(hash, 11) * P1; return XxHash.finalize(hash); }
@Override public long hashInt(int input) { input = NATIVE_XX.toLittleEndian(input); long hash = seed() + P5 + 4; hash ^= Primitives.unsignedInt(input) * P1; hash = Long.rotateLeft(hash, 23) * P2 + P3; return XxHash.finalize(hash); }
@Override public <T> long hash(T input, Access<T> access, long off, long len) { long seed = seed(); if (access.byteOrder(input) == LITTLE_ENDIAN) { return XxHash.INSTANCE.xxHash64(seed, input, access, off, len); } else { return BigEndian.INSTANCE.xxHash64(seed, input, access, off, len); } } }