/** * Deserialize from given byte array into given writable, * using given reusable UnsafeReusableByteArrayInput. * * @param data Byte array representing writable * @param to Object to fill * @param reusableInput Reusable input to use * @param <T> Type of the object */ public static <T extends Writable> void fromByteArrayUnsafe( byte[] data, T to, UnsafeReusableByteArrayInput reusableInput) { try { reusableInput.initialize(data, 0, data.length); to.readFields(reusableInput); if (reusableInput.available() != 0) { throw new RuntimeException( "Serialization encountered issues, " + reusableInput.available() + " bytes left to be read"); } } catch (IOException e) { throw new RuntimeException(e); } }