Re: [TinkerPop] Order by using Longs seem to cause ClassCastException

44 views
Skip to first unread message

Daniel Kuppitz

unread,
Aug 16, 2017, 1:20:11 PM8/16/17
to gremli...@googlegroups.com
Can you reproduce it in TinkerGraph or does it only happen in DSE Graph?
Can you provide a small sample graph, so we can reproduce it?

Cheers,
Daniel


On Wed, Aug 16, 2017 at 10:13 AM, Martin Tapp <martin...@gmail.com> wrote:
Hi,

I have the following gremlin query where I'm trying to sum an edge property which is a long (BigInteger). The query runs fine except when I add an order by clause.

top_5_of_some_long_value_sorted =
  g.V().hasLabel("people").group().by("some_long_id").by(outE("knows").values("some_long_value").sum())
    .order(local).by(values, decr) // Adding this clause causes java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
    .limit(local, 5)

I even tried .<Long,Long>group() and .<Long>sum() with the same cast exception. Seems the order by gets an Integer comparator instead of a Long for some unknown reason.

Any idea if that's a bug or how I can prevent a full client-side sort?

Thanks

Here's the full stack trace using DSE Graph 5.0:
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
	at java.lang.Integer.compareTo(Integer.java:52)
	at java.util.Collections$ReverseComparator.compare(Collections.java:5117)
	at java.util.Collections$ReverseComparator.compare(Collections.java:5108)
	at org.apache.tinkerpop.gremlin.process.traversal.Order$2.compare(Order.java:43)
	at org.apache.tinkerpop.gremlin.util.function.ChainedComparator.compare(ChainedComparator.java:63)
	at java.util.TimSort.countRunAndMakeAscending(TimSort.java:360)
	at java.util.TimSort.sort(TimSort.java:234)
	at java.util.Arrays.sort(Arrays.java:1512)
	at java.util.ArrayList.sort(ArrayList.java:1454)
	at java.util.Collections.sort(Collections.java:175)
	at org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderLocalStep.sortMap(OrderLocalStep.java:149)
	at org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderLocalStep.map(OrderLocalStep.java:63)
	at org.apache.tinkerpop.gremlin.process.traversal.step.map.MapStep.processNextStart(MapStep.java:37)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.next(ExpandableStepIterator.java:50)
	at org.apache.tinkerpop.gremlin.process.traversal.step.map.MapStep.processNextStart(MapStep.java:36)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.hasNext(ExpandableStepIterator.java:42)
	at com.datastax.bdp.graph.impl.tinkerpop.optimizer.TraverserPrefetchBuffer.fetchNext(TraverserPrefetchBuffer.java:83)
	at com.datastax.bdp.graph.impl.tinkerpop.optimizer.TraverserIdentityPrefetchBuffer.processNextStart(TraverserIdentityPrefetchBuffer.java:35)
	at com.datastax.bdp.graph.impl.tinkerpop.optimizer.DsegPropertyLoadStep.processNextStart(DsegPropertyLoadStep.java:63)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:128)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:38)
	at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.next(DefaultTraversal.java:193)
	at java_util_Iterator$next.call(Unknown Source)
	at Script100.run(Script100.groovy:5)
	at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:812)
	at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:525)
	at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233)
	at org.apache.tinkerpop.gremlin.groovy.engine.ScriptEngines.eval(ScriptEngines.java:120)
	at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval$53(GremlinExecutor.java:314)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:748)

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/f145d54b-70ca-44f6-a887-f9bb9ec15d7e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Martin Tapp

unread,
Aug 17, 2017, 8:49:15 AM8/17/17
to Gremlin-users
I've reproduced it with the gremlin-console of TinkerPop 3.2.5. The query fails on the modern graph except for a Double instead of a Long. My program also fails for any number type other than Integer.

