Skip to content

Commit

Permalink
Merge pull request #4029 from atlanhq/mlh-62-optimize-delete
Browse files Browse the repository at this point in the history
MLH-62: Optimize delete by fetching only active edges
  • Loading branch information
sumandas0 authored Jan 24, 2025
2 parents 190151a + fe1722e commit 3a631cb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1673,12 +1673,29 @@ public static List<AtlasEdge> getCollectionElementsUsingRelationship(AtlasVertex
return getCollectionElementsUsingRelationship(vertex, attribute, edgeLabel);
}

public static List<AtlasEdge> getActiveCollectionElementsUsingRelationship(AtlasVertex vertex, AtlasAttribute attribute) throws AtlasBaseException {
String edgeLabel = attribute.getRelationshipEdgeLabel();
return getActiveCollectionElementsUsingRelationship(vertex, attribute, edgeLabel);
}

public static List<AtlasEdge> getCollectionElementsUsingRelationship(AtlasVertex vertex, AtlasAttribute attribute,
boolean isStructType) {
String edgeLabel = isStructType ? AtlasGraphUtilsV2.getEdgeLabel(attribute.getName()) : attribute.getRelationshipEdgeLabel();
return getCollectionElementsUsingRelationship(vertex, attribute, edgeLabel);
}

public static List<AtlasEdge> getActiveCollectionElementsUsingRelationship(AtlasVertex vertex, AtlasAttribute attribute, String edgeLabel) throws AtlasBaseException {
List<AtlasEdge> ret;
AtlasRelationshipEdgeDirection edgeDirection = attribute.getRelationshipEdgeDirection();
Iterator<AtlasEdge> edgesForLabel = getActiveEdges(vertex, edgeLabel, AtlasEdgeDirection.valueOf(edgeDirection.name()));

ret = IteratorUtils.toList(edgesForLabel);

sortCollectionElements(attribute, ret);

return ret;
}


public static List<AtlasEdge> getCollectionElementsUsingRelationship(AtlasVertex vertex, AtlasAttribute attribute, String edgeLabel) {
List<AtlasEdge> ret;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ protected void deleteTypeVertex(AtlasVertex instanceVertex, boolean force) throw
AtlasType elemType = arrType.getElementType();

if (isReference(elemType.getTypeCategory())) {
List<AtlasEdge> edges = getCollectionElementsUsingRelationship(instanceVertex, attributeInfo);
List<AtlasEdge> edges = getActiveCollectionElementsUsingRelationship(instanceVertex, attributeInfo);

if (CollectionUtils.isNotEmpty(edges)) {
for (AtlasEdge edge : edges) {
Expand Down

0 comments on commit 3a631cb

Please sign in to comment.