roaring_bitmap_or_many on array of bitmaps

9 views
Skip to first unread message

Blazer zip

unread,
Sep 24, 2023, 3:00:27 PM9/24/23
to Roaring Bitmaps
Hi

I'm trying to do aggregate the array of bitmaps though getting app crashes. What is the correct way to define an array or bitmaps then union them.

#include <stdio.h>
#include <stdlib.h>
#include "roaring.h"

int main()
{
    roaring_bitmap_t ** roaring_bitmaps;

    roaring_bitmaps = (roaring_bitmap_t**) malloc(2 * sizeof(roaring_bitmap_t*));

    roaring_bitmaps[0] = roaring_bitmap_create();
    roaring_bitmaps[1] = roaring_bitmap_create();

    for (uint32_t i = 100; i < 1000; i++) roaring_bitmap_add(roaring_bitmaps[0], i);
    for (uint32_t i = 1000; i < 2000; i++) roaring_bitmap_add(roaring_bitmaps[1], i);

    printf("%d\n",roaring_bitmap_contains(roaring_bitmaps[0], 200));
    printf("%d\n",roaring_bitmap_contains(roaring_bitmaps[0], 1001));
    printf("%d\n",roaring_bitmap_contains(roaring_bitmaps[1], 1500));
    printf("%d\n",roaring_bitmap_contains(roaring_bitmaps[1], 3500));

    roaring_bitmap_t *bigunion = roaring_bitmap_or_many(2, roaring_bitmaps);

    printf("%d\n",roaring_bitmap_contains(bigunion, 200));
    printf("%d\n",roaring_bitmap_contains(bigunion, 1001));
    printf("%d\n",roaring_bitmap_contains(bigunion, 1500));
    printf("%d\n",roaring_bitmap_contains(bigunion, 3500));

    return 0;
}

Daniel Lemire

unread,
Sep 24, 2023, 5:48:22 PM9/24/23
to Blazer zip, Roaring Bitmaps
I have added your code to our unit tests:


It should work fine.

--
You received this message because you are subscribed to the Google Groups "Roaring Bitmaps" group.
To unsubscribe from this group and stop receiving emails from it, send an email to roaring-bitma...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/roaring-bitmaps/b9b83150-ff0b-41c0-b668-90020848d519n%40googlegroups.com.

Blazer zip

unread,
Sep 24, 2023, 9:18:32 PM9/24/23
to Roaring Bitmaps
Hi

Thanks for testing and getting back so promptly. Yes you are correct it does work, seems like it was the compiler I was using, I have tried with different ones and they are all working fine. Seems like it was a bad compiler on my end which left me scratching my head as the app would sometimes crash and sometimes work when it go to the roaring_bitmap_or_many.

Also thanks for adding it as testcase.
Reply all
Reply to author
Forward
0 new messages