private static long updateTail(long hash, Object base, long address, int index, int length) { while (index <= length - 8) { hash = updateTail(hash, unsafe.getLong(base, address + index)); index += 8; } if (index <= length - 4) { hash = updateTail(hash, unsafe.getInt(base, address + index)); index += 4; } while (index < length) { hash = updateTail(hash, unsafe.getByte(base, address + index)); index++; } hash = finalShuffle(hash); return hash; }
private static long updateTail(long hash, Object base, long address, int index, int length) { while (index <= length - 8) { hash = updateTail(hash, unsafe.getLong(base, address + index)); index += 8; } if (index <= length - 4) { hash = updateTail(hash, unsafe.getInt(base, address + index)); index += 4; } while (index < length) { hash = updateTail(hash, unsafe.getByte(base, address + index)); index++; } hash = finalShuffle(hash); return hash; }
public static long hash(long value) { long hash = DEFAULT_SEED + PRIME64_5 + SizeOf.SIZE_OF_LONG; hash = updateTail(hash, value); hash = finalShuffle(hash); return hash; }
public long hash() { long hash; if (bodyLength > 0) { hash = computeBody(); } else { hash = seed + PRIME64_5; } hash += bodyLength + bufferSize; return updateTail(hash, buffer, BUFFER_ADDRESS, 0, bufferSize); }
public static long hash(long value) { long hash = DEFAULT_SEED + PRIME64_5 + SizeOf.SIZE_OF_LONG; hash = updateTail(hash, value); hash = finalShuffle(hash); return hash; }
public long hash() { long hash; if (bodyLength > 0) { hash = computeBody(); } else { hash = seed + PRIME64_5; } hash += bodyLength + bufferSize; return updateTail(hash, buffer, BUFFER_ADDRESS, 0, bufferSize); }
public static long hash(long seed, Slice data, int offset, int length) { checkPositionIndexes(0, offset + length, data.length()); Object base = data.getBase(); final long address = data.getAddress() + offset; long hash; if (length >= 32) { hash = updateBody(seed, base, address, length); } else { hash = seed + PRIME64_5; } hash += length; // round to the closest 32 byte boundary // this is the point up to which updateBody() processed int index = length & 0xFFFFFFE0; return updateTail(hash, base, address, index, length); }
public static long hash(long seed, Slice data, int offset, int length) { checkPositionIndexes(0, offset + length, data.length()); Object base = data.getBase(); final long address = data.getAddress() + offset; long hash; if (length >= 32) { hash = updateBody(seed, base, address, length); } else { hash = seed + PRIME64_5; } hash += length; // round to the closest 32 byte boundary // this is the point up to which updateBody() processed int index = length & 0xFFFFFFE0; return updateTail(hash, base, address, index, length); }