Search in sources :

Example 1 with StringSerializer

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);
}
Also used : Random(java.util.Random) StringSerializer(org.apache.flink.api.common.typeutils.base.StringSerializer) Test(org.junit.Test)

Example 2 with StringSerializer

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);
}
Also used : Path(org.apache.flink.core.fs.Path) TaskInfo(org.apache.flink.api.common.TaskInfo) MapSerializer(org.apache.flink.api.common.typeutils.base.MapSerializer) ExecutionConfig(org.apache.flink.api.common.ExecutionConfig) StringSerializer(org.apache.flink.api.common.typeutils.base.StringSerializer) KryoSerializer(org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer) Test(org.junit.Test)

Aggregations

StringSerializer (org.apache.flink.api.common.typeutils.base.StringSerializer)2 Test (org.junit.Test)2 Random (java.util.Random)1 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)1 TaskInfo (org.apache.flink.api.common.TaskInfo)1 MapSerializer (org.apache.flink.api.common.typeutils.base.MapSerializer)1 KryoSerializer (org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer)1 Path (org.apache.flink.core.fs.Path)1