krlawrence / graph

Practical Gremlin - An Apache TinkerPop Tutorial
Apache License 2.0
836 stars 253 forks source link

Non-negative limit expected in range() function #165

Closed andrew-aernos closed 4 years ago

andrew-aernos commented 4 years ago

book: Pg 51 of Version 282-preview, October 25th 2019 tinkerpop version: 3.4.4(?) not sure how to check

When trying to run:

// Return all the remaining vertices starting at the 3500th one
g.V().range(3500,-1)

gremlin console returns:

gremlin> g.V().range(3500,-1)
Non-negative limit expected: -1
Type ':help' or ':h' for help.
Display stack trace? [yN]y
java.lang.IllegalArgumentException: Non-negative limit expected: -1
        at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145)
        at org.janusgraph.graphdb.query.graph.GraphCentricQueryBuilder.limit(GraphCentricQueryBuilder.java:153)
        at org.janusgraph.graphdb.query.graph.GraphCentricQueryBuilder.limit(GraphCentricQueryBuilder.java:50)
        at org.janusgraph.graphdb.tinkerpop.optimize.JanusGraphStep.buildGlobalGraphCentricQuery(JanusGraphStep.java:122)
        at org.janusgraph.graphdb.tinkerpop.optimize.JanusGraphStep.lambda$new$2(JanusGraphStep.java:84)
        at org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep.processNextStart(GraphStep.java:155)
        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.server.op.AbstractOpProcessor.handleIterator(AbstractOpProcessor.java:96)
        at org.apache.tinkerpop.gremlin.server.op.AbstractEvalOpProcessor.lambda$evalOpInternal$5(AbstractEvalOpProcessor.java:275)
        at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval$0(GremlinExecutor.java:277)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
krlawrence commented 4 years ago

Hi @andrew-aernos , this may be an issue unique to JanusGraph's TinkerPop implementation. I just tested using range(3500,-1) with TinkerGraph and with Amazon Neptune and in each case the query worked correctly. Perhaps this would be a good question to ask on the JanusGraph user's list located at https://groups.google.com/forum/#!forum/janusgraph-users

I don't have the latest JanusGraph istalled where I am currently so have not been able to test on JanusGraph but as it works on TinkerGraph I would have expected it to work on JanusGraph as well.

krlawrence commented 4 years ago

As it has been 14 days going to close this one.