Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.getState;
import static org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.__.id;
import static org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.__.outV;
import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.hasId;
import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.not;

public abstract class DeleteHandlerV1 {
public static final Logger LOG = LoggerFactory.getLogger(DeleteHandlerV1.class);
Expand Down Expand Up @@ -1895,9 +1897,10 @@ private void updateAssetHasLineageStatusV2(AtlasVertex assetVertex, AtlasEdge cu

/**
* Helper method to check for active lineage in a specific direction
*
* @param assetVertex The vertex to check
* @param currentEdge The current edge to exclude
* @param direction The edge direction to explore
* @param direction The edge direction to explore
* @return True if active lineage exists in the specified direction
*/
private boolean hasActiveLineageDirection(AtlasVertex assetVertex, AtlasEdge currentEdge, Direction direction) {
Expand All @@ -1915,24 +1918,19 @@ private boolean hasActiveLineageDirection(AtlasVertex assetVertex, AtlasEdge cur
.has(STATE_PROPERTY_KEY, ACTIVE_STATE_VALUE);
}

// Complete the traversal with common operations

// Filter out current edge using Gremlin
traversal = traversal.where(not(hasId(currentEdge.getIdForDisplay())));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont see this change behind FF @aarshi0301


for (String deletedEdgeId : RequestContext.get().getDeletedEdgesIdsForResetHasLineage()) {
traversal = traversal.where(not(hasId(deletedEdgeId)));
}
Copy link

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop modifies the traversal object repeatedly, which could create performance issues if there are many deleted edge IDs. Consider building a single filter condition or using a more efficient batch filtering approach to avoid multiple traversal modifications.

Suggested change
// Filter out current edge using Gremlin
traversal = traversal.where(not(hasId(currentEdge.getIdForDisplay())));
for (String deletedEdgeId : RequestContext.get().getDeletedEdgesIdsForResetHasLineage()) {
traversal = traversal.where(not(hasId(deletedEdgeId)));
}
// Filter out current edge and all deleted edges using a single Gremlin filter
Set<String> excludedEdgeIds = new HashSet<>();
excludedEdgeIds.add(currentEdge.getIdForDisplay());
excludedEdgeIds.addAll(RequestContext.get().getDeletedEdgesIdsForResetHasLineage());
traversal = traversal.where(not(hasId(excludedEdgeIds.toArray(new String[0]))));

Copilot uses AI. Check for mistakes.


return traversal
.project("id", HAS_LINEAGE)
.by(id())
.by(outV().values(HAS_LINEAGE))
.toStream()
.anyMatch(edge -> {
Object edgeId = edge.get("id");
String edgeIdStr = (edgeId != null) ? edgeId.toString() : "";

// Skip if in deleted list or matches current edge
if (RequestContext.get().getDeletedEdgesIdsForResetHasLineage().contains(edgeIdStr) ||
currentEdge.getIdForDisplay().equals(edgeIdStr)) {
return false;
}
.outV() // Get the connected vertex
.has(HAS_LINEAGE, true) // Filter vertices with lineage=true
.hasNext(); // Just check existence, don't materialize using stream()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Incorrect Lineage Calculation and Edge Traversal

The hasActiveLineageDirection method may calculate lineage incorrectly. It passes string representations of edge IDs to hasId(), which expects actual ID objects, causing filtering to fail. Additionally, the traversal uses .outV() universally, which is incorrect for outgoing edges as it returns the source vertex instead of the connected target.

Fix in Cursor Fix in Web


// Check if this edge has lineage
return Boolean.TRUE.equals(edge.get(HAS_LINEAGE));
});
}
}
Loading