Uploaded image for project: 'Beam'
  1. Beam
  2. BEAM-2303

Add SpecificData to AvroCoder

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • P3
    • Resolution: Fixed
    • 2.1.0
    • 2.30.0
    • sdk-java-core

    Description

      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.

                  return myCoder.getType().equals(GenericRecord.class)
                      ? new GenericDatumReader<T>(myCoder.getSchema())
                      : new ReflectDatumReader<T>(
                          myCoder.getSchema(), myCoder.getSchema(), myCoder.reflectData.get());
      

      should be

                              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());
      

      Attachments

        Issue Links

          Activity

            People

              R3tto Vitaly Terentyev
              arvid Arvid Heise
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2h
                  2h