use of org.apache.flink.core.memory.DataInputViewStreamWrapper in project flink by apache.
the class VersionedIOWriteableTest method testReadCompatibleVersion.
@Test
public void testReadCompatibleVersion() throws Exception {
String payload = "test";
TestWriteable testWriteable = new TestWriteable(1, payload);
byte[] serialized;
try (ByteArrayOutputStreamWithPos out = new ByteArrayOutputStreamWithPos()) {
testWriteable.write(new DataOutputViewStreamWrapper(out));
serialized = out.toByteArray();
}
testWriteable = new TestWriteable(2) {
@Override
public boolean isCompatibleVersion(int version) {
return getVersion() >= version;
}
};
try (ByteArrayInputStreamWithPos in = new ByteArrayInputStreamWithPos(serialized)) {
testWriteable.read(new DataInputViewStreamWrapper(in));
}
Assert.assertEquals(payload, testWriteable.getData());
}
use of org.apache.flink.core.memory.DataInputViewStreamWrapper in project flink by apache.
the class PrimitiveDataTypeTest method setup.
@Before
public void setup() throws Exception {
in = new PipedInputStream(1000);
out = new PipedOutputStream(in);
mIn = new DataInputViewStreamWrapper(in);
mOut = new DataOutputViewStreamWrapper(out);
}
use of org.apache.flink.core.memory.DataInputViewStreamWrapper in project flink by apache.
the class RecordITCase method setUp.
@Before
public void setUp() throws Exception {
PipedInputStream pipedInput = new PipedInputStream(32 * 1024 * 1024);
this.in = new DataInputViewStreamWrapper(pipedInput);
this.out = new DataOutputViewStreamWrapper(new PipedOutputStream(pipedInput));
}
use of org.apache.flink.core.memory.DataInputViewStreamWrapper in project flink by apache.
the class RecordTest method setUp.
@Before
public void setUp() throws Exception {
PipedInputStream pipeIn = new PipedInputStream(1024 * 1024);
PipedOutputStream pipeOut = new PipedOutputStream(pipeIn);
this.in = new DataInputViewStreamWrapper(pipeIn);
this.out = new DataOutputViewStreamWrapper(pipeOut);
}
use of org.apache.flink.core.memory.DataInputViewStreamWrapper in project flink by apache.
the class DefaultOperatorStateBackend method deserializeStateValues.
private static <S> void deserializeStateValues(PartitionableListState<S> stateListForName, FSDataInputStream in, OperatorStateHandle.StateMetaInfo metaInfo) throws IOException {
if (null != metaInfo) {
long[] offsets = metaInfo.getOffsets();
if (null != offsets) {
DataInputView div = new DataInputViewStreamWrapper(in);
TypeSerializer<S> serializer = stateListForName.getPartitionStateSerializer();
for (long offset : offsets) {
in.seek(offset);
stateListForName.add(serializer.deserialize(div));
}
}
}
}
Aggregations