我对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]
最佳答案
我在论坛帖子上随机找到了与问题完全无关的答案。
尽管如此,答案如下:
gremlin> m.keySet()_().outE.map
==> {weight=1.0}
==> {weight=0.4}
只需在 keySet()
方法调用后添加文本 _()
似乎就能将其直接转回 GremlinGrrovyPipeline
对象:
gremlin> m.keySet()_().getClass()
==> class com.tinkerpop.gremlin.groovy.GremlinGroovyPipeline
关于groovy - Gremlin/Groovy 组计数结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11200124/