[
https://issues.apache.org/jira/browse/AVRO-1325?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13654909#comment-13654909
]
Scott Carey commented on AVRO-1325:
-----------------------------------
{quote}
What is the difference between intWith() and intType()
{quote}
Dealing with properties or not could be as follows for primitive types.
JSON:
{code}
{"type":"map", "values":{"type":"string", "avro.java.string":"String"}}
{"type":"map", "values":{"type":"string"}} // same as {"type":"map",
"values":"string"}
{code}
trunk:
{code}
Schema strWithProps = Schema.create(Schema.Type.STRING);
strWithProps.addProp("avro.java.string", "String");
SchemaBuilder.mapType(strWithProps);
SchemaBiulder.mapType(SchemaBuilder.STRING);
{code}
Current proposal:
{code}
SchemaBuilder.map().values().stringWith().prop("avro.java.string").endInt();
SchemaBuilder.map().values().stringType();
{code}
Alternative:
{code}
SchemaBuilder.map().values().stringType().prop("avro.java.string",
"String").endString();
SchemaBuilder.map().values().stringType().endString();
{code}
The benefit of the alternative is fewer methods on the type builder -- only one
for each primitive type. The drawback is the common case -- no props --
requires another method call to close the property setting context.
Another alternative is to significantly increase the number of methods
available on the map for setting values to shorten the common case:
{code}
SchemaBuilder.map().values().stringType().prop("avro.java.string",
"String").endString();
SchemaBuilder.map().valuesString(); // looks a lot like {"type":"map",
"values":"string"}
{code}
'valuesString()' is shortcut for 'values().stringType().endString()', and it
also looks a lot like the json.
I did not like this variation because it adds a lot of methods to the array and
map cases and makes their APIs differ more. It is also less consitent with
unions, and I wanted to have unions, maps, arrays, and fields be similar in API
look/feel where possible. Fewer public methods are also easier to document. :)
> Enhanced Schema Builder API
> ---------------------------
>
> Key: AVRO-1325
> URL: https://issues.apache.org/jira/browse/AVRO-1325
> Project: Avro
> Issue Type: Bug
> Reporter: Scott Carey
> Assignee: Scott Carey
> Fix For: 1.7.5
>
> Attachments: AVRO-1325-preliminary.patch
>
>
> The schema builder from AVRO-1274 has a few key limitations. I have proposed
> changes to make before it is released and the public API is locked in.
--
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