~/apache-tinkerpop-gremlin-console-3.2.5/bin$ ./gremlin.sh

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph
gremlin> graph = TinkerFactory.createModern()
==>tinkergraph[vertices:6 edges:6]
gremlin> g = graph.traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin> g.V().hasLabel("person").group().by("name").by(outE("knows").values("weight").sum()).order(local).by(values, decr)
java.lang.Double cannot be cast to java.lang.Integer
Type ':help' or ':h' for help.
Display stack trace? [yN]y
java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer
at java.lang.Integer.compareTo(Integer.java:52)
at java.util.Collections$ReverseComparator.compare(Collections.java:5117)
at java.util.Collections$ReverseComparator.compare(Collections.java:5108)
at org.apache.tinkerpop.gremlin.process.traversal.Order$2.compare(Order.java:43)
at org.apache.tinkerpop.gremlin.util.function.ChainedComparator.compare(ChainedComparator.java:63)
at java.util.TimSort.countRunAndMakeAscending(TimSort.java:360)
at java.util.TimSort.sort(TimSort.java:220)
at java.util.Arrays.sort(Arrays.java:1512)
at java.util.ArrayList.sort(ArrayList.java:1454)
at java.util.Collections.sort(Collections.java:175)
at org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderLocalStep.sortMap(OrderLocalStep.java:149)
at org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderLocalStep.map(OrderLocalStep.java:63)
at org.apache.tinkerpop.gremlin.process.traversal.step.map.MapStep.processNextStart(MapStep.java:37)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143)
at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:192)
at org.apache.tinkerpop.gremlin.console.Console$_closure3.doCall(Console.groovy:234)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
at org.codehaus.groovy.tools.shell.Groovysh.setLastResult(Groovysh.groovy:447)
at org.codehaus.groovy.tools.shell.Groovysh.execute(Groovysh.groovy:191)
at org.apache.tinkerpop.gremlin.console.GremlinGroovysh.super$3$execute(GremlinGroovysh.groovy)
at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:132)
at org.apache.tinkerpop.gremlin.console.GremlinGroovysh.execute(GremlinGroovysh.groovy:72)
at org.codehaus.groovy.tools.shell.Shell.leftShift(Shell.groovy:122)
at org.codehaus.groovy.tools.shell.InteractiveShellRunner.super$2$work(InteractiveShellRunner.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:132)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:152)
at org.codehaus.groovy.tools.shell.ShellRunner.run(ShellRunner.groovy:59)
at org.codehaus.groovy.tools.shell.InteractiveShellRunner.super$2$run(InteractiveShellRunner.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:132)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:152)
at org.codehaus.groovy.tools.shell.InteractiveShellRunner.run(InteractiveShellRunner.groovy:83)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:232)
at org.apache.tinkerpop.gremlin.console.Console.<init>(Console.groovy:166)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:232)
at org.apache.tinkerpop.gremlin.console.Console.main(Console.groovy:478)
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.

Daniel Kuppitz

unread,
Aug 17, 2017, 9:42:53 AM8/17/17
to gremli...@googlegroups.com
Interesting! I created a ticket: https://issues.apache.org/jira/browse/TINKERPOP-1753

Cheers,
Daniel


To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/deeb6fe4-49d8-4079-b9be-eb1ce03fc2ed%40googlegroups.com.

Robert Dale

unread,
Aug 17, 2017, 9:49:44 AM8/17/17
to gremli...@googlegroups.com
The world's most interesting gremlin says: I don't always order a double, but when I do, I cast it to an integer first!

Robert Dale

Martin Tapp

unread,
Aug 17, 2017, 10:08:08 AM8/17/17
to gremli...@googlegroups.com
Thanks for the excellent support guys!
Martin

--
You received this message because you are subscribed to a topic in the Google Groups "Gremlin-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gremlin-users/-EDFAN2ZrmY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/CABed_4oFXFkvvkCPSCEeaOq6qYHRLT%2Bm9eBRim-q9vpDt7MLaA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages