Skip to content

Commit

Permalink
fix(metadata-io): remove logic keeping one path from result since no …
Browse files Browse the repository at this point in the history
…longer necessary

* One path between every node pair is already guaranteed by Cypher spanningTree query
  • Loading branch information
lix-mms committed Aug 21, 2023
1 parent 47f2311 commit 23a9d05
Showing 1 changed file with 0 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,6 @@ public EntityLineageResult getLineage(@Nonnull Urn entityUrn, @Nonnull LineageDi
List<Record> neo4jResult =
statement != null ? runQuery(buildStatement(statement, parameters)).list() : new ArrayList<>();

// It is possible to have more than 1 path from node A to node B in the graph and previous query returns all the paths.
// We convert the List into Map with only the shortest paths. "item.get(i).size()" is the path size between two nodes in relation.
// The key for mapping is the destination node as the source node is always the same, and it is defined by parameter.
neo4jResult = neo4jResult.stream()
.collect(Collectors.toMap(item -> item.values().get(2).asNode().get("urn").asString(), Function.identity(),
(item1, item2) -> item1.get(1).asPath().length() < item2.get(1).asPath().length() ? item1 : item2))
.values()
.stream()
.collect(Collectors.toList());

LineageRelationshipArray relations = new LineageRelationshipArray();
neo4jResult.stream().skip(offset).limit(count).forEach(item -> {
String urn = item.values().get(2).asNode().get("urn").asString();
Expand Down

0 comments on commit 23a9d05

Please sign in to comment.