/** * Deserialize a byte array into a int array. * @param b byte array storing serialized vints * @param length number of serialized vints * @return int array */ public static int[] deserializeVIntArray(byte[] b, int length) { ByteArrayInputStream bytesIn = new ByteArrayInputStream(b); DataInputStream in = new DataInputStream(bytesIn); try { return deserializeVIntArray(in,length); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public void readFields(DataInput input) throws IOException { // Decode hasSeparator and isFixedLength from vint storing offset array length int length = WritableUtils.readVInt(input); hasSeparator = (length & 0x02) != 0; isFixedLength = (length & 0x01) != 0; length >>= 2; offsets = ByteUtil.deserializeVIntArray(input, length); }
public static int[] deserializeVIntArray(DataInput in) throws IOException { return deserializeVIntArray(in, WritableUtils.readVInt(in)); }
/** * Deserialize a byte array into a int array. * @param b byte array storing serialized vints * @return int array */ public static int[] deserializeVIntArray(byte[] b) { ByteArrayInputStream bytesIn = new ByteArrayInputStream(b); DataInputStream in = new DataInputStream(bytesIn); try { int length = WritableUtils.readVInt(in); return deserializeVIntArray(in, length); } catch (IOException e) { throw new RuntimeException(e); // not possible } finally { try { in.close(); } catch (IOException e) { throw new RuntimeException(e); // not possible } } }