/** * Registers the given Serializer via its class as a serializer for the given type at the KryoSerializer. * * @param type The class of the types serialized with the given serializer. * @param serializerClass The class of the serializer to use. */ public void registerTypeWithKryoSerializer(Class<?> type, Class<? extends Serializer<?>> serializerClass) { config.registerTypeWithKryoSerializer(type, serializerClass); }
/** * Registers the given type with a Kryo Serializer. * * <p>Note that the serializer instance must be serializable (as defined by java.io.Serializable), * because it may be distributed to the worker nodes by java serialization. * * @param type The class of the types serialized with the given serializer. * @param serializer The serializer to use. */ public <T extends Serializer<?> & Serializable>void registerTypeWithKryoSerializer(Class<?> type, T serializer) { config.registerTypeWithKryoSerializer(type, serializer); }
/** * Registers the given Serializer via its class as a serializer for the * given type at the KryoSerializer. * * @param type * The class of the types serialized with the given serializer. * @param serializerClass * The class of the serializer to use. */ @SuppressWarnings("rawtypes") public void registerTypeWithKryoSerializer(Class<?> type, Class<? extends Serializer> serializerClass) { config.registerTypeWithKryoSerializer(type, serializerClass); }
/** * Registers the given type with a Kryo Serializer. * * <p>Note that the serializer instance must be serializable (as defined by * java.io.Serializable), because it may be distributed to the worker nodes * by java serialization. * * @param type * The class of the types serialized with the given serializer. * @param serializer * The serializer to use. */ public <T extends Serializer<?> & Serializable>void registerTypeWithKryoSerializer(Class<?> type, T serializer) { config.registerTypeWithKryoSerializer(type, serializer); }
@Override public void addAvroSerializersIfRequired(ExecutionConfig reg, Class<?> type) { if (org.apache.avro.specific.SpecificRecordBase.class.isAssignableFrom(type) || org.apache.avro.generic.GenericData.Record.class.isAssignableFrom(type)) { // Avro POJOs contain java.util.List which have GenericData.Array as their runtime type // because Kryo is not able to serialize them properly, we use this serializer for them reg.registerTypeWithKryoSerializer(GenericData.Array.class, Serializers.SpecificInstanceCollectionSerializerForArrayList.class); // We register this serializer for users who want to use untyped Avro records (GenericData.Record). // Kryo is able to serialize everything in there, except for the Schema. // This serializer is very slow, but using the GenericData.Records of Kryo is in general a bad idea. // we add the serializer as a default serializer because Avro is using a private sub-type at runtime. reg.addDefaultKryoSerializer(Schema.class, AvroSchemaSerializer.class); } }
@Override protected <T> TypeSerializer<T> createSerializer(Class<T> type) { ExecutionConfig conf = new ExecutionConfig(); conf.registerTypeWithKryoSerializer(LocalDate.class, LocalDateSerializer.class); TypeInformation<T> typeInfo = new GenericTypeInfo<T>(type); return typeInfo.createSerializer(conf); }
@Test public void testDuplicateSerializerWithRegisteredSerializerClass() { ExecutionConfig executionConfig = new ExecutionConfig(); executionConfig.registerTypeWithKryoSerializer(WrappedString.class, TestSerializer.class); runDuplicateSerializerTest(executionConfig); }
@Test public void testDuplicateSerializerWithRegisteredSerializerInstance() { ExecutionConfig executionConfig = new ExecutionConfig(); executionConfig.registerTypeWithKryoSerializer(WrappedString.class, new TestSerializer()); runDuplicateSerializerTest(executionConfig); }
@Test public void testAvroToRow() throws Exception { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.getConfig().registerTypeWithKryoSerializer(LocalDate.class, AvroKryoSerializerUtils.JodaLocalDateSerializer.class); env.getConfig().registerTypeWithKryoSerializer(LocalTime.class, AvroKryoSerializerUtils.JodaLocalTimeSerializer.class); BatchTableEnvironment tEnv = TableEnvironment.getTableEnvironment(env, config()); Table t = tEnv.fromDataSet(testData(env)); Table result = t.select("*"); List<Row> results = tEnv.toDataSet(result, Row.class).collect(); String expected = "black,null,Whatever,[true],[hello],true,java.nio.HeapByteBuffer[pos=0 lim=10 cap=10]," + "2014-03-01,java.nio.HeapByteBuffer[pos=0 lim=2 cap=2],[7, -48],0.0,GREEN," + "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],42,{},null,null,null,123456," + "12:12:12.000,123456,2014-03-01T12:12:12.321Z,null\n" + "blue,null,Charlie,[],[],false,java.nio.HeapByteBuffer[pos=0 lim=10 cap=10],2014-03-01," + "java.nio.HeapByteBuffer[pos=0 lim=2 cap=2],[7, -48],1.337,RED,null,1337,{}," + "{\"num\": 42, \"street\": \"Bakerstreet\", \"city\": \"Berlin\", \"state\": " + "\"Berlin\", \"zip\": \"12049\"},null,null,123456,12:12:12.000,123456," + "2014-03-01T12:12:12.321Z,null\n" + "yellow,null,Terminator,[false],[world],false," + "java.nio.HeapByteBuffer[pos=0 lim=10 cap=10],2014-03-01," + "java.nio.HeapByteBuffer[pos=0 lim=2 cap=2],[7, -48],0.0,GREEN," + "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],1,{},null,null,null,123456," + "12:12:12.000,123456,2014-03-01T12:12:12.321Z,null"; TestBaseUtils.compareResultAsText(results, expected); }
public void testOutputBufferedBeingClearedInCaseOfException() throws Exception { ExecutionConfig executionConfig = new ExecutionConfig(); executionConfig.registerTypeWithKryoSerializer(TestRecord.class, new TestRecordSerializer()); executionConfig.registerKryoType(TestRecord.class);
/** * Registers the given type with a Kryo Serializer. * * <p>Note that the serializer instance must be serializable (as defined by java.io.Serializable), * because it may be distributed to the worker nodes by java serialization. * * @param type The class of the types serialized with the given serializer. * @param serializer The serializer to use. */ public <T extends Serializer<?> & Serializable>void registerTypeWithKryoSerializer(Class<?> type, T serializer) { config.registerTypeWithKryoSerializer(type, serializer); }
/** * Registers the given Serializer via its class as a serializer for the given type at the KryoSerializer. * * @param type The class of the types serialized with the given serializer. * @param serializerClass The class of the serializer to use. */ public void registerTypeWithKryoSerializer(Class<?> type, Class<? extends Serializer<?>> serializerClass) { config.registerTypeWithKryoSerializer(type, serializerClass); }
/** * Registers the given Serializer via its class as a serializer for the given type at the KryoSerializer. * * @param type The class of the types serialized with the given serializer. * @param serializerClass The class of the serializer to use. */ public void registerTypeWithKryoSerializer(Class<?> type, Class<? extends Serializer<?>> serializerClass) { config.registerTypeWithKryoSerializer(type, serializerClass); }
/** * Registers the given Serializer via its class as a serializer for the given type at the KryoSerializer. * * @param type The class of the types serialized with the given serializer. * @param serializerClass The class of the serializer to use. */ public void registerTypeWithKryoSerializer(Class<?> type, Class<? extends Serializer<?>> serializerClass) { config.registerTypeWithKryoSerializer(type, serializerClass); }
/** * Registers the given Serializer via its class as a serializer for the * given type at the KryoSerializer. * * @param type * The class of the types serialized with the given serializer. * @param serializerClass * The class of the serializer to use. */ @SuppressWarnings("rawtypes") public void registerTypeWithKryoSerializer(Class<?> type, Class<? extends Serializer> serializerClass) { config.registerTypeWithKryoSerializer(type, serializerClass); }
/** * Registers the given Serializer via its class as a serializer for the * given type at the KryoSerializer. * * @param type * The class of the types serialized with the given serializer. * @param serializerClass * The class of the serializer to use. */ @SuppressWarnings("rawtypes") public void registerTypeWithKryoSerializer(Class<?> type, Class<? extends Serializer> serializerClass) { config.registerTypeWithKryoSerializer(type, serializerClass); }
/** * Registers the given type with a Kryo Serializer. * * <p>Note that the serializer instance must be serializable (as defined by java.io.Serializable), * because it may be distributed to the worker nodes by java serialization. * * @param type The class of the types serialized with the given serializer. * @param serializer The serializer to use. */ public <T extends Serializer<?> & Serializable>void registerTypeWithKryoSerializer(Class<?> type, T serializer) { config.registerTypeWithKryoSerializer(type, serializer); }
/** * Registers the given type with a Kryo Serializer. * * <p>Note that the serializer instance must be serializable (as defined by java.io.Serializable), * because it may be distributed to the worker nodes by java serialization. * * @param type The class of the types serialized with the given serializer. * @param serializer The serializer to use. */ public <T extends Serializer<?> & Serializable>void registerTypeWithKryoSerializer(Class<?> type, T serializer) { config.registerTypeWithKryoSerializer(type, serializer); }
/** * Registers the given Serializer via its class as a serializer for the * given type at the KryoSerializer. * * @param type * The class of the types serialized with the given serializer. * @param serializerClass * The class of the serializer to use. */ @SuppressWarnings("rawtypes") public void registerTypeWithKryoSerializer(Class<?> type, Class<? extends Serializer> serializerClass) { config.registerTypeWithKryoSerializer(type, serializerClass); }
/** * Registers the given Serializer via its class as a serializer for the * given type at the KryoSerializer. * * @param type * The class of the types serialized with the given serializer. * @param serializerClass * The class of the serializer to use. */ @SuppressWarnings("rawtypes") public void registerTypeWithKryoSerializer(Class<?> type, Class<? extends Serializer> serializerClass) { config.registerTypeWithKryoSerializer(type, serializerClass); }