Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DG-1791 | Retrieve only the active edges #3609

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -2006,6 +2006,31 @@ public static Iterator<AtlasVertex> getActiveVertices(AtlasVertex vertex, AtlasE
}
}

/**
* Get all the active edges
* @param vertex entity vertex
* @param childrenEdgeLabel Edge label of children
* @return Iterator of children edges
*/
public static Iterator<AtlasEdge> getActiveEdges(AtlasVertex vertex, String childrenEdgeLabel, AtlasEdgeDirection direction) throws AtlasBaseException {
AtlasPerfMetrics.MetricRecorder metricRecorder = RequestContext.get().startMetricRecord("GraphHelper.getActiveEdges");

try {
return vertex.query()
.direction(direction)
.label(childrenEdgeLabel)
.has(STATE_PROPERTY_KEY, ACTIVE_STATE_VALUE)
.edges()
.iterator();
} catch (Exception e) {
LOG.error("Error while getting active edges of vertex for edge label " + childrenEdgeLabel, e);
throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, e);
}
finally {
RequestContext.get().endMetricRecord(metricRecorder);
}
}

public static Iterator<AtlasVertex> getAllChildrenVertices(AtlasVertex vertex, String childrenEdgeLabel) throws AtlasBaseException {
return getAllVertices(vertex, childrenEdgeLabel, AtlasEdgeDirection.OUT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,7 @@ private boolean skipClassificationTaskCreation(String classificationId) throws A
}


public void removeHasLineageOnDelete(Collection<AtlasVertex> vertices) {
public void removeHasLineageOnDelete(Collection<AtlasVertex> vertices) throws AtlasBaseException {
AtlasPerfMetrics.MetricRecorder metricRecorder = RequestContext.get().startMetricRecord("removeHasLineageOnDelete");

for (AtlasVertex vertexToBeDeleted : vertices) {
Expand Down Expand Up @@ -1495,7 +1495,7 @@ public void removeHasLineageOnDelete(Collection<AtlasVertex> vertices) {
}


public void resetHasLineageOnInputOutputDelete(Collection<AtlasEdge> removedEdges, AtlasVertex deletedVertex) {
public void resetHasLineageOnInputOutputDelete(Collection<AtlasEdge> removedEdges, AtlasVertex deletedVertex) throws AtlasBaseException {
AtlasPerfMetrics.MetricRecorder metricRecorder = RequestContext.get().startMetricRecord("resetHasLineageOnInputOutputDelete");

for (AtlasEdge atlasEdge : removedEdges) {
Expand All @@ -1513,13 +1513,15 @@ public void resetHasLineageOnInputOutputDelete(Collection<AtlasEdge> removedEdge
if (getStatus(processVertex) == ACTIVE && !processVertex.equals(deletedVertex)) {
String edgeLabel = isOutputEdge ? PROCESS_OUTPUTS : PROCESS_INPUTS;

Iterator<AtlasEdge> edgeIterator = processVertex.getEdges(AtlasEdgeDirection.BOTH, edgeLabel).iterator();
// Iterator<AtlasEdge> edgeIterator = processVertex.getEdges(AtlasEdgeDirection.BOTH, edgeLabel).iterator();
Iterator<AtlasEdge> edgeIterator = GraphHelper.getActiveEdges(processVertex, edgeLabel, AtlasEdgeDirection.BOTH);

boolean activeEdgeFound = false;

while (edgeIterator.hasNext()) {
AtlasPerfMetrics.MetricRecorder edgeIteratorMetricRecorder1 = RequestContext.get().startMetricRecord("resetHasLineageOnInputOutputDelete_edgeIterator1");
AtlasEdge edge = edgeIterator.next();
if (getStatus(edge) == ACTIVE && !removedEdges.contains(edge)) {
if (!removedEdges.contains(edge)) {
AtlasVertex relatedAssetVertex = edge.getInVertex();

if (getStatus(relatedAssetVertex) == ACTIVE) {
Expand All @@ -1535,7 +1537,8 @@ public void resetHasLineageOnInputOutputDelete(Collection<AtlasEdge> removedEdge

String oppositeEdgeLabel = isOutputEdge ? PROCESS_INPUTS : PROCESS_OUTPUTS;

Iterator<AtlasEdge> processEdgeIterator = processVertex.getEdges(AtlasEdgeDirection.BOTH, oppositeEdgeLabel).iterator();
// Iterator<AtlasEdge> processEdgeIterator = processVertex.getEdges(AtlasEdgeDirection.BOTH, oppositeEdgeLabel).iterator();
Iterator<AtlasEdge> processEdgeIterator = GraphHelper.getActiveEdges(processVertex, oppositeEdgeLabel, AtlasEdgeDirection.BOTH);

while (processEdgeIterator.hasNext()) {
AtlasPerfMetrics.MetricRecorder edgeIteratorMetricRecorder2 = RequestContext.get().startMetricRecord("resetHasLineageOnInputOutputDelete_edgeIterator2");
Expand Down
Loading