ATLAS-4803: Optimize Relationship Edge fetch

Signed-off-by: Pinal Shah <pinal.shah@freestoneinfotech.com>
This commit is contained in:
pareshD 2023-11-01 12:49:37 +05:30 committed by Pinal Shah
parent 8bc7a29055
commit 12b81d79e7
2 changed files with 11 additions and 9 deletions

View File

@ -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;
}
}

View File

@ -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;