diff --git a/Cargo.lock b/Cargo.lock index c62fc55..c9f0222 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -186,7 +186,7 @@ dependencies = [ [[package]] name = "croaring-sys" -version = "4.1.1" +version = "4.1.2" dependencies = [ "cc", ] diff --git a/README.md b/README.md index 91f7c06..5afdbd2 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ Current documentation is available at https://docs.rs/croaring/latest/croaring/ ## CRoaring Version -This crate uses [CRoaring version `4.1.1`](https://github.com/RoaringBitmap/CRoaring/releases/tag/v4.1.1). +This crate uses [CRoaring version `4.1.2`](https://github.com/RoaringBitmap/CRoaring/releases/tag/v4.1.2). 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. \ No newline at end of file diff --git a/croaring-sys/CRoaring/bindgen_bundled_version.rs b/croaring-sys/CRoaring/bindgen_bundled_version.rs index afa695e..841dbc2 100644 --- a/croaring-sys/CRoaring/bindgen_bundled_version.rs +++ b/croaring-sys/CRoaring/bindgen_bundled_version.rs @@ -1,9 +1,9 @@ -/* automatically generated by rust-bindgen 0.69.4 */ +/* automatically generated by rust-bindgen 0.70.1 */ -pub const ROARING_VERSION: &[u8; 6] = b"4.1.1\0"; +pub const ROARING_VERSION: &[u8; 6] = b"4.1.2\0"; pub const ROARING_VERSION_MAJOR: _bindgen_ty_1 = 4; pub const ROARING_VERSION_MINOR: _bindgen_ty_1 = 1; -pub const ROARING_VERSION_REVISION: _bindgen_ty_1 = 1; +pub const ROARING_VERSION_REVISION: _bindgen_ty_1 = 2; pub type _bindgen_ty_1 = ::core::ffi::c_uint; extern "C" { #[doc = " result might be undefined when input_num is zero"] @@ -861,6 +861,12 @@ extern "C" { #[doc = " Creates a new bitmap of a pointer to N 64-bit integers."] pub fn roaring64_bitmap_of_ptr(n_args: usize, vals: *const u64) -> *mut roaring64_bitmap_t; } +extern "C" { + #[doc = " Create a new bitmap by moving containers from a 32 bit roaring bitmap.\n\n After calling this function, the original bitmap will be empty, and the\n returned bitmap will contain all the values from the original bitmap."] + pub fn roaring64_bitmap_move_from_roaring32( + r: *mut roaring_bitmap_t, + ) -> *mut roaring64_bitmap_t; +} extern "C" { #[doc = " Create a new bitmap containing all the values in [min, max) that are at a\n distance k*step from min."] pub fn roaring64_bitmap_from_range(min: u64, max: u64, step: u64) -> *mut roaring64_bitmap_t; diff --git a/croaring-sys/CRoaring/roaring.c b/croaring-sys/CRoaring/roaring.c index 21489cd..770df76 100644 --- a/croaring-sys/CRoaring/roaring.c +++ b/croaring-sys/CRoaring/roaring.c @@ -1,5 +1,5 @@ // !!! DO NOT EDIT - THIS IS AN AUTO-GENERATED FILE !!! -// Created by amalgamation.sh on 2024-07-30T19:32:00Z +// Created by amalgamation.sh on 2024-09-04T03:07:22Z /* * The CRoaring project is under a dual license (Apache/MIT). @@ -22868,6 +22868,43 @@ roaring64_bitmap_t *roaring64_bitmap_copy(const roaring64_bitmap_t *r) { return result; } +/** + * Steal the containers from a 32-bit bitmap and insert them into a 64-bit + * bitmap (with an offset) + * + * After calling this function, the original bitmap will be empty, and the + * returned bitmap will contain all the values from the original bitmap. + */ +static void move_from_roaring32_offset(roaring64_bitmap_t *dst, + roaring_bitmap_t *src, + uint32_t high_bits) { + uint64_t key_base = ((uint64_t)high_bits) << 32; + uint32_t r32_size = ra_get_size(&src->high_low_container); + for (uint32_t i = 0; i < r32_size; ++i) { + uint16_t key = ra_get_key_at_index(&src->high_low_container, i); + uint8_t typecode; + container_t *container = ra_get_container_at_index( + &src->high_low_container, (uint16_t)i, &typecode); + + uint8_t high48[ART_KEY_BYTES]; + uint64_t high48_bits = key_base | ((uint64_t)key << 16); + split_key(high48_bits, high48); + leaf_t *leaf = create_leaf(container, typecode); + art_insert(&dst->art, high48, (art_val_t *)leaf); + } + // We stole all the containers, so leave behind a size of zero + src->high_low_container.size = 0; +} + +roaring64_bitmap_t *roaring64_bitmap_move_from_roaring32( + roaring_bitmap_t *bitmap32) { + roaring64_bitmap_t *result = roaring64_bitmap_create(); + + move_from_roaring32_offset(result, bitmap32, 0); + + return result; +} + roaring64_bitmap_t *roaring64_bitmap_from_range(uint64_t min, uint64_t max, uint64_t step) { if (step == 0 || max <= min) { @@ -24637,22 +24674,8 @@ roaring64_bitmap_t *roaring64_bitmap_portable_deserialize_safe( read_bytes += bitmap32_size; // Insert all containers of the 32-bit bitmap into the 64-bit bitmap. - uint32_t r32_size = ra_get_size(&bitmap32->high_low_container); - for (size_t i = 0; i < r32_size; ++i) { - uint16_t key16 = - ra_get_key_at_index(&bitmap32->high_low_container, (uint16_t)i); - uint8_t typecode; - container_t *container = ra_get_container_at_index( - &bitmap32->high_low_container, (uint16_t)i, &typecode); - - uint64_t high48_bits = - (((uint64_t)high32) << 32) | (((uint64_t)key16) << 16); - uint8_t high48[ART_KEY_BYTES]; - split_key(high48_bits, high48); - leaf_t *leaf = create_leaf(container, typecode); - art_insert(&r->art, high48, (art_val_t *)leaf); - } - roaring_bitmap_free_without_containers(bitmap32); + move_from_roaring32_offset(r, bitmap32, high32); + roaring_bitmap_free(bitmap32); } return r; } diff --git a/croaring-sys/CRoaring/roaring.h b/croaring-sys/CRoaring/roaring.h index faf8587..ae34ba4 100644 --- a/croaring-sys/CRoaring/roaring.h +++ b/croaring-sys/CRoaring/roaring.h @@ -1,5 +1,5 @@ // !!! DO NOT EDIT - THIS IS AN AUTO-GENERATED FILE !!! -// Created by amalgamation.sh on 2024-07-30T19:32:00Z +// Created by amalgamation.sh on 2024-09-04T03:07:22Z /* * The CRoaring project is under a dual license (Apache/MIT). @@ -59,11 +59,11 @@ // /include/roaring/roaring_version.h automatically generated by release.py, do not change by hand #ifndef ROARING_INCLUDE_ROARING_VERSION #define ROARING_INCLUDE_ROARING_VERSION -#define ROARING_VERSION "4.1.1" +#define ROARING_VERSION "4.1.2" enum { ROARING_VERSION_MAJOR = 4, ROARING_VERSION_MINOR = 1, - ROARING_VERSION_REVISION = 1 + ROARING_VERSION_REVISION = 2 }; #endif // ROARING_INCLUDE_ROARING_VERSION // clang-format on/* end file include/roaring/roaring_version.h */ @@ -655,6 +655,8 @@ static inline uint32_t croaring_refcount_get(const croaring_refcount_t *val) { #if defined(__GNUC__) || defined(__clang__) #define CROARING_DEPRECATED __attribute__((deprecated)) +#elif defined(_MSC_VER) +#define CROARING_DEPRECATED __declspec(deprecated) #else #define CROARING_DEPRECATED #endif // defined(__GNUC__) || defined(__clang__) @@ -2260,12 +2262,12 @@ using namespace ::roaring::api; #ifndef INCLUDE_ROARING_MEMORY_H_ #define INCLUDE_ROARING_MEMORY_H_ +#include // for size_t + #ifdef __cplusplus extern "C" { #endif -#include // for size_t - typedef void* (*roaring_malloc_p)(size_t); typedef void* (*roaring_realloc_p)(void*, size_t); typedef void* (*roaring_calloc_p)(size_t, size_t); @@ -2389,6 +2391,14 @@ roaring64_bitmap_t *roaring64_bitmap_of_ptr(size_t n_args, &((const uint64_t[]){0, __VA_ARGS__})[1]) #endif +/** + * Create a new bitmap by moving containers from a 32 bit roaring bitmap. + * + * After calling this function, the original bitmap will be empty, and the + * returned bitmap will contain all the values from the original bitmap. + */ +roaring64_bitmap_t *roaring64_bitmap_move_from_roaring32(roaring_bitmap_t *r); + /** * Create a new bitmap containing all the values in [min, max) that are at a * distance k*step from min. diff --git a/croaring-sys/CRoaring/roaring.hh b/croaring-sys/CRoaring/roaring.hh index 1b292ba..820a87b 100644 --- a/croaring-sys/CRoaring/roaring.hh +++ b/croaring-sys/CRoaring/roaring.hh @@ -1,5 +1,5 @@ // !!! DO NOT EDIT - THIS IS AN AUTO-GENERATED FILE !!! -// Created by amalgamation.sh on 2024-07-30T19:32:00Z +// Created by amalgamation.sh on 2024-09-04T03:07:22Z /* * The CRoaring project is under a dual license (Apache/MIT). diff --git a/croaring-sys/Cargo.toml b/croaring-sys/Cargo.toml index d87fd16..a8ff870 100644 --- a/croaring-sys/Cargo.toml +++ b/croaring-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "croaring-sys" -version = "4.1.1" +version = "4.1.2" edition = "2021" authors = ["croaring-rs developers"] license = "Apache-2.0"