yuqi1129 commented on code in PR #7796:
URL: https://github.com/apache/gravitino/pull/7796#discussion_r2251405812


##########
core/src/main/java/org/apache/gravitino/meta/DummyEntity.java:
##########
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.meta;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.apache.gravitino.Entity;
+import org.apache.gravitino.Field;
+import org.apache.gravitino.HasIdentifier;
+
+/** A dummy entity that mainly used for temporary transactions or internal 
operations. */
+@EqualsAndHashCode
+@ToString
+public class DummyEntity implements Entity, HasIdentifier {

Review Comment:
   What you want is a class that can carry information such as name identifier, 
type, and meet the interface constraints.  
   
   Both `InternalEntity` or `DummyEntity` are okay, since I also can't come up 
with a better name. By the way, you'd better add more comments about the 
functionality of class `DummyEntity`.



##########
core/src/main/java/org/apache/gravitino/storage/relational/service/PolicyMetaService.java:
##########
@@ -266,38 +264,15 @@ public List<MetadataObject> 
listAssociatedMetadataObjectsForPolicy(NameIdentifie
                   mapper.listPolicyMetadataObjectRelsByMetalakeAndPolicyName(
                       metalakeName, policyName));
 
-      List<MetadataObject> metadataObjects = Lists.newArrayList();
-      Map<String, List<PolicyMetadataObjectRelPO>> 
policyMetadataObjectRelPOsByType =
-          policyMetadataObjectRelPOs.stream()
-              
.collect(Collectors.groupingBy(PolicyMetadataObjectRelPO::getMetadataObjectType));
-
-      for (Map.Entry<String, List<PolicyMetadataObjectRelPO>> entry :
-          policyMetadataObjectRelPOsByType.entrySet()) {
-        String metadataObjectType = entry.getKey();
-        List<PolicyMetadataObjectRelPO> rels = entry.getValue();
-
-        List<Long> metadataObjectIds =
-            rels.stream()
-                .map(PolicyMetadataObjectRelPO::getMetadataObjectId)
-                .collect(Collectors.toList());
-        Map<Long, String> metadataObjectNames =
-            MetadataObjectService.TYPE_TO_FULLNAME_FUNCTION_MAP
-                .get(MetadataObject.Type.valueOf(metadataObjectType))
-                .apply(metadataObjectIds);
-
-        for (Map.Entry<Long, String> metadataObjectName : 
metadataObjectNames.entrySet()) {
-          String fullName = metadataObjectName.getValue();
-
-          // Metadata object may be deleted asynchronously when we query the 
name, so it will
-          // return null, we should skip this metadata object.
-          if (fullName != null) {
-            metadataObjects.add(
-                MetadataObjects.parse(fullName, 
MetadataObject.Type.valueOf(metadataObjectType)));
-          }
-        }
-      }
+      return policyMetadataObjectRelPOs.stream()
+          .map(
+              r ->
+                  DummyEntity.builder()
+                      .withId(r.getMetadataObjectId())
+                      
.withEntityType(Entity.EntityType.valueOf(r.getMetadataObjectType()))

Review Comment:
   MetadataObjectUtil.toEntityType()



##########
core/src/main/java/org/apache/gravitino/storage/relational/service/PolicyMetaService.java:
##########
@@ -327,6 +302,19 @@ public List<PolicyEntity> 
associatePoliciesWithMetadataObject(
               ? Collections.emptyList()
               : getPolicyPOsByMetalakeAndNames(metalake, policyNamesToAdd);
 
+      // Check if the policies to add all support the metadata object type.
+      policyPOsToAdd.forEach(

Review Comment:
   boolen allSupport = xx.stream().allMatch()
   if (!allSupport) {
      throw xxx;
   }



-- 
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