xunliu commented on code in PR #5075:
URL: https://github.com/apache/gravitino/pull/5075#discussion_r1794774785
##########
core/src/main/java/org/apache/gravitino/tag/TagManager.java:
##########
@@ -431,27 +424,7 @@ private TagEntity updateTagEntity(TagEntity tagEntity,
TagChange... changes) {
// for this entity, with this uid tags can be associated with this entity.
// This method should be called out of the tree lock, otherwise it will
cause deadlock.
@VisibleForTesting
- boolean checkAndImportEntity(String metalake, MetadataObject metadataObject,
GravitinoEnv env) {
- NameIdentifier entityIdent = MetadataObjectUtil.toEntityIdent(metalake,
metadataObject);
- Entity.EntityType entityType =
MetadataObjectUtil.toEntityType(metadataObject);
-
- switch (entityType) {
- case METALAKE:
- return env.metalakeDispatcher().metalakeExists(entityIdent);
- case CATALOG:
- return env.catalogDispatcher().catalogExists(entityIdent);
- case SCHEMA:
- return env.schemaDispatcher().schemaExists(entityIdent);
- case TABLE:
- return env.tableDispatcher().tableExists(entityIdent);
- case TOPIC:
- return env.topicDispatcher().topicExists(entityIdent);
- case FILESET:
- return env.filesetDispatcher().filesetExists(entityIdent);
- case COLUMN:
- default:
- throw new IllegalArgumentException(
- "Unsupported metadata object type: " + metadataObject.type());
- }
+ void checkAndImportEntity(String metalake, MetadataObject metadataObject,
GravitinoEnv env) {
+ MetadataObjectUtil.checkMetadataObject(metalake, metadataObject, env);
}
Review Comment:
The `checkAndImportEntity(...)` function only have one line code.
We can directly call `MetadataObjectUtil.checkMetadataObject(metalake,
metadataObject, env)`.
##########
core/src/main/java/org/apache/gravitino/utils/MetadataObjectUtil.java:
##########
@@ -98,4 +104,77 @@ public static NameIdentifier toEntityIdent(String
metalakeName, MetadataObject m
"Unknown metadata object type: " + metadataObject.type());
}
}
+
+ /**
+ * This method will check if the entity is existed explicitly, internally
this check will load the
+ * entity from underlying sources to entity store if not stored, and will
allocate an uid for this
+ * entity, with this uid tags can be associated with this entity. This
method should be called out
+ * of the tree lock, otherwise it will cause deadlock.
+ *
+ * @param metalake The metalake name
+ * @param object The metadata object
+ * @param env The Gravitino environment
+ * @throws NoSuchMetadataObjectException if the metadata object type doesn't
exist.
+ */
+ public static void checkMetadataObject(String metalake, MetadataObject
object, GravitinoEnv env) {
+ NameIdentifier identifier = toEntityIdent(metalake, object);
Review Comment:
I think we doesn't need `GravitinoEnv env` params in the
`checkMetadataObject(...)` function.
We can directly call `GravitinoEnv.getInstance()` in the function body.
--
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]