Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-972

Avro IDL compiler should support "NaN", "Infinity", and "-Infinity" as float literals

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.6.1
    • 1.6.2
    • java
    • None

    Description

      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.

      Attachments

        1. AVRO-972.patch
          5 kB
          Doug Cutting
        2. AVRO-972.patch
          5 kB
          Doug Cutting
        3. AVRO-972.patch
          4 kB
          Doug Cutting

        Issue Links

          Activity

            People

              cutting Doug Cutting
              brandonb Brandon Ballinger
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: