简体   繁体   English

OrientDB从顶点获取标签并从顶点获取关系

[英]OrientDB get label from vertex and get relationship from vertex

I have two separate questions: 我有两个单独的问题:

How can I get the label of a vertex object. 如何获取顶点对象的标签。 I tried vertex.getId() .getClass() and similar but nothing is even close to the label I set to the vertex. 我尝试了vertex.getId().getClass()和类似的东西,但是没有什么东西与我为顶点设置的标签接近。

and, how can I get a relationship which connects any vertices of a set of vertices. 以及如何获得一个连接一组顶点中任何顶点的关系。

Iterable<Vertex> startNodes = getVertexList(relationshipStorage.getStartNode(), graph);
                Iterable<Vertex> endNodes = getVertexList(relationshipStorage.getEndNode(), graph);

                List<Edge> list = StreamSupport.stream(startNodes.spliterator(), false)
                        .flatMap(vertex1 -> StreamSupport.stream(vertex1.getEdges(Direction.OUT, relationshipId).spliterator(), false))
                        .filter(edge -> StreamSupport.stream(endNodes.spliterator(), false).anyMatch(vertex -> edge.getVertex(Direction.OUT).equals(vertex)))
                        .collect(Collectors.toList());

I am currently streaming through all the start vertices and looking if a relationship leaving them matches one of the end vertices. 我目前正在流经所有起始顶点,并查看离开它们的关系是否与其中一个终止顶点匹配。 Isn't there nothing more nicer? 没有更好的了吗?

You could use 你可以用

vertex.getProperty("@class");

to get the name of the class of your vertex. 获得顶点类的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM