Commit 36956bc0 by Nikhil Bonte Committed by Madhan Neethiraj

ATLAS-3701: performance improvements in classification-dissociation

parent 6b783702
...@@ -2014,6 +2014,12 @@ public class EntityGraphMapper { ...@@ -2014,6 +2014,12 @@ public class EntityGraphMapper {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, entityGuid); throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, entityGuid);
} }
AtlasPerfTracer perf = null;
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityGraphMapper.deleteClassification");
}
List<String> traitNames = getTraitNames(entityVertex); List<String> traitNames = getTraitNames(entityVertex);
if (CollectionUtils.isEmpty(traitNames)) { if (CollectionUtils.isEmpty(traitNames)) {
...@@ -2022,8 +2028,6 @@ public class EntityGraphMapper { ...@@ -2022,8 +2028,6 @@ public class EntityGraphMapper {
validateClassificationExists(traitNames, classificationName); validateClassificationExists(traitNames, classificationName);
Map<AtlasVertex, List<AtlasClassification>> removedClassifications = new HashMap<>();
AtlasVertex classificationVertex = getClassificationVertex(entityVertex, classificationName); AtlasVertex classificationVertex = getClassificationVertex(entityVertex, classificationName);
AtlasClassification classification = entityRetriever.toAtlasClassification(classificationVertex); AtlasClassification classification = entityRetriever.toAtlasClassification(classificationVertex);
...@@ -2032,36 +2036,23 @@ public class EntityGraphMapper { ...@@ -2032,36 +2036,23 @@ public class EntityGraphMapper {
} }
// remove classification from propagated entities if propagation is turned on // remove classification from propagated entities if propagation is turned on
if (isPropagationEnabled(classificationVertex)) { final List<AtlasVertex> entityVertices;
List<AtlasVertex> propagatedEntityVertices = deleteDelegate.getHandler().removeTagPropagation(classificationVertex);
// add propagated entities and deleted classification details to removeClassifications map
if (CollectionUtils.isNotEmpty(propagatedEntityVertices)) {
for (AtlasVertex propagatedEntityVertex : propagatedEntityVertices) {
List<AtlasClassification> classifications = removedClassifications.get(propagatedEntityVertex);
if (classifications == null) {
classifications = new ArrayList<>();
removedClassifications.put(propagatedEntityVertex, classifications); if (isPropagationEnabled(classificationVertex)) {
} entityVertices = deleteDelegate.getHandler().removeTagPropagation(classificationVertex);
classifications.add(classification); if (LOG.isDebugEnabled()) {
} LOG.debug("Number of propagations to delete -> {}", entityVertices.size());
} }
} else {
entityVertices = new ArrayList<>();
} }
// add associated entity and deleted classification details to removeClassifications map // add associated entity to entityVertices list
List<AtlasClassification> classifications = removedClassifications.get(entityVertex); if (!entityVertices.contains(entityVertex)) {
entityVertices.add(entityVertex);
if (classifications == null) {
classifications = new ArrayList<>();
removedClassifications.put(entityVertex, classifications);
} }
classifications.add(classification);
// remove classifications from associated entity // remove classifications from associated entity
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("Removing classification: [{}] from: [{}][{}] with edge label: [{}]", classificationName, LOG.debug("Removing classification: [{}] from: [{}][{}] with edge label: [{}]", classificationName,
...@@ -2078,12 +2069,13 @@ public class EntityGraphMapper { ...@@ -2078,12 +2069,13 @@ public class EntityGraphMapper {
updateModificationMetadata(entityVertex); updateModificationMetadata(entityVertex);
for (Map.Entry<AtlasVertex, List<AtlasClassification>> entry : removedClassifications.entrySet()) { if (CollectionUtils.isNotEmpty(entityVertices)) {
AtlasEntity entity = updateClassificationText(entry.getKey()); List<AtlasEntity> propagatedEntities = updateClassificationText(classification, entityVertices);
List<AtlasClassification> deletedClassificationNames = entry.getValue(); //Sending audit request for all entities at once
entityChangeNotifier.onClassificationDeletedFromEntity(entity, deletedClassificationNames); entityChangeNotifier.onClassificationsDeletedFromEntities(propagatedEntities, Collections.singletonList(classification));
} }
AtlasPerfTracer.log(perf);
} }
private AtlasEntity updateClassificationText(AtlasVertex vertex) throws AtlasBaseException { private AtlasEntity updateClassificationText(AtlasVertex vertex) throws AtlasBaseException {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment