Search in sources :

Example 51 with DataInputViewStreamWrapper

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());
}
Also used : DataOutputViewStreamWrapper(org.apache.flink.core.memory.DataOutputViewStreamWrapper) ByteArrayInputStreamWithPos(org.apache.flink.core.memory.ByteArrayInputStreamWithPos) ByteArrayOutputStreamWithPos(org.apache.flink.core.memory.ByteArrayOutputStreamWithPos) DataInputViewStreamWrapper(org.apache.flink.core.memory.DataInputViewStreamWrapper) Test(org.junit.Test)

Example 52 with DataInputViewStreamWrapper

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);
}
Also used : DataOutputViewStreamWrapper(org.apache.flink.core.memory.DataOutputViewStreamWrapper) PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream) DataInputViewStreamWrapper(org.apache.flink.core.memory.DataInputViewStreamWrapper) Before(org.junit.Before)

Example 53 with DataInputViewStreamWrapper

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));
}
Also used : DataOutputViewStreamWrapper(org.apache.flink.core.memory.DataOutputViewStreamWrapper) PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream) DataInputViewStreamWrapper(org.apache.flink.core.memory.DataInputViewStreamWrapper) Before(org.junit.Before)

Example 54 with DataInputViewStreamWrapper

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);
}
Also used : DataOutputViewStreamWrapper(org.apache.flink.core.memory.DataOutputViewStreamWrapper) PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream) DataInputViewStreamWrapper(org.apache.flink.core.memory.DataInputViewStreamWrapper) Before(org.junit.Before)

Example 55 with DataInputViewStreamWrapper

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));
            }
        }
    }
}
Also used : DataInputView(org.apache.flink.core.memory.DataInputView) DataInputViewStreamWrapper(org.apache.flink.core.memory.DataInputViewStreamWrapper)

Aggregations

DataInputViewStreamWrapper (org.apache.flink.core.memory.DataInputViewStreamWrapper)74 DataOutputViewStreamWrapper (org.apache.flink.core.memory.DataOutputViewStreamWrapper)25 ByteArrayInputStream (java.io.ByteArrayInputStream)23 IOException (java.io.IOException)21 ByteArrayInputStreamWithPos (org.apache.flink.core.memory.ByteArrayInputStreamWithPos)19 Test (org.junit.Test)19 FSDataInputStream (org.apache.flink.core.fs.FSDataInputStream)13 ByteArrayOutputStreamWithPos (org.apache.flink.core.memory.ByteArrayOutputStreamWithPos)11 DataInputView (org.apache.flink.core.memory.DataInputView)11 RocksDBException (org.rocksdb.RocksDBException)10 KeyGroupStatePartitionStreamProvider (org.apache.flink.runtime.state.KeyGroupStatePartitionStreamProvider)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 ArrayList (java.util.ArrayList)6 InputStream (java.io.InputStream)4 PipedInputStream (java.io.PipedInputStream)4 PipedOutputStream (java.io.PipedOutputStream)4 EOFException (java.io.EOFException)3 ObjectInputStream (java.io.ObjectInputStream)3 HashMap (java.util.HashMap)3 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)3