Interface SerializerConfig

  • All Superinterfaces:
    Serializable
    All Known Implementing Classes:
    SerializerConfigImpl

    @PublicEvolving
    public interface SerializerConfig
    extends Serializable
    A config to define the behavior for serializers in Flink job, it manages the registered types and serializers. The config is created from job configuration and used by Flink to create serializers for data types.
    • Method Detail

      • addDefaultKryoSerializer

        @Internal
        <T extends com.esotericsoftware.kryo.Serializer<?> & Serializable> void addDefaultKryoSerializer​(Class<?> type,
                                                                                                         T serializer)
        Adds a new Kryo default serializer to the Runtime.

        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.

        The method will be converted to private in the next Flink major version after removing its deprecated caller methods.

        Parameters:
        type - The class of the types serialized with the given serializer.
        serializer - The serializer to use.
      • addDefaultKryoSerializer

        @Internal
        void addDefaultKryoSerializer​(Class<?> type,
                                      Class<? extends com.esotericsoftware.kryo.Serializer<?>> serializerClass)
        Adds a new Kryo default serializer to the Runtime.

        The method will be converted to private in the next Flink major version after removing its deprecated caller methods.

        Parameters:
        type - The class of the types serialized with the given serializer.
        serializerClass - The class of the serializer to use.
      • registerTypeWithKryoSerializer

        @Internal
        <T extends com.esotericsoftware.kryo.Serializer<?> & Serializable> void registerTypeWithKryoSerializer​(Class<?> type,
                                                                                                               T serializer)
        Registers the given type with a Kryo Serializer.

        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.

        The method will be converted to private in the next Flink major version after removing its deprecated caller methods.

        Parameters:
        type - The class of the types serialized with the given serializer.
        serializer - The serializer to use.
      • registerTypeWithKryoSerializer

        @Internal
        void registerTypeWithKryoSerializer​(Class<?> type,
                                            Class<? extends com.esotericsoftware.kryo.Serializer> serializerClass)
        Registers the given Serializer via its class as a serializer for the given type at the KryoSerializer.

        The method will be converted to private in the next Flink major version after removing its deprecated caller methods.

        Parameters:
        type - The class of the types serialized with the given serializer.
        serializerClass - The class of the serializer to use.
      • registerPojoType

        @Internal
        void registerPojoType​(Class<?> type)
        Registers the given type with the serialization stack. If the type is eventually serialized as a POJO, then the type is registered with the POJO serializer. If the type ends up being serialized with Kryo, then it will be registered at Kryo to make sure that only tags are written.

        The method will be converted to private in the next Flink major version after removing its deprecated caller methods.

        Parameters:
        type - The class of the type to register.
      • registerKryoType

        @Internal
        void registerKryoType​(Class<?> type)
        Registers the given type with the serialization stack. If the type is eventually serialized as a POJO, then the type is registered with the POJO serializer. If the type ends up being serialized with Kryo, then it will be registered at Kryo to make sure that only tags are written.

        The method will be converted to private in the next Flink major version after removing its deprecated caller methods.

        Parameters:
        type - The class of the type to register.
      • getRegisteredTypesWithKryoSerializerClasses

        LinkedHashMap<Class<?>,​Class<? extends com.esotericsoftware.kryo.Serializer<?>>> getRegisteredTypesWithKryoSerializerClasses()
        Returns the registered types with their Kryo Serializer classes.
      • getDefaultKryoSerializerClasses

        LinkedHashMap<Class<?>,​Class<? extends com.esotericsoftware.kryo.Serializer<?>>> getDefaultKryoSerializerClasses()
        Returns the registered default Kryo Serializer classes.
      • getRegisteredKryoTypes

        LinkedHashSet<Class<?>> getRegisteredKryoTypes()
        Returns the registered Kryo types.
      • getRegisteredPojoTypes

        LinkedHashSet<Class<?>> getRegisteredPojoTypes()
        Returns the registered POJO types.
      • getRegisteredTypeInfoFactories

        Map<Class<?>,​Class<? extends TypeInfoFactory<?>>> getRegisteredTypeInfoFactories()
        Returns the registered type info factories.
      • hasGenericTypesDisabled

        boolean hasGenericTypesDisabled()
        Checks whether generic types are supported. Generic types are types that go through Kryo during serialization.

        Generic types are enabled by default.

      • setGenericTypes

        @Internal
        void setGenericTypes​(boolean genericTypes)
        The method will be converted to private in the next Flink major version after removing its deprecated caller methods.
      • isForceKryoEnabled

        boolean isForceKryoEnabled()
        Returns whether Kryo is the serializer for POJOs.
      • setForceKryo

        @Internal
        void setForceKryo​(boolean forceKryo)
        The method will be converted to private in the next Flink major version after removing its deprecated caller methods.
      • isForceAvroEnabled

        boolean isForceAvroEnabled()
        Returns whether the Apache Avro is the serializer for POJOs.
      • setForceAvro

        @Internal
        void setForceAvro​(boolean forceAvro)
        The method will be converted to private in the next Flink major version after removing its deprecated caller methods.
      • setForceKryoAvro

        @Internal
        void setForceKryoAvro​(boolean forceKryoAvro)
        The method will be converted to private in the next Flink major version after removing its deprecated caller methods.
      • isForceKryoAvroEnabled

        TernaryBoolean isForceKryoAvroEnabled()
        Returns whether forces Flink to register Apache Avro classes in Kryo serializer.
      • configure

        void configure​(ReadableConfig configuration,
                       ClassLoader classLoader)
        Sets all relevant options contained in the ReadableConfig such as e.g. PipelineOptions.FORCE_KRYO.

        It will change the value of a setting only if a corresponding option was set in the configuration. If a key is not present, the current value of a field will remain untouched.

        Parameters:
        configuration - a configuration to read the values from
        classLoader - a class loader to use when loading classes