use of com.esotericsoftware.kryo.io.Input in project apex-malhar by apache.
the class PairSerdeTest method simpleSerdeTest.
@Test
public void simpleSerdeTest() {
PairSerde<String, Integer> serdePair = new PairSerde<>(new StringSerde(), new IntSerde());
Pair<String, Integer> pair = new ImmutablePair<>("abc", 123);
SerializationBuffer buffer = new SerializationBuffer(new WindowedBlockStream());
serdePair.serialize(pair, buffer);
Slice slice = buffer.toSlice();
Pair<String, Integer> deserializedPair = serdePair.deserialize(new Input(slice.buffer, slice.offset, slice.length));
Assert.assertEquals(pair, deserializedPair);
}
use of com.esotericsoftware.kryo.io.Input in project apex-malhar by apache.
the class SpillableTestUtils method checkValue.
public static <T> void checkValue(SpillableStateStore store, long bucketId, byte[] bytes, T expectedValue, int offset, Serde<T> serde) {
Slice slice = store.getSync(bucketId, new Slice(bytes));
if (slice == null || slice.length == 0) {
if (expectedValue != null) {
Assert.assertEquals(expectedValue, slice);
} else {
return;
}
}
T string = serde.deserialize(new Input(slice.buffer, slice.offset + offset, slice.length));
Assert.assertEquals(expectedValue, string);
}
use of com.esotericsoftware.kryo.io.Input in project apex-malhar by apache.
the class GenericSerdeTest method timeWindowSerdeTest.
@Test
public void timeWindowSerdeTest() {
GenericSerde<Window.TimeWindow>[] serdes = new GenericSerde[] { new GenericSerde<>(Window.TimeWindow.class), GenericSerde.DEFAULT };
for (GenericSerde<Window.TimeWindow> serde : serdes) {
Window.TimeWindow pojo = new Window.TimeWindow(System.currentTimeMillis(), 1000);
SerializationBuffer buffer = new SerializationBuffer(new WindowedBlockStream());
serde.serialize(pojo, buffer);
Slice slice = buffer.toSlice();
Window.TimeWindow deserializedPojo = serde.deserialize(new Input(slice.buffer, slice.offset, slice.length));
Assert.assertEquals(pojo, deserializedPojo);
}
}
use of com.esotericsoftware.kryo.io.Input in project apex-malhar by apache.
the class GenericSerdeTest method stringListTest.
@Test
public void stringListTest() {
GenericSerde<ArrayList> serdeList = new GenericSerde<>(ArrayList.class);
ArrayList<String> stringList = Lists.newArrayList("a", "b", "c");
SerializationBuffer buffer = new SerializationBuffer(new WindowedBlockStream());
serdeList.serialize(stringList, buffer);
Slice slice = buffer.toSlice();
List<String> deserializedList = serdeList.deserialize(new Input(slice.buffer, slice.offset, slice.length));
Assert.assertEquals(stringList, deserializedList);
}
use of com.esotericsoftware.kryo.io.Input in project apex-malhar by apache.
the class SerdeGeneralTest method testSerdeInt.
@Test
public void testSerdeInt() {
IntSerde intSerde = new IntSerde();
SerializationBuffer buffer = new SerializationBuffer(new WindowedBlockStream());
int value = 123;
intSerde.serialize(value, buffer);
Slice slice = buffer.toSlice();
int deserializedValue = intSerde.deserialize(new Input(slice.buffer, slice.offset, slice.length));
Assert.assertEquals(value, deserializedValue);
}
Aggregations