【发布时间】:2016-03-05 03:50:02
【问题描述】:
我目前正在阅读 TinkerPop3 Documentation
令我困惑的是,我找不到任何关于 next() 的解释。
例如,w/next() 或 w/o next() 返回相同的顶点
gremlin> g.V().has('name', 'marko')
==>v[1]
gremlin> g.V().has('name', 'marko').next()
==>v[1]
但是,类名彼此不同。
gremlin> g.V().has('name', 'marko').getClass()
==>class org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal
gremlin> g.V().has('name', 'marko').next().getClass()
==>class org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex
如果没有'next()',分配的变量就没有值。
gremlin> marko = g.V().has('name', 'marko')
==>v[1]
gremlin> marko
即使是clockWithResult(),输出也完全不同。
gremlin> clockWithResult(1){g.V().both().barrier().both().barrier().both().barrier().count().next()}
==>1.079524
==>72
gremlin> clockWithResult(1){g.V().both().barrier().both().barrier().both().barrier().count()}
==>0.11863599999999999
==>[GraphStep([],vertex), VertexStep(BOTH,vertex), NoOpBarrierStep(2147483647), VertexStep(BOTH,vertex), NoOpBarrierStep(2147483647), VertexStep(BOTH,vertex), NoOpBarrierStep(2147483647), CountGlobalStep]
或者这个例子:
gremlin> g.V(1).out('knows').values('name').fold()
==>[vadas, josh]
gremlin> g.V(1).out('knows').values('name').fold().next()
==>vadas
==>josh
在手册中,还有很多其他的例子让我感到困惑。
我希望马可和他的朋友们能帮助我。
【问题讨论】:
标签: titan tinkerpop3