Uploaded image for project: 'TinkerPop'
  1. TinkerPop
  2. TINKERPOP-2643

Equality for NaN and BigDecimal

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.5.1
    • None
    • process
    • None

    Description

      JDK11 seems to produce a different error from JDK8 when it comes to BigDecimal comparisons that hit NaN and such. For JDK8 they seem to produce NumberFormatException but for JDK11 you get stuff like:

      gremlin> g.V().has("key", Float.NaN)
      Character N is neither a decimal digit number, decimal point, nor "e" notation exponential mark.
      

      When Double/Float is stored, it always throws. With the proposed change, it wouldn't throw but because NaN is not equal to any numbers this returns empty result.

      Equality around BigDecimal and special values which cannot be parsed as Integer such as{{NaN}}, INF should not produce exceptions and should filter.

      gremlin> g.addV().property('key',Float.NaN)
      ==>v[0]
      gremlin> g.addV().property('key',1.0f)
      ==>v[2]
      gremlin> g.V().has('key',Float.NaN)
      ==>v[0]
      gremlin> g.V().has('key',1.0f)
      ==>v[2]
      gremlin> g.V().values("key").is(eq(1.0f)) // 3.5.x
      ==>1.0
      gremlin> g.V().has('key',1.0) // 3.5.x - likely due to Groovy going to BigDecimal for "1.0"
      java.lang.NumberFormatException
      Type ':help' or ':h' for help.
      Display stack trace? [yN]n
      gremlin> g.V().values("key").is(eq(new BigDecimal(1.0f))) // 3.5.x
      java.lang.NumberFormatException
      Type ':help' or ':h' for help.
      Display stack trace? [yN]
      gremlin> g.V().has('key',1.0) // proposed
      ==>v[2]
      gremlin> g.V().values("key").is(eq(1.0)) // proposed
      ==>1.0
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            spmallette Stephen Mallette
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: