首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >OrientDB中的Java Gremlin API遍历

OrientDB中的Java Gremlin API遍历
EN

Stack Overflow用户
提问于 2018-06-20 00:01:57
回答 1查看 189关注 0票数 0

我有一个关于在OrientDB中使用Gremlin API和Java的问题。所以,我创建了一个GremlinPipeline对象,从这个管道对象我想跳到下一个顶点:

代码语言:javascript
复制
GremlinPipeline pipe = new GremlinPipeline();
pipe.start(graph.getVertex("#18:0"));
pipe.out();

输出:

代码语言:javascript
复制
v(TokenClass)[#19:0]
v(TokenClass)[#19:1]
v(TokenClass)[#19:2]

有了这段代码,它在我的例子中返回了三个顶点,到目前为止都很完美。现在我想再次遍历返回的每个顶点,并将每个结果保存在一个单独的列表中。我如何实现这一点?我是否为每个顶点创建了一个新的GremlinPipeline对象,或者是否有一个嵌套的GremlinPipeline函数?

非常感谢你提前

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-20 04:31:48

好吧,这是我网站上的误会。GremlinPipeline返回Vertex对象。问题的关键在于,如果我们想要开始一个新的GremlinPipeline,我们只需要返回一个顶点,所以我们不需要调用OrientDB来检索想要的顶点。我们已经有了Vertex对象来启动一个新的GremlinPipeline。例如,它看起来像这样:

代码语言:javascript
复制
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);
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50932581

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档