[
https://issues.apache.org/jira/browse/AVRO-1268?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Doug Cutting updated AVRO-1268:
-------------------------------
Attachment: GenericStringsPerf.patch
I just noticed that GenericDatumReader#readString() does a Schema.getProp() for
every String read. This could be optimized if we added a state/class parameter
to GenericDatumReader#read(). We might add a getStringClass(Schema) method
called once when the DatumReader is created, then readString(Class...) would do
something like:
{code}
if (c == Utf8.class)
return in.readString(old);
else {
String s = in.readString();
if (c == null)
return s;
try { return c.getConstructor(s);}
catch ...
}
{code}
This should make things faster than they are at present, since it would avoid
the Schema.getProp() call for every string read. Simply commenting out that
call I see a 17% performance improvement in reading a GenericRecord with three
strings (benchmark attached).
> Add java-class, java-key-class and java-element-class support for stringable
> types to SpecificData
> --------------------------------------------------------------------------------------------------
>
> Key: AVRO-1268
> URL: https://issues.apache.org/jira/browse/AVRO-1268
> Project: Avro
> Issue Type: Improvement
> Components: java
> Affects Versions: 1.7.4
> Reporter: Alexandre Normand
> Assignee: Alexandre Normand
> Priority: Minor
> Fix For: 1.7.5
>
> Attachments: AVRO-1268.patch, AVRO-1268.patch,
> GenericStringsPerf.patch
>
>
> Stringable types are java classes that can be serialized through strings
> (which require a single string constructor and a valid toString()
> implementation). ReflectData currently has support from stringable types but
> it would be desirable to get this feature with SpecificData.
> The work involves changes to the SpecificCompiler (depends on {{@java-class}}
> support in AVRO-1267) to generate the specific sources with the proper java
> type as well as moving the ReflectDatumReader and ReflectDatumWriter to read
> the java-class/java-key-class and java-element-class properties.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira