aviggiano / redis-roaring

Roaring Bitmaps for Redis
MIT License
348 stars 56 forks source link

how to append a bigint number just like 33383002443812481 #69

Closed sunyaf closed 4 years ago

sunyaf commented 4 years ago

our user_id is very big , number type is bigint,like 33383002443812481 when i excutor R.APPENDINTARRAY test 33383002443812481 i get is R.GETINTARRAY test result is 4063432321

aviggiano commented 4 years ago

Hello @sunyaf thank you for the bug report.

Indeed I believe this is being caused by an integer overflow, since 33383002443812481 % 2^32 = 4063432321

I'll look into this and see if this limitation can be removed, otherwise I'll update the documentation to be explicit about this.

sunyaf commented 4 years ago

thank you,it would be soon to be happy. because i will use it as soon as possible. it would be very helpful to me. thank you very much.

sunyaf commented 4 years ago

Hello @sunyaf thank you for the bug report.

Indeed I believe this is being caused by an integer overflow, since 33383002443812481 % 2^32 = 4063432321

I'll look into this and see if this limitation can be removed, otherwise I'll update the documentation to be explicit about this. thank you,it would be soon to be happy. because i will use it as soon as possible. it would be very helpful to me. thank you very much.

aviggiano commented 4 years ago

Hello

I have confirmed that this issue is due to R.APPENDINTARRAY using internally (1, 2) 32-bit integer arrays, which is the default implementation of the CRoaring build.

From a quick look on their repo it seems that it is possible to create a 64-bit version of the library for C++, but I didn't find anything for C specifically, which could put us in trouble.

In any case, I think this issue won't be very easy to fix. I'll probably just update the README for now to make it clearer that integers are capped at 32-bits.

I'll keep you updated.

aviggiano commented 4 years ago

Update: I have confirmed that CRoaring do not support 64-bit integers: https://github.com/RoaringBitmap/CRoaring/issues/232, https://github.com/RoaringBitmap/CRoaring/issues/1

We'll have to monitor their progress, so there isn't much we can do on this front for now. I'll update the README.

sunyaf commented 4 years ago

i find this
`

include

include "roaring.hh"

include "roaring.c"

int main() { Roaring r1; for (uint32_t i = 100; i < 1000; i++) { r1.add(i); } std::cout << "cardinality = " << r1.cardinality() << std::endl;

Roaring64Map r2; for (uint64_t i = 18000000000000000100ull; i < 18000000000000001000ull; i++) { r2.add(i); } std::cout << "cardinality = " << r2.cardinality() << std::endl; return 0; } ` https://github.com/RoaringBitmap/CRoaring you can search 'Roaring64Map'

lemire commented 4 years ago

The C library is 32-bit only but there is a 64-bit extension in C++.

sunyaf commented 4 years ago

i find this `

include

include "roaring.hh"

include "roaring.c"

int main() { Roaring r1; for (uint32_t i = 100; i < 1000; i++) { r1.add(i); } std::cout << "cardinality = " << r1.cardinality() << std::endl;

Roaring64Map r2; for (uint64_t i = 18000000000000000100ull; i < 18000000000000001000ull; i++) { r2.add(i); } std::cout << "cardinality = " << r2.cardinality() << std::endl; return 0; } ` https://github.com/RoaringBitmap/CRoaring you can search 'Roaring64Map'

Requirements

sunyaf commented 4 years ago

I think C can code with C++