/** * Reads a big-endian 4-byte integer from the begining of the given array. * @param b The array to read from. * @return An integer. * @throws IndexOutOfBoundsException if the byte array is too small. */ public static int getInt(final byte[] b) { return getInt(b, 0); }
/** * Reads a big-endian 4-byte unsigned integer from an offset in the * given array. * @param b The array to read from. * @param offset The offset in the array to start reading from. * @return A positive integer. * @throws IndexOutOfBoundsException if the byte array is too small. */ public static long getUnsignedInt(final byte[] b, final int offset) { return getInt(b, offset) & 0x00000000FFFFFFFFL; }
/** * Extracts the value of a cell containing a data point. * * @param value The contents of a cell in HBase. * @param value_idx The offset inside {@code values} at which the value * starts. * @param flags The flags for this value. * @return The value of the cell. */ static double extractFloatingPointValue(final byte[] values, final int value_idx, final byte flags) { switch (flags & Const.LENGTH_MASK) { case 7: return Double.longBitsToDouble(Bytes.getLong(values, value_idx)); case 3: return Float.intBitsToFloat(Bytes.getInt(values, value_idx)); } throw new IllegalDataException("Floating point value @ " + value_idx + " not on 8 or 4 bytes in " + Arrays.toString(values)); }
if (data[0] == MAGIC) { newstyle = true; final int metadata_length = Bytes.getInt(data, 1); if (metadata_length < 1 || metadata_length > 65000) { LOG.error("Malformed meta-data in " + Bytes.pretty(data)
/** * Extracts the value of a cell containing a data point. * * @param value The contents of a cell in HBase. * @param value_idx The offset inside {@code values} at which the value * starts. * @param flags The flags for this value. * @return The value of the cell. */ static long extractIntegerValue(final byte[] values, final int value_idx, final byte flags) { switch (flags & Const.LENGTH_MASK) { case 7: return Bytes.getLong(values, value_idx); case 3: return Bytes.getInt(values, value_idx); case 1: return Bytes.getShort(values, value_idx); case 0: return values[value_idx]; } throw new IllegalDataException("Integer value @ " + value_idx + " not on 8/4/2/1 bytes in " + Arrays.toString(values)); }
final int metadata_length = Bytes.getInt(data, 1); if (metadata_length < 1 || metadata_length > 65000) { LOG.error("Malformed META region meta-data in " + Bytes.pretty(data) final int pbuf_magic = Bytes.getInt(data, offset); if (pbuf_magic != PBUF_MAGIC) { LOG.error("Malformed META region meta-data in " + Bytes.pretty(data)
values[size] = (value.length == 8 ? Bytes.getLong(value) : Bytes.getInt(value) & 0x00000000FFFFFFFFL); size++;
deserializeProtobufRegionInfo(final KeyValue kv, final byte[][] out_start_key) { final byte[] value = kv.value(); final int magic = Bytes.getInt(value); if (magic != HBaseClient.PBUF_MAGIC) { throw BrokenMetaException.badKV(null, "the magic number is invalid", kv);