Class KryoUtils
- java.lang.Object
-
- org.apache.flink.api.java.typeutils.runtime.KryoUtils
-
@Internal public class KryoUtils extends Object
Convenience methods for Kryo
-
-
Constructor Summary
Constructors Constructor Description KryoUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidapplyRegistrations(com.esotericsoftware.kryo.Kryo kryo, Collection<KryoRegistration> resolvedRegistrations, int firstRegistrationId)Apply a list ofKryoRegistrationto a Kryo instance.static <T> Tcopy(T from, com.esotericsoftware.kryo.Kryo kryo, TypeSerializer<T> serializer)Tries to copy the given record from using the provided Kryo instance.static <T> Tcopy(T from, T reuse, com.esotericsoftware.kryo.Kryo kryo, TypeSerializer<T> serializer)Tries to copy the given record from using the provided Kryo instance.
-
-
-
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 copykryo- Kryo instance to useserializer- 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 copyreuse- Reuse element for the deserializationkryo- Kryo instance to useserializer- 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 ofKryoRegistrationto 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
firstRegistrationIdand incrementing it for each registration.- Parameters:
kryo- the Kryo instance to apply the registrationsresolvedRegistrations- the registrations, which should already be resolved of all possible registration overwritesfirstRegistrationId- the first registration id to use
-
-