From ce27ec3d44fbbf836ee0048efb273a25c21ca0a1 Mon Sep 17 00:00:00 2001 From: PRATHAM2002-DS Date: Tue, 10 Sep 2024 23:57:05 +0530 Subject: [PATCH] mesh-184: optimised linked assets check code --- .../datamesh/AbstractDomainPreProcessor.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/AbstractDomainPreProcessor.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/AbstractDomainPreProcessor.java index 3955955ca4..2d6628488f 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/AbstractDomainPreProcessor.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/AbstractDomainPreProcessor.java @@ -289,7 +289,6 @@ protected List getPolicies(Set resources) throws Atla protected Boolean hasLinkedAssets(String domainGuid) throws AtlasBaseException { AtlasPerfMetrics.MetricRecorder metricRecorder = RequestContext.get().startMetricRecord("isAssetLinked"); - boolean exists = false; try { List> mustClauseList = new ArrayList<>(); mustClauseList.add(mapOf("term", mapOf(DOMAIN_GUIDS, domainGuid))); @@ -299,19 +298,14 @@ protected Boolean hasLinkedAssets(String domainGuid) throws AtlasBaseException { Map dsl = mapOf("query", mapOf("bool", bool)); - boolean hasLinkedAsset = fetchLinkedAssets(dsl, DOMAIN_GUID_ATTR, this.discovery); - if (hasLinkedAsset) { - exists = true; - } - - return exists; + return hasLinkedAssets(dsl, DOMAIN_GUID_ATTR, this.discovery); } finally { RequestContext.get().endMetricRecord(metricRecorder); } } - protected static Boolean fetchLinkedAssets(Map dsl, Set attributes, EntityDiscoveryService discovery) throws AtlasBaseException { + protected static Boolean hasLinkedAssets(Map dsl, Set attributes, EntityDiscoveryService discovery) throws AtlasBaseException { IndexSearchParams searchParams = new IndexSearchParams(); boolean exists = false;