mneethiraj commented on code in PR #312: URL: https://github.com/apache/atlas/pull/312#discussion_r2014520431
########## repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java: ########## @@ -283,13 +287,66 @@ private void processEntityGuid(String guid, ExportContext context) throws AtlasB return; } - AtlasEntityWithExtInfo entityWithExtInfo = entityGraphRetriever.toAtlasEntityWithExtInfo(guid); + if (context.fetchType != ExportFetchType.INCREMENTAL) { + AtlasEntityWithExtInfo entityWithExtInfo = entityGraphRetriever.toAtlasEntityWithExtInfo(guid); - processEntity(entityWithExtInfo, context); + processEntity(entityWithExtInfo, context); + } else { + AtlasVertex vertex = AtlasGraphUtilsV2.findByGuid(guid); + + processVertex(context, vertex, guid); + } LOG.debug("<== processEntityGuid({})", guid); } + public void processVertex(ExportContext context, AtlasVertex vertex, String guid) throws AtlasBaseException { + if (MapUtils.isNotEmpty(context.termsGlossary)) { + addGlossaryEntities(context); + } + + addVertex(vertex, guid, context); + + context.guidsProcessed.add(guid); + + extractRelatedVertices(vertex, context); + } + + public void extractRelatedVertices(AtlasVertex vertex, ExportContext context) { + List<AtlasVertex> relationshipEntities = entityGraphRetriever.findAllRelationshipVertices(vertex); Review Comment: `findAllRelationshipVertices()` => `findAllConnectedVertices()` ########## repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java: ########## @@ -470,6 +527,15 @@ public boolean doesTimestampQualify(AtlasEntity entity) { return changeMarker <= entity.getUpdateTime().getTime(); } + public boolean doesTimestampQualify(AtlasVertex vertex) { + if (fetchType != ExportFetchType.INCREMENTAL) { + return true; + } + + Long updatedTime = AtlasGraphUtilsV2.getEncodedProperty(vertex, MODIFICATION_TIMESTAMP_PROPERTY_KEY, Long.class); Review Comment: Is it not necessary to handle null? ``` return updateTime != null && changeMarker <= updatedTime; ``` ########## repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java: ########## @@ -283,13 +287,66 @@ private void processEntityGuid(String guid, ExportContext context) throws AtlasB return; } - AtlasEntityWithExtInfo entityWithExtInfo = entityGraphRetriever.toAtlasEntityWithExtInfo(guid); + if (context.fetchType != ExportFetchType.INCREMENTAL) { + AtlasEntityWithExtInfo entityWithExtInfo = entityGraphRetriever.toAtlasEntityWithExtInfo(guid); - processEntity(entityWithExtInfo, context); + processEntity(entityWithExtInfo, context); + } else { + AtlasVertex vertex = AtlasGraphUtilsV2.findByGuid(guid); + + processVertex(context, vertex, guid); + } LOG.debug("<== processEntityGuid({})", guid); } + public void processVertex(ExportContext context, AtlasVertex vertex, String guid) throws AtlasBaseException { + if (MapUtils.isNotEmpty(context.termsGlossary)) { + addGlossaryEntities(context); + } + + addVertex(vertex, guid, context); + + context.guidsProcessed.add(guid); + + extractRelatedVertices(vertex, context); + } + + public void extractRelatedVertices(AtlasVertex vertex, ExportContext context) { + List<AtlasVertex> relationshipEntities = entityGraphRetriever.findAllRelationshipVertices(vertex); + if (CollectionUtils.isNotEmpty(relationshipEntities)) { + for (AtlasVertex e : relationshipEntities) { + String relGuid = AtlasGraphUtilsV2.getEncodedProperty(e, GUID_PROPERTY_KEY, String.class); Review Comment: Verify that the vertex represents an entity before processing it further. ``` String typeName = GraphHelper.getTypeName(e); if (typeRegistry.getEntityTypeByName(typeName) != null) { String guid = AtlasGraphUtilsV2.getEncodedProperty(e, GUID_PROPERTY_KEY, String.class); if (!context.guidsProcessed.contains(guid)) { context.guidsToProcess.add(guid); } } ``` ########## repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java: ########## @@ -482,6 +482,10 @@ public AtlasEntitiesWithExtInfo toAtlasEntitiesWithExtInfo(List<String> guids, b return ret; } + public List<AtlasVertex> findAllRelationshipVertices(AtlasVertex vertex) { Review Comment: `findAllRelationshipVertices()` => `findAllConnectedVertices()` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@atlas.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org