Skip, Limit, Range

431 views
Skip to first unread message

Guy Ellis

unread,
Nov 9, 2016, 3:02:10 PM11/9/16
to Gremlin-users
Trying to work out how to do a "skip" in Gremlin in isolation.

- Limit - get the first 5

g.V().limit(5)
or
g.V().range(0,5)

- Range - skip 10 then get next 5

g.V().range(10,5)

- Skip - skip 10 then get rest...?

g.V().range(10)
^ doesn't work

Daniel Kuppitz

unread,
Nov 9, 2016, 3:47:39 PM11/9/16
to gremli...@googlegroups.com
.range(10, -1) should do what you're looking for.

Cheers,
Daniel

From: Guy Ellis
Sent: ‎11/‎9/‎2016 21:02
To: Gremlin-users
Subject: [TinkerPop] Skip, Limit, Range

--
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-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/8f63f12f-99b0-4ad2-957e-a4953522f729%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Guy Ellis

unread,
Nov 9, 2016, 4:18:42 PM11/9/16
to Gremlin-users
That gives me: "org.apache.tinkerpop.gremlin.driver.exception.ResponseException: IllegalArgumentException"

Using latest DSE Server/Studio combo.

Daniel Kuppitz

unread,
Nov 9, 2016, 5:02:38 PM11/9/16
to gremli...@googlegroups.com
Can you post a full stacktrace? It works just fine in TinkerPop alone:

gremlin> g = TinkerFactory.createModern().traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin> g.V()
==>v[1]
==>v[2]
==>v[3]
==>v[4]
==>v[5]
==>v[6]
gremlin> g.V().range(3, -1)
==>v[4]
==>v[5]
==>v[6]

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/29a31d99-aba0-488b-8524-4f1648d416f5%40googlegroups.com.

Guy Ellis

unread,
Nov 10, 2016, 10:45:31 AM11/10/16
to Gremlin-users
Struggling to find the stack. In the meantime I've checked with what you tried Daniel and can confirm that it works as you showed.

In addition, on my dataset of 120 vertices I tried this:
g.V().range(0,500).range(10,-1)
and it works. Not sure why apply range(10,-1) to V() would fail but applying it to another range() result would work on the same dataset?

Daniel Kuppitz

unread,
Nov 10, 2016, 10:55:47 AM11/10/16
to gremli...@googlegroups.com
I guess it's a bug in DSEG. It's probably trying to optimize g.V().range(x, -1) somehow and then doesn't handle the negative value properly (maybe it passes the -1 directly to Cassandra's LIMIT clause).

But I'm just guessing, I currently don't have a test environment to try that out.

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/16a3997f-5b6f-4b1b-b291-58a60fe5d84c%40googlegroups.com.

Daniel Kuppitz

unread,
Nov 10, 2016, 11:02:07 AM11/10/16
to gremli...@googlegroups.com
Nvm, I do have a test environment. I can confirm that this is broken in DSEG. Even .explain() doesn't work, so I could see what's going on. I will make a ticket.

Cheers,
Daniel

Guy Ellis

unread,
Nov 10, 2016, 3:11:48 PM11/10/16
to Gremlin-users
Thanks Daniel! Is the ticket public or is there a way I can follow it?

Daniel Kuppitz

unread,
Nov 10, 2016, 3:53:30 PM11/10/16
to gremli...@googlegroups.com
You need to have a DataStax Jira account to see the ticket, which is most likely not the case. I can keep you updated here when the status of the ticket changes.

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/7dadf0df-84e8-42b0-8f1d-7dc1620e7388%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages