ts1=graph.addVertex(label,"test","test_id",872)
ts2=graph.addVertex(label,"test","test_id",873)
rj1=graph.addVertex(label,"req","id1",113,"status","S")
rj2=graph.addVertex(label,"req","id1",114,"status","S")
e1=rj1.addEdge("edgeA",ts1,"seq",1)
e2=rj2.addEdge("edgeA",ts2,"seq",2)
我可以在单独的查询中获得以下内容:
g.V().hasLabel("req").has("status","S").outE("edgeA").valueMap()
==>[seq:1]
==>[seq:2]
g.V().hasLabel("job").has("status","S").outE("job_edge").inV().valueMap()
==>[test_id,872]
==>[test_id,873]
如何在单个查询中同时获取序列和相应的test_id
更新的问题:
public void readTestbedJob(String tbName){
GraphTraversalSource traversalSource = getTitanTraversalSource();
GraphTraversal<Vertex, Map<String, Object>> query1 = traversalSource.V()
.has("req","id1",113).valueMap();
GraphTraversal<Vertex, Map<String, Object>> query2 = traversalSource.V().has("status","S").as("a").
outE("edgeA").as("e").
inV().as("v").
select("a","e","v").by(valueMap());
}
从gremlin控制台:query1和query2都正确返回了结果。
但是,我无法直接在Java中使用query2中的valueMap()或values(),
GraphTraversal<Vertex, Map<String, Object>> query2 = traversalSource.V().has("status","S").as("a").
outE("edgeA").as("e").
inV().as("v").
select("a","e","v").by(valueMap());
1)当我在上面的查询中直接使用by(valueMap())或by(values())时,出现以下编译错误:未定义的函数valueMap()
2)by()代替by(valueMap()),仅返回顶点ID和边ID。
a = v [16576],b = e [2pjpce-6eo-90r9-9ig] [edgeA],c = v [8304]}
您能帮我解决这个问题吗?我无法确定如何在Java中使用by(valueMap())。
最佳答案
您可以使用select()
:
gremlin> g.V().has("job_status","S").
......1> outE("edgeA").as('e').
......2> inV().as('v').
......3> select('e','v').by(valueMap())
==>[e:[sequence:1],v:[test_suite_id:[872]]]
==>[e:[sequence:2],v:[test_suite_id:[873]]]
关于cassandra - 如何在Greemlin泰坦图数据库和Java中的valueMap()中同时获取边缘和顶点属性,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43672338/