-
Notifications
You must be signed in to change notification settings - Fork 175
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
fix only first two iters checked #121
Conversation
Thanks for your PR! That is a great catch. However it does not solve the issue completely. func (m *multiIterator) Next() bool {
next := m.iters[m.current].Next()
for ; !next && m.current < len(m.iters); m.current++ {
next = m.iters[m.current].Next()
}
m.current %= len(m.iters)
return next
} The modulo just guarantees that we don't panic out-of-bounds if |
I did a slight refactor and forgot to remove a The change above should fix it, I'm writing a test to confirm but it's failing because it seems that items aren't returned in insert order (for memory storage at least). Don't merge until this test is ready |
Test added, ready for review. Items are returned in correct order, was confused by this not doing what was intended (I assume). goka/storage/multi_iterator_test.go Lines 11 to 25 in 8b40064
Only 3 keys in are in the storages, one per storage. I believe the intention was to create 3 keys per storage. On lines 22 & 23 existing keys are overwritten. |
I can’t check it now, but I guess the fix isn’t correct. It will skip the first partition even if it has items. Try your mixedValues test case, but add values only to partitions 0 and 2.
I think you should first call Next() on the m.current partition.
Can you double check?
… On 6. Apr 2018, at 11:14, j0hnsmith ***@***.***> wrote:
Test added, ready for review.
Items are returned in correct order, was confused by this not doing what was intended (I assume).
https://github.com/lovoo/goka/blob/8b40064e42411817f53812c22d2428d5b12b5ec2/storage/multi_iterator_test.go#L11-L25
Only 3 keys in are in the storages, one per storage. I believe the intention was to create 3 keys per storage. On lines 22 & 23 existing keys are overwritten.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
if !next && len(m.iters)-1 > m.current { | ||
m.current++ | ||
func (m *multiIterator) Next() (next bool) { | ||
for ; m.current < len(m.iters); m.current++ { | ||
next = m.iters[m.current].Next() |
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 you should first call Next() on the m.current partition.
That's exactly what it does do (m.current
only gets incremented at the end of the iteration when next
is false
). I updated the test to have values only in storages 0 & 2, it still passes.
Ah, I see. That looks good to me. Thanks.
@frairon @SamiHiltunen can you merge this, please?
… On 6. Apr 2018, at 17:55, j0hnsmith ***@***.***> wrote:
@j0hnsmith commented on this pull request.
In storage/multi_iterator.go:
> @@ -14,13 +14,13 @@ func NewMultiIterator(iters []Iterator) Iterator {
return &multiIterator{current: 0, iters: iters}
}
-func (m *multiIterator) Next() bool {
- next := m.iters[m.current].Next()
- if !next && len(m.iters)-1 > m.current {
- m.current++
+func (m *multiIterator) Next() (next bool) {
+ for ; m.current < len(m.iters); m.current++ {
next = m.iters[m.current].Next()
I think you should first call Next() on the m.current partition.
That's exactly what it does do (m.current only gets incremented when next is false). I updated the test to have values only in storages 0 & 2, it still passes.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I'll merge this. The test cases are nondeterministic, however, and fail often. That is because the iteration over maps is nondeterministic in go. I'll create a PR to fix that afterwards. Thanks for your contribution. |
Only the first two iterators are checked, this is a bug that only shows when there are more than 2 partitions.