-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#4305] improvement(core): Improved the way of fill parentEntityId in POBuilder #6114
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6632784
[CORE]Improved the way of fill parentEntityId in POBuilder
c5fc23a
extract method getParentEntityIdsByNamespace into CommonMetaService
e232f6d
fix spotless run failed
f31d537
change initial array length to namespace's length
f404e42
Merge branch 'main' into main
luoshipeng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,4 +57,29 @@ public Long getParentEntityIdByNamespace(Namespace namespace) { | |
"Parent entity id should not be null and should be greater than 0."); | ||
return parentEntityId; | ||
} | ||
|
||
public Long[] getParentEntityIdsByNamespace(Namespace namespace) { | ||
Preconditions.checkArgument( | ||
!namespace.isEmpty() && namespace.levels().length <= 3, | ||
"Namespace should not be empty and length should be less than or equal to 3."); | ||
Long[] parentEntityIds = new Long[3]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The length should be the same as namespace's. |
||
if (namespace.levels().length >= 1) { | ||
parentEntityIds[0] = | ||
MetalakeMetaService.getInstance().getMetalakeIdByName(namespace.level(0)); | ||
} | ||
|
||
if (namespace.levels().length >= 2) { | ||
parentEntityIds[1] = | ||
CatalogMetaService.getInstance() | ||
.getCatalogIdByMetalakeIdAndName(parentEntityIds[0], namespace.level(1)); | ||
} | ||
|
||
if (namespace.levels().length >= 3) { | ||
parentEntityIds[2] = | ||
SchemaMetaService.getInstance() | ||
.getSchemaIdByCatalogIdAndName(parentEntityIds[1], namespace.level(2)); | ||
} | ||
|
||
return parentEntityIds; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -314,26 +314,10 @@ public int deleteFilesetVersionsByRetentionCount(Long versionRetentionCount, int | |
|
||
private void fillFilesetPOBuilderParentEntityId(FilesetPO.Builder builder, Namespace namespace) { | ||
NamespaceUtil.checkFileset(namespace); | ||
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); | ||
builder.withMetalakeId(parentEntityId); | ||
continue; | ||
case 1: | ||
parentEntityId = | ||
CatalogMetaService.getInstance() | ||
.getCatalogIdByMetalakeIdAndName(parentEntityId, name); | ||
builder.withCatalogId(parentEntityId); | ||
continue; | ||
case 2: | ||
parentEntityId = | ||
SchemaMetaService.getInstance().getSchemaIdByCatalogIdAndName(parentEntityId, name); | ||
builder.withSchemaId(parentEntityId); | ||
break; | ||
} | ||
} | ||
Long[] parentEntityIds = | ||
CommonMetaService.getInstance().getParentEntityIdsByNamespace(namespace); | ||
builder.withMetalakeId(parentEntityIds[0]); | ||
builder.withCatalogId(parentEntityIds[1]); | ||
builder.withSchemaId(parentEntityIds[2]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can change to this style for here and below. builder.withMetalakeId(parentEntityIds[0])
.withCatalogId(parentEntityIds[1]);
.withSchemaId(parentEntityIds[2]); |
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The length of schema won't be 3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this is the same problem as the last one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If namespace belongs to a
schema
, the length of namespace will be 2 instead of 3.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. so if i update the array length to namespace's length, it will solve this problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to replace the similar code of
ColumnMetaService
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've checked the code of ColumnMetaService, and not found the similar code. Did i miss that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ColumnPO get parentEntityId from TablePO, so i think there's no need to replace it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I got it.