2

我对groupCount使用结果节点执行更多查询感到有些困惑。我一直在 Neo4j 控制台中这样做。例如,使用 TinkerGraph 数据集:

gremlin> g = TinkerGraphFactory.createTinkerGraph()
==> tinkergraph[vertices:6 edges:6]

gremlin> g.V.getClass()
==> class com.tinkerpop.gremlin.groovy.GremlinGroovyPipeline

gremlin> m = [:]

gremlin> g.V.out.groupCount(m)
==> v[2]
==> v[4]
==> v[3]
==> v[3]
==> v[5]
==> v[3]

gremlin> m
==> v[2]=1
==> v[4]=1
==> v[3]=3
==> v[5]=1

gremlin> m.getClass()
==> class java.util.LinkedHashMap

gremlin> m = m.keySet()
==> v[2]
==> v[4]
==> v[3]
==> v[5]

gremlin> m.getClass()
==> class java.util.HashMap$KeySet

gremlin> m.outE
==> [StartPipe, OutEdgesPipe]
==> [StartPipe, OutEdgesPipe]
==> [StartPipe, OutEdgesPipe]
==> [StartPipe, OutEdgesPipe]

gremlin> m.outE.map
==> [StartPipe, OutEdgesPipe, PropertyMapPipe]
==> [StartPipe, OutEdgesPipe, PropertyMapPipe]
==> [StartPipe, OutEdgesPipe, PropertyMapPipe]
==> [StartPipe, OutEdgesPipe, PropertyMapPipe]

如何m用作GremlinGroovyPipeline对象?我期待与此类似的结果:

gremlin> m.outE
==> e[7][1-knows->2]
==> e[8][1-knows->4]
==> e[9][1-created->3]
==> e[12][6-created->3]
==> e[10][4-created->5]
==> e[11][4-created->3]
4

1 回答 1

2

我在与问题完全无关的论坛帖子上随机找到了答案。

尽管如此,这里的答案是:

gremlin> m.keySet()_().outE.map
==> {weight=1.0}
==> {weight=0.4}

_()在方法调用之后简单地添加文本keySet()似乎可以直接将其转换回GremlinGrrovyPipeline对象:

gremlin> m.keySet()_().getClass()
==> class com.tinkerpop.gremlin.groovy.GremlinGroovyPipeline
于 2012-06-26T06:48:46.400 回答