add getReverseBatchIterator in RoaringBitmap
Is your feature request related to a problem? Please describe. My use-case is that i'm trying to do before/after pagination from a specific index. I know there already has a bitmap.previousValue(int fromIndex), and nextValue(int fromIndex). Just wondering if we could support getReverseBatchIterator(). I guess it has better performance?
Describe the solution you'd like I hope getReverseBatchIterator could iterate the values in reverse order.
Please note that this is a community-based project. Consider proposing a fix (code, documentation) as a pull request.
@shshen Yes. That's reasonable. Do you want to prepare a pull request ?
HI @lemire , just looked into the code once more. I found there already a BufferReverseIntIteratorFlyweight, and it works well for me. Curious why BufferReverseIntIteratorFlyweight's parent interface is IntIterator and not PeekableIntIterator. (i need advanceIfNeeded method in it). Could i change BufferReverseIntIteratorFlyweight's parent to PeekableIntIterator if you do not mind?
Another solution for my use-case is that i continue adding reverse iterator for batch. The classes like RoaringReverseBatchIterator, ReverseArrayBatchIterator, ReverseBitmapBatchIterator, and ReverseRunBatchIterator. This will need more code.
Do you have any preference/suggestions/comments? Thanks!
Could i change BufferReverseIntIteratorFlyweight's parent to PeekableIntIterator if you do not mind?
It does not provide the PeekableIntIterator interface, but if you are willing to code the missing int peekNext() function, then sure! Pull request invited. Please include tests.
Do you have any preference/suggestions/comments? Thanks!
You should see benefits with BufferReverseIntIteratorFlyweight on the garbage collector if you use it properly so that's maybe a reasonable starting point. Note that it is only faster if you use it how it is meant to be used (with a single instance that you reuse).
If you truly want high speed, the batched approach is hard to beat.