-
Notifications
You must be signed in to change notification settings - Fork 14.3k
KAFKA-13022: Optimize ClientQuotasImage#describe #19079
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
base: trunk
Are you sure you want to change the base?
Conversation
a106160
to
91841c5
Compare
973ed33
to
9ebfa97
Compare
Signed-off-by: PoAn Yang <[email protected]>
9ebfa97
to
4d9df83
Compare
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.
personally this logic seems really hard to follow, especially with all the stacked for loops. I think some code comments would really help!
entitiesByType.get(exactMatchEntry.getKey()).containsKey(exactMatchEntry.getValue())) { | ||
for (Entry<ClientQuotaEntity, ClientQuotaImage> entry : entitiesByType.get(exactMatchEntry.getKey()).get(exactMatchEntry.getValue())) { |
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.
nit: local vars to reduce redundant gets and improve readability?
if (entitiesByType.containsKey(exactMatchEntry.getKey()) && | ||
entitiesByType.get(exactMatchEntry.getKey()).containsKey(exactMatchEntry.getValue())) { | ||
for (Entry<ClientQuotaEntity, ClientQuotaImage> entry : entitiesByType.get(exactMatchEntry.getKey()).get(exactMatchEntry.getValue())) { | ||
if (request.strict() && !entry.getKey().entries().equals(exactMatch)) { |
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.
does this have to equal exactMatch as long as entry.getKey().entries() are encompassed by both typeMatch and exactMatch?
In previous implementation, the
ClientQuotasImage#describe
goes through allClientQuotaEntity
and checks whether entity type and entity name are matched the filter. In this PR, it goes through allClientQuotaEntity#entries
in the constructor and build a new data structureMap<String, Map<String, Set<Entry<ClientQuotaEntity, ClientQuotaImage>>>>
. The first layer is entity type. There are only three entity types: user, client-id, and ip. The second layer is entity name. The last layer is a set of matched entries. With this data structure, we can speed updescribe
function.Correctness is covered by
ClientQuotasRequestTest
.Benchmark result:
trunk
branch