Search in sources :

Example 86 with DataOutputViewStreamWrapper

use of org.apache.flink.core.memory.DataOutputViewStreamWrapper in project flink by apache.

the class ImmutableAggregatingStateTest method setUp.

@Before
public void setUp() throws Exception {
    if (!aggrStateDesc.isSerializerInitialized()) {
        aggrStateDesc.initializeSerializerUnlessSet(new ExecutionConfig());
    }
    final String initValue = "42";
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    aggrStateDesc.getSerializer().serialize(initValue, new DataOutputViewStreamWrapper(out));
    aggrState = ImmutableAggregatingState.createState(aggrStateDesc, out.toByteArray());
}
Also used : DataOutputViewStreamWrapper(org.apache.flink.core.memory.DataOutputViewStreamWrapper) ExecutionConfig(org.apache.flink.api.common.ExecutionConfig) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Before(org.junit.Before)

Example 87 with DataOutputViewStreamWrapper

use of org.apache.flink.core.memory.DataOutputViewStreamWrapper in project flink by apache.

the class PostVersionedIOReadableWritableTest method serializeWithPostVersionedReadableWritable.

private byte[] serializeWithPostVersionedReadableWritable(byte[] payload) throws IOException {
    TestPostVersionedReadableWritable versionedReadableWritable = new TestPostVersionedReadableWritable(payload);
    byte[] serialized;
    try (ByteArrayOutputStreamWithPos out = new ByteArrayOutputStreamWithPos()) {
        versionedReadableWritable.write(new DataOutputViewStreamWrapper(out));
        serialized = out.toByteArray();
    }
    return serialized;
}
Also used : DataOutputViewStreamWrapper(org.apache.flink.core.memory.DataOutputViewStreamWrapper) ByteArrayOutputStreamWithPos(org.apache.flink.core.memory.ByteArrayOutputStreamWithPos)

Example 88 with DataOutputViewStreamWrapper

use of org.apache.flink.core.memory.DataOutputViewStreamWrapper in project flink by apache.

the class PostVersionedIOReadableWritableTest method serializeWithNonVersionedReadableWritable.

private byte[] serializeWithNonVersionedReadableWritable(byte[] payload) throws IOException {
    TestNonVersionedReadableWritable versionedReadableWritable = new TestNonVersionedReadableWritable(payload);
    byte[] serialized;
    try (ByteArrayOutputStreamWithPos out = new ByteArrayOutputStreamWithPos()) {
        versionedReadableWritable.write(new DataOutputViewStreamWrapper(out));
        serialized = out.toByteArray();
    }
    return serialized;
}
Also used : DataOutputViewStreamWrapper(org.apache.flink.core.memory.DataOutputViewStreamWrapper) ByteArrayOutputStreamWithPos(org.apache.flink.core.memory.ByteArrayOutputStreamWithPos)

Example 89 with DataOutputViewStreamWrapper

use of org.apache.flink.core.memory.DataOutputViewStreamWrapper 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 90 with DataOutputViewStreamWrapper

use of org.apache.flink.core.memory.DataOutputViewStreamWrapper 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)

Aggregations

DataOutputViewStreamWrapper (org.apache.flink.core.memory.DataOutputViewStreamWrapper)123 DataInputViewStreamWrapper (org.apache.flink.core.memory.DataInputViewStreamWrapper)55 ByteArrayOutputStream (java.io.ByteArrayOutputStream)49 Test (org.junit.Test)43 ByteArrayOutputStreamWithPos (org.apache.flink.core.memory.ByteArrayOutputStreamWithPos)35 IOException (java.io.IOException)28 ByteArrayInputStream (java.io.ByteArrayInputStream)26 ByteArrayInputStreamWithPos (org.apache.flink.core.memory.ByteArrayInputStreamWithPos)23 DataOutputView (org.apache.flink.core.memory.DataOutputView)18 HashMap (java.util.HashMap)13 ArrayList (java.util.ArrayList)12 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)11 Map (java.util.Map)10 TypeSerializerSnapshot (org.apache.flink.api.common.typeutils.TypeSerializerSnapshot)7 StateMetaInfoSnapshot (org.apache.flink.runtime.state.metainfo.StateMetaInfoSnapshot)7 Before (org.junit.Before)6 Socket (java.net.Socket)5 PipedInputStream (java.io.PipedInputStream)4 PipedOutputStream (java.io.PipedOutputStream)4 List (java.util.List)4