Skip to content

Commit

Permalink
revert: Circular Rendering issue for lineage (#19270)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohityadav766 committed Jan 9, 2025
1 parent a43835d commit a31f01a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,6 @@ public Map<String, Object> searchLineageInternal(
boolean deleted,
String entityType)
throws IOException {
Set<String> visitedFQN = new HashSet<>();
Map<String, Object> responseMap = new HashMap<>();
Set<Map<String, Object>> edges = new HashSet<>();
Set<Map<String, Object>> nodes = new HashSet<>();
Expand All @@ -800,22 +799,14 @@ public Map<String, Object> searchLineageInternal(
}
getLineage(
fqn,
visitedFQN,
downstreamDepth,
edges,
nodes,
queryFilter,
"lineage.fromEntity.fqnHash.keyword",
deleted);
getLineage(
fqn,
visitedFQN,
upstreamDepth,
edges,
nodes,
queryFilter,
"lineage.toEntity.fqnHash.keyword",
deleted);
fqn, upstreamDepth, edges, nodes, queryFilter, "lineage.toEntity.fqnHash.keyword", deleted);
responseMap.put("edges", edges);
responseMap.put("nodes", nodes);
return responseMap;
Expand Down Expand Up @@ -1041,18 +1032,16 @@ public Response searchSchemaEntityRelationship(

private void getLineage(
String fqn,
Set<String> visitedFQN,
int depth,
Set<Map<String, Object>> edges,
Set<Map<String, Object>> nodes,
String queryFilter,
String direction,
boolean deleted)
throws IOException {
if (depth <= 0 || visitedFQN.contains(fqn)) {
if (depth <= 0) {
return;
}
visitedFQN.add(fqn);
es.org.elasticsearch.action.search.SearchRequest searchRequest =
new es.org.elasticsearch.action.search.SearchRequest(
Entity.getSearchRepository().getIndexOrAliasName(GLOBAL_SEARCH_ALIAS));
Expand Down Expand Up @@ -1082,27 +1071,13 @@ private void getLineage(
if (!edges.contains(lin) && fromEntity.get("fqn").equals(fqn)) {
edges.add(lin);
getLineage(
toEntity.get("fqn"),
visitedFQN,
depth - 1,
edges,
nodes,
queryFilter,
direction,
deleted);
toEntity.get("fqn"), depth - 1, edges, nodes, queryFilter, direction, deleted);
}
} else {
if (!edges.contains(lin) && toEntity.get("fqn").equals(fqn)) {
edges.add(lin);
getLineage(
fromEntity.get("fqn"),
visitedFQN,
depth - 1,
edges,
nodes,
queryFilter,
direction,
deleted);
fromEntity.get("fqn"), depth - 1, edges, nodes, queryFilter, direction, deleted);
}
}
}
Expand Down Expand Up @@ -1254,7 +1229,6 @@ private Map<String, Object> searchPipelineLineage(
boolean deleted,
Map<String, Object> responseMap)
throws IOException {
Set<String> visitedFQN = new HashSet<>();
Set<Map<String, Object>> edges = new HashSet<>();
Set<Map<String, Object>> nodes = new HashSet<>();
Object[] searchAfter = null;
Expand Down Expand Up @@ -1300,7 +1274,6 @@ private Map<String, Object> searchPipelineLineage(
edges.add(lin);
getLineage(
fromEntity.get("fqn"),
visitedFQN,
upstreamDepth,
edges,
nodes,
Expand All @@ -1309,7 +1282,6 @@ private Map<String, Object> searchPipelineLineage(
deleted);
getLineage(
toEntity.get("fqn"),
visitedFQN,
downstreamDepth,
edges,
nodes,
Expand All @@ -1329,23 +1301,9 @@ private Map<String, Object> searchPipelineLineage(
}
}
getLineage(
fqn,
visitedFQN,
downstreamDepth,
edges,
nodes,
queryFilter,
"lineage.fromEntity.fqn.keyword",
deleted);
fqn, downstreamDepth, edges, nodes, queryFilter, "lineage.fromEntity.fqn.keyword", deleted);
getLineage(
fqn,
visitedFQN,
upstreamDepth,
edges,
nodes,
queryFilter,
"lineage.toEntity.fqn.keyword",
deleted);
fqn, upstreamDepth, edges, nodes, queryFilter, "lineage.toEntity.fqn.keyword", deleted);

// TODO: Fix this , this is hack
if (edges.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,6 @@ public Map<String, Object> searchLineageInternal(
boolean deleted,
String entityType)
throws IOException {
Set<String> visitedFQN = new HashSet<>();
if (entityType.equalsIgnoreCase(Entity.PIPELINE)
|| entityType.equalsIgnoreCase(Entity.STORED_PROCEDURE)) {
return searchPipelineLineage(fqn, upstreamDepth, downstreamDepth, queryFilter, deleted);
Expand All @@ -802,22 +801,14 @@ public Map<String, Object> searchLineageInternal(
}
getLineage(
fqn,
visitedFQN,
downstreamDepth,
edges,
nodes,
queryFilter,
"lineage.fromEntity.fqnHash.keyword",
deleted);
getLineage(
fqn,
visitedFQN,
upstreamDepth,
edges,
nodes,
queryFilter,
"lineage.toEntity.fqnHash.keyword",
deleted);
fqn, upstreamDepth, edges, nodes, queryFilter, "lineage.toEntity.fqnHash.keyword", deleted);
responseMap.put("edges", edges);
responseMap.put("nodes", nodes);
return responseMap;
Expand Down Expand Up @@ -1041,18 +1032,16 @@ public Response searchSchemaEntityRelationship(

private void getLineage(
String fqn,
Set<String> visitedFQN,
int depth,
Set<Map<String, Object>> edges,
Set<Map<String, Object>> nodes,
String queryFilter,
String direction,
boolean deleted)
throws IOException {
if (depth <= 0 || visitedFQN.contains(fqn)) {
if (depth <= 0) {
return;
}
visitedFQN.add(fqn);
os.org.opensearch.action.search.SearchRequest searchRequest =
new os.org.opensearch.action.search.SearchRequest(
Entity.getSearchRepository().getIndexOrAliasName(GLOBAL_SEARCH_ALIAS));
Expand Down Expand Up @@ -1084,27 +1073,13 @@ private void getLineage(
if (!edges.contains(lin) && fromEntity.get("fqn").equals(fqn)) {
edges.add(lin);
getLineage(
toEntity.get("fqn"),
visitedFQN,
depth - 1,
edges,
nodes,
queryFilter,
direction,
deleted);
toEntity.get("fqn"), depth - 1, edges, nodes, queryFilter, direction, deleted);
}
} else {
if (!edges.contains(lin) && toEntity.get("fqn").equals(fqn)) {
edges.add(lin);
getLineage(
fromEntity.get("fqn"),
visitedFQN,
depth - 1,
edges,
nodes,
queryFilter,
direction,
deleted);
fromEntity.get("fqn"), depth - 1, edges, nodes, queryFilter, direction, deleted);
}
}
}
Expand Down Expand Up @@ -1251,7 +1226,6 @@ private SearchResponse performLineageSearch(String fqn, String queryFilter, bool
private Map<String, Object> searchPipelineLineage(
String fqn, int upstreamDepth, int downstreamDepth, String queryFilter, boolean deleted)
throws IOException {
Set<String> visitedFQN = new HashSet<>();
Map<String, Object> responseMap = new HashMap<>();
Set<Map<String, Object>> edges = new HashSet<>();
Set<Map<String, Object>> nodes = new HashSet<>();
Expand Down Expand Up @@ -1298,7 +1272,6 @@ private Map<String, Object> searchPipelineLineage(
edges.add(lin);
getLineage(
fromEntity.get("fqn"),
visitedFQN,
upstreamDepth,
edges,
nodes,
Expand All @@ -1307,7 +1280,6 @@ private Map<String, Object> searchPipelineLineage(
deleted);
getLineage(
toEntity.get("fqn"),
visitedFQN,
downstreamDepth,
edges,
nodes,
Expand All @@ -1327,23 +1299,9 @@ private Map<String, Object> searchPipelineLineage(
}
}
getLineage(
fqn,
visitedFQN,
downstreamDepth,
edges,
nodes,
queryFilter,
"lineage.fromEntity.fqn.keyword",
deleted);
fqn, downstreamDepth, edges, nodes, queryFilter, "lineage.fromEntity.fqn.keyword", deleted);
getLineage(
fqn,
visitedFQN,
upstreamDepth,
edges,
nodes,
queryFilter,
"lineage.toEntity.fqn.keyword",
deleted);
fqn, upstreamDepth, edges, nodes, queryFilter, "lineage.toEntity.fqn.keyword", deleted);

if (edges.isEmpty()) {
os.org.opensearch.action.search.SearchRequest searchRequestForEntity =
Expand Down

0 comments on commit a31f01a

Please sign in to comment.