问题
I would like to know how to implement the following gremlin query g.V.has("mgrNo",T.neq,"0").sideEffect{g.V.has("empNo",it.mgrNo).next().addEdge("manages",it)}
in java using GremlinPipeLine .
I getting confused while implementing from the .next() onwards.
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;
}
});
回答1:
You almost have it, actually you already have too much code. This should work for you:
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();
来源:https://stackoverflow.com/questions/29146174/how-to-use-gremlinpipeline-sideeffect-in-java