You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Doug Cutting (Commented) (JIRA)" <ji...@apache.org> on 2011/10/06 20:49:30 UTC

[jira] [Commented] (AVRO-803) Java generated Avro classes make using Avro painful and surprising

    [ https://issues.apache.org/jira/browse/AVRO-803?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13122154#comment-13122154 ] 

Doug Cutting commented on AVRO-803:
-----------------------------------

Here's a new proposal:
  - add a new Decoder method, 'String readString()' implemented to avoid allocating new intermediate byte arrays for each call as is currently done when Utf8's are not reused.
  - change generated specific code to optionally use String everywhere instead of CharSequence.  (We could also add an option to emit Utf8 everywhere.)  When String is used we add a property to the string schemas in the generated code so they become {"type":"string", "java":"String"}.
  - GenericData#readString() would call the new Decoder method when "java":"String" is present in the String's schema.

This is totally back-compatible.

                
> Java generated Avro classes make using Avro painful and surprising
> ------------------------------------------------------------------
>
>                 Key: AVRO-803
>                 URL: https://issues.apache.org/jira/browse/AVRO-803
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.5.0
>         Environment: Any
>            Reporter: Sam Pullara
>             Fix For: 1.6.0
>
>         Attachments: Foo.java
>
>
> Currently the Avro generated Java classes expose CharSequence in their API. However, you cannot use any old CharSequence when interacting with them. In fact, you have to use the Utf8 class if you want to get consistent results. I think that Avro should work with any CharSequence if that is the API. Here is an example where this happens:
> https://github.com/spullara/avro-generated-code/blob/master/src/test/java/AnnoyingTest.java
> That prints out 'false' three times unexpectedly. If you can't get it to print 'true' three times then you should probably change it back to Utf8.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira