You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "Daniel Kuppitz (JIRA)" <ji...@apache.org> on 2015/06/29 13:14:04 UTC

[jira] [Commented] (TINKERPOP3-750) Compare should not have special case for Number

    [ https://issues.apache.org/jira/browse/TINKERPOP3-750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14605472#comment-14605472 ] 

Daniel Kuppitz commented on TINKERPOP3-750:
-------------------------------------------

IIRC that was done because we want to be able to do {{.count().is(0)}} instead of {{count().is(0L)}}. Same for things like {{.outE("rated").has("stars", between(3.5, 5))}} - that would also work if {{stars}} is of type {{Integer}}.

> Compare should not have special case for Number
> -----------------------------------------------
>
>                 Key: TINKERPOP3-750
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP3-750
>             Project: TinkerPop 3
>          Issue Type: Improvement
>            Reporter: Matt Frantz
>
> The current implementation of {{Compare}} has a special case for {{Number}} which uses {{doubleValue}} for all comparisons.  However, this fails for some implementations of {{Number}}, e.g. {{BigInteger}}.  Also, most implementations of {{Number}} implement {{Comparable}} for appropriately typed arguments.  It should be more robust and less surprising to simply use {{Object.equals}} and {{Comparable.compareTo}}.  This would also be more performant as it removes the {{instanceof}} checks.
> If we want the option of treating all numbers as doubles, perhaps something called {{CompareDouble}} would be more appropriate.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)