This is an automated email from the ASF dual-hosted git repository.

pinal pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 144ca0a51 ATLAS-4803: Optimize Relationship Edge fetch
144ca0a51 is described below

commit 144ca0a51f7b01e50e026f8d28302016c2c5c8ad
Author: pareshD <paresh.deva...@cloudera.com>
AuthorDate: Wed Nov 1 12:49:37 2023 +0530

    ATLAS-4803: Optimize Relationship Edge fetch
    
    Signed-off-by: Pinal Shah <pinal.s...@freestoneinfotech.com>
---
 .../atlas/repository/graphdb/janus/AtlasJanusGraph.java  | 16 ++++++++++------
 .../store/graph/v2/AtlasRelationshipStoreV2.java         |  4 +---
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git 
a/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraph.java
 
b/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraph.java
index 0dd573b89..004cab9c8 100644
--- 
a/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraph.java
+++ 
b/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraph.java
@@ -575,15 +575,19 @@ public class AtlasJanusGraph implements 
AtlasGraph<AtlasJanusVertex, AtlasJanusE
         }
     }
     private Edge getFirstActiveEdge(GraphTraversal gt) {
-        while (gt.hasNext()) {
-            Edge gremlinEdge = (Edge) gt.next();
-            if (gremlinEdge != null && 
gremlinEdge.property(STATE_PROPERTY_KEY).isPresent() &&
-                    
gremlinEdge.property(STATE_PROPERTY_KEY).value().equals(AtlasEntity.Status.ACTIVE.toString())
-            ) {
-                return gremlinEdge;
+
+        if(gt != null) {
+            while (gt.hasNext()) {
+                Edge gremlinEdge = (Edge) gt.next();
+                if (gremlinEdge != null && 
gremlinEdge.property(STATE_PROPERTY_KEY).isPresent() &&
+                        
gremlinEdge.property(STATE_PROPERTY_KEY).value().equals(AtlasEntity.Status.ACTIVE.toString())
+                ) {
+                    return gremlinEdge;
+                }
             }
         }
 
+
         return null;
     }
 }
diff --git 
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2.java
 
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2.java
index ef0313e02..6af80a1c7 100644
--- 
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2.java
+++ 
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2.java
@@ -648,9 +648,7 @@ public class AtlasRelationshipStoreV2 implements 
AtlasRelationshipStore {
 
         AtlasEdge ret = null;
 
-        if (toVertex.hasEdges(AtlasEdgeDirection.IN, relationshipLabel) && 
fromVertex.hasEdges(AtlasEdgeDirection.OUT, relationshipLabel)) {
-            ret = graph.getEdgeBetweenVertices(fromVertex, toVertex, 
relationshipLabel);
-        }
+        ret = graph.getEdgeBetweenVertices(fromVertex, toVertex, 
relationshipLabel);
 
         RequestContext.get().endMetricRecord(metric);
         return ret;

Reply via email to