Class KryoUtils


  • @Internal
    public class KryoUtils
    extends Object
    Convenience methods for Kryo
    • Constructor Detail

      • KryoUtils

        public KryoUtils()
    • Method Detail

      • copy

        public static <T> T copy​(T from,
                                 com.esotericsoftware.kryo.Kryo kryo,
                                 TypeSerializer<T> serializer)
        Tries to copy the given record from using the provided Kryo instance. If this fails, then the record from is copied by serializing it into a byte buffer and deserializing it from there.
        Type Parameters:
        T - Type of the element to be copied
        Parameters:
        from - Element to copy
        kryo - Kryo instance to use
        serializer - TypeSerializer which is used in case of a Kryo failure
        Returns:
        Copied element
      • copy

        public static <T> T copy​(T from,
                                 T reuse,
                                 com.esotericsoftware.kryo.Kryo kryo,
                                 TypeSerializer<T> serializer)
        Tries to copy the given record from using the provided Kryo instance. If this fails, then the record from is copied by serializing it into a byte buffer and deserializing it from there.
        Type Parameters:
        T - Type of the element to be copied
        Parameters:
        from - Element to copy
        reuse - Reuse element for the deserialization
        kryo - Kryo instance to use
        serializer - TypeSerializer which is used in case of a Kryo failure
        Returns:
        Copied element
      • applyRegistrations

        public static void applyRegistrations​(com.esotericsoftware.kryo.Kryo kryo,
                                              Collection<KryoRegistration> resolvedRegistrations,
                                              int firstRegistrationId)
        Apply a list of KryoRegistration to a Kryo instance. The list of registrations is assumed to already be a final resolution of all possible registration overwrites.

        The registrations are applied in the given order and always specify the registration id, using the given firstRegistrationId and incrementing it for each registration.

        Parameters:
        kryo - the Kryo instance to apply the registrations
        resolvedRegistrations - the registrations, which should already be resolved of all possible registration overwrites
        firstRegistrationId - the first registration id to use