You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "Stephen Mallette (Jira)" <ji...@apache.org> on 2021/11/04 12:42:00 UTC

[jira] [Created] (TINKERPOP-2643) Equality for NaN and BigDecimal

Stephen Mallette created TINKERPOP-2643:
-------------------------------------------

             Summary: Equality for NaN and BigDecimal
                 Key: TINKERPOP-2643
                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2643
             Project: TinkerPop
          Issue Type: Improvement
          Components: process
    Affects Versions: 3.5.1
            Reporter: Stephen Mallette


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:

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

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.

{code}
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
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)