jerqi commented on code in PR #7734:
URL: https://github.com/apache/gravitino/pull/7734#discussion_r2275577917


##########
core/src/main/java/org/apache/gravitino/storage/relational/JDBCBackend.java:
##########
@@ -569,6 +593,103 @@ public <E extends Entity & HasIdentifier> List<E> 
updateEntityRelations(
     }
   }
 
+  @Override
+  public int deleteEntitiesAndRelations(
+      Type relType, Relation.VertexType deleteVertexType, List<Relation> 
relations)
+      throws IOException {
+    switch (relType) {
+      case METADATA_OBJECT_STAT_REL:
+        Preconditions.checkArgument(
+            deleteVertexType == Relation.VertexType.DESTINATION,
+            "Only supports to delete relations of destination vertex");
+
+        AtomicInteger deleteCount = new AtomicInteger(0);
+        Map<Pair<NameIdentifier, Entity.EntityType>, List<Relation>> 
groupedRelations =
+            
relations.stream().collect(Collectors.groupingBy(Relation::getSourceVertex));
+
+        if (groupedRelations.isEmpty()) {
+          return 0; // No relations to delete.
+        }
+
+        Preconditions.checkArgument(
+            groupedRelations.size() == 1,
+            "The relations must have the same source identifier and type, but 
got %s groups",
+            groupedRelations.size());
+
+        groupedRelations.forEach(

Review Comment:
   OK, I modified this place.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to