public static byte toByte(ByteBuffer buf, int offset) {
    if (buf.isDirect()) {
      return HBasePlatformDependent.getByte(directBufferAddress(buf) + offset);
    } else {
      return HBasePlatformDependent.getByte(buf.array(),
        BYTE_ARRAY_BASE_OFFSET + buf.arrayOffset() + offset);
    }
  }
Returns the byte at the given offset
@param buf    the buffer to read
@param offset the offset at which the byte has to be read
@return the byte at the given offset
hbase-common/src/main/java/org/apache/hadoop/hbase/util/UnsafeAccess.java