Skip to content

Commit

Permalink
[#4303] improvement(core): Improved removed loop code and readability (
Browse files Browse the repository at this point in the history
…#4335)

**What changes were proposed in this pull request?**
Reflect changes to improve readability

**Why are the changes needed?**
Readability and no unnecessary repetition compared to existing code

Fix: #4303

**Does this PR introduce any user-facing change?**
No

**How was this patch tested?**
Check change code and existing code comparison
  • Loading branch information
khmgobe authored Aug 5, 2024
1 parent 4c4f15a commit 24b305d
Showing 1 changed file with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 >= 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));
}
Preconditions.checkState(
parentEntityId != null && parentEntityId > 0,
Expand Down

0 comments on commit 24b305d

Please sign in to comment.