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 (JIRA)" <ji...@apache.org> on 2009/08/14 20:25:14 UTC
[jira] Created: (AVRO-90) json encoding does not encode unions
correctly
json encoding does not encode unions correctly
----------------------------------------------
Key: AVRO-90
URL: https://issues.apache.org/jira/browse/AVRO-90
Project: Avro
Issue Type: Bug
Components: java
Affects Versions: 1.0.1
Reporter: Doug Cutting
Assignee: Doug Cutting
The Json encoding implemented in Java does not encode unions as intended. In particular:
- branches are labeled with their Java type enum name (all caps) rather than their Json type name (lowercase)
- branches for named types (records, enums, fixed) are labeled with the type rather than the name
- nulls are labelled -- a null value for a union should be untagged
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (AVRO-90) json encoding does not encode unions
correctly
Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/AVRO-90?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Doug Cutting updated AVRO-90:
-----------------------------
Resolution: Fixed
Fix Version/s: 1.0.1
Status: Resolved (was: Patch Available)
I just committed this.
> json encoding does not encode unions correctly
> ----------------------------------------------
>
> Key: AVRO-90
> URL: https://issues.apache.org/jira/browse/AVRO-90
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.0.1
> Reporter: Doug Cutting
> Assignee: Doug Cutting
> Fix For: 1.0.1
>
> Attachments: AVRO-90.patch
>
>
> The Json encoding implemented in Java does not encode unions as intended. In particular:
> - branches are labeled with their Java type enum name (all caps) rather than their Json type name (lowercase)
> - branches for named types (records, enums, fixed) are labeled with the type rather than the name
> - nulls are labelled -- a null value for a union should be untagged
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (AVRO-90) json encoding does not encode unions
correctly
Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/AVRO-90?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Doug Cutting updated AVRO-90:
-----------------------------
Attachment: AVRO-90.patch
Here's a patch that fixes this and adds tests to ensure that the Json encoding of unions is as expected.
> json encoding does not encode unions correctly
> ----------------------------------------------
>
> Key: AVRO-90
> URL: https://issues.apache.org/jira/browse/AVRO-90
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.0.1
> Reporter: Doug Cutting
> Assignee: Thiruvalluvan M. G.
> Attachments: AVRO-90.patch
>
>
> The Json encoding implemented in Java does not encode unions as intended. In particular:
> - branches are labeled with their Java type enum name (all caps) rather than their Json type name (lowercase)
> - branches for named types (records, enums, fixed) are labeled with the type rather than the name
> - nulls are labelled -- a null value for a union should be untagged
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Assigned: (AVRO-90) json encoding does not encode unions
correctly
Posted by "Thiruvalluvan M. G. (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/AVRO-90?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Thiruvalluvan M. G. reassigned AVRO-90:
---------------------------------------
Assignee: Thiruvalluvan M. G. (was: Doug Cutting)
> json encoding does not encode unions correctly
> ----------------------------------------------
>
> Key: AVRO-90
> URL: https://issues.apache.org/jira/browse/AVRO-90
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.0.1
> Reporter: Doug Cutting
> Assignee: Thiruvalluvan M. G.
>
> The Json encoding implemented in Java does not encode unions as intended. In particular:
> - branches are labeled with their Java type enum name (all caps) rather than their Json type name (lowercase)
> - branches for named types (records, enums, fixed) are labeled with the type rather than the name
> - nulls are labelled -- a null value for a union should be untagged
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (AVRO-90) json encoding does not encode unions
correctly
Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/AVRO-90?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Doug Cutting updated AVRO-90:
-----------------------------
Assignee: Doug Cutting (was: Thiruvalluvan M. G.)
Status: Patch Available (was: Open)
Sorry, Thiru, I hope you haven't already started working on this!
> json encoding does not encode unions correctly
> ----------------------------------------------
>
> Key: AVRO-90
> URL: https://issues.apache.org/jira/browse/AVRO-90
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.0.1
> Reporter: Doug Cutting
> Assignee: Doug Cutting
> Attachments: AVRO-90.patch
>
>
> The Json encoding implemented in Java does not encode unions as intended. In particular:
> - branches are labeled with their Java type enum name (all caps) rather than their Json type name (lowercase)
> - branches for named types (records, enums, fixed) are labeled with the type rather than the name
> - nulls are labelled -- a null value for a union should be untagged
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (AVRO-90) json encoding does not encode unions
correctly
Posted by "Thiruvalluvan M. G. (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/AVRO-90?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12743537#action_12743537 ]
Thiruvalluvan M. G. commented on AVRO-90:
-----------------------------------------
Some little code can be saved in JsonDecoder.readIndex():
{code:title=JsonDecoder.java}
public int readIndex() throws IOException {
parser.advance(Symbol.UNION);
Symbol.Alternative a = (Symbol.Alternative) parser.popSymbol();
String label;
if (in.getCurrentToken() == JsonToken.VALUE_NULL) {
label = "null";
} else if (in.getCurrentToken() == JsonToken.START_OBJECT &&
in.nextToken() == JsonToken.FIELD_NAME) {
label = in.getText();
in.nextToken();
parser.pushSymbol(Symbol.UNION_END);
} else {
throw error("start-union");
}
int n = a.findLabel(label);
if (n < 0)
throw new AvroTypeException("Unknown union branch " + label);
parser.pushSymbol(a.getSymbol(n));
return n;
}
{code}
> json encoding does not encode unions correctly
> ----------------------------------------------
>
> Key: AVRO-90
> URL: https://issues.apache.org/jira/browse/AVRO-90
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.0.1
> Reporter: Doug Cutting
> Assignee: Doug Cutting
> Attachments: AVRO-90.patch
>
>
> The Json encoding implemented in Java does not encode unions as intended. In particular:
> - branches are labeled with their Java type enum name (all caps) rather than their Json type name (lowercase)
> - branches for named types (records, enums, fixed) are labeled with the type rather than the name
> - nulls are labelled -- a null value for a union should be untagged
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.