-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-14330. MinHeapMergeIterator should use key comparator while popping out entries from the heap #9576
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
…ing out entries from the heap Change-Id: Ia196692c74237ae100180b27dc5c2b5b661ba783
jojochuang
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.
is it a hypothetical problem or is there a case to reproduce?
| class TestMinHeapMergeIterator { | ||
|
|
||
| private static final Comparator<String> STRING_COMPARATOR = String::compareTo; | ||
| private static final Comparator<byte[]> BYTE_COMPARATOR = UnsignedBytes.lexicographicalComparator(); |
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.
is updating String to byte array a necessary change to reproduce the problem?
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 iterator need not be always an Itr it can be Itr<KeyValue<String, >> and KeyValue doesn't implement equals method
| KeyValue<KEY, Object> defaultNullValue = newKeyValue(null, null); | ||
| Comparator<KeyValue<KEY, Object>> comparator = Comparator.comparing(KeyValue::getKey, keyComparator); | ||
| return new MinHeapMergeIterator<KeyValue<KEY, Object>, Table.KeyValueIterator<KEY, Object>, | ||
| KeyValue<KEY, Collection<Object>>>(table.length + 1, comparator) { |
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 don't recall why it was table.length + 1 before.
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 was a typo
|
Thank you @jojochuang for reviewing the patch |
What changes were proposed in this pull request?
MinHeapMergeIterator should use key comparator while popping out entries from the heap. Currently it uses Object.equals() which can fetch wrong results when comparing the key without the key comparator.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-14330
How was this patch tested?
Updated unit tests to use byte array