@Override public boolean endOfInput() { return available() == 0; }
/** * Deserialize from given byte array into given writable, * using new instance of ExtendedByteArrayDataInput. * * @param data Byte array representing writable * @param to Object to fill * @param <T> Type of the object */ public static <T extends Writable> void fromByteArray(byte[] data, T to) { try { ExtendedByteArrayDataInput in = new ExtendedByteArrayDataInput(data, 0, data.length); to.readFields(in); if (in.available() != 0) { throw new RuntimeException( "Serialization encountered issues, " + in.available() + " bytes left to be read"); } } catch (IOException e) { throw new RuntimeException(e); } }
public void readStash(ODAGStash stashToReadTo) { ExtendedByteArrayDataInput byteArrayInputCache = null; try { byteArrayInputCache = new ExtendedByteArrayDataInput(byteArrayOutputCache.getByteArray(), 0, byteArrayOutputCache.getPos()); LOG.info(byteArrayInputCache.available()); stashToReadTo.readFields(byteArrayInputCache); } catch (IOException e) { LOG.info("stashToReadTo: " + stashToReadTo); LOG.info("input.available: " + byteArrayInputCache.available()); LOG.info("input.pos: " + byteArrayInputCache.getPos()); LOG.info("output.pos: " + byteArrayOutputCache.getPos()); throw new RuntimeException(e); } }
public void readEzip(ODAG ezip) { ExtendedByteArrayDataInput byteArrayInputCache = null; try { byteArrayInputCache = new ExtendedByteArrayDataInput(byteArrayOutputCache.getByteArray(), 0, byteArrayOutputCache.getPos()); //LOG.info(byteArrayInputCache.available()); ezip.setPattern(pattern); ezip.readFields(byteArrayInputCache); } catch (IOException e) { LOG.info("pattern: " + pattern); LOG.info("partId: " + partId); LOG.info("ezip: " + ezip); LOG.info("input.available: " + byteArrayInputCache.available()); LOG.info("input.pos: " + byteArrayInputCache.getPos()); LOG.info("output.pos: " + byteArrayOutputCache.getPos()); throw new RuntimeException(e); } }