我对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]
答案 0 :(得分:2)
我在论坛帖子上随机找到了与该问题完全无关的答案。
尽管如此,答案是:
gremlin> m.keySet()_().outE.map
==> {weight=1.0}
==> {weight=0.4}
在_()
方法调用之后简单地添加文本keySet()
似乎会将其直接转回GremlinGrrovyPipeline
对象:
gremlin> m.keySet()_().getClass()
==> class com.tinkerpop.gremlin.groovy.GremlinGroovyPipeline