-
Notifications
You must be signed in to change notification settings - Fork 624
Add ability to delete indexes #3118
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
Conversation
This PR diffs the index configuration that the user provides with the currently active definition and removes indexes that are no longer used
Coverage ReportAffected SDKs
Test Logs
NotesHTML coverage reports can be produced locally with Head commit (0474c6bf) is created by Prow via merging commits: fe64756 1dec73a. |
Binary Size ReportAffected SDKs
Test Logs
NotesHead commit (0474c6bf) is created by Prow via merging commits: fe64756 1dec73a. |
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.
LGTM on what is in the PR.
I only left one comment, let me know if you want to simply add a TODO, I'll approve in that case.
Collection<FieldIndex> existingIndexes = indexManager.getFieldIndexes(); | ||
|
||
// Delete indices that are no longer used. | ||
for (FieldIndex existingIndex : existingIndexes) { |
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 am a bit worried about performance here. With a 30 indexes setup, this could easily lead up to 1800 (or 1000 realistically) operations.
I want to suggest to explore something like a bloom filter to help. But I realize this might also be premature optimization. So how about adding a TODO to followup?
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.
Also, can the two loop be merged, such that we only call matchesConstraints
half times?
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 rewrote the entire thing to run in O(n log n)
. Can you take another look?
|
||
if (existingValue != null && updatedValue != null) { | ||
int cmp = FieldIndex.SEMANTIC_COMPARATOR.compare(existingValue, updatedValue); | ||
if (cmp < 0) { |
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.
It is not obvious immediately why comparison result leads to deleted
or updated
. Can we add some comment? Ideally a high level comment for the method, and some implementation comment to explain details.
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 added comments to the more generic implementation, as well as tests.
@Nullable FieldIndex updatedValue = advanceIterator(updatedIt); | ||
|
||
while (existingValue != null || updatedValue != null) { | ||
boolean deleted = false; |
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 think they can be named deleteExistingIndex
and writeNewIndex
?
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 actually realized yesterday that I need to re-use this functionality in a follow up PR, so I changed this method to be more generic and moved it to Util.
@schmidt-sebastian: The following test failed, say
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/test device-check-changed |
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.
LGTM!
This PR diffs the index configuration that the user provides with the currently active definition and removes indexes that are no longer used