You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "Ismaël Mejía (Jira)" <ji...@apache.org> on 2021/04/12 19:27:00 UTC

[jira] [Updated] (BEAM-2303) Add SpecificData to AvroCoder

     [ https://issues.apache.org/jira/browse/BEAM-2303?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ismaël Mejía updated BEAM-2303:
-------------------------------
    Resolution: Fixed
        Status: Resolved  (was: In Progress)

> Add SpecificData to AvroCoder
> -----------------------------
>
>                 Key: BEAM-2303
>                 URL: https://issues.apache.org/jira/browse/BEAM-2303
>             Project: Beam
>          Issue Type: Improvement
>          Components: sdk-java-core
>    Affects Versions: 2.1.0
>            Reporter: Arvid Heise
>            Assignee: Vitaly Terentyev
>            Priority: P3
>              Labels: Clarified
>             Fix For: 2.30.0
>
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> The AvroCoder currently supports GenericData and ReflectData, but not SpecificData.
> It should relatively easy to incorporate it by expanding the logic while constructing the Reader and Writer by also checking if the type implements the SpecificRecord interface. It would greatly speed up (de-)serialization of Avro-generated java classes.
> {code}
>             return myCoder.getType().equals(GenericRecord.class)
>                 ? new GenericDatumReader<T>(myCoder.getSchema())
>                 : new ReflectDatumReader<T>(
>                     myCoder.getSchema(), myCoder.getSchema(), myCoder.reflectData.get());
> {code}
> should be
> {code}
>                         if (myCoder.getType().equals(GenericRecord.class)) {
>                             return new GenericDatumReader<T>(myCoder.getSchema());
>                         }
>                         if (SpecificRecord.class.isAssignableFrom(myCoder.getType())) {
>                             return new SpecificDatumReader<T>(myCoder.getType());
>                         }
>                         return new ReflectDatumReader<T>(
>                                 myCoder.getSchema(), myCoder.getSchema(), myCoder.reflectData.get());
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)