-
Notifications
You must be signed in to change notification settings - Fork 271
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
add roaring_bitmap_rank_many(): get rank()
values in Bulk
#527
Conversation
rank()
values in Bulkrank()
values in Bulk
@lemire Would you take a look ? |
Of course I will review. |
include/roaring/roaring.h
Outdated
* it puts rank value of each element in `[begin .. end)` to `ans[]` | ||
* | ||
* the values in `[begin .. end)` must be sorted in Ascending order; | ||
* the `ans` must have enough size. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be we can be more precise and state what is meant by size. It is size_t length = (end-begin)
. Correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. i borrowed a doc from roaring_bitmap_to_uint32_array()
.
* ans = malloc((end-begin) * sizeof(uint64_t));
@longqimin This looks very good to me. Can you check my comment above? |
include/roaring/containers/array.h
Outdated
uint16_t xhigh = x >> 16; | ||
if(xhigh != high) return iter - begin;// stop at next container | ||
|
||
const int32_t idx = binarySearch(arr->array+pos, arr->cardinality-pos, x&0xFFFF); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const int32_t idx = binarySearch(arr->array+pos, arr->cardinality-pos, x&0xFFFF); | |
const int32_t idx = binarySearch(arr->array+pos, arr->cardinality-pos, (uint16_t)x); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
include/roaring/containers/array.h
Outdated
@@ -412,6 +412,29 @@ inline int array_container_rank(const array_container_t *arr, uint16_t x) { | |||
} | |||
} | |||
|
|||
// bulk version of array_container_rank(); return number of consumed elements | |||
inline uint32_t array_container_rank_many(const array_container_t *arr, uint64_t start_rank, const uint32_t* begin, const uint32_t* end, uint64_t* ans){ | |||
const uint16_t high = (*begin) >> 16; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const uint16_t high = (*begin) >> 16; | |
const uint16_t high = (uint16_t)((*begin) >> 16); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
include/roaring/containers/array.h
Outdated
const uint32_t* iter = begin; | ||
for(; iter != end; iter++) { | ||
uint32_t x = *iter; | ||
uint16_t xhigh = x >> 16; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint16_t xhigh = x >> 16; | |
uint16_t xhigh = (uint16_t)(x >> 16); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/containers/bitset.c
Outdated
@@ -1232,6 +1232,29 @@ int bitset_container_rank(const bitset_container_t *container, uint16_t x) { | |||
return sum; | |||
} | |||
|
|||
uint32_t bitset_container_rank_many(const bitset_container_t *container, uint64_t start_rank, const uint32_t* begin, const uint32_t* end, uint64_t* ans){ | |||
const uint16_t high = (*begin) >> 16; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const uint16_t high = (*begin) >> 16; | |
const uint16_t high = (uint16_t)((*begin) >> 16); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/containers/bitset.c
Outdated
const uint32_t* iter = begin; | ||
for(; iter != end; iter++) { | ||
uint32_t x = *iter; | ||
uint16_t xhigh = x >> 16; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint16_t xhigh = x >> 16; | |
uint16_t xhigh = (uint16_t)(x >> 16); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/containers/bitset.c
Outdated
uint16_t xhigh = x >> 16; | ||
if(xhigh != high) return iter - begin; // stop at next container | ||
|
||
uint16_t xlow = x & 0xFFFF; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint16_t xlow = x & 0xFFFF; | |
uint16_t xlow = (uint16_t)x; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/containers/run.c
Outdated
int i = 0; | ||
for(;iter != end; iter++) { | ||
uint32_t x = *iter; | ||
uint16_t xhigh = x >> 16; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint16_t xhigh = x >> 16; | |
uint16_t xhigh = (uint16_t)(x >> 16); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
…ny(begin,end,ans)`
Merged. Will be part of the next release. Thanks. |
It might be worth documenting which of the following can occur if this is not upheld:
|
this pr provide an api implementation for fast getting
rank
of many elements in bulk mode.as well as test/benchmark.