Is your feature request related to a problem? Please describe.
For class with nested generics such as:
class Foo {
List<Integer> intLists;
Map<String, List<Long>> map;
}
If we push Integer type to ListSerializer and String, List<Long> to MapSerializer, then ListSerializer will know every element is an Integer, there will be no need to query element serializer and write element type every time serializing those elements, thus much space/time efficient.
MapSerializer can use same mechanism. Also when serializing List<Long> value, MapSerializer can push Long to ListSerializer, which make nested list serialization more efficient too.
Java generics is erasured at runtime,List type won't have element type. We need a way to push and propagate those erasured generics along the serialization.
Describe the solution you'd like
- Using guava
TypeToken to extract generics
- Create an
Generics to record generics hierarchy and current generics
- Create an
GenericType to tracking children generics and binding serializer to reduce map loopup cost
Additional context
#70
Is your feature request related to a problem? Please describe.
For class with nested generics such as:
If we push
Integertype toListSerializerandString, List<Long>toMapSerializer, thenListSerializerwill know every element is anInteger, there will be no need to query element serializer and write element type every time serializing those elements, thus much space/time efficient.MapSerializercan use same mechanism. Also when serializingList<Long>value,MapSerializercan pushLongtoListSerializer, which make nested list serialization more efficient too.Java generics is erasured at runtime,
Listtype won't have element type. We need a way to push and propagate those erasured generics along the serialization.Describe the solution you'd like
TypeTokento extract genericsGenericsto record generics hierarchy and current genericsGenericTypeto tracking children generics and binding serializer to reduce map loopup costAdditional context
#70