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

Matt Frantz commented on TINKERPOP3-750:
----------------------------------------

Coercion rules are useful, but the current rule, "treat all Numbers like 
doubles," is a sledgehammer.  Perhaps the behavior we should seek would be the 
promotion rules that are familiar to Java programmers.  For the "count" case, 
that would mean widening the zero literal to long.  For the "stars" case, you 
would widen to double, since one of the operands is a double.

To some degree, we could lean on static analysis (with a 
{{TraversalStrategy}}).  This would help with the "count" case, but not with 
the "stars" case.  If we ever have schema information, we could handle the 
"stars" case as well.

I looked around for prior implementations of numeric conversion logic, but 
haven't found anything so far.

> 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
>          Components: process
>            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)

Reply via email to