Double M
Double M

Reputation: 1503

How Do I Perform Pagination with TinkerPop in Java?

In Gremlin, we can paginate like this:

gremlin> g.V().hasLabel('person').fold().as('persons','count').
               select('persons','count').
                 by(range(local, 0, 2)).
                 by(count(local))
==>[persons:[v[1],v[2]],count:4]

I'm trying to do the same thing in Java, but have no idea what local is in this case. My current query looks like this:

.fold()
.as("persons", "count")
.select("persons", "count")
.by(__.range(0, 2))
.by(__.count())

However, it always returns all results with a count of 1. How would the pagination be correctly performed in Java?

Upvotes: 0

Views: 324

Answers (1)

stephen mallette
stephen mallette

Reputation: 46216

The details for pagination are described best here but your question seems like it's more about use of local. local is an value from the enum Scope and a common import for all languages Gremlin is implemented in.

import static org.apache.tinkerpop.gremlin.process.traversal.Scope.local;

You can always find out more about the arguments to Gremlin steps by looking at the javadoc.

Upvotes: 2

Related Questions