-
Notifications
You must be signed in to change notification settings - Fork 350
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
Fixed the searchRing function for consistentHash #2460
Conversation
CI failed because of #2457 (comment) |
@RomanZavodskikh Please update commit message (and PR description) with the description of the problem and why this is the proper fix. |
It is not obvious how to interpret the graphs tbh. We should think how to make it easier to eyeball sanity check, maybe color-code datapoints according to endpoint. |
@RomanZavodskikh Would it be possible to craft a specific test that fails before the fix and passes after? |
656267f
to
24e762b
Compare
@AlexanderYastrebov FYI:
|
Great work! |
👍 |
Nice find, makes sense! |
24e762b
to
d905bad
Compare
187043d
to
696fdf5
Compare
Signed-off-by: Roman Zavodskikh <[email protected]>
696fdf5
to
c74f478
Compare
2c72a3d
to
8f94d9e
Compare
Signed-off-by: Roman Zavodskikh <[email protected]>
This fix is needed to comply the requirements of input for binary search https://pkg.go.dev/sort#Search Search uses binary search to find and return the smallest index i in [0, n) at which f(i) is true, assuming that on the range [0, n), f(i) == true implies f(i+1) == true. That is, Search requires that f is false for some (possibly empty) prefix of the input range [0, n) and then true for the (possibly empty) remainder Signed-off-by: Roman Zavodskikh <[email protected]>
Signed-off-by: Roman Zavodskikh <[email protected]>
8f94d9e
to
bb2126f
Compare
Signed-off-by: Roman Zavodskikh <[email protected]>
bb2126f
to
af3d546
Compare
👍 |
1 similar comment
👍 |
This fix is needed to comply the requirements of input for binary search https://pkg.go.dev/sort#Search
This requirement is not satisfied before this PR, because
skipEndpoint(idx int)
may return false for every specific index regardless of other indicies. So, even if skipEndpoint(i) is true, nothing can stop skipEndpoint(i+1) being false.