我正在尝试读取之前添加到数据库中的边:
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.IN).equals(vertex)))
.collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
我正在创建以下方式:
Iterable<Vertex> startNodes = this.getVertexList(storage.getStartNode(), graph);
Iterable<Vertex> endNodes = this.getVertexList(storage.getEndNode(), graph);
for (Vertex startNode : startNodes)
{
for (Vertex endNode : endNodes)
{
String edgeClass = "class:" + storage.getId();
Edge edge = startNode.addEdge(edgeClass, endNode);
for (Map.Entry<String, Object> entry : storage.getProperties().entrySet())
{
edge.setProperty(entry.getKey(), entry.getValue());
}
edge.setProperty(Constants.TAG_HASH, HashCreator.sha1FromRelationship(storage));
edge.setProperty(Constants.TAG_SNAPSHOT_ID, snapshotId);
}
}
graph.commit();
Run Code Online (Sandbox Code Playgroud)
但似乎返回始终为空,因为第一个返回vertex1.getEdges(Direction.OUT, relationshipId)为null.奇怪的是,如果我使用它不是空的,Direction.IN但这对我没有帮助.
| 归档时间: |
|
| 查看次数: |
120 次 |
| 最近记录: |