-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-23103][core] Ensure correct sort order for negative values in LevelDB. #20284
Conversation
…LevelDB. The code was sorting "0" as "less than" negative values, which is a little wrong. Fix is simple, most of the changes are the added test and related cleanup.
Test build #86210 has finished for PR 20284 at commit
|
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
@@ -112,7 +114,8 @@ public void setup() throws Exception { | |||
t.key = "key" + i; | |||
t.id = "id" + i; | |||
t.name = "name" + RND.nextInt(MAX_ENTRIES); | |||
t.num = RND.nextInt(MAX_ENTRIES); | |||
// Force one item to have an integer value of zero to test the fix for SPARK-23103. | |||
t.num = (i != 0) ? (int) RND.nextLong() : 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.
why the chang from RND.nextInt(MAX_ENTRIES)
? this seems fine, just seemed like you were more likely to stress collision on this index 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.
nextInt
doesn't return negative values. I can add a mod operator here, but the code already explicitly generates some clashes a few lines below.
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
retest this please |
@vanzin The unit test fix is not related to the sorting issue right? Also it's totally fine to include it in this PR since it's minor. |
It is actually. Before, negative values (empty metrics all have value "-1") would show up when starting iteration from 0, and now they don't.
|
Ah, thanks for the explanation! |
Test build #86295 has finished for PR 20284 at commit
|
even though we don't know of this causing a bug in 2.3, I still think we should merge it in there just because there may be some case we aren't thinking of, and this is a relatively small, safe fix. so, I'm merging to master & 2.3 |
…LevelDB. The code was sorting "0" as "less than" negative values, which is a little wrong. Fix is simple, most of the changes are the added test and related cleanup. Author: Marcelo Vanzin <vanzin@cloudera.com> Closes #20284 from vanzin/SPARK-23103. (cherry picked from commit aa3a127) Signed-off-by: Imran Rashid <irashid@cloudera.com>
The code was sorting "0" as "less than" negative values, which is a little
wrong. Fix is simple, most of the changes are the added test and related
cleanup.