atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject incubator-atlas git commit: ATLAS-1656: Lineage query performance improvement
Date Wed, 08 Mar 2017 01:48:25 GMT
Repository: incubator-atlas
Updated Branches:
  refs/heads/0.8-incubating 050f03529 -> 163beb0c2


ATLAS-1656: Lineage query performance improvement

Signed-off-by: Madhan Neethiraj <madhan@apache.org>
(cherry picked from commit 0ed5e0aa5a0afb1cef8031e274645a8398d2a7f0)


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/163beb0c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/163beb0c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/163beb0c

Branch: refs/heads/0.8-incubating
Commit: 163beb0c288d5ba86211e1ae69f5d6d97e0ffc45
Parents: 050f035
Author: Sarath Subramanian <ssubramanian@hortonworks.com>
Authored: Tue Mar 7 16:52:04 2017 -0800
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Tue Mar 7 17:48:13 2017 -0800

----------------------------------------------------------------------
 .../apache/atlas/discovery/EntityLineageService.java  | 14 ++++++++------
 .../apache/atlas/repository/graph/GraphHelper.java    | 14 ++++++++++++++
 2 files changed, 22 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/163beb0c/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java
----------------------------------------------------------------------
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 3035d16..b81754d 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java
@@ -28,9 +28,9 @@ import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageRelation;
 import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection;
 import org.apache.atlas.repository.Constants;
 import org.apache.atlas.repository.graph.AtlasGraphProvider;
+import org.apache.atlas.repository.graph.GraphHelper;
 import org.apache.atlas.repository.graphdb.AtlasGraph;
 import org.apache.atlas.repository.graphdb.AtlasVertex;
-import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1;
 import org.apache.atlas.repository.store.graph.v1.EntityGraphRetriever;
 import org.apache.atlas.type.AtlasTypeRegistry;
 import org.apache.atlas.util.AtlasGremlinQueryProvider;
@@ -172,14 +172,16 @@ public class EntityLineageService implements AtlasLineageService {
     }
 
     private boolean entityExists(String guid) {
-        boolean ret = false;
+        boolean               ret     = false;
         Iterator<AtlasVertex> results = graph.query()
-                .has(Constants.GUID_PROPERTY_KEY, guid)
-                .has(Constants.SUPER_TYPES_PROPERTY_KEY, AtlasClient.DATA_SET_SUPER_TYPE)
-                .vertices().iterator();
+                                        .has(Constants.GUID_PROPERTY_KEY, guid)
+                                        .vertices().iterator();
 
         while (results.hasNext()) {
-            return true;
+            AtlasVertex  entityVertex = results.next();
+            List<String> superTypes   = GraphHelper.getSuperTypeNames(entityVertex);
+
+            ret = (CollectionUtils.isNotEmpty(superTypes)) ? superTypes.contains(AtlasClient.DATA_SET_SUPER_TYPE)
: false;
         }
 
         return ret;

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/163beb0c/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
index d7bffff..ca7fad0 100755
--- a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
+++ b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
@@ -57,6 +57,7 @@ import org.apache.atlas.typesystem.types.utils.TypesUtil;
 import org.apache.atlas.util.AttributeValueMap;
 import org.apache.atlas.util.IndexedInstance;
 import org.apache.atlas.utils.ParamChecker;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
 import org.codehaus.jettison.json.JSONArray;
 import org.slf4j.Logger;
@@ -613,6 +614,19 @@ public final class GraphHelper {
         return traits;
     }
 
+    public static List<String> getSuperTypeNames(AtlasVertex<?,?> entityVertex)
{
+        ArrayList<String>  superTypes     = new ArrayList<>();
+        Collection<String> propertyValues = entityVertex.getPropertyValues(Constants.SUPER_TYPES_PROPERTY_KEY,
String.class);
+
+        if (CollectionUtils.isNotEmpty(propertyValues)) {
+            for(String value : propertyValues) {
+                superTypes.add(value);
+            }
+        }
+
+        return superTypes;
+    }
+
     public static String getEdgeLabel(ITypedInstance typedInstance, AttributeInfo aInfo)
throws AtlasException {
         IDataType dataType = typeSystem.getDataType(IDataType.class, typedInstance.getTypeName());
         return getEdgeLabel(dataType, aInfo);


Mime
View raw message