Skip to content
This repository has been archived by the owner on Jan 27, 2020. It is now read-only.

Commit

Permalink
Merge branch 'schedoscope-168' into Release-0.8.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Utz Westermann committed Aug 4, 2017
2 parents c1b6101 + 14fc1a3 commit af66d30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ public static MetascopeSchemaLineage getSchemaLineage(MetascopeTable table) {
List<MetascopeLineageEdge> backwardEdges = new ArrayList<>();

for (MetascopeField metascopeField : table.getFields()) {
forwardEdges.addAll(computeRecursiveSchemaLineage(metascopeField, false));
forwardEdges.addAll(computeRecursiveSchemaLineage(metascopeField, false, new HashSet<MetascopeField>()));
}

for (MetascopeField metascopeField : table.getFields()) {
backwardEdges.addAll(computeRecursiveSchemaLineage(metascopeField, true));
backwardEdges.addAll(computeRecursiveSchemaLineage(metascopeField, true, new HashSet<MetascopeField>()));
}

schemaLineage.setForwardEdges(forwardEdges);
Expand All @@ -80,7 +80,8 @@ public static MetascopeSchemaLineage getSchemaLineage(MetascopeTable table) {
* @param isBackward {@code true}: backward, {@code false}: forward
* @return the edges to display in the graph
*/
private static Set<MetascopeLineageEdge> computeRecursiveSchemaLineage(MetascopeField field, boolean isBackward) {
private static Set<MetascopeLineageEdge> computeRecursiveSchemaLineage(MetascopeField field, boolean isBackward, Set<MetascopeField> seen) {
seen.add(field);
Collection<MetascopeField> lineage = isBackward ? field.getDependencies() : field.getSuccessors();
HashSet<MetascopeLineageEdge> result = new HashSet<>();
if (lineage.isEmpty()) return result;
Expand All @@ -89,7 +90,9 @@ private static Set<MetascopeLineageEdge> computeRecursiveSchemaLineage(Metascope
MetascopeLineageNode from = new MetascopeLineageNode(field.getFieldId(), field.getFieldName(), field.getTable().getFqdn());
MetascopeLineageNode to = new MetascopeLineageNode(otherField.getFieldId(), otherField.getFieldName(), otherField.getTable().getFqdn());
result.add(new MetascopeLineageEdge(from, to));
result.addAll(computeRecursiveSchemaLineage(otherField, isBackward));
if (!seen.contains(otherField)) {
result.addAll(computeRecursiveSchemaLineage(otherField, isBackward, seen));
}
}

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,9 @@ function LineageGraph(containerSelector, direction) {
// check if graph is acyclic
if (!dagreD3.graphlib.alg.isAcyclic(fullGraph)) {
var cycles = dagreD3.graphlib.alg.findCycles(fullGraph);
var message = "Lineage graph is not acyclic. Brace yourself, display bugs are coming!";
cycles.forEach(function (cycle) {
message += "\nFound cycle: " + cycle.join(" → ") + " → " + cycle[0];
fullGraph.removeEdge(cycle[cycle.length - 2], cycle[cycle.length - 1])
});
alert(message);
}

if (!startNodes) {
Expand Down

0 comments on commit af66d30

Please sign in to comment.