[
https://issues.apache.org/jira/browse/AVRO-1274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13607159#comment-13607159
]
Scott Carey commented on AVRO-1274:
-----------------------------------
I have not had time to review thoroughly, but I have some thoughts on this as I
had planned on taking this on sometime this year:
Schema has a few warts that cause problems:
* Schamas are mutable (ok, Record schemas are). This has many down-stream
effects on performance when used as keys or transofrming them or traversing
them.
* Defaults are defined using Jackson JSON objects, there are many placed where
having a canonical data form for defaults would be beneficial, and we would not
leak our our use of Jackson through the API (which makes upgrading to Jackson
2.x an API breaking change). This causes performance problems in decoding and
complications elsewhere.
* Field, Schema, and Protocol do not share a common parent, so writing generic
transformation / traversal code is not possible (Visitor Pattern, or a 'shaped
like a schma' monad-like data structure).
* There is no builder.
Builders are awesome for helping hide implementation details from the user, so
my hope is that this API could work with both the current Schema code and what
it evolves into. A Builder API maps very cleanly into the spec, which is also
quite handy and changes more slowly than APIs in general.
On a quick review, I noticed that there are triplets of methods for each type.
One for a required field, and two for an optional one -- with a null default
value and one with a specified default value. We are missing the required
field with a default value, that is important if you want to read data with a
schema that is missing that field. The union builder may also work better if
you can add schemas one at a time, and if it enforced that a default for a
union must be the same type as the first schema in the union as the spec
requires.
> Add a schema builder API
> ------------------------
>
> Key: AVRO-1274
> URL: https://issues.apache.org/jira/browse/AVRO-1274
> Project: Avro
> Issue Type: New Feature
> Components: java
> Reporter: Tom White
> Assignee: Tom White
> Attachments: AVRO-1274.patch, AVRO-1274.patch, AVRO-1274.patch,
> AVRO-1274.patch, AVRO-1274.patch, TestDefaults.patch
>
>
> It would be nice to have a fluent API that made it easier to construct record
> schemas.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira