Github user dkuppitz commented on the issue:
https://github.com/apache/tinkerpop/pull/697
Alright, turned out it doesn't have a measurable performance impact.
```
if (first instanceof Number && second instanceof Number) {
return NumberHelper.compare((Number) second, (Number) first);
}
return Comparator.<~>naturalOrder().compare((Comparable) first,
(Comparable) second);
```
is as fast as
```
try {
return Comparator.<~>naturalOrder().compare((Comparable) first,
(Comparable) second);
} catch (final ClassCastException ex) {
if (first instanceof Number && second instanceof Number) {
return NumberHelper.compare((Number) first, (Number) second);
} else throw ex;
}
```
Tested using the Grateful Dead graph and the following query:
```
g.V().hasLabel("song").
project("a","b").
by("name").
by(outE("followedBy").values("weight").sum()).
order().
by(select("b"), decr)
```
Thus I will go with the first variant, not using `try / catch`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---