如何在java中使用Gremlin PipeLine side Effect

时间:2015-03-19 13:41:19

标签: java titan gremlin

我想知道如何使用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;
    }
});

1 个答案:

答案 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();