[
https://issues.apache.org/jira/browse/AVRO-803?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Doug Cutting updated AVRO-803:
------------------------------
Attachment: Foo.java
A couple more observations:
- I'd rather keep the raw fields using CharSequence, so that we can avoid any
conversions on write. The low-level output routines can handle either Utf8 or
String, so we should pass along whichever the application prefers to create.
- Map keys and values are not currently reused, so there's little point to
using Utf8 there. So we might just always use String in maps, especially as
keys to avoid comparison problems.
- It is possible to wrap a map and convert keys and/or values.
I've attached code that illustrates how this might look. This assumes that map
keys are now always String but that values can be any CharSequence.
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira