我想知道如何使用GremlinPipeLine在java中实现以下gremlin查询g.V.has("mgrNo",T.neq,"0").sideEffect{g.V.has("empNo",it.mgrNo).next().addEdge("manages",it)}
。
从.next()开始实现时我感到困惑。
GremlinPipeline pipe = new GremlinPipeline(graph).V().has("mgrNo",T.neq,0).sideEffect(new PipeFunction<Vertex, Object>(){
@Override
public Object compute(Vertex vertex) {
@SuppressWarnings("rawtypes")
GremlinPipeline pipeline = (GremlinPipeline) new GremlinPipeline(graph).V().has("empNo", vertex.getProperty("mgrNo")).next();
//code here
return pipeline;
}
});
答案 0 :(得分:1)
你几乎拥有它,实际上你已经有太多代码了。这应该适合你:
new GremlinPipeline(graph).V().has("mgrNo",T.neq,0).sideEffect(new PipeFunction<Vertex, Object>(){
@Override
public Object compute(Vertex vertex) {
@SuppressWarnings("rawtypes")
Vertex mgr = (Vertex) new GremlinPipeline(graph).V().has("empNo", vertex.getProperty("mgrNo")).next();
return mgr.addEdge("manages", vertex);
}
}).iterate();