如何在 java 中获取 gremlin titan 图形数据库和 valueMap() 中的边和顶点属性
How to get both edge and vertex properties in gremlin titan graph database and valueMap() in java
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()) 时,出现以下编译错误:undefined function valueMap()
2)代替by(valueMap()),by()只返回顶点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]]]
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()) 时,出现以下编译错误:undefined function valueMap()
2)代替by(valueMap()),by()只返回顶点id和边id。
a=v[16576],b=e[2pjpce-6eo-90r9-9ig][edgeA],c=v[8304]}
你能帮我解决这个问题吗?我无法确定如何在 Java.
你可以使用 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]]]