每个顶点和边都有以下属性:
Request [req_id: long, submit_time:long, priority:int, status:char]
Test_B [tb_id: long, tb_name: string]
TestSuite [suite_id: long, Suite_Status: char]
Edge-A [sequence_num: int]
Edge-B [ sequence_num: int, suite_status: char]
顶点与边之间的关系:
Request----EdgeA----Test-B
Request----EdgeB----TestSuite
TestSuite----EdgeC----Test-B
以下查询按升序排序(来自请求的submit_time)并显示TestSuite详细信息:
g.V().order().by("submit_time",incr).outE("Edge-B").
has("suite_status","Q").inV().valueMap()
以下是示例图表:
rj1=graph.addVertex(label,"request","req_id",1138,"status","S","priority",3,"submit_time",1330647978000)
rj2=graph.addVertex(label,"request","req_id",1133,"status","S","priority",2,"submit_time",1330662012000)
rj3=graph.addVertex(label,"request","req_id",1136,"status","S","priority",1,"submit_time",1330652298000)
rj4=graph.addVertex(label,"request","req_id",1135,"status","S","priority",1,"submit_time",1330666768000)
ts1=graph.addVertex(label,"test_suite","test_suite_id",8713)
ts2=graph.addVertex(label,"test_suite","test_suite_id",8718)
ts3=graph.addVertex(label,"test_suite","test_suite_id",8688)
ts4=graph.addVertex(label,"test_suite","test_suite_id",8729)
tb1=graph.addVertex(label,"test_b","tb_id",574)
tb2=graph.addVertex(label,"test_b","tb_id",573)
tb3=graph.addVertex(label,"test_b","tb_id",577)
e1=rj1.addEdge("edgeB",ts1,"sequence",1,"job_suite_status","Q")
e2=rj1.addEdge("edgeB",ts2,"sequence",2,"job_suite_status","Q")
e1=rj2.addEdge("edgeB",ts1,"sequence",1,"job_suite_status","Q")
e2=rj2.addEdge("edgeB",ts3,"sequence",2,"job_suite_status","Q")
e1=rj3.addEdge("edgeB",ts4,"sequence",1,"job_suite_status","Q")
e2=rj3.addEdge("edgeB",ts2,"sequence",2,"job_suite_status","Q")
e1=rj4.addEdge("edgeB",ts3,"sequence",1,"job_suite_status","Q")
e2=rj4.addEdge("edgeB",ts4,"sequence",2,"job_suite_status","Q")
e1=rj1.addEdge("edgeA",tb1,"sequence",1)
e2=rj1.addEdge("edgeA",tb2,"sequence",2)
e3=rj2.addEdge("edgeA",tb1,"sequence",1)
e4=rj2.addEdge("edgeA",tb1,"sequence",2)
e5=rj3.addEdge("edgeA",tb2,"sequence",1)
e6=rj3.addEdge("edgeA",tb3,"sequence",2)
e7=rj4.addEdge("edgeA",tb3,"sequence",2)
e8=rj4.addEdge("edgeA",tb1,"sequence",1)
这里,rj1,rj2,rj4连接到tb1(edgeA): 所以对于每个test_b(例如:tb_id = 574),基于submit_time排序请求(rj1,rj2,rj4)并获取test_suite_id和sequence。
最后,我需要打印 test_suite_id,序列和相应的req_id 。请帮我解决这个问题。感谢。
答案 0 :(得分:1)
使用as()
标记步骤,然后使用select()
来准备结果很有帮助。
g.V().has("tb_id", 574).
in("edgeA").dedup().as("r").
order().by("submit_time", Order.incr).as("st").
outE("edgeB").has("job_suite_status", "Q").as("s").
inV().as("t").
select("t", "s", "r", "st").
by("test_suite_id").by("sequence").by("req_id").by("submit_time")
从tb_id 574开始测试,然后遍历其请求(标记为r
),按提交时间(标签为st
)对请求进行排序,遍历序列(标签为{ {1}}),最后遍历测试套件(标签为s
)。
使用t
准备结果输出,使用select()
选择属性:测试套件,序列,请求和提交时间。