How to use GremlinPipeLine sideEffect in java

二次信任 提交于 2019-12-12 01:53:58

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!