@Override default short readShort(S handle, long offset) { return handle.readShort(offset); }
@Override default short readShort(S handle, long offset) { return handle.readShort(offset); }
/** * Read an unsigned short at an offset * * @param offset to read * @return the unsigned short * @throws BufferUnderflowException if the offset is outside the limits of the Bytes */ @ForceInline default int readUnsignedShort(long offset) throws BufferUnderflowException { return readShort(offset) & 0xFFFF; }
default int fastHash(long offset, int length) throws BufferUnderflowException { long hash = 0; int i = 0; if (length >= 4) { hash = readInt(offset + i); i += 4; } for (; i < length - 3; i += 4) { hash *= 0x6d0f27bd; hash += readInt(offset + i); } if (i < length - 1) { hash *= 0x6d0f27bdL; hash += readShort(offset + i); i += 2; } if (i < length) hash += readByte(offset + i); hash *= 0x855dd4db; return (int) (hash ^ (hash >> 32)); } }
public static boolean bytesEqual( @org.jetbrains.annotations.NotNull @NotNull RandomDataInput a, long offset, @org.jetbrains.annotations.NotNull @NotNull RandomDataInput second, long secondOffset, long len) throws BufferUnderflowException { long i = 0; while (len - i >= 8L) { if (a.readLong(offset + i) != second.readLong(secondOffset + i)) return false; i += 8L; } if (len - i >= 4L) { if (a.readInt(offset + i) != second.readInt(secondOffset + i)) return false; i += 4L; } if (len - i >= 2L) { if (a.readShort(offset + i) != second.readShort(secondOffset + i)) return false; i += 2L; } if (i < len) return a.readByte(offset + i) == second.readByte(secondOffset + i); return true; }