我正在尝试读取之前添加到数据库中的边缘:
declare @mytble table
(
orders int,
product varchar (50),
quantity int
)
INSERT @mytble
SELECT 100,'CUP','1' UNION ALL
SELECT 100, 'PLATE',2 UNION ALL
SELECT 101,'CUP','1' UNION ALL
SELECT 102,'CUP','2' UNION ALL
SELECT 103, 'CUP',1 UNION ALL
SELECT 103,'PLATE','3' UNION ALL
SELECT 103,'GLASS','1'
SELECT * FROM @mytble
我正在创建以下方式:
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());
但似乎返回始终为空,因为第一个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();
的返回为空。
奇怪的是,如果我使用vertex1.getEdges(Direction.OUT, relationshipId)
,它不会为空,但这对我没有帮助。