Nov11 / kryo

Automatically exported from code.google.com/p/kryo
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

CompatibleFieldSerializer performance issue #120

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Both CompatibleFieldSerializer & TaggeFieldSerializer typically generate a way 
larger byte stream due to :
for (int i = 0, n = fields.length; i < n; i++)
      output.writeString(fields[i].field.getName());

However,using FieldSerializer provides zero backward compatibility.

Should there be an optional annotation/setting that allows an "integer-field" 
mapping that replaces "output.writeString(fields[i].field.getName())" by 
"output.writeInt(fieldId)" ?

Original issue reported on code.google.com by njz...@gmail.com on 19 Jul 2013 at 6:41

GoogleCodeExporter commented 8 years ago
Another naive solution to this issue would be using the hashcode of the field 
name (given that the hashing algorithm yields a infinitesimal small collision 
rate) instead of the fieldname string itself.

Original comment by njz...@gmail.com on 19 Jul 2013 at 7:11

GoogleCodeExporter commented 8 years ago
Just to clarify that I understand your problem correctly:

Currently, when using CompatibleFieldSerializer Kryo does the following (see 
the comment at the beginning of CompatibleFieldSerializer):
A header is output the first time an object of a given type is serialized. The 
header consists of an int for the number of fields, then a String for each 
field name.

So, if you serialize a lot of objects of the same class using this serializer, 
all those field names will be written only once. But you say that a generated 
byte stream is a way too large. Can you explain under which circumstances it 
occurs? May be you have a test case?

-Leo

Original comment by romixlev on 23 Jul 2013 at 9:17