/** * Reads {@code [offset, offset + 7]} bytes of the byte sequence represented by the given * {@code input} as a single {@code long} value. * * @param input the object to access * @param offset offset to the first byte to read within the byte sequence represented * by the given object * @return eight bytes as a {@code long} value, in {@linkplain #byteOrder(Object) the expected * order} */ public long getLong(T input, long offset) { if (byteOrder(input) == LITTLE_ENDIAN) { return getUnsignedInt(input, offset) | (getUnsignedInt(input, offset + 4L) << 32); } else { return getUnsignedInt(input, offset + 4L) | (getUnsignedInt(input, offset) << 32); } }
/** * Shortcut for {@code getByte(input, offset) & 0xFF}. Could be implemented more efficiently. * * @param input the object to access * @param offset offset to the byte to read within the byte sequence represented * by the given object * @return a byte by the given {@code offset}, interpreted as unsigned */ public int getUnsignedByte(T input, long offset) { return getByte(input, offset) & 0xFF; }
/** * Shortcut for {@code getInt(input, offset) & 0xFFFFFFFFL}. Could be implemented more * efficiently. * * @param input the object to access * @param offset offset to the first byte to read within the byte sequence represented * by the given object * @return four bytes as an unsigned int value, in {@linkplain #byteOrder(Object) the expected * order} */ public long getUnsignedInt(T input, long offset) { return ((long) getInt(input, offset)) & 0xFFFFFFFFL; }
/** * Reads {@code [offset, offset + 3]} bytes of the byte sequence represented by the given * {@code input} as a single {@code int} value. * * @param input the object to access * @param offset offset to the first byte to read within the byte sequence represented * by the given object * @return four bytes as an {@code int} value, in {@linkplain #byteOrder(Object) the expected * order} */ public int getInt(T input, long offset) { if (byteOrder(input) == LITTLE_ENDIAN) { return getUnsignedShort(input, offset) | (getUnsignedShort(input, offset + 2L) << 16); } else { return getUnsignedShort(input, offset + 2L) | (getUnsignedShort(input, offset) << 16); } }
/** * Shortcut for {@code getShort(input, offset) & 0xFFFF}. Could be implemented more * efficiently. * * @param input the object to access * @param offset offset to the first byte to read within the byte sequence represented * by the given object * @return two bytes as an unsigned short value, in {@linkplain #byteOrder(Object) the expected * order} */ public int getUnsignedShort(T input, long offset) { if (byteOrder(input) == LITTLE_ENDIAN) { return getUnsignedByte(input, offset) | (getUnsignedByte(input, offset + 1L) << 8); } else { return getUnsignedByte(input, offset + 1L) | (getUnsignedByte(input, offset) << 8); } }
@Override public <T> long hash(T input, Access<T> access, long off, long len) { CityAndFarmHash_1_1 instance = access.byteOrder(input) == LITTLE_ENDIAN ? CityAndFarmHash_1_1.INSTANCE : BigEndian.INSTANCE; if (len <= 64) { return instance.naHash64(access, input, off, len); } return instance.uoHash64WithSeeds(access, input, off, len, 81, 0); } }
<T> long fetch64(Access<T> access, T in, long off) { return access.getLong(in, off); }
<T> int fetch8(Access<T> access, T in, long off) { return access.getUnsignedByte(in, off); }
/** * Reads {@code [offset, offset + 1]} bytes of the byte sequence represented by the given * {@code input} as a single {@code short} value, returned widened to {@code int}. * * @param input the object to access * @param offset offset to the first byte to read within the byte sequence represented * by the given object * @return two bytes as a {@code short} value, in {@linkplain #byteOrder(Object) the expected * order}, widened to {@code int} */ public int getShort(T input, long offset) { return (int) (short) getUnsignedShort(input, offset); }
<T> long fetch32(Access<T> access, T in, long off) { return access.getUnsignedInt(in, off); }
@Override <T> long fetch16(Access<T> access, T in, long off) { return Short.reverseBytes((short)access.getShort(in, off)) & 0xFFFFL; }
@Override public <T> long hash(T input, Access<T> access, long off, long len) { if (access.byteOrder(input) == LITTLE_ENDIAN) { return CityAndFarmHash_1_1.INSTANCE.uoHash64WithSeeds( access, input, off, len, seed0, seed1); } else { return BigEndian.INSTANCE.uoHash64WithSeeds(access, input, off, len, seed0, seed1); } } }
<T> long fetch64(Access<T> access, T in, long off) { return access.getLong(in, off); }
<T> int fetch8(Access<T> access, T in, long off) { return access.getUnsignedByte(in, off); }
<T> long fetch16(Access<T> access, T in, long off) { return access.getUnsignedShort(in, off); }
<T> long fetch32(Access<T> access, T in, long off) { return access.getUnsignedInt(in, off); }
@Override public <T> long hash(T input, Access<T> access, long off, long len) { long seed = seed(); if (access.byteOrder(input) == LITTLE_ENDIAN) { return MurmurHash_3.INSTANCE.hash(seed, input, access, off, len); } else { return BigEndian.INSTANCE.hash(seed, input, access, off, len); } } }
<T> int fetch32(Access<T> access, T in, long off) { return access.getInt(in, off); }
<T> long fetch64(Access<T> access, T in, long off) { return access.getLong(in, off); }
switch ((int) remaining) { case 15: k2 ^= ((long) access.getUnsignedByte(input, offset + 14L)) << 48;// fall through case 14: k2 ^= ((long) access.getUnsignedByte(input, offset + 13L)) << 40;// fall through case 13: k2 ^= ((long) access.getUnsignedByte(input, offset + 12L)) << 32;// fall through case 12: k2 ^= ((long) access.getUnsignedByte(input, offset + 11L)) << 24;// fall through case 11: k2 ^= ((long) access.getUnsignedByte(input, offset + 10L)) << 16;// fall through case 10: k2 ^= ((long) access.getUnsignedByte(input, offset + 9L)) << 8; // fall through case 9: k2 ^= ((long) access.getUnsignedByte(input, offset + 8L)); // fall through case 8: k1 ^= fetch64(access, input, offset); break; case 7: k1 ^= ((long) access.getUnsignedByte(input, offset + 6L)) << 48; // fall through case 6: k1 ^= ((long) access.getUnsignedByte(input, offset + 5L)) << 40; // fall through case 5: k1 ^= ((long) access.getUnsignedByte(input, offset + 4L)) << 32; // fall through case 4: k1 ^= Primitives.unsignedInt(fetch32(access, input, offset)); break; case 3: k1 ^= ((long) access.getUnsignedByte(input, offset + 2L)) << 16; // fall through