Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-2423

GenericDatumReader.newRecord() is depricated but newArray() is not

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.8.2, 1.10.0
    • None
    • java
    • None

    Description

      The GenericDatumReader method newRecord() should no longer be used because breaks one area in the extensibility concept of the GenericRecords. Perfect. Good idea.

       

      But with the same argument the newArray() method should be depreciated and instead use the GenericData.newArray() method.

       

      Without that the extensibility is broken again and we have an inconsistency in the API.

       

       

      /**
      {{ * Called to create new record instances. Subclasses may override to use a}}
      {{ * different record implementation. The returned instance must conform to the}}
      {{ * schema provided. If the old object contains fields not present in the}}
      {{ * schema, they should either be removed from the old object, or it should}}
      {{ * create a new instance that conforms to the schema. By default, this returns}}
      {{ * a {@link GenericData.Record}.}}
      {{ * @deprecated As of Avro 1.6.0 this method has been moved to}}
      {{ * {@link GenericData#newRecord(Object, Schema)}}}
      {{ */}}
      {{ @Deprecated}}
      {{ protected Object newRecord(Object old, Schema schema) {}}
      {{ return data.newRecord(old, schema);}}
      {{ }}}/** Called to create new array instances. Subclasses may override to use a
      {{ * different array implementation. By default, this returns a {@link}}
      {{ * GenericData.Array}.*/}}
      {{ @SuppressWarnings("unchecked")}}
      {{ protected Object newArray(Object old, int size, Schema schema) {}}
      {{ if (old instanceof Collection) {}}
      {{ ((Collection) old).clear();}}
      {{ return old;}}
      {{ } else return new GenericData.Array(size, schema);}}
      {{ }}}

      Attachments

        Activity

          People

            Unassigned Unassigned
            wdaehn Werner Daehn
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: