aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/croaring
diff options
context:
space:
mode:
authorAlexander Smirnov <alex@ydb.tech>2024-09-26 14:44:45 +0000
committerAlexander Smirnov <alex@ydb.tech>2024-09-26 14:44:45 +0000
commitc853e78c5e416ede1d99665049657f2e304872e4 (patch)
treeb6e2e59629b8e0f863eec9a700121ca3f7416f28 /contrib/libs/croaring
parent7d208c76420539a7e44f2393c66e7d0444744517 (diff)
parent47e779420bb80722978c1ffd518245bffd886a50 (diff)
downloadydb-c853e78c5e416ede1d99665049657f2e304872e4.tar.gz
Merge branch 'rightlib' into mergelibs-240926-1443
Diffstat (limited to 'contrib/libs/croaring')
-rw-r--r--contrib/libs/croaring/include/roaring/memory.h4
-rw-r--r--contrib/libs/croaring/include/roaring/portability.h2
-rw-r--r--contrib/libs/croaring/include/roaring/roaring64.h9
-rw-r--r--contrib/libs/croaring/include/roaring/roaring_version.h4
-rw-r--r--contrib/libs/croaring/src/roaring64.c55
-rw-r--r--contrib/libs/croaring/ya.make4
6 files changed, 56 insertions, 22 deletions
diff --git a/contrib/libs/croaring/include/roaring/memory.h b/contrib/libs/croaring/include/roaring/memory.h
index ad9a64f5e2..6ec3d348dc 100644
--- a/contrib/libs/croaring/include/roaring/memory.h
+++ b/contrib/libs/croaring/include/roaring/memory.h
@@ -1,12 +1,12 @@
#ifndef INCLUDE_ROARING_MEMORY_H_
#define INCLUDE_ROARING_MEMORY_H_
+#include <stddef.h> // for size_t
+
#ifdef __cplusplus
extern "C" {
#endif
-#include <stddef.h> // 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);
diff --git a/contrib/libs/croaring/include/roaring/portability.h b/contrib/libs/croaring/include/roaring/portability.h
index 5aebe193c9..897feedbf8 100644
--- a/contrib/libs/croaring/include/roaring/portability.h
+++ b/contrib/libs/croaring/include/roaring/portability.h
@@ -585,6 +585,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__)
diff --git a/contrib/libs/croaring/include/roaring/roaring64.h b/contrib/libs/croaring/include/roaring/roaring64.h
index c71bccb917..fd89feb5e0 100644
--- a/contrib/libs/croaring/include/roaring/roaring64.h
+++ b/contrib/libs/croaring/include/roaring/roaring64.h
@@ -1,6 +1,7 @@
#ifndef ROARING64_H
#define ROARING64_H
+#include <roaring.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
@@ -93,6 +94,14 @@ roaring64_bitmap_t *roaring64_bitmap_of_ptr(size_t n_args,
#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/contrib/libs/croaring/include/roaring/roaring_version.h b/contrib/libs/croaring/include/roaring/roaring_version.h
index 3f7519449e..0d136bbbd3 100644
--- a/contrib/libs/croaring/include/roaring/roaring_version.h
+++ b/contrib/libs/croaring/include/roaring/roaring_version.h
@@ -2,11 +2,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 \ No newline at end of file
diff --git a/contrib/libs/croaring/src/roaring64.c b/contrib/libs/croaring/src/roaring64.c
index d41507b3c4..e63d3d965c 100644
--- a/contrib/libs/croaring/src/roaring64.c
+++ b/contrib/libs/croaring/src/roaring64.c
@@ -178,6 +178,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) {
@@ -1947,22 +1984,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/contrib/libs/croaring/ya.make b/contrib/libs/croaring/ya.make
index f6a661c0b7..55acab5673 100644
--- a/contrib/libs/croaring/ya.make
+++ b/contrib/libs/croaring/ya.make
@@ -10,9 +10,9 @@ LICENSE(
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-VERSION(4.1.1)
+VERSION(4.1.2)
-ORIGINAL_SOURCE(https://github.com/RoaringBitmap/CRoaring/archive/v4.1.1.tar.gz)
+ORIGINAL_SOURCE(https://github.com/RoaringBitmap/CRoaring/archive/v4.1.2.tar.gz)
ADDINCL(
GLOBAL contrib/libs/croaring/include