Skip to content

Conversation

@hdygxsj
Copy link
Collaborator

@hdygxsj hdygxsj commented Nov 25, 2025

What changes were proposed in this pull request?

Optimize metadata authorization in the list metalake and list role.

Why are the changes needed?

Fix: #9254 #9168

Does this PR introduce any user-facing change?

None

How was this patch tested?

Existing test case in org.apache.gravitino.client.integration.test.authorization.MetalakeAuthorizationIT
Existing test case in org.apache.gravitino.client.integration.test.authorization.RoleAuthorizationIT

.toArray(NameIdentifier[]::new);
}

public static Metalake[] filterMetalakes(Metalake[] metalakes, String expression) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to create a new method instead of reusing the method filterByExpression?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this method requires passing a metalake.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can extract common part and reuse them instead of producing duplicated code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@jerqi jerqi requested a review from Copilot November 26, 2025 11:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes metadata authorization in the list metalakes operation by refactoring inline filtering logic into a reusable helper method. The change improves code maintainability by centralizing the authorization filtering logic and adds concurrent processing capabilities for better performance.

Key changes:

  • Extracted metalake filtering logic from MetalakeOperations.listMetalakes() into a dedicated MetadataAuthzHelper.filterMetalakes() method
  • Implemented concurrent authorization evaluation using CompletableFuture for improved performance when filtering multiple metalakes

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
MetalakeOperations.java Simplified listMetalakes() by replacing inline filtering logic with a call to the new helper method
MetadataAuthzHelper.java Added new filterMetalakes() method that performs concurrent authorization evaluation for metalakes

Comment on lines 108 to 109
Map<Entity.EntityType, NameIdentifier> nameIdentifierMap =
spiltMetadataNames(
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method name 'spiltMetadataNames' appears to be a typo. It should likely be 'splitMetadataNames'. However, since this is an existing method being called (not introduced in this PR), this should be addressed separately if confirmed.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@jerqi
Copy link
Contributor

jerqi commented Nov 27, 2025

RoleOperations has the similar issue. Could u fix them together?

@hdygxsj
Copy link
Collaborator Author

hdygxsj commented Nov 27, 2025

RoleOperations has the similar issue. Could u fix them together?

fixed

@jerqi
Copy link
Contributor

jerqi commented Nov 27, 2025

RoleOperations has the similar issue. Could u fix them together?

fixed

Could you modify the description to align to the new implementation?

@jerqi
Copy link
Contributor

jerqi commented Nov 27, 2025

cc @danhuawang This will improve the performance of listing roles.

@hdygxsj hdygxsj changed the title [#9254] improvement(authz): Optimize metadata authorization in the list metalake. [#9254] improvement(authz): Optimize metadata authorization in the list metalake and list role. Nov 27, 2025
@hdygxsj hdygxsj changed the title [#9254] improvement(authz): Optimize metadata authorization in the list metalake and list role. [#9254,#9168] improvement(authz): Optimize metadata authorization in the list metalake and list role. Nov 27, 2025
Copy link
Contributor

@jerqi jerqi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, merged, thanks.

@jerqi jerqi merged commit 1d6de4c into apache:main Nov 27, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Improvement] Optimize metadata authorization in the list metalake.

2 participants