-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-29706: Alter table with reopen false should pass if coprocessors havenot changed #7575
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: master
Are you sure you want to change the base?
Conversation
cd74717 to
4272f2c
Compare
This comment has been minimized.
This comment has been minimized.
|
Need to run |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
...-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestModifyTableProcedure.java
Outdated
Show resolved
Hide resolved
Umeshkumar9414
left a comment
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
4272f2c to
3a1ebef
Compare
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
@apurtell @virajjasani please review when you get some free cycle. |
Apache9
left a comment
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 title of the PR is different with the title of the jira...
Could someone explain more about what do we actually fix here?
Thanks.
| ) { | ||
| return false; | ||
| } | ||
| return new TreeMap<>(getProperties()).equals(new TreeMap<>(other.getProperties())); |
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 we could use equals directly here?
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.
Fixed and improved it.
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(className, jarPath, priority, new TreeMap<>(properties)); |
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.
Better use Objects.hash to calculate hashCode for fields other than properties, and then use stream.sorted to iterator over properties and calculate hashCode on the fly.
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.
Done. Almost what you suggested.
| if ( | ||
| this.unmodifiedTableDescriptor.getCoprocessorDescriptors().hashCode() | ||
| != this.modifiedTableDescriptor.getCoprocessorDescriptors().hashCode() | ||
| !new HashSet<>(this.unmodifiedTableDescriptor.getCoprocessorDescriptors()) |
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.
This is not on the critial read/write path so maybe this is acceptable, but a better way, is to first check size, and then, create a HashSet for one of the descriptors, and then iterator over the other one, and check whethere the HashSet contains 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.
Done.
…s havenot changed
3a1ebef to
d66e3ac
Compare
|
🎊 +1 overall
This message was automatically generated. |
| @Override | ||
| public int hashCode() { | ||
| int result = Objects.hash(className, jarPath, priority); | ||
| List<Map.Entry<String, String>> entries = new ArrayList<>(properties.entrySet()); |
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.
Ah, checked the code, properties is already a TreeMap... So we do not need to sort here, just iterate over it is enough...
To make it safe, we can change the declaration of properties from Map to SortedMap or NavigableMap.
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.
Consdering this change is not in hot path should we still change the treemap to map(Navigable or sortable)?
This might become a cleanup exercise where treemap specific functionality is used elsewhere. I mean i am happy to change it but doesn't make sense to do it in this jira atleast.
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.
Let me know if you want it within same jira.
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 it is related. We want to make sure the hash code calculation is stable, so here we want to sort the entries before calculating. Since we already use TreeMap in CoprocessorDescriptorBuilder, we can make sure that the Map in CoprocessorDescriptor is a TreeMap, which is sorted, so we do not need to sort it again.
To prevent later developers break the assumption, i.e, changing the TreeMap to HashMap in CoprocessorDescriptorBuilder without any compilation errors, we'd better change the declaration in CoprocessorDescriptor to SortedMap or NavigableMap, so the constructor will not accept a HashMap any more. And we could also add some comments to explain that we must use SortedMap here as we need it for a stable hash code calculation.
Thanks.
|
🎊 +1 overall
This message was automatically generated. |
No description provided.