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
KAFKA-16669: Remove extra collection copy when generating DescribeAclsResource #15924
base: trunk
Are you sure you want to change the base?
Conversation
@chiacyu we don't need to collect all items to a new collection, right? |
ResourcePattern key = entry.getKey(); | ||
List<AclDescription> aclDescriptions = new ArrayList<>(); | ||
List<AclDescription> aclDescriptions = new ArrayList<>(128); |
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.
why not using entry.getValue().size()
?
@@ -69,7 +69,7 @@ class AclApis(authHelper: AuthHelper, | |||
case Some(auth) => | |||
val filter = describeAclsRequest.filter | |||
val returnedAcls = new util.HashSet[AclBinding]() | |||
auth.acls(filter).forEach(returnedAcls.add) | |||
returnedAcls.add(auth.acls(filter).iterator().next()) |
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.
Originally we will add all auth.acls(filter)
content into returnedAcls
, but after this change, we only add the first element. Why do we need this change?
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 know why you did this change now.
we don't need to collect all items to a new collection, right?
I believe what @chia7712 meant is we don't have to do a collection copy here because we already allow passing Iterable
into aclsResource
method. To make it clear, in the JIRA, we said:
- Iterable -> HashSet
This is the collection copy we want to avoid here. So we don't need returnedAcls
anymore, we can pass the result of auth.acls(filter)
into aclsResource
directly. Is that clear?
This pr reduced the occurrence of collection copy when generating DescribeAclsResource.