This is an automated email from the ASF dual-hosted git repository. pinal pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/master by this push: new 12b81d79e ATLAS-4803: Optimize Relationship Edge fetch 12b81d79e is described below commit 12b81d79e7284c890a50a6043e6890a1acc9fba8 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;