Closed jackjoesh closed 3 years ago
@jackjoesh: Kryo only supports built-in JDK classes. Support for some Guava classes can be found in https://github.com/magro/kryo-serializers. But there is no serializer for Guava's Transforming*Lists.
It should be quite easy to write and register a custom serializer for these classes. Take a look at the implementations JdkImmutableListSerializer for instance.
You could override the write
method to something like this:
@Override
public void write (Kryo kryo, Output output, T collection) {
super.write(kryo, output, new ArrayList(collection));
}
thank you very much , I will try this, it's a good idea
Sometimes, we use the "Lists.transform" of google guava's api to convert the do object to vo object as the following:
But "Lists.transform" only return the lazy functional object from provider service, and kryo will not execute functional object, just return. That will return the do object to the customer service(not vo object , because lazy functional object), so the kryo deserialize of customer service will throw exception because it hasn't do object.
Can we support executing functional object of guava or jdk in kryo, like that:
List executeRows = Lists.newCopyOnWriteArrayList((AbstractList)rows); //convert functional rows to common list executeRows
Convert guava list to a common list, and continue serializing. So it will not return the functional object.