From 8f7e8433a26b65703dbf9e682c07605056b28c9f Mon Sep 17 00:00:00 2001 From: akshaysw Date: Thu, 1 Aug 2024 18:28:18 +0530 Subject: [PATCH 1/2] [add] add relationship attr search in lineage list API --- .../atlas/model/lineage/LineageListRequest.java | 13 ++++++++++++- .../atlas/discovery/AtlasLineageListContext.java | 10 ++++++++++ .../atlas/discovery/EntityLineageService.java | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/intg/src/main/java/org/apache/atlas/model/lineage/LineageListRequest.java b/intg/src/main/java/org/apache/atlas/model/lineage/LineageListRequest.java index 66ff5f71d7..0eb31fd032 100644 --- a/intg/src/main/java/org/apache/atlas/model/lineage/LineageListRequest.java +++ b/intg/src/main/java/org/apache/atlas/model/lineage/LineageListRequest.java @@ -22,6 +22,7 @@ public class LineageListRequest { private SearchParameters.FilterCriteria entityTraversalFilters; private SearchParameters.FilterCriteria relationshipTraversalFilters; private Set attributes; + private Set relationAttributes; private Boolean excludeMeanings; private Boolean excludeClassifications; @@ -29,11 +30,12 @@ public enum LineageDirection {INPUT, OUTPUT} public LineageListRequest() { this.attributes = new HashSet<>(); + this.relationAttributes = new HashSet<>(); } public LineageListRequest(String guid, Integer size, Integer from, Integer depth, LineageDirection direction, SearchParameters.FilterCriteria entityFilters, SearchParameters.FilterCriteria entityTraversalFilters, SearchParameters.FilterCriteria relationshipTraversalFilters, - Set attributes, boolean excludeMeanings, boolean excludeClassifications) { + Set attributes, boolean excludeMeanings, boolean excludeClassifications, Set relationAttributes) { //Set relationAttributes) this.guid = guid; this.size = size; this.from = from; @@ -45,6 +47,7 @@ public LineageListRequest(String guid, Integer size, Integer from, Integer depth this.attributes = attributes; this.excludeMeanings = excludeMeanings; this.excludeClassifications = excludeClassifications; + this.relationAttributes = relationAttributes; } public String getGuid() { @@ -119,6 +122,14 @@ public void setAttributes(Set attributes) { this.attributes = attributes; } + public Set getRelationAttributes() { + return relationAttributes; + } + + public void setRelationAttributes(Set relationAttributes) { + this.relationAttributes = relationAttributes; + } + public Boolean isExcludeMeanings() { return excludeMeanings; } diff --git a/repository/src/main/java/org/apache/atlas/discovery/AtlasLineageListContext.java b/repository/src/main/java/org/apache/atlas/discovery/AtlasLineageListContext.java index b0ac3bd3cc..95657aaabe 100644 --- a/repository/src/main/java/org/apache/atlas/discovery/AtlasLineageListContext.java +++ b/repository/src/main/java/org/apache/atlas/discovery/AtlasLineageListContext.java @@ -18,6 +18,7 @@ public final class AtlasLineageListContext { private Predicate vertexTraversalPredicate; private Predicate edgeTraversalPredicate; private Set attributes; + private Set relationAttributes; private int currentFromCounter; private int currentEntityCounter; private boolean depthLimitReached; @@ -33,6 +34,7 @@ public AtlasLineageListContext(LineageListRequest lineageListRequest, AtlasTypeR this.vertexTraversalPredicate = constructInMemoryPredicate(typeRegistry, lineageListRequest.getEntityTraversalFilters()); this.edgeTraversalPredicate = constructInMemoryPredicate(typeRegistry, lineageListRequest.getRelationshipTraversalFilters()); this.attributes = lineageListRequest.getAttributes(); + this.relationAttributes = lineageListRequest.getRelationAttributes(); } public String getGuid() { @@ -111,6 +113,14 @@ public void setAttributes(Set attributes) { this.attributes = attributes; } + public Set getRelationAttributes() { + return relationAttributes; + } + + public void setRelationAttributes(Set relationAttributes) { + this.relationAttributes = relationAttributes; + } + public int getCurrentFromCounter() { return currentFromCounter; } diff --git a/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java b/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java index 9c4b07764c..7e83794113 100644 --- a/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java +++ b/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java @@ -193,6 +193,8 @@ public AtlasLineageListInfo getLineageListInfoOnDemand(String guid, LineageListR AtlasPerfMetrics.MetricRecorder metricRecorder = RequestContext.get().startMetricRecord("getLineageListInfoOnDemand"); AtlasLineageListInfo ret = new AtlasLineageListInfo(new ArrayList<>()); + RequestContext.get().setRelationAttrsForSearch(lineageListRequest.getRelationAttributes()); + traverseEdgesUsingBFS(guid, new AtlasLineageListContext(lineageListRequest, atlasTypeRegistry), ret); ret.setSearchParameters(lineageListRequest); From fcafe07898783b9ff03bb712b32eb98715e1800e Mon Sep 17 00:00:00 2001 From: akshaysw Date: Thu, 1 Aug 2024 18:34:44 +0530 Subject: [PATCH 2/2] [remove] extra comment --- .../java/org/apache/atlas/model/lineage/LineageListRequest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intg/src/main/java/org/apache/atlas/model/lineage/LineageListRequest.java b/intg/src/main/java/org/apache/atlas/model/lineage/LineageListRequest.java index 0eb31fd032..e717fda066 100644 --- a/intg/src/main/java/org/apache/atlas/model/lineage/LineageListRequest.java +++ b/intg/src/main/java/org/apache/atlas/model/lineage/LineageListRequest.java @@ -35,7 +35,7 @@ public LineageListRequest() { public LineageListRequest(String guid, Integer size, Integer from, Integer depth, LineageDirection direction, SearchParameters.FilterCriteria entityFilters, SearchParameters.FilterCriteria entityTraversalFilters, SearchParameters.FilterCriteria relationshipTraversalFilters, - Set attributes, boolean excludeMeanings, boolean excludeClassifications, Set relationAttributes) { //Set relationAttributes) + Set attributes, boolean excludeMeanings, boolean excludeClassifications, Set relationAttributes) { this.guid = guid; this.size = size; this.from = from;