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 (Updated) (JIRA)" <ji...@apache.org> on 2011/12/08 22:19:40 UTC

[jira] [Updated] (AVRO-972) Avro IDL compiler should support "NaN", "Infinity", and "-Infinity" as float literals

     [ https://issues.apache.org/jira/browse/AVRO-972?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doug Cutting updated AVRO-972:
------------------------------

    Attachment: AVRO-972.patch

Here's a patch that should implement this. Since JSON doesn't support Nan and infinities we encode them as strings there to keep our JSON portable.

The only odd thing is that a schema that includes a NaN as a default value is not equal to itself, since NaN is not equal to anything.  We should perhaps explicitly check for this in Schema.Field#equals().
                
> Avro IDL compiler should support "NaN", "Infinity", and "-Infinity" as float literals
> -------------------------------------------------------------------------------------
>
>                 Key: AVRO-972
>                 URL: https://issues.apache.org/jira/browse/AVRO-972
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.6.1
>            Reporter: Brandon Ballinger
>            Priority: Minor
>         Attachments: AVRO-972.patch
>
>
> The Avro IDL defines floating point literals as follows:
>   < FLOATING_POINT_LITERAL:
>   ("-")?
>     ( <DECIMAL_FLOATING_POINT_LITERAL> | <HEXADECIMAL_FLOATING_POINT_LITERAL> )
>   >
> |
>   < #DECIMAL_FLOATING_POINT_LITERAL:
>         (["0"-"9"])+ "." (["0"-"9"])* (<DECIMAL_EXPONENT>)? (["f","F","d","D"])?
>       | "." (["0"-"9"])+ (<DECIMAL_EXPONENT>)? (["f","F","d","D"])?
>       | (["0"-"9"])+ <DECIMAL_EXPONENT> (["f","F","d","D"])?
>       | (["0"-"9"])+ (<DECIMAL_EXPONENT>)? ["f","F","d","D"]
>   >
> |
>   < #DECIMAL_EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
> |
>   < #HEXADECIMAL_FLOATING_POINT_LITERAL:
>         "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])+ (".")? <HEXADECIMAL_EXPONENT> (["f","F","d","D"])?
>       | "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])* "." (["0"-"9","a"-"f","A"-"F"])+ <HEXADECIMAL_EXPONENT> (["f","F","d","D"])?
>   >
> |
>   < #HEXADECIMAL_EXPONENT: ["p","P"] (["+","-"])? (["0"-"9"])+ >
> Java allows for "NaN", "Infinity", and "-Infinity" when parsing a Double from a String:
>   http://docs.oracle.com/javase/6/docs/api/java/lang/Double.html#valueOf(java.lang.String)
> The IDL compiler should allow the same set of values as Java Double.valueOf. Among other things, this would allow "NaN" to be used as a default value for float fields in Avro records.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira