@Override public void close() throws IOException { try { DataOutputViewStreamWrapper o = this.outView; if (o != null) { o.close(); } } finally { super.close(); } }
public static void testSerialization(String[] values) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(4096); DataOutputViewStreamWrapper serializer = new DataOutputViewStreamWrapper(baos); for (String value : values) { StringValue sv = new StringValue(value); sv.write(serializer); } serializer.close(); baos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); DataInputViewStreamWrapper deserializer = new DataInputViewStreamWrapper(bais); int num = 0; while (bais.available() > 0) { StringValue deser = new StringValue(); deser.read(deserializer); assertEquals("DeserializedString differs from original string.", values[num], deser.getValue()); num++; } assertEquals("Wrong number of deserialized values", values.length, num); }
serializer.close(); baos.close();
@Override public void close() throws IOException { try { DataOutputViewStreamWrapper o = this.outView; if (o != null) { o.close(); } } finally { super.close(); } }
@Override public void close() throws IOException { try { DataOutputViewStreamWrapper o = this.outView; if (o != null) { o.close(); } } finally { super.close(); } }
private void checkpointRecordQueueState() throws Exception { final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); final DataOutputViewStreamWrapper dataOutputView = new DataOutputViewStreamWrapper(byteArrayOutputStream); try { snapshotQueueState(this.priorityQueue, dataOutputView); this.queuedRecordsState.clear(); this.queuedRecordsState.add(byteArrayOutputStream.toByteArray()); } finally { dataOutputView.close(); byteArrayOutputStream.close(); } }
private void checkpointRecordQueueState() throws Exception { final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); final DataOutputViewStreamWrapper dataOutputView = new DataOutputViewStreamWrapper(byteArrayOutputStream); try { snapshotQueueState(this.priorityQueue, dataOutputView); this.queuedRecordsState.clear(); this.queuedRecordsState.add(byteArrayOutputStream.toByteArray()); } finally { dataOutputView.close(); byteArrayOutputStream.close(); } }
@Override public void write(DataOutputView out) throws IOException { int num = this.aggNames.length; out.writeInt(num); ByteArrayOutputStream boas = new ByteArrayOutputStream(); DataOutputViewStreamWrapper bufferStream = new DataOutputViewStreamWrapper(boas); for (int i = 0; i < num; i++) { // aggregator name and type out.writeUTF(this.aggNames[i]); out.writeUTF(this.aggregates[i].getClass().getName()); // aggregator value indirect as a byte array this.aggregates[i].write(bufferStream); bufferStream.flush(); byte[] bytes = boas.toByteArray(); out.writeInt(bytes.length); out.write(bytes); boas.reset(); } bufferStream.close(); boas.close(); }
@Override public void write(DataOutputView out) throws IOException { int num = this.aggNames.length; out.writeInt(num); ByteArrayOutputStream boas = new ByteArrayOutputStream(); DataOutputViewStreamWrapper bufferStream = new DataOutputViewStreamWrapper(boas); for (int i = 0; i < num; i++) { // aggregator name and type out.writeUTF(this.aggNames[i]); out.writeUTF(this.aggregates[i].getClass().getName()); // aggregator value indirect as a byte array this.aggregates[i].write(bufferStream); bufferStream.flush(); byte[] bytes = boas.toByteArray(); out.writeInt(bytes.length); out.write(bytes); boas.reset(); } bufferStream.close(); boas.close(); }
@Override public void write(DataOutputView out) throws IOException { int num = this.aggNames.length; out.writeInt(num); ByteArrayOutputStream boas = new ByteArrayOutputStream(); DataOutputViewStreamWrapper bufferStream = new DataOutputViewStreamWrapper(boas); for (int i = 0; i < num; i++) { // aggregator name and type out.writeUTF(this.aggNames[i]); out.writeUTF(this.aggregates[i].getClass().getName()); // aggregator value indirect as a byte array this.aggregates[i].write(bufferStream); bufferStream.flush(); byte[] bytes = boas.toByteArray(); out.writeInt(bytes.length); out.write(bytes); boas.reset(); } bufferStream.close(); boas.close(); }
@Override public void write(DataOutputView out) throws IOException { int num = this.aggNames.length; out.writeInt(num); ByteArrayOutputStream boas = new ByteArrayOutputStream(); DataOutputViewStreamWrapper bufferStream = new DataOutputViewStreamWrapper(boas); for (int i = 0; i < num; i++) { // aggregator name and type out.writeUTF(this.aggNames[i]); out.writeUTF(this.aggregates[i].getClass().getName()); // aggregator value indirect as a byte array this.aggregates[i].write(bufferStream); bufferStream.flush(); byte[] bytes = boas.toByteArray(); out.writeInt(bytes.length); out.write(bytes); boas.reset(); } bufferStream.close(); boas.close(); }
inputId.copy(inputView, outputView); byte[] writtenBytesOfCopy = outputStreamForCopy.toByteArray(); outputView.close(); inputView.close();