Skip to content
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

Cann't flip a bitmap by range #73

Closed
jiangtao244 opened this issue Nov 2, 2020 · 5 comments
Closed

Cann't flip a bitmap by range #73

jiangtao244 opened this issue Nov 2, 2020 · 5 comments

Comments

@jiangtao244
Copy link
Contributor

Need to pass “last“” from R.BITOP NOT

return roaring_bitmap_flip(bitmaps[0], 0, last + 1);

@aviggiano
Copy link
Owner

Hello, thank you for opening this issue.

Can you explain the problem in more detail? Do you have an example that I can use to reproduce?

Thanks

@jiangtao244
Copy link
Contributor Author

For example:
Now I have ten users, and the number of users is increasing.
login_monday = [ 1, 3, 5, 8, 9 ]
login_tuesday = [ 1, 2, 4, 6, 8]

I want to get the users login on monday but not login on tuesday.
I need to flip login_tuesday and expect [ 0, 3, 5, 7, 9 ], but get [0, 3, 5, 7] by using R.BITOP NOT

Now I have to use a redis transaction to achive this goal:

  1. R.BITSET login_tuesday 9 1
  2. R.BITOP NOT dest login_tuesday
  3. R.BITSET login_tuesday 9 0

This's Ugly.

@aviggiano
Copy link
Owner

aviggiano commented Nov 3, 2020

I was able to test this and can confirm this is not the intended behavior.
What do you think about this change? Passing last as an optional parameter, such as R.BITOP NOT destkey srckey last?
This would be the expected output:

> R.SETINTARRAY login_monday 1 3 5 8 9
OK
> R.SETINTARRAY login_tuesday 1 2 4 6 8
OK
> R.MAX login_monday
(integer) 9
> R.NOT login_monday
(integer) 9
> R.BITOP NOT not_login_tuesday login_tuesday 9
(integer) 5
> R.BITOP AND final login_monday not_login_tuesday
(integer) 5
> R.GETINTARRAY final
1) (integer) 0
2) (integer) 3
3) (integer) 5
4) (integer) 7
5) (integer) 9

@jiangtao244
Copy link
Contributor Author

Yes, we can change like this.

@aviggiano
Copy link
Owner

Closing this since it seems it was already resolved on #77 and #78

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants