Skip to content

Commit

Permalink
Update to croaring 4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Emann committed Jul 3, 2024
1 parent 1c3be74 commit 32a3cfb
Show file tree
Hide file tree
Showing 8 changed files with 234 additions and 178 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Current documentation is available at https://docs.rs/croaring/latest/croaring/

## CRoaring Version

This crate uses [CRoaring version `4.0.0`](https://github.com/RoaringBitmap/CRoaring/releases/tag/v4.0.0).
This crate uses [CRoaring version `4.1.0`](https://github.com/RoaringBitmap/CRoaring/releases/tag/v4.1.0).
The version of this crate does not necessarily match the version of CRoaring: the major version of the crate is only
incremented when there are breaking changes in the Rust API: It is possible (and has happened) that breaking changes
in the CRoaring C API do not necessitate a major version bump in this crate.
28 changes: 20 additions & 8 deletions croaring-sys/CRoaring/bindgen_bundled_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ pub const ROARING_VERSION_MAJOR: _bindgen_ty_1 = 4;
pub const ROARING_VERSION_MINOR: _bindgen_ty_1 = 0;
pub const ROARING_VERSION_REVISION: _bindgen_ty_1 = 0;
pub type _bindgen_ty_1 = ::core::ffi::c_uint;
extern "C" {
#[doc = " result might be undefined when input_num is zero"]
pub fn roaring_trailing_zeroes(input_num: ::core::ffi::c_ulonglong) -> ::core::ffi::c_int;
}
extern "C" {
#[doc = " result might be undefined when input_num is zero"]
pub fn roaring_leading_zeroes(input_num: ::core::ffi::c_ulonglong) -> ::core::ffi::c_int;
}
#[doc = " Roaring arrays are array-based key-value pairs having containers as values\n and 16-bit integer keys. A roaring bitmap might be implemented as such."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
Expand Down Expand Up @@ -73,14 +81,6 @@ pub struct roaring_container_iterator_s {
}
#[doc = " Roaring-internal type used to iterate within a roaring container."]
pub type roaring_container_iterator_t = roaring_container_iterator_s;
extern "C" {
#[doc = " result might be undefined when input_num is zero"]
pub fn roaring_trailing_zeroes(input_num: ::core::ffi::c_ulonglong) -> ::core::ffi::c_int;
}
extern "C" {
#[doc = " result might be undefined when input_num is zero"]
pub fn roaring_leading_zeroes(input_num: ::core::ffi::c_ulonglong) -> ::core::ffi::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct bitset_s {
Expand Down Expand Up @@ -925,6 +925,10 @@ extern "C" {
#[doc = " Remove all values in range [min, max]."]
pub fn roaring64_bitmap_remove_range_closed(r: *mut roaring64_bitmap_t, min: u64, max: u64);
}
extern "C" {
#[doc = " Empties the bitmap."]
pub fn roaring64_bitmap_clear(r: *mut roaring64_bitmap_t);
}
extern "C" {
#[doc = " Returns true if the provided value is present."]
pub fn roaring64_bitmap_contains(r: *const roaring64_bitmap_t, val: u64) -> bool;
Expand Down Expand Up @@ -977,6 +981,14 @@ extern "C" {
max: u64,
) -> u64;
}
extern "C" {
#[doc = " Returns the number of elements in the range [min, max]"]
pub fn roaring64_bitmap_range_closed_cardinality(
r: *const roaring64_bitmap_t,
min: u64,
max: u64,
) -> u64;
}
extern "C" {
#[doc = " Returns true if the bitmap is empty (cardinality is zero)."]
pub fn roaring64_bitmap_is_empty(r: *const roaring64_bitmap_t) -> bool;
Expand Down
46 changes: 33 additions & 13 deletions croaring-sys/CRoaring/roaring.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// !!! DO NOT EDIT - THIS IS AN AUTO-GENERATED FILE !!!
// Created by amalgamation.sh on 2024-05-13T21:29:25Z
// Created by amalgamation.sh on 2024-07-03T21:30:32Z

/*
* The CRoaring project is under a dual license (Apache/MIT).
Expand Down Expand Up @@ -10770,7 +10770,7 @@ static bool art_node_iterator_lower_bound(const art_node_t *node,
}

art_iterator_t art_init_iterator(const art_t *art, bool first) {
art_iterator_t iterator = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
art_iterator_t iterator = CROARING_ZERO_INITIALIZER;
if (art->root == NULL) {
return iterator;
}
Expand All @@ -10793,8 +10793,11 @@ bool art_iterator_lower_bound(art_iterator_t *iterator,
// a valid key. Start from the root.
iterator->frame = 0;
iterator->depth = 0;
return art_node_iterator_lower_bound(art_iterator_node(iterator),
iterator, key);
art_node_t *root = art_iterator_node(iterator);
if (root == NULL) {
return false;
}
return art_node_iterator_lower_bound(root, iterator, key);
}
int compare_result =
art_compare_prefix(iterator->key, 0, key, 0, ART_KEY_BYTES);
Expand Down Expand Up @@ -10827,15 +10830,15 @@ bool art_iterator_lower_bound(art_iterator_t *iterator,
}

art_iterator_t art_lower_bound(const art_t *art, const art_key_chunk_t *key) {
art_iterator_t iterator = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
art_iterator_t iterator = CROARING_ZERO_INITIALIZER;
if (art->root != NULL) {
art_node_iterator_lower_bound(art->root, &iterator, key);
}
return iterator;
}

art_iterator_t art_upper_bound(const art_t *art, const art_key_chunk_t *key) {
art_iterator_t iterator = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
art_iterator_t iterator = CROARING_ZERO_INITIALIZER;
if (art->root != NULL) {
if (art_node_iterator_lower_bound(art->root, &iterator, key) &&
art_compare_keys(iterator.key, key) == 0) {
Expand Down Expand Up @@ -19469,7 +19472,7 @@ roaring_bitmap_t *roaring_bitmap_of(size_t n_args, ...) {
// todo: could be greatly optimized but we do not expect this call to ever
// include long lists
roaring_bitmap_t *answer = roaring_bitmap_create();
roaring_bulk_context_t context = {0, 0, 0, 0};
roaring_bulk_context_t context = CROARING_ZERO_INITIALIZER;
va_list ap;
va_start(ap, n_args);
for (size_t i = 0; i < n_args; i++) {
Expand Down Expand Up @@ -20811,7 +20814,7 @@ roaring_bitmap_t *roaring_bitmap_deserialize(const void *buf) {
if (bitmap == NULL) {
return NULL;
}
roaring_bulk_context_t context = {0, 0, 0, 0};
roaring_bulk_context_t context = CROARING_ZERO_INITIALIZER;
for (uint32_t i = 0; i < card; i++) {
// elems may not be aligned, read with memcpy
uint32_t elem;
Expand Down Expand Up @@ -20854,7 +20857,7 @@ roaring_bitmap_t *roaring_bitmap_deserialize_safe(const void *buf,
if (bitmap == NULL) {
return NULL;
}
roaring_bulk_context_t context = {0, 0, 0, 0};
roaring_bulk_context_t context = CROARING_ZERO_INITIALIZER;
for (uint32_t i = 0; i < card; i++) {
// elems may not be aligned, read with memcpy
uint32_t elem;
Expand Down Expand Up @@ -22780,6 +22783,9 @@ roaring64_bitmap_t *roaring64_bitmap_create(void) {
}

void roaring64_bitmap_free(roaring64_bitmap_t *r) {
if (!r) {
return;
}
art_iterator_t it = art_init_iterator(&r->art, /*first=*/true);
while (it.value != NULL) {
leaf_t *leaf = (leaf_t *)it.value;
Expand Down Expand Up @@ -22856,7 +22862,7 @@ roaring64_bitmap_t *roaring64_bitmap_of_ptr(size_t n_args,

roaring64_bitmap_t *roaring64_bitmap_of(size_t n_args, ...) {
roaring64_bitmap_t *r = roaring64_bitmap_create();
roaring64_bulk_context_t context = {0, 0, 0, 0, 0, 0, 0};
roaring64_bulk_context_t context = CROARING_ZERO_INITIALIZER;
va_list ap;
va_start(ap, n_args);
for (size_t i = 0; i < n_args; i++) {
Expand Down Expand Up @@ -22949,7 +22955,7 @@ void roaring64_bitmap_add_many(roaring64_bitmap_t *r, size_t n_args,
return;
}
const uint64_t *end = vals + n_args;
roaring64_bulk_context_t context = {0, 0, 0, 0, 0, 0, 0};
roaring64_bulk_context_t context = CROARING_ZERO_INITIALIZER;
for (const uint64_t *current_val = vals; current_val != end;
current_val++) {
roaring64_bitmap_add_bulk(r, &context, *current_val);
Expand Down Expand Up @@ -23273,7 +23279,7 @@ void roaring64_bitmap_remove_many(roaring64_bitmap_t *r, size_t n_args,
return;
}
const uint64_t *end = vals + n_args;
roaring64_bulk_context_t context = {0, 0, 0, 0, 0, 0, 0};
roaring64_bulk_context_t context = CROARING_ZERO_INITIALIZER;
for (const uint64_t *current_val = vals; current_val != end;
current_val++) {
roaring64_bitmap_remove_bulk(r, &context, *current_val);
Expand Down Expand Up @@ -23339,6 +23345,10 @@ void roaring64_bitmap_remove_range_closed(roaring64_bitmap_t *r, uint64_t min,
remove_range_closed_at(art, max_high48, 0, max_low16);
}

void roaring64_bitmap_clear(roaring64_bitmap_t *r) {
roaring64_bitmap_remove_range_closed(r, 0, UINT64_MAX);
}

uint64_t roaring64_bitmap_get_cardinality(const roaring64_bitmap_t *r) {
art_iterator_t it = art_init_iterator(&r->art, /*first=*/true);
uint64_t cardinality = 0;
Expand All @@ -23356,7 +23366,17 @@ uint64_t roaring64_bitmap_range_cardinality(const roaring64_bitmap_t *r,
if (min >= max) {
return 0;
}
max--; // A closed range is easier to work with.
// Convert to a closed range
// No underflow here: passing the above condition implies min < max, so
// there is a number less than max
return roaring64_bitmap_range_closed_cardinality(r, min, max - 1);
}

uint64_t roaring64_bitmap_range_closed_cardinality(const roaring64_bitmap_t *r,
uint64_t min, uint64_t max) {
if (min > max) {
return 0;
}

uint64_t cardinality = 0;
uint8_t min_high48[ART_KEY_BYTES];
Expand Down
Loading

0 comments on commit 32a3cfb

Please sign in to comment.