use of org.apache.flink.api.common.typeutils.base.StringSerializer in project flink by apache.
the class AbstractGenericArraySerializerTest method testString.
@Test
public void testString() {
String[] arr1 = new String[] { "abc", "", StringUtils.getRandomString(new Random(289347567856686223L), 10, 100), StringUtils.getRandomString(new Random(289347567856686223L), 15, 50), StringUtils.getRandomString(new Random(289347567856686223L), 30, 170), StringUtils.getRandomString(new Random(289347567856686223L), 14, 15), "" };
String[] arr2 = new String[] { "foo", "", StringUtils.getRandomString(new Random(289347567856686223L), 10, 100), StringUtils.getRandomString(new Random(289347567856686223L), 1000, 5000), StringUtils.getRandomString(new Random(289347567856686223L), 30000, 35000), StringUtils.getRandomString(new Random(289347567856686223L), 100 * 1024, 105 * 1024), "bar" };
// run tests with the string serializer as the component serializer
runTests(String.class, new StringSerializer(), arr1, arr2);
// run the tests with the generic serializer as the component serializer
runTests(arr1, arr2);
}
use of org.apache.flink.api.common.typeutils.base.StringSerializer in project flink by apache.
the class MapStateDescriptorTest method testMapStateDescriptorLazySerializer.
@Test
public void testMapStateDescriptorLazySerializer() throws Exception {
// some different registered value
ExecutionConfig cfg = new ExecutionConfig();
cfg.registerKryoType(TaskInfo.class);
MapStateDescriptor<Path, String> descr = new MapStateDescriptor<>("testName", Path.class, String.class);
try {
descr.getSerializer();
fail("should cause an exception");
} catch (IllegalStateException ignored) {
}
descr.initializeSerializerUnlessSet(cfg);
assertNotNull(descr.getSerializer());
assertTrue(descr.getSerializer() instanceof MapSerializer);
assertNotNull(descr.getKeySerializer());
assertTrue(descr.getKeySerializer() instanceof KryoSerializer);
assertTrue(((KryoSerializer<?>) descr.getKeySerializer()).getKryo().getRegistration(TaskInfo.class).getId() > 0);
assertNotNull(descr.getValueSerializer());
assertTrue(descr.getValueSerializer() instanceof StringSerializer);
}
Aggregations