我有一个关于在OrientDB中使用Gremlin API和Java的问题。所以,我创建了一个GremlinPipeline
对象,从这个管道对象我想跳到下一个顶点:
GremlinPipeline pipe = new GremlinPipeline();
pipe.start(graph.getVertex("#18:0"));
pipe.out();
输出:
v(TokenClass)[#19:0]
v(TokenClass)[#19:1]
v(TokenClass)[#19:2]
有了这段代码,它在我的例子中返回了三个顶点,到目前为止都很完美。现在我想再次遍历返回的每个顶点,并将每个结果保存在一个单独的列表中。我如何实现这一点?我是否为每个顶点创建了一个新的GremlinPipeline
对象,或者是否有一个嵌套的GremlinPipeline
函数?
非常感谢你提前
发布于 2018-06-20 04:31:48
好吧,这是我网站上的误会。GremlinPipeline
返回Vertex
对象。问题的关键在于,如果我们想要开始一个新的GremlinPipeline
,我们只需要返回一个顶点,所以我们不需要调用OrientDB来检索想要的顶点。我们已经有了Vertex
对象来启动一个新的GremlinPipeline
。例如,它看起来像这样:
GremlinPipeline pipe = new GremlinPipeline();
pipe.start(graph.getVertex("#18:0"));
pipe.out();
List<Vertex> currentTokenList = pipe.toList();
for (Vertex currentToken : currentTokenList) { //with the currentToken we can start a new GremlinPipeline
System.out.println("aktuelles Token " + currentToken);
GremlinPipeline pipe2 = new GremlinPipeline();
pipe2.start(currentToken);
pipe2.out();
List<Vertex> currentRIDList = pipe2.toList();
for (Vertex ridVertex : currentRIDList) {
System.out.println(ridVertex);
}
}
https://stackoverflow.com/questions/50932581
复制相似问题