use of org.apache.flink.core.memory.DataOutputSerializer in project flink by apache.
the class SimpleVersionedSerializationTest method testSerializationRoundTrip.
@Test
public void testSerializationRoundTrip() throws IOException {
final SimpleVersionedSerializer<String> utfEncoder = new TestStringSerializer();
final String testString = "dugfakgs";
final DataOutputSerializer out = new DataOutputSerializer(32);
SimpleVersionedSerialization.writeVersionAndSerialize(utfEncoder, testString, out);
final byte[] outBytes = out.getCopyOfBuffer();
final byte[] bytes = SimpleVersionedSerialization.writeVersionAndSerialize(utfEncoder, testString);
assertArrayEquals(bytes, outBytes);
final DataInputDeserializer in = new DataInputDeserializer(bytes);
final String deserialized = SimpleVersionedSerialization.readVersionAndDeSerialize(utfEncoder, in);
final String deserializedFromBytes = SimpleVersionedSerialization.readVersionAndDeSerialize(utfEncoder, outBytes);
assertEquals(testString, deserialized);
assertEquals(testString, deserializedFromBytes);
}
use of org.apache.flink.core.memory.DataOutputSerializer in project flink by apache.
the class SimpleVersionedSerializationTest method testListSerializationRoundTrip.
@Test
public void testListSerializationRoundTrip() throws IOException {
final SimpleVersionedSerializer<String> utfEncoder = new TestStringSerializer();
final List<String> datums = ImmutableList.of("beeep!", "beep!!!");
final DataOutputSerializer out = new DataOutputSerializer(32);
SimpleVersionedSerialization.writeVersionAndSerializeList(utfEncoder, datums, out);
final byte[] outBytes = out.getCopyOfBuffer();
final DataInputDeserializer in = new DataInputDeserializer(outBytes);
final List<String> deserialized = SimpleVersionedSerialization.readVersionAndDeserializeList(utfEncoder, in);
assertEquals(datums, deserialized);
}
use of org.apache.flink.core.memory.DataOutputSerializer in project flink by apache.
the class FileWriterBucketStateSerializer method serialize.
@Override
public byte[] serialize(FileWriterBucketState state) throws IOException {
DataOutputSerializer out = new DataOutputSerializer(256);
out.writeInt(MAGIC_NUMBER);
serializeV3(state, out);
return out.getCopyOfBuffer();
}
use of org.apache.flink.core.memory.DataOutputSerializer in project flink by apache.
the class CompactorRequestSerializer method serialize.
@Override
public byte[] serialize(CompactorRequest request) throws IOException {
DataOutputSerializer out = new DataOutputSerializer(256);
out.writeInt(MAGIC_NUMBER);
serializeV1(request, out);
return out.getCopyOfBuffer();
}
use of org.apache.flink.core.memory.DataOutputSerializer in project flink by apache.
the class FileSinkCommittableSerializer method serialize.
@Override
public byte[] serialize(FileSinkCommittable committable) throws IOException {
DataOutputSerializer out = new DataOutputSerializer(256);
out.writeInt(MAGIC_NUMBER);
serializeV2(committable, out);
return out.getCopyOfBuffer();
}
Aggregations