Skip to content

Commit 2a6badb

Browse files
committed
Updating
1 parent fa717ab commit 2a6badb

File tree

3 files changed

+35
-29
lines changed

3 files changed

+35
-29
lines changed

roaring.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// !!! DO NOT EDIT - THIS IS AN AUTO-GENERATED FILE !!!
2-
// Created by amalgamation.sh on Sun 25 Jul 2021 12:08:33 EDT
2+
// Created by amalgamation.sh on Mon 16 Aug 2021 13:20:45 EDT
33

44
/*
55
* Copyright 2016-2020 The CRoaring authors
@@ -509,7 +509,7 @@ static inline int hamming(uint64_t x) {
509509
//
510510
// On 32-bit ARM, we would have smaller registers.
511511
//
512-
// The simdjson users should still have the fallback kernel. It is
512+
// The library should still have the fallback kernel. It is
513513
// slower, but it should run everywhere.
514514

515515
//
@@ -11569,7 +11569,8 @@ container_t *get_copy_of_container(
1156911569
* is responsible for deallocation.
1157011570
*/
1157111571
container_t *container_clone(const container_t *c, uint8_t typecode) {
11572-
c = container_unwrap_shared(c, &typecode);
11572+
// We do not want to allow cloning of shared containers.
11573+
// c = container_unwrap_shared(c, &typecode);
1157311574
switch (typecode) {
1157411575
case BITSET_CONTAINER_TYPE:
1157511576
return bitset_container_clone(const_CAST_bitset(c));
@@ -11578,8 +11579,7 @@ container_t *container_clone(const container_t *c, uint8_t typecode) {
1157811579
case RUN_CONTAINER_TYPE:
1157911580
return run_container_clone(const_CAST_run(c));
1158011581
case SHARED_CONTAINER_TYPE:
11581-
printf("shared containers are not cloneable\n");
11582-
assert(false);
11582+
// Shared containers are not cloneable. Are you mixing COW and non-COW bitmaps?
1158311583
return NULL;
1158411584
default:
1158511585
assert(false);
@@ -15282,7 +15282,6 @@ void roaring_bitmap_printf_describe(const roaring_bitmap_t *r) {
1528215282
printf("%d: %s (%d)", ra->keys[i],
1528315283
get_full_container_name(ra->containers[i], ra->typecodes[i]),
1528415284
container_get_cardinality(ra->containers[i], ra->typecodes[i]));
15285-
1528615285
if (ra->typecodes[i] == SHARED_CONTAINER_TYPE) {
1528715286
printf(
1528815287
"(shared count = %" PRIu32 " )",
@@ -15384,6 +15383,7 @@ roaring_bitmap_t *roaring_bitmap_copy(const roaring_bitmap_t *r) {
1538415383

1538515384
bool roaring_bitmap_overwrite(roaring_bitmap_t *dest,
1538615385
const roaring_bitmap_t *src) {
15386+
roaring_bitmap_set_copy_on_write(dest, is_cow(src));
1538715387
return ra_overwrite(&src->high_low_container, &dest->high_low_container,
1538815388
is_cow(src));
1538915389
}
@@ -15571,7 +15571,7 @@ roaring_bitmap_t *roaring_bitmap_and(const roaring_bitmap_t *x1,
1557115571
length2 = x2->high_low_container.size;
1557215572
uint32_t neededcap = length1 > length2 ? length2 : length1;
1557315573
roaring_bitmap_t *answer = roaring_bitmap_create_with_capacity(neededcap);
15574-
roaring_bitmap_set_copy_on_write(answer, is_cow(x1) && is_cow(x2));
15574+
roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
1557515575

1557615576
int pos1 = 0, pos2 = 0;
1557715577

@@ -15719,7 +15719,7 @@ roaring_bitmap_t *roaring_bitmap_or(const roaring_bitmap_t *x1,
1571915719
}
1572015720
roaring_bitmap_t *answer =
1572115721
roaring_bitmap_create_with_capacity(length1 + length2);
15722-
roaring_bitmap_set_copy_on_write(answer, is_cow(x1) && is_cow(x2));
15722+
roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
1572315723
int pos1 = 0, pos2 = 0;
1572415724
uint8_t type1, type2;
1572515725
uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, pos1);
@@ -15870,7 +15870,7 @@ roaring_bitmap_t *roaring_bitmap_xor(const roaring_bitmap_t *x1,
1587015870
}
1587115871
roaring_bitmap_t *answer =
1587215872
roaring_bitmap_create_with_capacity(length1 + length2);
15873-
roaring_bitmap_set_copy_on_write(answer, is_cow(x1) && is_cow(x2));
15873+
roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
1587415874
int pos1 = 0, pos2 = 0;
1587515875
uint8_t type1, type2;
1587615876
uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, pos1);
@@ -16031,14 +16031,14 @@ roaring_bitmap_t *roaring_bitmap_andnot(const roaring_bitmap_t *x1,
1603116031
length2 = x2->high_low_container.size;
1603216032
if (0 == length1) {
1603316033
roaring_bitmap_t *empty_bitmap = roaring_bitmap_create();
16034-
roaring_bitmap_set_copy_on_write(empty_bitmap, is_cow(x1) && is_cow(x2));
16034+
roaring_bitmap_set_copy_on_write(empty_bitmap, is_cow(x1) || is_cow(x2));
1603516035
return empty_bitmap;
1603616036
}
1603716037
if (0 == length2) {
1603816038
return roaring_bitmap_copy(x1);
1603916039
}
1604016040
roaring_bitmap_t *answer = roaring_bitmap_create_with_capacity(length1);
16041-
roaring_bitmap_set_copy_on_write(answer, is_cow(x1) && is_cow(x2));
16041+
roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
1604216042

1604316043
int pos1 = 0, pos2 = 0;
1604416044
uint8_t type1, type2;
@@ -17129,7 +17129,7 @@ roaring_bitmap_t *roaring_bitmap_lazy_or(const roaring_bitmap_t *x1,
1712917129
}
1713017130
roaring_bitmap_t *answer =
1713117131
roaring_bitmap_create_with_capacity(length1 + length2);
17132-
roaring_bitmap_set_copy_on_write(answer, is_cow(x1) && is_cow(x2));
17132+
roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
1713317133
int pos1 = 0, pos2 = 0;
1713417134
uint8_t type1, type2;
1713517135
uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, pos1);
@@ -17306,7 +17306,7 @@ roaring_bitmap_t *roaring_bitmap_lazy_xor(const roaring_bitmap_t *x1,
1730617306
}
1730717307
roaring_bitmap_t *answer =
1730817308
roaring_bitmap_create_with_capacity(length1 + length2);
17309-
roaring_bitmap_set_copy_on_write(answer, is_cow(x1) && is_cow(x2));
17309+
roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
1731017310
int pos1 = 0, pos2 = 0;
1731117311
uint8_t type1, type2;
1731217312
uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, pos1);

roaring.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// !!! DO NOT EDIT - THIS IS AN AUTO-GENERATED FILE !!!
2-
// Created by amalgamation.sh on Sun 25 Jul 2021 12:08:33 EDT
2+
// Created by amalgamation.sh on Mon 16 Aug 2021 13:20:45 EDT
33

44
/*
55
* Copyright 2016-2020 The CRoaring authors
@@ -23,11 +23,11 @@
2323
// /include/roaring/roaring_version.h automatically generated by release.py, do not change by hand
2424
#ifndef ROARING_INCLUDE_ROARING_VERSION
2525
#define ROARING_INCLUDE_ROARING_VERSION
26-
#define ROARING_VERSION = 0.3.3,
26+
#define ROARING_VERSION = 0.3.4,
2727
enum {
2828
ROARING_VERSION_MAJOR = 0,
2929
ROARING_VERSION_MINOR = 3,
30-
ROARING_VERSION_REVISION = 3
30+
ROARING_VERSION_REVISION = 4
3131
};
3232
#endif // ROARING_INCLUDE_ROARING_VERSION
3333
/* end file include/roaring/roaring_version.h */

roaring.hh

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// !!! DO NOT EDIT - THIS IS AN AUTO-GENERATED FILE !!!
2-
// Created by amalgamation.sh on Sun 25 Jul 2021 12:08:33 EDT
2+
// Created by amalgamation.sh on Mon 16 Aug 2021 13:20:45 EDT
33

44
/*
55
* Copyright 2016-2020 The CRoaring authors
@@ -38,6 +38,9 @@ A C++ header for Roaring Bitmaps.
3838

3939
#if !defined(ROARING_EXCEPTIONS)
4040
// Note that __cpp_exceptions is required by C++98 and we require C++11 and better.
41+
#ifndef __cpp_exceptions
42+
#error "__cpp_exceptions should be defined"
43+
#endif
4144
# if __cpp_exceptions
4245
# define ROARING_EXCEPTIONS 1
4346
# else
@@ -86,7 +89,7 @@ class Roaring {
8689
*/
8790
Roaring(const Roaring &r) : Roaring() {
8891
if (!api::roaring_bitmap_overwrite(&roaring, &r.roaring)) {
89-
ROARING_TERMINATE("failed memory alloc in constructor");
92+
ROARING_TERMINATE("failed roaring_bitmap_overwrite in constructor");
9093
}
9194
api::roaring_bitmap_set_copy_on_write(&roaring,
9295
api::roaring_bitmap_get_copy_on_write(&r.roaring));
@@ -1305,21 +1308,24 @@ class Roaring64Map {
13051308
}
13061309

13071310
/**
1308-
* Iterate over the bitmap elements. The function iterator is called once
1309-
* for all the values with ptr (can be NULL) as the second parameter of each
1310-
* call.
1311+
* Iterate over the bitmap elements in order(start from the smallest one)
1312+
* and call iterator once for every element until the iterator function returns
1313+
* false. To iterate over all values, the iterator function should always return
1314+
* true.
13111315
*
1312-
* roaring_iterator is simply a pointer to a function that returns bool
1316+
* The roaring_iterator64 parameter is a pointer to a function that returns bool
13131317
* (true means that the iteration should continue while false means that it
1314-
* should stop), and takes (uint32_t,void*) as inputs.
1318+
* should stop), and takes (uint64_t element, void* ptr) as inputs.
13151319
*/
13161320
void iterate(api::roaring_iterator64 iterator, void *ptr) const {
1317-
std::for_each(roarings.begin(), roarings.cend(),
1318-
[=](const std::pair<const uint32_t, Roaring> &map_entry) {
1319-
roaring_iterate64(&map_entry.second.roaring, iterator,
1320-
uint64_t(map_entry.first) << 32,
1321-
ptr);
1322-
});
1321+
for (const auto &map_entry : roarings) {
1322+
bool should_continue =
1323+
roaring_iterate64(&map_entry.second.roaring, iterator,
1324+
uint64_t(map_entry.first) << 32, ptr);
1325+
if (!should_continue) {
1326+
break;
1327+
}
1328+
}
13231329
}
13241330

13251331
/**

0 commit comments

Comments
 (0)