如何在 Java 中使用 TinkerPop 执行分页?

How Do I Perform Pagination with TinkerPop in Java?

在Gremlin中,我们可以这样分页:

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]

我正在尝试在 Java 中做同样的事情,但不知道在这种情况下 local 是什么。我当前的查询如下所示:

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

但是,它总是 returns all 结果计数为 1。如何在 Java 中正确执行分页?

对于 Gremlin 实现的所有语言,分页的详细信息描述得最好 but your question seems like it's more about use of local. local is an value from the enum Scope and a common import

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

您随时可以通过查看 javadoc.

找到更多关于 Gremlin 步骤的参数的信息