xloya commented on code in PR #4335:
URL: https://github.com/apache/gravitino/pull/4335#discussion_r1700202897
##########
core/src/main/java/org/apache/gravitino/storage/relational/service/CommonMetaService.java:
##########
@@ -37,22 +37,20 @@ public Long getParentEntityIdByNamespace(Namespace
namespace) {
!namespace.isEmpty() && namespace.levels().length <= 3,
"Namespace should not be empty and length should be less than or equal
to 3.");
Long parentEntityId = null;
- for (int level = 0; level < namespace.levels().length; level++) {
- String name = namespace.level(level);
- switch (level) {
- case 0:
- parentEntityId =
MetalakeMetaService.getInstance().getMetalakeIdByName(name);
- continue;
- case 1:
- parentEntityId =
- CatalogMetaService.getInstance()
- .getCatalogIdByMetalakeIdAndName(parentEntityId, name);
- continue;
- case 2:
- parentEntityId =
-
SchemaMetaService.getInstance().getSchemaIdByCatalogIdAndName(parentEntityId,
name);
- break;
- }
+ if (namespace.levels().length > 0) {
Review Comment:
> @xloya
>
> Thank you for your suggestion. I guess I missed something.
>
> ```
> if (namespace.levels().length >= 1) {
> parentEntityId =
MetalakeMetaService.getInstance().getMetalakeIdByName(namespace.level(0));
> }
>
> if (namespace.levels().length >= 2) {
> parentEntityId =
> CatalogMetaService.getInstance()
> .getCatalogIdByMetalakeIdAndName(parentEntityId,
namespace.level(1));
> }
>
> if (namespace.levels().length >= 3) {
> parentEntityId =
> SchemaMetaService.getInstance()
> .getSchemaIdByCatalogIdAndName(parentEntityId,
namespace.level(2));
> }
> ```
>
> Is it correct that you mentioned changing it like this? If it is, we will
proceed with the change like this.
Yes, I think this can better express the Namespace levels:
```
if (namespace.levels().length >= 1) {
......
}
if (namespace.levels().length >= 2) {
......
}
if (namespace.levels().length == 3) {
......
}
```
--
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]