avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thiruvalluvan M. G. (JIRA)" <j...@apache.org>
Subject [jira] Commented: (AVRO-90) json encoding does not encode unions correctly
Date Sat, 15 Aug 2009 04:12:14 GMT

    [ 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.


Mime
View raw message