unclear how to configure settings of kryo serializers
Zhen-hao opened this issue · 5 comments
for example, TaggedFieldSerializer has settings readUnknownTagData
and chunkedEncoding
but it is not clear how to set these values in this library.
it would be great to have some example in README.
Many thanks!
You can pass a serializer factory instead of a serializer class to kryo: (see https://github.com/EsotericSoftware/kryo#serializer-factories)
TaggedFieldSerializerFactory defaultFactory = new TaggedFieldSerializerFactory();
defaultFactory.getConfig().setReadUnknownTagData(true);
kryo.setDefaultSerializer(defaultFactory);
I'll add a hint into the README.
You can pass a serializer factory instead of a serializer class to kryo: (see https://github.com/EsotericSoftware/kryo#serializer-factories)
TaggedFieldSerializerFactory defaultFactory = new TaggedFieldSerializerFactory(); defaultFactory.getConfig().setReadUnknownTagData(true); kryo.setDefaultSerializer(defaultFactory);
Thanks!
but I can't figure out how to import the classes...
It looks like the Kryo documentation is outdated in this, I could not find the mentioned classes in their code base.
You could do this in preInit though:
kryo.getTaggedFieldSerializerConfig.setSkipUnknownTags(false)
kryo.setDefaultSerializer(classOf[TaggedFieldSerializer[_]])
The tagged field serializer is cloning this config upon creation.