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


##########
core/src/main/java/org/apache/gravitino/meta/EntityIds.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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 com.google.common.base.Preconditions;
+
+public class EntityIds {

Review Comment:
   `EntityIds` is quite misleading, it makes me think it's a list of entity ID.



##########
core/src/main/java/org/apache/gravitino/storage/relational/RelationalEntityStoreIdResolver.java:
##########
@@ -0,0 +1,205 @@
+/*
+ * 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.storage.relational;
+
+import com.google.common.collect.ImmutableSet;
+import java.util.Set;
+import org.apache.gravitino.Entity;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.meta.EntityIdResolver;
+import org.apache.gravitino.meta.EntityIds;
+import org.apache.gravitino.storage.relational.helper.CatalogIds;
+import org.apache.gravitino.storage.relational.helper.SchemaIds;
+import org.apache.gravitino.storage.relational.service.CatalogMetaService;
+import org.apache.gravitino.storage.relational.service.FilesetMetaService;
+import org.apache.gravitino.storage.relational.service.GroupMetaService;
+import org.apache.gravitino.storage.relational.service.MetalakeMetaService;
+import org.apache.gravitino.storage.relational.service.ModelMetaService;
+import org.apache.gravitino.storage.relational.service.RoleMetaService;
+import org.apache.gravitino.storage.relational.service.SchemaMetaService;
+import org.apache.gravitino.storage.relational.service.TableColumnMetaService;
+import org.apache.gravitino.storage.relational.service.TableMetaService;
+import org.apache.gravitino.storage.relational.service.TagMetaService;
+import org.apache.gravitino.storage.relational.service.TopicMetaService;
+import org.apache.gravitino.storage.relational.service.UserMetaService;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+public class RelationalEntityStoreIdResolver implements EntityIdResolver {
+  private static final Set<Entity.EntityType> needMetalakeId =

Review Comment:
   Better to use UPPER_CASE name.
   
   



##########
core/src/main/java/org/apache/gravitino/utils/NameIdentifierUtil.java:
##########
@@ -600,4 +610,52 @@ public static NameIdentifier 
getModelIdentifier(NameIdentifier ident) {
     }
     return NameIdentifier.of(allElems.get(0), allElems.get(1), 
allElems.get(2), allElems.get(3));
   }
+
+  public static NameIdentifier parentNameIdentifier(
+      NameIdentifier nameIdentifier, Entity.EntityType type) {
+    Set<Entity.EntityType> supportsVirtualNamespaceTypes =

Review Comment:
   Please just set it as a static final field.



##########
core/src/main/java/org/apache/gravitino/storage/relational/service/CatalogMetaService.java:
##########
@@ -92,9 +92,18 @@ public CatalogPO getCatalogPOByName(String metalakeName, 
String catalogName) {
       metricsSource = GRAVITINO_RELATIONAL_STORE_METRIC_NAME,
       baseMetricName = "getCatalogIdByMetalakeAndCatalogName")
   public CatalogIds getCatalogIdByMetalakeAndCatalogName(String metalakeName, 
String catalogName) {
-    return SessionUtils.getWithoutCommit(
-        CatalogMetaMapper.class,
-        mapper -> 
mapper.selectCatalogIdByMetalakeNameAndCatalogName(metalakeName, catalogName));
+    CatalogIds catalogIds =
+        SessionUtils.getWithoutCommit(
+            CatalogMetaMapper.class,
+            mapper ->
+                
mapper.selectCatalogIdByMetalakeNameAndCatalogName(metalakeName, catalogName));
+    if (catalogIds == null) {

Review Comment:
   Why does it work fine without adding this check? Is the reason that no test 
have covered this?



##########
core/src/main/java/org/apache/gravitino/storage/relational/RelationalEntityStoreIdResolver.java:
##########
@@ -0,0 +1,205 @@
+/*
+ * 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.storage.relational;
+
+import com.google.common.collect.ImmutableSet;
+import java.util.Set;
+import org.apache.gravitino.Entity;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.meta.EntityIdResolver;
+import org.apache.gravitino.meta.EntityIds;
+import org.apache.gravitino.storage.relational.helper.CatalogIds;
+import org.apache.gravitino.storage.relational.helper.SchemaIds;
+import org.apache.gravitino.storage.relational.service.CatalogMetaService;
+import org.apache.gravitino.storage.relational.service.FilesetMetaService;
+import org.apache.gravitino.storage.relational.service.GroupMetaService;
+import org.apache.gravitino.storage.relational.service.MetalakeMetaService;
+import org.apache.gravitino.storage.relational.service.ModelMetaService;
+import org.apache.gravitino.storage.relational.service.RoleMetaService;
+import org.apache.gravitino.storage.relational.service.SchemaMetaService;
+import org.apache.gravitino.storage.relational.service.TableColumnMetaService;
+import org.apache.gravitino.storage.relational.service.TableMetaService;
+import org.apache.gravitino.storage.relational.service.TagMetaService;
+import org.apache.gravitino.storage.relational.service.TopicMetaService;
+import org.apache.gravitino.storage.relational.service.UserMetaService;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+public class RelationalEntityStoreIdResolver implements EntityIdResolver {
+  private static final Set<Entity.EntityType> needMetalakeId =
+      ImmutableSet.of(
+          Entity.EntityType.METALAKE,
+          Entity.EntityType.ROLE,
+          Entity.EntityType.USER,
+          Entity.EntityType.GROUP,
+          Entity.EntityType.TAG);
+  private static final Set<Entity.EntityType> needCatalogIds =

Review Comment:
   I'm not very clear about why the entity catalog needs `needCatalogIds` here? 
Could you try to rename them or add more comments here? 



##########
core/src/main/java/org/apache/gravitino/meta/EntityIdResolver.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * 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 org.apache.gravitino.Entity;
+import org.apache.gravitino.NameIdentifier;
+
+/** Interface for resolving entity IDs based on NameIdentifiers and Entity 
types. */
+public interface EntityIdResolver {
+
+  /**
+   * Get EntityIds for the given NameIdentifier and Entity type.
+   *
+   * @param nameIdentifier NameIdentifier of the entity.
+   * @param type Entity type.
+   * @return EntityIds corresponding to the NameIdentifier and Entity type.
+   */
+  EntityIds getEntityIds(NameIdentifier nameIdentifier, Entity.EntityType 
type);

Review Comment:
   This method is enough to meet our needs, but why do we add the following 
method as well? 



##########
core/src/main/java/org/apache/gravitino/storage/relational/helper/MetadataObjectIds.java:
##########
@@ -0,0 +1,37 @@
+/*
+ * 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.storage.relational.helper;
+
+public class MetadataObjectIds {

Review Comment:
   It's unused, and maybe you need to remove it. 



##########
core/src/main/java/org/apache/gravitino/meta/EntityIds.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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 com.google.common.base.Preconditions;
+
+public class EntityIds {
+
+  private final long entityId;
+  private final long[] namespaceIds;
+
+  public EntityIds(long entityId, long... namespaceIds) {
+    Preconditions.checkArgument(namespaceIds != null, "namespaceIds cannot be 
null");
+    this.entityId = entityId;
+    this.namespaceIds = namespaceIds;
+  }
+
+  public EntityIds(long entityId) {
+    this(entityId, new long[0]);
+  }
+
+  public long entityId() {
+    return entityId;
+  }
+
+  public long[] namespaceIds() {
+    return namespaceIds;
+  }
+
+  public long[] fullIds() {
+    long[] allIds = new long[namespaceIds.length + 1];
+    System.arraycopy(namespaceIds, 0, allIds, 0, namespaceIds.length);
+    allIds[allIds.length - 1] = entityId;
+    return allIds;

Review Comment:
   ```suggestion
   return ArrayUtils.add(namespaceIds, entityId);
   ```



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