Support 1.23 iterator in a backward-compatible way#475
Support 1.23 iterator in a backward-compatible way#475lemire merged 5 commits intoRoaringBitmap:masterfrom
Conversation
|
Can you add benchmarks ? See Line 18 in fb67118 |
|
@amikai Can you share your benchmark results ? E.g., on your own machine ? |
|
|
||
| t.Run("#6", func(t *testing.T) { | ||
| b := New() | ||
| b.AddInt(MaxUint32) |
There was a problem hiding this comment.
An int might be a signed 32-bit integer, so MaxUint32 can't be represented.
But when it works, you might be allocating 512 MB of memory. Please don't do this as part of our routine tests.
|
|
||
| func TestBackward(t *testing.T) { | ||
| t.Run("#1", func(t *testing.T) { | ||
| values := []uint32{0, 2, 15, 16, 31, 32, 33, 9999, MaxUint16, MaxUint32} |
There was a problem hiding this comment.
This will allocate hundreds of megabytes. Please don't do this in tests.
There was a problem hiding this comment.
In fact, I just wrote a similar test of the TestReverseIterator to make sure the behavior is same as before. How about I change it to values := []uint32{0, 2, 15, 16, 31, 32, 33, 9999, MaxUint16}? Is that okay with you?
Lines 2428 to 2449 in b705c37
|
|
||
| t.Run("#6", func(t *testing.T) { | ||
| b := New() | ||
| b.AddInt(MaxUint32) |
There was a problem hiding this comment.
This will allocate hundreds of megabytes. Please don't do this in tests.
There was a problem hiding this comment.
Same as before, I just wrote a similar test to make sure the behavior same as before. Will delete this test.
Lines 2488 to 2496 in b705c37
There was a problem hiding this comment.
@amikai It is entirely possible that it was pre-existing. it is still a terrible idea. :-)
There was a problem hiding this comment.
To be clear, we do not have AddInt(MaxUint32) in the code base because that does not work....
MaxUint32 may not fit in an int.
There was a problem hiding this comment.
Sorry, I didn't see clearly.
|
Hi @lemire, here is the benchmark on my computer: |
|
@amikai The performance is ok. Can you just tweak the small things I flagged ? We will be able to merge. |
|
Hi @lemire, I have tweaked the test. |
|
Great. I am running the CI tests, if it passes, we shall merge and release !!! |
|
Hi @lemire, If there any concerns to merge the PR and release? |
|
Merging! |
This builds on the previous work in RoaringBitmap#475.
Resolve #471
Provide two new functions:
Values: An iterator in normal orderBackward: An iterator in reverse orderUnit test:
iter123_test.go: Test the 1.23 iterator by for-rangeiter_test.go: Test the iterator by call function wayDesign consideration
slices.Valuesandslices.Backwardto make it easier to use.ValuesandBackwardbefore version 1.23 without for-range function syntax, which means we don't need to update the go.mod version.iterpackage.Hi @lemire,
The unit test I wrote uses a similar approach to the one for testing
Bitmap.ReverseIteratorandBitmap.Iterator. However, I am not confident that the test case is robust enough. Could you please review it? If you find the implementation acceptable, I will proceed with writing the Go doc comments and add examples to it.