public class CompatibleFieldSerializer<T> extends FieldSerializer<T>
FieldSerializer
, it can serialize most classes without needing annotations.
The forward and backward compatibility and serialization performance depend on
CompatibleFieldSerializer.CompatibleFieldSerializerConfig.setReadUnknownFieldData(boolean)
and
CompatibleFieldSerializer.CompatibleFieldSerializerConfig.setChunkedEncoding(boolean)
. Additionally, the first time the class is encountered in
the serialized bytes, a simple schema is written containing the field name strings.
Note that the field data is identified by name. If a super class has a field with the same name as a subclass,
FieldSerializer.FieldSerializerConfig.setExtendedFieldNames(boolean)
must be true.
Modifier and Type | Class and Description |
---|---|
static class |
CompatibleFieldSerializer.CompatibleFieldSerializerConfig
Configuration for CompatibleFieldSerializer instances.
|
FieldSerializer.Bind, FieldSerializer.CachedField, FieldSerializer.FieldSerializerConfig, FieldSerializer.NotNull, FieldSerializer.Optional
Constructor and Description |
---|
CompatibleFieldSerializer(Kryo kryo,
java.lang.Class type) |
CompatibleFieldSerializer(Kryo kryo,
java.lang.Class type,
CompatibleFieldSerializer.CompatibleFieldSerializerConfig config) |
Modifier and Type | Method and Description |
---|---|
CompatibleFieldSerializer.CompatibleFieldSerializerConfig |
getCompatibleFieldSerializerConfig() |
T |
read(Kryo kryo,
Input input,
java.lang.Class<? extends T> type)
Reads bytes and returns a new object of the specified concrete type.
|
void |
write(Kryo kryo,
Output output,
T object)
Writes the bytes for the object to the output.
|
copy, create, createCopy, getCopyFields, getField, getFields, getFieldSerializerConfig, getKryo, getType, initializeCachedFields, log, popTypeVariables, pushTypeVariables, removeField, removeField, updateFields
getAcceptsNull, isImmutable, setAcceptsNull, setImmutable
public CompatibleFieldSerializer(Kryo kryo, java.lang.Class type)
public CompatibleFieldSerializer(Kryo kryo, java.lang.Class type, CompatibleFieldSerializer.CompatibleFieldSerializerConfig config)
public void write(Kryo kryo, Output output, T object)
Serializer
This method should not be called directly, instead this serializer can be passed to Kryo
write methods that accept a
serialier.
write
in class FieldSerializer<T>
object
- May be null if Serializer.getAcceptsNull()
is true.public T read(Kryo kryo, Input input, java.lang.Class<? extends T> type)
Serializer
Before Kryo can be used to read child objects, Kryo.reference(Object)
must be called with the parent object to
ensure it can be referenced by the child objects. Any serializer that uses Kryo
to read a child object may need to
be reentrant.
This method should not be called directly, instead this serializer can be passed to Kryo
read methods that accept a
serialier.
read
in class FieldSerializer<T>
Serializer.getAcceptsNull()
is true.public CompatibleFieldSerializer.CompatibleFieldSerializerConfig getCompatibleFieldSerializerConfig()
Copyright © 2019. All Rights Reserved.