Coverage Report

Created: 2024-11-20 15:52

/var/local/thirdparty/installed/include/roaring/containers/containers.h
Line
Count
Source (jump to first uncovered line)
1
#ifndef CONTAINERS_CONTAINERS_H
2
#define CONTAINERS_CONTAINERS_H
3
4
#include <assert.h>
5
#include <stdbool.h>
6
#include <stdio.h>
7
8
#include <roaring/containers/array.h>
9
#include <roaring/containers/bitset.h>
10
#include <roaring/containers/convert.h>
11
#include <roaring/containers/mixed_andnot.h>
12
#include <roaring/containers/mixed_equal.h>
13
#include <roaring/containers/mixed_intersection.h>
14
#include <roaring/containers/mixed_negation.h>
15
#include <roaring/containers/mixed_subset.h>
16
#include <roaring/containers/mixed_union.h>
17
#include <roaring/containers/mixed_xor.h>
18
#include <roaring/containers/run.h>
19
#include <roaring/bitset_util.h>
20
21
#ifdef __cplusplus
22
extern "C" { namespace roaring { namespace internal {
23
#endif
24
25
// would enum be possible or better?
26
27
/**
28
 * The switch case statements follow
29
 * BITSET_CONTAINER_TYPE -- ARRAY_CONTAINER_TYPE -- RUN_CONTAINER_TYPE
30
 * so it makes more sense to number them 1, 2, 3 (in the vague hope that the
31
 * compiler might exploit this ordering).
32
 */
33
34
#define BITSET_CONTAINER_TYPE 1
35
#define ARRAY_CONTAINER_TYPE 2
36
#define RUN_CONTAINER_TYPE 3
37
#define SHARED_CONTAINER_TYPE 4
38
39
/**
40
 * Macros for pairing container type codes, suitable for switch statements.
41
 * Use PAIR_CONTAINER_TYPES() for the switch, CONTAINER_PAIR() for the cases:
42
 *
43
 *     switch (PAIR_CONTAINER_TYPES(type1, type2)) {
44
 *        case CONTAINER_PAIR(BITSET,ARRAY):
45
 *        ...
46
 *     }
47
 */
48
#define PAIR_CONTAINER_TYPES(type1,type2) \
49
    (4 * (type1) + (type2))
50
51
#define CONTAINER_PAIR(name1,name2) \
52
    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
53
54
/**
55
 * A shared container is a wrapper around a container
56
 * with reference counting.
57
 */
58
STRUCT_CONTAINER(shared_container_s) {
59
    container_t *container;
60
    uint8_t typecode;
61
    croaring_refcount_t counter;  // to be managed atomically
62
};
63
64
typedef struct shared_container_s shared_container_t;
65
66
#define CAST_shared(c)         CAST(shared_container_t *, c)  // safer downcast
67
#define const_CAST_shared(c)   CAST(const shared_container_t *, c)
68
#define movable_CAST_shared(c) movable_CAST(shared_container_t **, c)
69
70
/*
71
 * With copy_on_write = true
72
 *  Create a new shared container if the typecode is not SHARED_CONTAINER_TYPE,
73
 * otherwise, increase the count
74
 * If copy_on_write = false, then clone.
75
 * Return NULL in case of failure.
76
 **/
77
container_t *get_copy_of_container(container_t *container, uint8_t *typecode,
78
                                   bool copy_on_write);
79
80
/* Frees a shared container (actually decrement its counter and only frees when
81
 * the counter falls to zero). */
82
void shared_container_free(shared_container_t *container);
83
84
/* extract a copy from the shared container, freeing the shared container if
85
there is just one instance left,
86
clone instances when the counter is higher than one
87
*/
88
container_t *shared_container_extract_copy(shared_container_t *container,
89
                                           uint8_t *typecode);
90
91
/* access to container underneath */
92
static inline const container_t *container_unwrap_shared(
93
    const container_t *candidate_shared_container, uint8_t *type
94
0
){
95
0
    if (*type == SHARED_CONTAINER_TYPE) {
96
0
        *type = const_CAST_shared(candidate_shared_container)->typecode;
97
0
        assert(*type != SHARED_CONTAINER_TYPE);
98
0
        return const_CAST_shared(candidate_shared_container)->container;
99
0
    } else {
100
0
        return candidate_shared_container;
101
0
    }
102
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL23container_unwrap_sharedEPKNS_3api11container_sEPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL23container_unwrap_sharedEPKNS_3api11container_sEPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL23container_unwrap_sharedEPKNS_3api11container_sEPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL23container_unwrap_sharedEPKNS_3api11container_sEPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL23container_unwrap_sharedEPKNS_3api11container_sEPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL23container_unwrap_sharedEPKNS_3api11container_sEPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL23container_unwrap_sharedEPKNS_3api11container_sEPh
103
104
105
/* access to container underneath */
106
static inline container_t *container_mutable_unwrap_shared(
107
    container_t *c, uint8_t *type
108
0
) {
109
0
    if (*type == SHARED_CONTAINER_TYPE) {  // the passed in container is shared
110
0
        *type = CAST_shared(c)->typecode;
111
0
        assert(*type != SHARED_CONTAINER_TYPE);
112
0
        return CAST_shared(c)->container;  // return the enclosed container
113
0
    } else {
114
0
        return c;  // wasn't shared, so return as-is
115
0
    }
116
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL31container_mutable_unwrap_sharedEPNS_3api11container_sEPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL31container_mutable_unwrap_sharedEPNS_3api11container_sEPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL31container_mutable_unwrap_sharedEPNS_3api11container_sEPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL31container_mutable_unwrap_sharedEPNS_3api11container_sEPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL31container_mutable_unwrap_sharedEPNS_3api11container_sEPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL31container_mutable_unwrap_sharedEPNS_3api11container_sEPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL31container_mutable_unwrap_sharedEPNS_3api11container_sEPh
117
118
/* access to container underneath and queries its type */
119
static inline uint8_t get_container_type(
120
    const container_t *c, uint8_t type
121
0
){
122
0
    if (type == SHARED_CONTAINER_TYPE) {
123
0
        return const_CAST_shared(c)->typecode;
124
0
    } else {
125
0
        return type;
126
0
    }
127
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL18get_container_typeEPKNS_3api11container_sEh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL18get_container_typeEPKNS_3api11container_sEh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL18get_container_typeEPKNS_3api11container_sEh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL18get_container_typeEPKNS_3api11container_sEh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL18get_container_typeEPKNS_3api11container_sEh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL18get_container_typeEPKNS_3api11container_sEh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL18get_container_typeEPKNS_3api11container_sEh
128
129
/**
130
 * Copies a container, requires a typecode. This allocates new memory, caller
131
 * is responsible for deallocation. If the container is not shared, then it is
132
 * physically cloned. Sharable containers are not cloneable.
133
 */
134
container_t *container_clone(const container_t *container, uint8_t typecode);
135
136
/* access to container underneath, cloning it if needed */
137
static inline container_t *get_writable_copy_if_shared(
138
    container_t *c, uint8_t *type
139
0
){
140
0
    if (*type == SHARED_CONTAINER_TYPE) {  // shared, return enclosed container
141
0
        return shared_container_extract_copy(CAST_shared(c), type);
142
0
    } else {
143
0
        return c;  // not shared, so return as-is
144
0
    }
145
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL27get_writable_copy_if_sharedEPNS_3api11container_sEPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL27get_writable_copy_if_sharedEPNS_3api11container_sEPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL27get_writable_copy_if_sharedEPNS_3api11container_sEPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL27get_writable_copy_if_sharedEPNS_3api11container_sEPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL27get_writable_copy_if_sharedEPNS_3api11container_sEPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL27get_writable_copy_if_sharedEPNS_3api11container_sEPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL27get_writable_copy_if_sharedEPNS_3api11container_sEPh
146
147
/**
148
 * End of shared container code
149
 */
150
151
static const char *container_names[] = {"bitset", "array", "run", "shared"};
152
static const char *shared_container_names[] = {
153
    "bitset (shared)", "array (shared)", "run (shared)"};
154
155
// no matter what the initial container was, convert it to a bitset
156
// if a new container is produced, caller responsible for freeing the previous
157
// one
158
// container should not be a shared container
159
static inline bitset_container_t *container_to_bitset(
160
    container_t *c, uint8_t typecode
161
0
){
162
0
    bitset_container_t *result = NULL;
163
0
    switch (typecode) {
164
0
        case BITSET_CONTAINER_TYPE:
165
0
            return CAST_bitset(c);  // nothing to do
166
0
        case ARRAY_CONTAINER_TYPE:
167
0
            result = bitset_container_from_array(CAST_array(c));
168
0
            return result;
169
0
        case RUN_CONTAINER_TYPE:
170
0
            result = bitset_container_from_run(CAST_run(c));
171
0
            return result;
172
0
        case SHARED_CONTAINER_TYPE:
173
0
            assert(false);
174
0
            roaring_unreachable;
175
0
    }
176
0
    assert(false);
177
0
    roaring_unreachable;
178
0
    return 0;  // unreached
179
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL19container_to_bitsetEPNS_3api11container_sEh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL19container_to_bitsetEPNS_3api11container_sEh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL19container_to_bitsetEPNS_3api11container_sEh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL19container_to_bitsetEPNS_3api11container_sEh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL19container_to_bitsetEPNS_3api11container_sEh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL19container_to_bitsetEPNS_3api11container_sEh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL19container_to_bitsetEPNS_3api11container_sEh
180
181
/**
182
 * Get the container name from the typecode
183
 * (unused at time of writing)
184
 */
185
/*static inline const char *get_container_name(uint8_t typecode) {
186
    switch (typecode) {
187
        case BITSET_CONTAINER_TYPE:
188
            return container_names[0];
189
        case ARRAY_CONTAINER_TYPE:
190
            return container_names[1];
191
        case RUN_CONTAINER_TYPE:
192
            return container_names[2];
193
        case SHARED_CONTAINER_TYPE:
194
            return container_names[3];
195
        default:
196
            assert(false);
197
            roaring_unreachable;
198
            return "unknown";
199
    }
200
}*/
201
202
static inline const char *get_full_container_name(
203
    const container_t *c, uint8_t typecode
204
0
){
205
0
    switch (typecode) {
206
0
        case BITSET_CONTAINER_TYPE:
207
0
            return container_names[0];
208
0
        case ARRAY_CONTAINER_TYPE:
209
0
            return container_names[1];
210
0
        case RUN_CONTAINER_TYPE:
211
0
            return container_names[2];
212
0
        case SHARED_CONTAINER_TYPE:
213
0
            switch (const_CAST_shared(c)->typecode) {
214
0
                case BITSET_CONTAINER_TYPE:
215
0
                    return shared_container_names[0];
216
0
                case ARRAY_CONTAINER_TYPE:
217
0
                    return shared_container_names[1];
218
0
                case RUN_CONTAINER_TYPE:
219
0
                    return shared_container_names[2];
220
0
                default:
221
0
                    assert(false);
222
0
                    roaring_unreachable;
223
0
                    return "unknown";
224
0
            }
225
0
            break;
226
0
        default:
227
0
            assert(false);
228
0
            roaring_unreachable;
229
0
            return "unknown";
230
0
    }
231
0
    roaring_unreachable;
232
0
    return NULL;
233
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL23get_full_container_nameEPKNS_3api11container_sEh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL23get_full_container_nameEPKNS_3api11container_sEh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL23get_full_container_nameEPKNS_3api11container_sEh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL23get_full_container_nameEPKNS_3api11container_sEh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL23get_full_container_nameEPKNS_3api11container_sEh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL23get_full_container_nameEPKNS_3api11container_sEh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL23get_full_container_nameEPKNS_3api11container_sEh
234
235
/**
236
 * Get the container cardinality (number of elements), requires a  typecode
237
 */
238
static inline int container_get_cardinality(
239
    const container_t *c, uint8_t typecode
240
0
){
241
0
    c = container_unwrap_shared(c, &typecode);
242
0
    switch (typecode) {
243
0
        case BITSET_CONTAINER_TYPE:
244
0
            return bitset_container_cardinality(const_CAST_bitset(c));
245
0
        case ARRAY_CONTAINER_TYPE:
246
0
            return array_container_cardinality(const_CAST_array(c));
247
0
        case RUN_CONTAINER_TYPE:
248
0
            return run_container_cardinality(const_CAST_run(c));
249
0
    }
250
0
    assert(false);
251
0
    roaring_unreachable;
252
0
    return 0;  // unreached
253
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL25container_get_cardinalityEPKNS_3api11container_sEh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL25container_get_cardinalityEPKNS_3api11container_sEh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL25container_get_cardinalityEPKNS_3api11container_sEh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL25container_get_cardinalityEPKNS_3api11container_sEh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL25container_get_cardinalityEPKNS_3api11container_sEh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL25container_get_cardinalityEPKNS_3api11container_sEh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL25container_get_cardinalityEPKNS_3api11container_sEh
254
255
256
257
// returns true if a container is known to be full. Note that a lazy bitset
258
// container
259
// might be full without us knowing
260
0
static inline bool container_is_full(const container_t *c, uint8_t typecode) {
261
0
    c = container_unwrap_shared(c, &typecode);
262
0
    switch (typecode) {
263
0
        case BITSET_CONTAINER_TYPE:
264
0
            return bitset_container_cardinality(
265
0
                       const_CAST_bitset(c)) == (1 << 16);
266
0
        case ARRAY_CONTAINER_TYPE:
267
0
            return array_container_cardinality(
268
0
                       const_CAST_array(c)) == (1 << 16);
269
0
        case RUN_CONTAINER_TYPE:
270
0
            return run_container_is_full(const_CAST_run(c));
271
0
    }
272
0
    assert(false);
273
0
    roaring_unreachable;
274
0
    return 0;  // unreached
275
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL17container_is_fullEPKNS_3api11container_sEh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL17container_is_fullEPKNS_3api11container_sEh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL17container_is_fullEPKNS_3api11container_sEh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL17container_is_fullEPKNS_3api11container_sEh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL17container_is_fullEPKNS_3api11container_sEh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL17container_is_fullEPKNS_3api11container_sEh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL17container_is_fullEPKNS_3api11container_sEh
276
277
static inline int container_shrink_to_fit(
278
    container_t *c, uint8_t type
279
0
){
280
0
    c = container_mutable_unwrap_shared(c, &type);
281
0
    switch (type) {
282
0
        case BITSET_CONTAINER_TYPE:
283
0
            return 0;  // no shrinking possible
284
0
        case ARRAY_CONTAINER_TYPE:
285
0
            return array_container_shrink_to_fit(CAST_array(c));
286
0
        case RUN_CONTAINER_TYPE:
287
0
            return run_container_shrink_to_fit(CAST_run(c));
288
0
    }
289
0
    assert(false);
290
0
    roaring_unreachable;
291
0
    return 0;  // unreached
292
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL23container_shrink_to_fitEPNS_3api11container_sEh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL23container_shrink_to_fitEPNS_3api11container_sEh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL23container_shrink_to_fitEPNS_3api11container_sEh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL23container_shrink_to_fitEPNS_3api11container_sEh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL23container_shrink_to_fitEPNS_3api11container_sEh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL23container_shrink_to_fitEPNS_3api11container_sEh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL23container_shrink_to_fitEPNS_3api11container_sEh
293
294
295
/**
296
 * make a container with a run of ones
297
 */
298
/* initially always use a run container, even if an array might be
299
 * marginally
300
 * smaller */
301
static inline container_t *container_range_of_ones(
302
    uint32_t range_start, uint32_t range_end,
303
    uint8_t *result_type
304
0
){
305
0
    assert(range_end >= range_start);
306
0
    uint64_t cardinality =  range_end - range_start + 1;
307
0
    if(cardinality <= 2) {
308
0
      *result_type = ARRAY_CONTAINER_TYPE;
309
0
      return array_container_create_range(range_start, range_end);
310
0
    } else {
311
0
      *result_type = RUN_CONTAINER_TYPE;
312
0
      return run_container_create_range(range_start, range_end);
313
0
    }
314
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL23container_range_of_onesEjjPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL23container_range_of_onesEjjPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL23container_range_of_onesEjjPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL23container_range_of_onesEjjPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL23container_range_of_onesEjjPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL23container_range_of_onesEjjPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL23container_range_of_onesEjjPh
315
316
317
/*  Create a container with all the values between in [min,max) at a
318
    distance k*step from min. */
319
static inline container_t *container_from_range(
320
    uint8_t *type, uint32_t min,
321
    uint32_t max, uint16_t step
322
0
){
323
0
    if (step == 0) return NULL;  // being paranoid
324
0
    if (step == 1) {
325
0
        return container_range_of_ones(min,max,type);
326
0
        // Note: the result is not always a run (need to check the cardinality)
327
0
        //*type = RUN_CONTAINER_TYPE;
328
0
        //return run_container_create_range(min, max);
329
0
    }
330
0
    int size = (max - min + step - 1) / step;
331
0
    if (size <= DEFAULT_MAX_SIZE) {  // array container
332
0
        *type = ARRAY_CONTAINER_TYPE;
333
0
        array_container_t *array = array_container_create_given_capacity(size);
334
0
        array_container_add_from_range(array, min, max, step);
335
0
        assert(array->cardinality == size);
336
0
        return array;
337
0
    } else {  // bitset container
338
0
        *type = BITSET_CONTAINER_TYPE;
339
0
        bitset_container_t *bitset = bitset_container_create();
340
0
        bitset_container_add_from_range(bitset, min, max, step);
341
0
        assert(bitset->cardinality == size);
342
0
        return bitset;
343
0
    }
344
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL20container_from_rangeEPhjjt
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL20container_from_rangeEPhjjt
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL20container_from_rangeEPhjjt
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL20container_from_rangeEPhjjt
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL20container_from_rangeEPhjjt
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL20container_from_rangeEPhjjt
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL20container_from_rangeEPhjjt
345
346
/**
347
 * "repair" the container after lazy operations.
348
 */
349
static inline container_t *container_repair_after_lazy(
350
    container_t *c, uint8_t *type
351
0
){
352
0
    c = get_writable_copy_if_shared(c, type);  // !!! unnecessary cloning
353
0
    container_t *result = NULL;
354
0
    switch (*type) {
355
0
        case BITSET_CONTAINER_TYPE: {
356
0
            bitset_container_t *bc = CAST_bitset(c);
357
0
            bc->cardinality = bitset_container_compute_cardinality(bc);
358
0
            if (bc->cardinality <= DEFAULT_MAX_SIZE) {
359
0
                result = array_container_from_bitset(bc);
360
0
                bitset_container_free(bc);
361
0
                *type = ARRAY_CONTAINER_TYPE;
362
0
                return result;
363
0
            }
364
0
            return c; }
365
0
        case ARRAY_CONTAINER_TYPE:
366
0
            return c;  // nothing to do
367
0
        case RUN_CONTAINER_TYPE:
368
0
            return convert_run_to_efficient_container_and_free(
369
0
                            CAST_run(c), type);
370
0
        case SHARED_CONTAINER_TYPE:
371
0
            assert(false);
372
0
    }
373
0
    assert(false);
374
0
    roaring_unreachable;
375
0
    return 0;  // unreached
376
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL27container_repair_after_lazyEPNS_3api11container_sEPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL27container_repair_after_lazyEPNS_3api11container_sEPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL27container_repair_after_lazyEPNS_3api11container_sEPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL27container_repair_after_lazyEPNS_3api11container_sEPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL27container_repair_after_lazyEPNS_3api11container_sEPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL27container_repair_after_lazyEPNS_3api11container_sEPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL27container_repair_after_lazyEPNS_3api11container_sEPh
377
378
/**
379
 * Writes the underlying array to buf, outputs how many bytes were written.
380
 * This is meant to be byte-by-byte compatible with the Java and Go versions of
381
 * Roaring.
382
 * The number of bytes written should be
383
 * container_write(container, buf).
384
 *
385
 */
386
static inline int32_t container_write(
387
    const container_t *c, uint8_t typecode,
388
    char *buf
389
0
){
390
0
    c = container_unwrap_shared(c, &typecode);
391
0
    switch (typecode) {
392
0
        case BITSET_CONTAINER_TYPE:
393
0
            return bitset_container_write(const_CAST_bitset(c), buf);
394
0
        case ARRAY_CONTAINER_TYPE:
395
0
            return array_container_write(const_CAST_array(c), buf);
396
0
        case RUN_CONTAINER_TYPE:
397
0
            return run_container_write(const_CAST_run(c), buf);
398
0
    }
399
0
    assert(false);
400
0
    roaring_unreachable;
401
0
    return 0;  // unreached
402
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL15container_writeEPKNS_3api11container_sEhPc
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL15container_writeEPKNS_3api11container_sEhPc
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL15container_writeEPKNS_3api11container_sEhPc
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL15container_writeEPKNS_3api11container_sEhPc
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL15container_writeEPKNS_3api11container_sEhPc
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL15container_writeEPKNS_3api11container_sEhPc
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL15container_writeEPKNS_3api11container_sEhPc
403
404
/**
405
 * Get the container size in bytes under portable serialization (see
406
 * container_write), requires a
407
 * typecode
408
 */
409
static inline int32_t container_size_in_bytes(
410
    const container_t *c, uint8_t typecode
411
0
){
412
0
    c = container_unwrap_shared(c, &typecode);
413
0
    switch (typecode) {
414
0
        case BITSET_CONTAINER_TYPE:
415
0
            return bitset_container_size_in_bytes(const_CAST_bitset(c));
416
0
        case ARRAY_CONTAINER_TYPE:
417
0
            return array_container_size_in_bytes(const_CAST_array(c));
418
0
        case RUN_CONTAINER_TYPE:
419
0
            return run_container_size_in_bytes(const_CAST_run(c));
420
0
    }
421
0
    assert(false);
422
0
    roaring_unreachable;
423
0
    return 0;  // unreached
424
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL23container_size_in_bytesEPKNS_3api11container_sEh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL23container_size_in_bytesEPKNS_3api11container_sEh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL23container_size_in_bytesEPKNS_3api11container_sEh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL23container_size_in_bytesEPKNS_3api11container_sEh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL23container_size_in_bytesEPKNS_3api11container_sEh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL23container_size_in_bytesEPKNS_3api11container_sEh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL23container_size_in_bytesEPKNS_3api11container_sEh
425
426
/**
427
 * print the container (useful for debugging), requires a  typecode
428
 */
429
void container_printf(const container_t *container, uint8_t typecode);
430
431
/**
432
 * print the content of the container as a comma-separated list of 32-bit values
433
 * starting at base, requires a  typecode
434
 */
435
void container_printf_as_uint32_array(const container_t *container,
436
                                      uint8_t typecode, uint32_t base);
437
438
bool container_internal_validate(const container_t *container,
439
                                 uint8_t typecode, const char **reason);
440
441
/**
442
 * Checks whether a container is not empty, requires a  typecode
443
 */
444
static inline bool container_nonzero_cardinality(
445
    const container_t *c, uint8_t typecode
446
0
){
447
0
    c = container_unwrap_shared(c, &typecode);
448
0
    switch (typecode) {
449
0
        case BITSET_CONTAINER_TYPE:
450
0
            return bitset_container_const_nonzero_cardinality(
451
0
                            const_CAST_bitset(c));
452
0
        case ARRAY_CONTAINER_TYPE:
453
0
            return array_container_nonzero_cardinality(const_CAST_array(c));
454
0
        case RUN_CONTAINER_TYPE:
455
0
            return run_container_nonzero_cardinality(const_CAST_run(c));
456
0
    }
457
0
    assert(false);
458
0
    roaring_unreachable;
459
0
    return 0;  // unreached
460
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL29container_nonzero_cardinalityEPKNS_3api11container_sEh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL29container_nonzero_cardinalityEPKNS_3api11container_sEh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL29container_nonzero_cardinalityEPKNS_3api11container_sEh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL29container_nonzero_cardinalityEPKNS_3api11container_sEh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL29container_nonzero_cardinalityEPKNS_3api11container_sEh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL29container_nonzero_cardinalityEPKNS_3api11container_sEh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL29container_nonzero_cardinalityEPKNS_3api11container_sEh
461
462
/**
463
 * Recover memory from a container, requires a  typecode
464
 */
465
void container_free(container_t *container, uint8_t typecode);
466
467
/**
468
 * Convert a container to an array of values, requires a  typecode as well as a
469
 * "base" (most significant values)
470
 * Returns number of ints added.
471
 */
472
static inline int container_to_uint32_array(
473
    uint32_t *output,
474
    const container_t *c, uint8_t typecode,
475
    uint32_t base
476
0
){
477
0
    c = container_unwrap_shared(c, &typecode);
478
0
    switch (typecode) {
479
0
        case BITSET_CONTAINER_TYPE:
480
0
            return bitset_container_to_uint32_array(
481
0
                            output, const_CAST_bitset(c), base);
482
0
        case ARRAY_CONTAINER_TYPE:
483
0
            return array_container_to_uint32_array(
484
0
                            output, const_CAST_array(c), base);
485
0
        case RUN_CONTAINER_TYPE:
486
0
            return run_container_to_uint32_array(
487
0
                            output, const_CAST_run(c), base);
488
0
    }
489
0
    assert(false);
490
0
    roaring_unreachable;
491
0
    return 0;  // unreached
492
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL25container_to_uint32_arrayEPjPKNS_3api11container_sEhj
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL25container_to_uint32_arrayEPjPKNS_3api11container_sEhj
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL25container_to_uint32_arrayEPjPKNS_3api11container_sEhj
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL25container_to_uint32_arrayEPjPKNS_3api11container_sEhj
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL25container_to_uint32_arrayEPjPKNS_3api11container_sEhj
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL25container_to_uint32_arrayEPjPKNS_3api11container_sEhj
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL25container_to_uint32_arrayEPjPKNS_3api11container_sEhj
493
494
/**
495
 * Add a value to a container, requires a  typecode, fills in new_typecode and
496
 * return (possibly different) container.
497
 * This function may allocate a new container, and caller is responsible for
498
 * memory deallocation
499
 */
500
static inline container_t *container_add(
501
    container_t *c, uint16_t val,
502
    uint8_t typecode,  // !!! should be second argument?
503
    uint8_t *new_typecode
504
0
){
505
0
    c = get_writable_copy_if_shared(c, &typecode);
506
0
    switch (typecode) {
507
0
        case BITSET_CONTAINER_TYPE:
508
0
            bitset_container_set(CAST_bitset(c), val);
509
0
            *new_typecode = BITSET_CONTAINER_TYPE;
510
0
            return c;
511
0
        case ARRAY_CONTAINER_TYPE: {
512
0
            array_container_t *ac = CAST_array(c);
513
0
            if (array_container_try_add(ac, val, DEFAULT_MAX_SIZE) != -1) {
514
0
                *new_typecode = ARRAY_CONTAINER_TYPE;
515
0
                return ac;
516
0
            } else {
517
0
                bitset_container_t* bitset = bitset_container_from_array(ac);
518
0
                bitset_container_add(bitset, val);
519
0
                *new_typecode = BITSET_CONTAINER_TYPE;
520
0
                return bitset;
521
0
            }
522
0
        } break;
523
0
        case RUN_CONTAINER_TYPE:
524
0
            // per Java, no container type adjustments are done (revisit?)
525
0
            run_container_add(CAST_run(c), val);
526
0
            *new_typecode = RUN_CONTAINER_TYPE;
527
0
            return c;
528
0
        default:
529
0
            assert(false);
530
0
            roaring_unreachable;
531
0
            return NULL;
532
0
    }
533
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL13container_addEPNS_3api11container_sEthPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL13container_addEPNS_3api11container_sEthPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL13container_addEPNS_3api11container_sEthPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL13container_addEPNS_3api11container_sEthPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL13container_addEPNS_3api11container_sEthPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL13container_addEPNS_3api11container_sEthPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL13container_addEPNS_3api11container_sEthPh
534
535
/**
536
 * Remove a value from a container, requires a  typecode, fills in new_typecode
537
 * and
538
 * return (possibly different) container.
539
 * This function may allocate a new container, and caller is responsible for
540
 * memory deallocation
541
 */
542
static inline container_t *container_remove(
543
    container_t *c, uint16_t val,
544
    uint8_t typecode,  // !!! should be second argument?
545
    uint8_t *new_typecode
546
0
){
547
0
    c = get_writable_copy_if_shared(c, &typecode);
548
0
    switch (typecode) {
549
0
        case BITSET_CONTAINER_TYPE:
550
0
            if (bitset_container_remove(CAST_bitset(c), val)) {
551
0
                int card = bitset_container_cardinality(CAST_bitset(c));
552
0
                if (card <= DEFAULT_MAX_SIZE) {
553
0
                    *new_typecode = ARRAY_CONTAINER_TYPE;
554
0
                    return array_container_from_bitset(CAST_bitset(c));
555
0
                }
556
0
            }
557
0
            *new_typecode = typecode;
558
0
            return c;
559
0
        case ARRAY_CONTAINER_TYPE:
560
0
            *new_typecode = typecode;
561
0
            array_container_remove(CAST_array(c), val);
562
0
            return c;
563
0
        case RUN_CONTAINER_TYPE:
564
0
            // per Java, no container type adjustments are done (revisit?)
565
0
            run_container_remove(CAST_run(c), val);
566
0
            *new_typecode = RUN_CONTAINER_TYPE;
567
0
            return c;
568
0
        default:
569
0
            assert(false);
570
0
            roaring_unreachable;
571
0
            return NULL;
572
0
    }
573
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL16container_removeEPNS_3api11container_sEthPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL16container_removeEPNS_3api11container_sEthPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL16container_removeEPNS_3api11container_sEthPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL16container_removeEPNS_3api11container_sEthPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL16container_removeEPNS_3api11container_sEthPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL16container_removeEPNS_3api11container_sEthPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL16container_removeEPNS_3api11container_sEthPh
574
575
/**
576
 * Check whether a value is in a container, requires a  typecode
577
 */
578
static inline bool container_contains(
579
    const container_t *c,
580
    uint16_t val,
581
    uint8_t typecode  // !!! should be second argument?
582
0
){
583
0
    c = container_unwrap_shared(c, &typecode);
584
0
    switch (typecode) {
585
0
        case BITSET_CONTAINER_TYPE:
586
0
            return bitset_container_get(const_CAST_bitset(c), val);
587
0
        case ARRAY_CONTAINER_TYPE:
588
0
            return array_container_contains(const_CAST_array(c), val);
589
0
        case RUN_CONTAINER_TYPE:
590
0
            return run_container_contains(const_CAST_run(c), val);
591
0
        default:
592
0
            assert(false);
593
0
            roaring_unreachable;
594
0
            return false;
595
0
    }
596
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL18container_containsEPKNS_3api11container_sEth
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL18container_containsEPKNS_3api11container_sEth
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL18container_containsEPKNS_3api11container_sEth
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL18container_containsEPKNS_3api11container_sEth
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL18container_containsEPKNS_3api11container_sEth
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL18container_containsEPKNS_3api11container_sEth
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL18container_containsEPKNS_3api11container_sEth
597
598
/**
599
 * Check whether a range of values from range_start (included) to range_end (excluded)
600
 * is in a container, requires a typecode
601
 */
602
static inline bool container_contains_range(
603
    const container_t *c,
604
    uint32_t range_start, uint32_t range_end,
605
    uint8_t typecode  // !!! should be second argument?
606
0
){
607
0
    c = container_unwrap_shared(c, &typecode);
608
0
    switch (typecode) {
609
0
        case BITSET_CONTAINER_TYPE:
610
0
            return bitset_container_get_range(const_CAST_bitset(c),
611
0
                                                range_start, range_end);
612
0
        case ARRAY_CONTAINER_TYPE:
613
0
            return array_container_contains_range(const_CAST_array(c),
614
0
                                                    range_start, range_end);
615
0
        case RUN_CONTAINER_TYPE:
616
0
            return run_container_contains_range(const_CAST_run(c),
617
0
                                                    range_start, range_end);
618
0
        default:
619
0
            assert(false);
620
0
            roaring_unreachable;
621
0
            return false;
622
0
    }
623
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL24container_contains_rangeEPKNS_3api11container_sEjjh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL24container_contains_rangeEPKNS_3api11container_sEjjh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL24container_contains_rangeEPKNS_3api11container_sEjjh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL24container_contains_rangeEPKNS_3api11container_sEjjh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL24container_contains_rangeEPKNS_3api11container_sEjjh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL24container_contains_rangeEPKNS_3api11container_sEjjh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL24container_contains_rangeEPKNS_3api11container_sEjjh
624
625
/**
626
 * Returns true if the two containers have the same content. Note that
627
 * two containers having different types can be "equal" in this sense.
628
 */
629
static inline bool container_equals(
630
    const container_t *c1, uint8_t type1,
631
    const container_t *c2, uint8_t type2
632
0
){
633
0
    c1 = container_unwrap_shared(c1, &type1);
634
0
    c2 = container_unwrap_shared(c2, &type2);
635
0
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
636
0
        case CONTAINER_PAIR(BITSET,BITSET):
637
0
            return bitset_container_equals(const_CAST_bitset(c1),
638
0
                                           const_CAST_bitset(c2));
639
0
640
0
        case CONTAINER_PAIR(BITSET,RUN):
641
0
            return run_container_equals_bitset(const_CAST_run(c2),
642
0
                                               const_CAST_bitset(c1));
643
0
644
0
        case CONTAINER_PAIR(RUN,BITSET):
645
0
            return run_container_equals_bitset(const_CAST_run(c1),
646
0
                                               const_CAST_bitset(c2));
647
0
648
0
        case CONTAINER_PAIR(BITSET,ARRAY):
649
0
            // java would always return false?
650
0
            return array_container_equal_bitset(const_CAST_array(c2),
651
0
                                                const_CAST_bitset(c1));
652
0
653
0
        case CONTAINER_PAIR(ARRAY,BITSET):
654
0
            // java would always return false?
655
0
            return array_container_equal_bitset(const_CAST_array(c1),
656
0
                                                const_CAST_bitset(c2));
657
0
658
0
        case CONTAINER_PAIR(ARRAY,RUN):
659
0
            return run_container_equals_array(const_CAST_run(c2),
660
0
                                              const_CAST_array(c1));
661
0
662
0
        case CONTAINER_PAIR(RUN,ARRAY):
663
0
            return run_container_equals_array(const_CAST_run(c1),
664
0
                                              const_CAST_array(c2));
665
0
666
0
        case CONTAINER_PAIR(ARRAY,ARRAY):
667
0
            return array_container_equals(const_CAST_array(c1),
668
0
                                          const_CAST_array(c2));
669
0
670
0
        case CONTAINER_PAIR(RUN,RUN):
671
0
            return run_container_equals(const_CAST_run(c1),
672
0
                                        const_CAST_run(c2));
673
0
674
0
        default:
675
0
            assert(false);
676
0
            roaring_unreachable;
677
0
            return false;
678
0
    }
679
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL16container_equalsEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL16container_equalsEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL16container_equalsEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL16container_equalsEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL16container_equalsEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL16container_equalsEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL16container_equalsEPKNS_3api11container_sEhS4_h
680
681
/**
682
 * Returns true if the container c1 is a subset of the container c2. Note that
683
 * c1 can be a subset of c2 even if they have a different type.
684
 */
685
static inline bool container_is_subset(
686
    const container_t *c1, uint8_t type1,
687
    const container_t *c2, uint8_t type2
688
0
){
689
0
    c1 = container_unwrap_shared(c1, &type1);
690
0
    c2 = container_unwrap_shared(c2, &type2);
691
0
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
692
0
        case CONTAINER_PAIR(BITSET,BITSET):
693
0
            return bitset_container_is_subset(const_CAST_bitset(c1),
694
0
                                              const_CAST_bitset(c2));
695
0
696
0
        case CONTAINER_PAIR(BITSET,RUN):
697
0
            return bitset_container_is_subset_run(const_CAST_bitset(c1),
698
0
                                                  const_CAST_run(c2));
699
0
700
0
        case CONTAINER_PAIR(RUN,BITSET):
701
0
            return run_container_is_subset_bitset(const_CAST_run(c1),
702
0
                                                  const_CAST_bitset(c2));
703
0
704
0
        case CONTAINER_PAIR(BITSET,ARRAY):
705
0
            return false;  // by construction, size(c1) > size(c2)
706
0
707
0
        case CONTAINER_PAIR(ARRAY,BITSET):
708
0
            return array_container_is_subset_bitset(const_CAST_array(c1),
709
0
                                                    const_CAST_bitset(c2));
710
0
711
0
        case CONTAINER_PAIR(ARRAY,RUN):
712
0
            return array_container_is_subset_run(const_CAST_array(c1),
713
0
                                                 const_CAST_run(c2));
714
0
715
0
        case CONTAINER_PAIR(RUN,ARRAY):
716
0
            return run_container_is_subset_array(const_CAST_run(c1),
717
0
                                                 const_CAST_array(c2));
718
0
719
0
        case CONTAINER_PAIR(ARRAY,ARRAY):
720
0
            return array_container_is_subset(const_CAST_array(c1),
721
0
                                             const_CAST_array(c2));
722
0
723
0
        case CONTAINER_PAIR(RUN,RUN):
724
0
            return run_container_is_subset(const_CAST_run(c1),
725
0
                                           const_CAST_run(c2));
726
0
727
0
        default:
728
0
            assert(false);
729
0
            roaring_unreachable;
730
0
            return false;
731
0
    }
732
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL19container_is_subsetEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL19container_is_subsetEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL19container_is_subsetEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL19container_is_subsetEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL19container_is_subsetEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL19container_is_subsetEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL19container_is_subsetEPKNS_3api11container_sEhS4_h
733
734
// macro-izations possibilities for generic non-inplace binary-op dispatch
735
736
/**
737
 * Compute intersection between two containers, generate a new container (having
738
 * type result_type), requires a typecode. This allocates new memory, caller
739
 * is responsible for deallocation.
740
 */
741
static inline container_t *container_and(
742
    const container_t *c1, uint8_t type1,
743
    const container_t *c2, uint8_t type2,
744
    uint8_t *result_type
745
0
){
746
0
    c1 = container_unwrap_shared(c1, &type1);
747
0
    c2 = container_unwrap_shared(c2, &type2);
748
0
    container_t *result = NULL;
749
0
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
750
0
        case CONTAINER_PAIR(BITSET,BITSET):
751
0
            *result_type = bitset_bitset_container_intersection(
752
0
                                const_CAST_bitset(c1),
753
0
                                const_CAST_bitset(c2), &result)
754
0
                                    ? BITSET_CONTAINER_TYPE
755
0
                                    : ARRAY_CONTAINER_TYPE;
756
0
            return result;
757
0
758
0
        case CONTAINER_PAIR(ARRAY,ARRAY):
759
0
            result = array_container_create();
760
0
            array_container_intersection(const_CAST_array(c1),
761
0
                                         const_CAST_array(c2),
762
0
                                         CAST_array(result));
763
0
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
764
0
            return result;
765
0
766
0
        case CONTAINER_PAIR(RUN,RUN):
767
0
            result = run_container_create();
768
0
            run_container_intersection(const_CAST_run(c1),
769
0
                                       const_CAST_run(c2),
770
0
                                       CAST_run(result));
771
0
            return convert_run_to_efficient_container_and_free(
772
0
                        CAST_run(result), result_type);
773
0
774
0
        case CONTAINER_PAIR(BITSET,ARRAY):
775
0
            result = array_container_create();
776
0
            array_bitset_container_intersection(const_CAST_array(c2),
777
0
                                                const_CAST_bitset(c1),
778
0
                                                CAST_array(result));
779
0
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
780
0
            return result;
781
0
782
0
        case CONTAINER_PAIR(ARRAY,BITSET):
783
0
            result = array_container_create();
784
0
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
785
0
            array_bitset_container_intersection(const_CAST_array(c1),
786
0
                                                const_CAST_bitset(c2),
787
0
                                                CAST_array(result));
788
0
            return result;
789
0
790
0
        case CONTAINER_PAIR(BITSET,RUN):
791
0
            *result_type = run_bitset_container_intersection(
792
0
                                const_CAST_run(c2),
793
0
                                const_CAST_bitset(c1), &result)
794
0
                                    ? BITSET_CONTAINER_TYPE
795
0
                                    : ARRAY_CONTAINER_TYPE;
796
0
            return result;
797
0
798
0
        case CONTAINER_PAIR(RUN,BITSET):
799
0
            *result_type = run_bitset_container_intersection(
800
0
                                const_CAST_run(c1),
801
0
                                const_CAST_bitset(c2), &result)
802
0
                                    ? BITSET_CONTAINER_TYPE
803
0
                                    : ARRAY_CONTAINER_TYPE;
804
0
            return result;
805
0
806
0
        case CONTAINER_PAIR(ARRAY,RUN):
807
0
            result = array_container_create();
808
0
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
809
0
            array_run_container_intersection(const_CAST_array(c1),
810
0
                                             const_CAST_run(c2),
811
0
                                             CAST_array(result));
812
0
            return result;
813
0
814
0
        case CONTAINER_PAIR(RUN,ARRAY):
815
0
            result = array_container_create();
816
0
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
817
0
            array_run_container_intersection(const_CAST_array(c2),
818
0
                                             const_CAST_run(c1),
819
0
                                             CAST_array(result));
820
0
            return result;
821
0
822
0
        default:
823
0
            assert(false);
824
0
            roaring_unreachable;
825
0
            return NULL;
826
0
    }
827
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL13container_andEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL13container_andEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL13container_andEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL13container_andEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL13container_andEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL13container_andEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL13container_andEPKNS_3api11container_sEhS4_hPh
828
829
/**
830
 * Compute the size of the intersection between two containers.
831
 */
832
static inline int container_and_cardinality(
833
    const container_t *c1, uint8_t type1,
834
    const container_t *c2, uint8_t type2
835
0
){
836
0
    c1 = container_unwrap_shared(c1, &type1);
837
0
    c2 = container_unwrap_shared(c2, &type2);
838
0
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
839
0
        case CONTAINER_PAIR(BITSET,BITSET):
840
0
            return bitset_container_and_justcard(
841
0
                const_CAST_bitset(c1), const_CAST_bitset(c2));
842
0
843
0
        case CONTAINER_PAIR(ARRAY,ARRAY):
844
0
            return array_container_intersection_cardinality(
845
0
                const_CAST_array(c1), const_CAST_array(c2));
846
0
847
0
        case CONTAINER_PAIR(RUN,RUN):
848
0
            return run_container_intersection_cardinality(
849
0
                const_CAST_run(c1), const_CAST_run(c2));
850
0
851
0
        case CONTAINER_PAIR(BITSET,ARRAY):
852
0
            return array_bitset_container_intersection_cardinality(
853
0
                const_CAST_array(c2), const_CAST_bitset(c1));
854
0
855
0
        case CONTAINER_PAIR(ARRAY,BITSET):
856
0
            return array_bitset_container_intersection_cardinality(
857
0
                const_CAST_array(c1), const_CAST_bitset(c2));
858
0
859
0
        case CONTAINER_PAIR(BITSET,RUN):
860
0
            return run_bitset_container_intersection_cardinality(
861
0
                const_CAST_run(c2), const_CAST_bitset(c1));
862
0
863
0
        case CONTAINER_PAIR(RUN,BITSET):
864
0
            return run_bitset_container_intersection_cardinality(
865
0
                const_CAST_run(c1), const_CAST_bitset(c2));
866
0
867
0
        case CONTAINER_PAIR(ARRAY,RUN):
868
0
            return array_run_container_intersection_cardinality(
869
0
                const_CAST_array(c1), const_CAST_run(c2));
870
0
871
0
        case CONTAINER_PAIR(RUN,ARRAY):
872
0
            return array_run_container_intersection_cardinality(
873
0
                const_CAST_array(c2), const_CAST_run(c1));
874
0
875
0
        default:
876
0
            assert(false);
877
0
            roaring_unreachable;
878
0
            return 0;
879
0
    }
880
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL25container_and_cardinalityEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL25container_and_cardinalityEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL25container_and_cardinalityEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL25container_and_cardinalityEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL25container_and_cardinalityEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL25container_and_cardinalityEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL25container_and_cardinalityEPKNS_3api11container_sEhS4_h
881
882
/**
883
 * Check whether two containers intersect.
884
 */
885
static inline bool container_intersect(
886
    const container_t *c1, uint8_t type1,
887
    const container_t *c2, uint8_t type2
888
0
){
889
0
    c1 = container_unwrap_shared(c1, &type1);
890
0
    c2 = container_unwrap_shared(c2, &type2);
891
0
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
892
0
        case CONTAINER_PAIR(BITSET,BITSET):
893
0
            return bitset_container_intersect(const_CAST_bitset(c1),
894
0
                                              const_CAST_bitset(c2));
895
0
896
0
        case CONTAINER_PAIR(ARRAY,ARRAY):
897
0
            return array_container_intersect(const_CAST_array(c1),
898
0
                                             const_CAST_array(c2));
899
0
900
0
        case CONTAINER_PAIR(RUN,RUN):
901
0
            return run_container_intersect(const_CAST_run(c1),
902
0
                                           const_CAST_run(c2));
903
0
904
0
        case CONTAINER_PAIR(BITSET,ARRAY):
905
0
            return array_bitset_container_intersect(const_CAST_array(c2),
906
0
                                                    const_CAST_bitset(c1));
907
0
908
0
        case CONTAINER_PAIR(ARRAY,BITSET):
909
0
            return array_bitset_container_intersect(const_CAST_array(c1),
910
0
                                                    const_CAST_bitset(c2));
911
0
912
0
        case CONTAINER_PAIR(BITSET,RUN):
913
0
            return run_bitset_container_intersect(const_CAST_run(c2),
914
0
                                                  const_CAST_bitset(c1));
915
0
916
0
        case CONTAINER_PAIR(RUN,BITSET):
917
0
            return run_bitset_container_intersect(const_CAST_run(c1),
918
0
                                                  const_CAST_bitset(c2));
919
0
920
0
        case CONTAINER_PAIR(ARRAY,RUN):
921
0
            return array_run_container_intersect(const_CAST_array(c1),
922
0
                                                 const_CAST_run(c2));
923
0
924
0
        case CONTAINER_PAIR(RUN,ARRAY):
925
0
            return array_run_container_intersect(const_CAST_array(c2),
926
0
                                                 const_CAST_run(c1));
927
0
928
0
        default:
929
0
            assert(false);
930
0
            roaring_unreachable;
931
0
            return 0;
932
0
    }
933
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL19container_intersectEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL19container_intersectEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL19container_intersectEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL19container_intersectEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL19container_intersectEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL19container_intersectEPKNS_3api11container_sEhS4_h
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL19container_intersectEPKNS_3api11container_sEhS4_h
934
935
/**
936
 * Compute intersection between two containers, with result in the first
937
 container if possible. If the returned pointer is identical to c1,
938
 then the container has been modified. If the returned pointer is different
939
 from c1, then a new container has been created and the caller is responsible
940
 for freeing it.
941
 The type of the first container may change. Returns the modified
942
 (and possibly new) container.
943
*/
944
static inline container_t *container_iand(
945
    container_t *c1, uint8_t type1,
946
    const container_t *c2, uint8_t type2,
947
    uint8_t *result_type
948
0
){
949
0
    c1 = get_writable_copy_if_shared(c1, &type1);
950
0
    c2 = container_unwrap_shared(c2, &type2);
951
0
    container_t *result = NULL;
952
0
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
953
0
        case CONTAINER_PAIR(BITSET,BITSET):
954
0
            *result_type =
955
0
                bitset_bitset_container_intersection_inplace(
956
0
                    CAST_bitset(c1), const_CAST_bitset(c2), &result)
957
0
                        ? BITSET_CONTAINER_TYPE
958
0
                        : ARRAY_CONTAINER_TYPE;
959
0
            return result;
960
0
961
0
        case CONTAINER_PAIR(ARRAY,ARRAY):
962
0
            array_container_intersection_inplace(CAST_array(c1),
963
0
                                                 const_CAST_array(c2));
964
0
            *result_type = ARRAY_CONTAINER_TYPE;
965
0
            return c1;
966
0
967
0
        case CONTAINER_PAIR(RUN,RUN):
968
0
            result = run_container_create();
969
0
            run_container_intersection(const_CAST_run(c1),
970
0
                                       const_CAST_run(c2),
971
0
                                       CAST_run(result));
972
0
            // as of January 2016, Java code used non-in-place intersection for
973
0
            // two runcontainers
974
0
            return convert_run_to_efficient_container_and_free(
975
0
                            CAST_run(result), result_type);
976
0
977
0
        case CONTAINER_PAIR(BITSET,ARRAY):
978
0
            // c1 is a bitmap so no inplace possible
979
0
            result = array_container_create();
980
0
            array_bitset_container_intersection(const_CAST_array(c2),
981
0
                                                const_CAST_bitset(c1),
982
0
                                                CAST_array(result));
983
0
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
984
0
            return result;
985
0
986
0
        case CONTAINER_PAIR(ARRAY,BITSET):
987
0
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
988
0
            array_bitset_container_intersection(
989
0
                    const_CAST_array(c1), const_CAST_bitset(c2),
990
0
                    CAST_array(c1));  // result is allowed to be same as c1
991
0
            return c1;
992
0
993
0
        case CONTAINER_PAIR(BITSET,RUN):
994
0
            // will attempt in-place computation
995
0
            *result_type = run_bitset_container_intersection(
996
0
                                const_CAST_run(c2),
997
0
                                const_CAST_bitset(c1), &c1)
998
0
                                    ? BITSET_CONTAINER_TYPE
999
0
                                    : ARRAY_CONTAINER_TYPE;
1000
0
            return c1;
1001
0
1002
0
        case CONTAINER_PAIR(RUN,BITSET):
1003
0
            *result_type = run_bitset_container_intersection(
1004
0
                                const_CAST_run(c1),
1005
0
                                const_CAST_bitset(c2), &result)
1006
0
                                    ? BITSET_CONTAINER_TYPE
1007
0
                                    : ARRAY_CONTAINER_TYPE;
1008
0
            return result;
1009
0
1010
0
        case CONTAINER_PAIR(ARRAY,RUN):
1011
0
            result = array_container_create();
1012
0
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
1013
0
            array_run_container_intersection(const_CAST_array(c1),
1014
0
                                             const_CAST_run(c2),
1015
0
                                             CAST_array(result));
1016
0
            return result;
1017
0
1018
0
        case CONTAINER_PAIR(RUN,ARRAY):
1019
0
            result = array_container_create();
1020
0
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
1021
0
            array_run_container_intersection(const_CAST_array(c2),
1022
0
                                             const_CAST_run(c1),
1023
0
                                             CAST_array(result));
1024
0
            return result;
1025
0
1026
0
        default:
1027
0
            assert(false);
1028
0
            roaring_unreachable;
1029
0
            return NULL;
1030
0
    }
1031
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL14container_iandEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL14container_iandEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL14container_iandEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL14container_iandEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL14container_iandEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL14container_iandEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL14container_iandEPNS_3api11container_sEhPKS2_hPh
1032
1033
/**
1034
 * Compute union between two containers, generate a new container (having type
1035
 * result_type), requires a typecode. This allocates new memory, caller
1036
 * is responsible for deallocation.
1037
 */
1038
static inline container_t *container_or(
1039
    const container_t *c1, uint8_t type1,
1040
    const container_t *c2, uint8_t type2,
1041
    uint8_t *result_type
1042
0
){
1043
0
    c1 = container_unwrap_shared(c1, &type1);
1044
0
    c2 = container_unwrap_shared(c2, &type2);
1045
0
    container_t *result = NULL;
1046
0
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1047
0
        case CONTAINER_PAIR(BITSET,BITSET):
1048
0
            result = bitset_container_create();
1049
0
            bitset_container_or(const_CAST_bitset(c1),
1050
0
                                const_CAST_bitset(c2),
1051
0
                                CAST_bitset(result));
1052
0
            *result_type = BITSET_CONTAINER_TYPE;
1053
0
            return result;
1054
0
1055
0
        case CONTAINER_PAIR(ARRAY,ARRAY):
1056
0
            *result_type = array_array_container_union(
1057
0
                                const_CAST_array(c1),
1058
0
                                const_CAST_array(c2), &result)
1059
0
                                    ? BITSET_CONTAINER_TYPE
1060
0
                                    : ARRAY_CONTAINER_TYPE;
1061
0
            return result;
1062
0
1063
0
        case CONTAINER_PAIR(RUN,RUN):
1064
0
            result = run_container_create();
1065
0
            run_container_union(const_CAST_run(c1),
1066
0
                                const_CAST_run(c2),
1067
0
                                CAST_run(result));
1068
0
            *result_type = RUN_CONTAINER_TYPE;
1069
0
            // todo: could be optimized since will never convert to array
1070
0
            result = convert_run_to_efficient_container_and_free(
1071
0
                            CAST_run(result), result_type);
1072
0
            return result;
1073
0
1074
0
        case CONTAINER_PAIR(BITSET,ARRAY):
1075
0
            result = bitset_container_create();
1076
0
            array_bitset_container_union(const_CAST_array(c2),
1077
0
                                         const_CAST_bitset(c1),
1078
0
                                         CAST_bitset(result));
1079
0
            *result_type = BITSET_CONTAINER_TYPE;
1080
0
            return result;
1081
0
1082
0
        case CONTAINER_PAIR(ARRAY,BITSET):
1083
0
            result = bitset_container_create();
1084
0
            array_bitset_container_union(const_CAST_array(c1),
1085
0
                                         const_CAST_bitset(c2),
1086
0
                                         CAST_bitset(result));
1087
0
            *result_type = BITSET_CONTAINER_TYPE;
1088
0
            return result;
1089
0
1090
0
        case CONTAINER_PAIR(BITSET,RUN):
1091
0
            if (run_container_is_full(const_CAST_run(c2))) {
1092
0
                result = run_container_create();
1093
0
                *result_type = RUN_CONTAINER_TYPE;
1094
0
                run_container_copy(const_CAST_run(c2),
1095
0
                                   CAST_run(result));
1096
0
                return result;
1097
0
            }
1098
0
            result = bitset_container_create();
1099
0
            run_bitset_container_union(const_CAST_run(c2),
1100
0
                                       const_CAST_bitset(c1),
1101
0
                                       CAST_bitset(result));
1102
0
            *result_type = BITSET_CONTAINER_TYPE;
1103
0
            return result;
1104
0
1105
0
        case CONTAINER_PAIR(RUN,BITSET):
1106
0
            if (run_container_is_full(const_CAST_run(c1))) {
1107
0
                result = run_container_create();
1108
0
                *result_type = RUN_CONTAINER_TYPE;
1109
0
                run_container_copy(const_CAST_run(c1),
1110
0
                                   CAST_run(result));
1111
0
                return result;
1112
0
            }
1113
0
            result = bitset_container_create();
1114
0
            run_bitset_container_union(const_CAST_run(c1),
1115
0
                                       const_CAST_bitset(c2),
1116
0
                                       CAST_bitset(result));
1117
0
            *result_type = BITSET_CONTAINER_TYPE;
1118
0
            return result;
1119
0
1120
0
        case CONTAINER_PAIR(ARRAY,RUN):
1121
0
            result = run_container_create();
1122
0
            array_run_container_union(const_CAST_array(c1),
1123
0
                                      const_CAST_run(c2),
1124
0
                                      CAST_run(result));
1125
0
            result = convert_run_to_efficient_container_and_free(
1126
0
                            CAST_run(result), result_type);
1127
0
            return result;
1128
0
1129
0
        case CONTAINER_PAIR(RUN,ARRAY):
1130
0
            result = run_container_create();
1131
0
            array_run_container_union(const_CAST_array(c2),
1132
0
                                      const_CAST_run(c1),
1133
0
                                      CAST_run(result));
1134
0
            result = convert_run_to_efficient_container_and_free(
1135
0
                            CAST_run(result), result_type);
1136
0
            return result;
1137
0
1138
0
        default:
1139
0
            assert(false);
1140
0
            roaring_unreachable;
1141
0
            return NULL;  // unreached
1142
0
    }
1143
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL12container_orEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL12container_orEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL12container_orEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL12container_orEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL12container_orEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL12container_orEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL12container_orEPKNS_3api11container_sEhS4_hPh
1144
1145
/**
1146
 * Compute union between two containers, generate a new container (having type
1147
 * result_type), requires a typecode. This allocates new memory, caller
1148
 * is responsible for deallocation.
1149
 *
1150
 * This lazy version delays some operations such as the maintenance of the
1151
 * cardinality. It requires repair later on the generated containers.
1152
 */
1153
static inline container_t *container_lazy_or(
1154
    const container_t *c1, uint8_t type1,
1155
    const container_t *c2, uint8_t type2,
1156
    uint8_t *result_type
1157
0
){
1158
0
    c1 = container_unwrap_shared(c1, &type1);
1159
0
    c2 = container_unwrap_shared(c2, &type2);
1160
0
    container_t *result = NULL;
1161
0
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1162
0
        case CONTAINER_PAIR(BITSET,BITSET):
1163
0
            result = bitset_container_create();
1164
0
            bitset_container_or_nocard(
1165
0
                    const_CAST_bitset(c1), const_CAST_bitset(c2),
1166
0
                    CAST_bitset(result));  // is lazy
1167
0
            *result_type = BITSET_CONTAINER_TYPE;
1168
0
            return result;
1169
0
1170
0
        case CONTAINER_PAIR(ARRAY,ARRAY):
1171
0
            *result_type = array_array_container_lazy_union(
1172
0
                                const_CAST_array(c1),
1173
0
                                const_CAST_array(c2), &result)
1174
0
                                    ? BITSET_CONTAINER_TYPE
1175
0
                                    : ARRAY_CONTAINER_TYPE;
1176
0
            return result;
1177
0
1178
0
        case CONTAINER_PAIR(RUN,RUN):
1179
0
            result = run_container_create();
1180
0
            run_container_union(const_CAST_run(c1),
1181
0
                                const_CAST_run(c2),
1182
0
                                CAST_run(result));
1183
0
            *result_type = RUN_CONTAINER_TYPE;
1184
0
            // we are being lazy
1185
0
            result = convert_run_to_efficient_container_and_free(
1186
0
                CAST_run(result), result_type);
1187
0
            return result;
1188
0
1189
0
        case CONTAINER_PAIR(BITSET,ARRAY):
1190
0
            result = bitset_container_create();
1191
0
            array_bitset_container_lazy_union(
1192
0
                    const_CAST_array(c2), const_CAST_bitset(c1),
1193
0
                    CAST_bitset(result));  // is lazy
1194
0
            *result_type = BITSET_CONTAINER_TYPE;
1195
0
            return result;
1196
0
1197
0
        case CONTAINER_PAIR(ARRAY,BITSET):
1198
0
            result = bitset_container_create();
1199
0
            array_bitset_container_lazy_union(
1200
0
                    const_CAST_array(c1), const_CAST_bitset(c2),
1201
0
                    CAST_bitset(result));  // is lazy
1202
0
            *result_type = BITSET_CONTAINER_TYPE;
1203
0
            return result;
1204
0
1205
0
        case CONTAINER_PAIR(BITSET,RUN):
1206
0
            if (run_container_is_full(const_CAST_run(c2))) {
1207
0
                result = run_container_create();
1208
0
                *result_type = RUN_CONTAINER_TYPE;
1209
0
                run_container_copy(const_CAST_run(c2), CAST_run(result));
1210
0
                return result;
1211
0
            }
1212
0
            result = bitset_container_create();
1213
0
            run_bitset_container_lazy_union(
1214
0
                const_CAST_run(c2), const_CAST_bitset(c1),
1215
0
                CAST_bitset(result));  // is lazy
1216
0
            *result_type = BITSET_CONTAINER_TYPE;
1217
0
            return result;
1218
0
1219
0
        case CONTAINER_PAIR(RUN,BITSET):
1220
0
            if (run_container_is_full(const_CAST_run(c1))) {
1221
0
                result = run_container_create();
1222
0
                *result_type = RUN_CONTAINER_TYPE;
1223
0
                run_container_copy(const_CAST_run(c1), CAST_run(result));
1224
0
                return result;
1225
0
            }
1226
0
            result = bitset_container_create();
1227
0
            run_bitset_container_lazy_union(
1228
0
                const_CAST_run(c1), const_CAST_bitset(c2),
1229
0
                CAST_bitset(result));  // is lazy
1230
0
            *result_type = BITSET_CONTAINER_TYPE;
1231
0
            return result;
1232
0
1233
0
        case CONTAINER_PAIR(ARRAY,RUN):
1234
0
            result = run_container_create();
1235
0
            array_run_container_union(const_CAST_array(c1),
1236
0
                                      const_CAST_run(c2),
1237
0
                                      CAST_run(result));
1238
0
            *result_type = RUN_CONTAINER_TYPE;
1239
0
            // next line skipped since we are lazy
1240
0
            // result = convert_run_to_efficient_container(result, result_type);
1241
0
            return result;
1242
0
1243
0
        case CONTAINER_PAIR(RUN,ARRAY):
1244
0
            result = run_container_create();
1245
0
            array_run_container_union(
1246
0
                const_CAST_array(c2), const_CAST_run(c1),
1247
0
                CAST_run(result));  // TODO make lazy
1248
0
            *result_type = RUN_CONTAINER_TYPE;
1249
0
            // next line skipped since we are lazy
1250
0
            // result = convert_run_to_efficient_container(result, result_type);
1251
0
            return result;
1252
0
1253
0
        default:
1254
0
            assert(false);
1255
0
            roaring_unreachable;
1256
0
            return NULL;  // unreached
1257
0
    }
1258
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL17container_lazy_orEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL17container_lazy_orEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL17container_lazy_orEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL17container_lazy_orEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL17container_lazy_orEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL17container_lazy_orEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL17container_lazy_orEPKNS_3api11container_sEhS4_hPh
1259
1260
/**
1261
 * Compute the union between two containers, with result in the first container.
1262
 * If the returned pointer is identical to c1, then the container has been
1263
 * modified.
1264
 * If the returned pointer is different from c1, then a new container has been
1265
 * created and the caller is responsible for freeing it.
1266
 * The type of the first container may change. Returns the modified
1267
 * (and possibly new) container
1268
*/
1269
static inline container_t *container_ior(
1270
    container_t *c1, uint8_t type1,
1271
    const container_t *c2, uint8_t type2,
1272
    uint8_t *result_type
1273
0
){
1274
0
    c1 = get_writable_copy_if_shared(c1, &type1);
1275
0
    c2 = container_unwrap_shared(c2, &type2);
1276
0
    container_t *result = NULL;
1277
0
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1278
0
        case CONTAINER_PAIR(BITSET,BITSET):
1279
0
            bitset_container_or(const_CAST_bitset(c1),
1280
0
                                const_CAST_bitset(c2),
1281
0
                                CAST_bitset(c1));
1282
0
#ifdef OR_BITSET_CONVERSION_TO_FULL
1283
0
            if (CAST_bitset(c1)->cardinality == (1 << 16)) {  // we convert
1284
0
                result = run_container_create_range(0, (1 << 16));
1285
0
                *result_type = RUN_CONTAINER_TYPE;
1286
0
                return result;
1287
0
            }
1288
0
#endif
1289
0
            *result_type = BITSET_CONTAINER_TYPE;
1290
0
            return c1;
1291
0
1292
0
        case CONTAINER_PAIR(ARRAY,ARRAY):
1293
0
            *result_type = array_array_container_inplace_union(
1294
0
                                CAST_array(c1), const_CAST_array(c2), &result)
1295
0
                                    ? BITSET_CONTAINER_TYPE
1296
0
                                    : ARRAY_CONTAINER_TYPE;
1297
0
            if((result == NULL)
1298
0
               && (*result_type == ARRAY_CONTAINER_TYPE)) {
1299
0
                 return c1; // the computation was done in-place!
1300
0
            }
1301
0
            return result;
1302
0
1303
0
        case CONTAINER_PAIR(RUN,RUN):
1304
0
            run_container_union_inplace(CAST_run(c1), const_CAST_run(c2));
1305
0
            return convert_run_to_efficient_container(CAST_run(c1),
1306
0
                                                      result_type);
1307
0
1308
0
        case CONTAINER_PAIR(BITSET,ARRAY):
1309
0
            array_bitset_container_union(const_CAST_array(c2),
1310
0
                                         const_CAST_bitset(c1),
1311
0
                                         CAST_bitset(c1));
1312
0
            *result_type = BITSET_CONTAINER_TYPE;  // never array
1313
0
            return c1;
1314
0
1315
0
        case CONTAINER_PAIR(ARRAY,BITSET):
1316
0
            // c1 is an array, so no in-place possible
1317
0
            result = bitset_container_create();
1318
0
            *result_type = BITSET_CONTAINER_TYPE;
1319
0
            array_bitset_container_union(const_CAST_array(c1),
1320
0
                                         const_CAST_bitset(c2),
1321
0
                                         CAST_bitset(result));
1322
0
            return result;
1323
0
1324
0
        case CONTAINER_PAIR(BITSET,RUN):
1325
0
            if (run_container_is_full(const_CAST_run(c2))) {
1326
0
                result = run_container_create();
1327
0
                *result_type = RUN_CONTAINER_TYPE;
1328
0
                run_container_copy(const_CAST_run(c2), CAST_run(result));
1329
0
                return result;
1330
0
            }
1331
0
            run_bitset_container_union(const_CAST_run(c2),
1332
0
                                       const_CAST_bitset(c1),
1333
0
                                       CAST_bitset(c1));  // allowed
1334
0
            *result_type = BITSET_CONTAINER_TYPE;
1335
0
            return c1;
1336
0
1337
0
        case CONTAINER_PAIR(RUN,BITSET):
1338
0
            if (run_container_is_full(const_CAST_run(c1))) {
1339
0
                *result_type = RUN_CONTAINER_TYPE;
1340
0
                return c1;
1341
0
            }
1342
0
            result = bitset_container_create();
1343
0
            run_bitset_container_union(const_CAST_run(c1),
1344
0
                                       const_CAST_bitset(c2),
1345
0
                                       CAST_bitset(result));
1346
0
            *result_type = BITSET_CONTAINER_TYPE;
1347
0
            return result;
1348
0
1349
0
        case CONTAINER_PAIR(ARRAY,RUN):
1350
0
            result = run_container_create();
1351
0
            array_run_container_union(const_CAST_array(c1),
1352
0
                                      const_CAST_run(c2),
1353
0
                                      CAST_run(result));
1354
0
            result = convert_run_to_efficient_container_and_free(
1355
0
                            CAST_run(result), result_type);
1356
0
            return result;
1357
0
1358
0
        case CONTAINER_PAIR(RUN,ARRAY):
1359
0
            array_run_container_inplace_union(const_CAST_array(c2),
1360
0
                                              CAST_run(c1));
1361
0
            c1 = convert_run_to_efficient_container(CAST_run(c1),
1362
0
                                                    result_type);
1363
0
            return c1;
1364
0
1365
0
        default:
1366
0
            assert(false);
1367
0
            roaring_unreachable;
1368
0
            return NULL;
1369
0
    }
1370
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL13container_iorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL13container_iorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL13container_iorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL13container_iorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL13container_iorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL13container_iorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL13container_iorEPNS_3api11container_sEhPKS2_hPh
1371
1372
/**
1373
 * Compute the union between two containers, with result in the first container.
1374
 * If the returned pointer is identical to c1, then the container has been
1375
 * modified.
1376
 * If the returned pointer is different from c1, then a new container has been
1377
 * created and the caller is responsible for freeing it.
1378
 * The type of the first container may change. Returns the modified
1379
 * (and possibly new) container
1380
 *
1381
 * This lazy version delays some operations such as the maintenance of the
1382
 * cardinality. It requires repair later on the generated containers.
1383
*/
1384
static inline container_t *container_lazy_ior(
1385
    container_t *c1, uint8_t type1,
1386
    const container_t *c2, uint8_t type2,
1387
    uint8_t *result_type
1388
0
){
1389
0
    assert(type1 != SHARED_CONTAINER_TYPE);
1390
0
    // c1 = get_writable_copy_if_shared(c1,&type1);
1391
0
    c2 = container_unwrap_shared(c2, &type2);
1392
0
    container_t *result = NULL;
1393
0
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1394
0
        case CONTAINER_PAIR(BITSET,BITSET):
1395
0
#ifdef LAZY_OR_BITSET_CONVERSION_TO_FULL
1396
0
            // if we have two bitsets, we might as well compute the cardinality
1397
0
            bitset_container_or(const_CAST_bitset(c1),
1398
0
                                const_CAST_bitset(c2),
1399
0
                                CAST_bitset(c1));
1400
0
            // it is possible that two bitsets can lead to a full container
1401
0
            if (CAST_bitset(c1)->cardinality == (1 << 16)) {  // we convert
1402
0
                result = run_container_create_range(0, (1 << 16));
1403
0
                *result_type = RUN_CONTAINER_TYPE;
1404
0
                return result;
1405
0
            }
1406
0
#else
1407
0
            bitset_container_or_nocard(const_CAST_bitset(c1),
1408
0
                                       const_CAST_bitset(c2),
1409
0
                                       CAST_bitset(c1));
1410
0
1411
0
#endif
1412
0
            *result_type = BITSET_CONTAINER_TYPE;
1413
0
            return c1;
1414
0
1415
0
        case CONTAINER_PAIR(ARRAY,ARRAY):
1416
0
            *result_type = array_array_container_lazy_inplace_union(
1417
0
                                CAST_array(c1),
1418
0
                                const_CAST_array(c2), &result)
1419
0
                                    ? BITSET_CONTAINER_TYPE
1420
0
                                    : ARRAY_CONTAINER_TYPE;
1421
0
            if((result == NULL)
1422
0
               && (*result_type == ARRAY_CONTAINER_TYPE)) {
1423
0
                 return c1; // the computation was done in-place!
1424
0
            }
1425
0
            return result;
1426
0
1427
0
        case CONTAINER_PAIR(RUN,RUN):
1428
0
            run_container_union_inplace(CAST_run(c1),
1429
0
                                        const_CAST_run(c2));
1430
0
            *result_type = RUN_CONTAINER_TYPE;
1431
0
            return convert_run_to_efficient_container(CAST_run(c1),
1432
0
                                                      result_type);
1433
0
1434
0
        case CONTAINER_PAIR(BITSET,ARRAY):
1435
0
            array_bitset_container_lazy_union(
1436
0
                    const_CAST_array(c2), const_CAST_bitset(c1),
1437
0
                    CAST_bitset(c1));              // is lazy
1438
0
            *result_type = BITSET_CONTAINER_TYPE;  // never array
1439
0
            return c1;
1440
0
1441
0
        case CONTAINER_PAIR(ARRAY,BITSET):
1442
0
            // c1 is an array, so no in-place possible
1443
0
            result = bitset_container_create();
1444
0
            *result_type = BITSET_CONTAINER_TYPE;
1445
0
            array_bitset_container_lazy_union(
1446
0
                    const_CAST_array(c1), const_CAST_bitset(c2),
1447
0
                    CAST_bitset(result));  // is lazy
1448
0
            return result;
1449
0
1450
0
        case CONTAINER_PAIR(BITSET,RUN):
1451
0
            if (run_container_is_full(const_CAST_run(c2))) {
1452
0
                result = run_container_create();
1453
0
                *result_type = RUN_CONTAINER_TYPE;
1454
0
                run_container_copy(const_CAST_run(c2),
1455
0
                                   CAST_run(result));
1456
0
                return result;
1457
0
            }
1458
0
            run_bitset_container_lazy_union(
1459
0
                const_CAST_run(c2), const_CAST_bitset(c1),
1460
0
                CAST_bitset(c1));  // allowed //  lazy
1461
0
            *result_type = BITSET_CONTAINER_TYPE;
1462
0
            return c1;
1463
0
1464
0
        case CONTAINER_PAIR(RUN,BITSET):
1465
0
            if (run_container_is_full(const_CAST_run(c1))) {
1466
0
                *result_type = RUN_CONTAINER_TYPE;
1467
0
                return c1;
1468
0
            }
1469
0
            result = bitset_container_create();
1470
0
            run_bitset_container_lazy_union(
1471
0
                const_CAST_run(c1), const_CAST_bitset(c2),
1472
0
                CAST_bitset(result));  //  lazy
1473
0
            *result_type = BITSET_CONTAINER_TYPE;
1474
0
            return result;
1475
0
1476
0
        case CONTAINER_PAIR(ARRAY,RUN):
1477
0
            result = run_container_create();
1478
0
            array_run_container_union(const_CAST_array(c1),
1479
0
                                      const_CAST_run(c2),
1480
0
                                      CAST_run(result));
1481
0
            *result_type = RUN_CONTAINER_TYPE;
1482
0
            // next line skipped since we are lazy
1483
0
            // result = convert_run_to_efficient_container_and_free(result,
1484
0
            // result_type);
1485
0
            return result;
1486
0
1487
0
        case CONTAINER_PAIR(RUN,ARRAY):
1488
0
            array_run_container_inplace_union(const_CAST_array(c2),
1489
0
                                              CAST_run(c1));
1490
0
            *result_type = RUN_CONTAINER_TYPE;
1491
0
            // next line skipped since we are lazy
1492
0
            // result = convert_run_to_efficient_container_and_free(result,
1493
0
            // result_type);
1494
0
            return c1;
1495
0
1496
0
        default:
1497
0
            assert(false);
1498
0
            roaring_unreachable;
1499
0
            return NULL;
1500
0
    }
1501
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL18container_lazy_iorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL18container_lazy_iorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL18container_lazy_iorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL18container_lazy_iorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL18container_lazy_iorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL18container_lazy_iorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL18container_lazy_iorEPNS_3api11container_sEhPKS2_hPh
1502
1503
/**
1504
 * Compute symmetric difference (xor) between two containers, generate a new
1505
 * container (having type result_type), requires a typecode. This allocates new
1506
 * memory, caller is responsible for deallocation.
1507
 */
1508
static inline container_t* container_xor(
1509
    const container_t *c1, uint8_t type1,
1510
    const container_t *c2, uint8_t type2,
1511
    uint8_t *result_type
1512
0
){
1513
0
    c1 = container_unwrap_shared(c1, &type1);
1514
0
    c2 = container_unwrap_shared(c2, &type2);
1515
0
    container_t *result = NULL;
1516
0
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1517
0
        case CONTAINER_PAIR(BITSET,BITSET):
1518
0
            *result_type = bitset_bitset_container_xor(
1519
0
                                const_CAST_bitset(c1),
1520
0
                                const_CAST_bitset(c2), &result)
1521
0
                                    ? BITSET_CONTAINER_TYPE
1522
0
                                    : ARRAY_CONTAINER_TYPE;
1523
0
            return result;
1524
0
1525
0
        case CONTAINER_PAIR(ARRAY,ARRAY):
1526
0
            *result_type = array_array_container_xor(
1527
0
                                const_CAST_array(c1),
1528
0
                                const_CAST_array(c2), &result)
1529
0
                                    ? BITSET_CONTAINER_TYPE
1530
0
                                    : ARRAY_CONTAINER_TYPE;
1531
0
            return result;
1532
0
1533
0
        case CONTAINER_PAIR(RUN,RUN):
1534
0
            *result_type =
1535
0
                (uint8_t)run_run_container_xor(const_CAST_run(c1),
1536
0
                                      const_CAST_run(c2), &result);
1537
0
            return result;
1538
0
1539
0
        case CONTAINER_PAIR(BITSET,ARRAY):
1540
0
            *result_type = array_bitset_container_xor(
1541
0
                                const_CAST_array(c2),
1542
0
                                const_CAST_bitset(c1), &result)
1543
0
                                    ? BITSET_CONTAINER_TYPE
1544
0
                                    : ARRAY_CONTAINER_TYPE;
1545
0
            return result;
1546
0
1547
0
        case CONTAINER_PAIR(ARRAY,BITSET):
1548
0
            *result_type = array_bitset_container_xor(
1549
0
                                const_CAST_array(c1),
1550
0
                                const_CAST_bitset(c2), &result)
1551
0
                                    ? BITSET_CONTAINER_TYPE
1552
0
                                    : ARRAY_CONTAINER_TYPE;
1553
0
            return result;
1554
0
1555
0
        case CONTAINER_PAIR(BITSET,RUN):
1556
0
            *result_type = run_bitset_container_xor(
1557
0
                                const_CAST_run(c2),
1558
0
                                const_CAST_bitset(c1), &result)
1559
0
                                    ? BITSET_CONTAINER_TYPE
1560
0
                                    : ARRAY_CONTAINER_TYPE;
1561
0
            return result;
1562
0
1563
0
        case CONTAINER_PAIR(RUN,BITSET):
1564
0
            *result_type = run_bitset_container_xor(
1565
0
                                const_CAST_run(c1),
1566
0
                                const_CAST_bitset(c2), &result)
1567
0
                                    ? BITSET_CONTAINER_TYPE
1568
0
                                    : ARRAY_CONTAINER_TYPE;
1569
0
            return result;
1570
0
1571
0
        case CONTAINER_PAIR(ARRAY,RUN):
1572
0
            *result_type =
1573
0
                (uint8_t)array_run_container_xor(const_CAST_array(c1),
1574
0
                                        const_CAST_run(c2), &result);
1575
0
            return result;
1576
0
1577
0
        case CONTAINER_PAIR(RUN,ARRAY):
1578
0
            *result_type =
1579
0
                (uint8_t)array_run_container_xor(const_CAST_array(c2),
1580
0
                                        const_CAST_run(c1), &result);
1581
0
            return result;
1582
0
1583
0
        default:
1584
0
            assert(false);
1585
0
            roaring_unreachable;
1586
0
            return NULL;  // unreached
1587
0
    }
1588
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL13container_xorEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL13container_xorEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL13container_xorEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL13container_xorEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL13container_xorEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL13container_xorEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL13container_xorEPKNS_3api11container_sEhS4_hPh
1589
1590
/* Applies an offset to the non-empty container 'c'.
1591
 * The results are stored in new containers returned via 'lo' and 'hi', for the
1592
 * low and high halves of the result (where the low half matches the original key
1593
 * and the high one corresponds to values for the following key).
1594
 * Either one of 'lo' and 'hi' are allowed to be 'NULL', but not both.
1595
 * Whenever one of them is not 'NULL', it should point to a 'NULL' container.
1596
 * Whenever one of them is 'NULL' the shifted elements for that part will not be
1597
 * computed.
1598
 * If either of the resulting containers turns out to be empty, the pointed
1599
 * container will remain 'NULL'.
1600
 */
1601
static inline void container_add_offset(const container_t *c, uint8_t type,
1602
                                        container_t **lo, container_t **hi,
1603
0
                                        uint16_t offset) {
1604
0
    assert(offset != 0);
1605
0
    assert(container_nonzero_cardinality(c, type));
1606
0
    assert(lo != NULL || hi != NULL);
1607
0
    assert(lo == NULL || *lo == NULL);
1608
0
    assert(hi == NULL || *hi == NULL);
1609
0
1610
0
    switch (type) {
1611
0
    case BITSET_CONTAINER_TYPE:
1612
0
        bitset_container_offset(const_CAST_bitset(c), lo, hi, offset);
1613
0
        break;
1614
0
    case ARRAY_CONTAINER_TYPE:
1615
0
        array_container_offset(const_CAST_array(c), lo, hi, offset);
1616
0
        break;
1617
0
    case RUN_CONTAINER_TYPE:
1618
0
        run_container_offset(const_CAST_run(c), lo, hi, offset);
1619
0
        break;
1620
0
    default:
1621
0
        assert(false);
1622
0
        roaring_unreachable;
1623
0
        break;
1624
0
    }
1625
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL20container_add_offsetEPKNS_3api11container_sEhPPS2_S6_t
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL20container_add_offsetEPKNS_3api11container_sEhPPS2_S6_t
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL20container_add_offsetEPKNS_3api11container_sEhPPS2_S6_t
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL20container_add_offsetEPKNS_3api11container_sEhPPS2_S6_t
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL20container_add_offsetEPKNS_3api11container_sEhPPS2_S6_t
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL20container_add_offsetEPKNS_3api11container_sEhPPS2_S6_t
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL20container_add_offsetEPKNS_3api11container_sEhPPS2_S6_t
1626
1627
/**
1628
 * Compute xor between two containers, generate a new container (having type
1629
 * result_type), requires a typecode. This allocates new memory, caller
1630
 * is responsible for deallocation.
1631
 *
1632
 * This lazy version delays some operations such as the maintenance of the
1633
 * cardinality. It requires repair later on the generated containers.
1634
 */
1635
static inline container_t *container_lazy_xor(
1636
    const container_t *c1, uint8_t type1,
1637
    const container_t *c2, uint8_t type2,
1638
    uint8_t *result_type
1639
0
){
1640
0
    c1 = container_unwrap_shared(c1, &type1);
1641
0
    c2 = container_unwrap_shared(c2, &type2);
1642
0
    container_t *result = NULL;
1643
0
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1644
0
        case CONTAINER_PAIR(BITSET,BITSET):
1645
0
            result = bitset_container_create();
1646
0
            bitset_container_xor_nocard(
1647
0
                const_CAST_bitset(c1), const_CAST_bitset(c2),
1648
0
                CAST_bitset(result));  // is lazy
1649
0
            *result_type = BITSET_CONTAINER_TYPE;
1650
0
            return result;
1651
0
1652
0
        case CONTAINER_PAIR(ARRAY,ARRAY):
1653
0
            *result_type = array_array_container_lazy_xor(
1654
0
                                const_CAST_array(c1),
1655
0
                                const_CAST_array(c2), &result)
1656
0
                                    ? BITSET_CONTAINER_TYPE
1657
0
                                    : ARRAY_CONTAINER_TYPE;
1658
0
            return result;
1659
0
1660
0
        case CONTAINER_PAIR(RUN,RUN):
1661
0
            // nothing special done yet.
1662
0
            *result_type =
1663
0
                (uint8_t)run_run_container_xor(const_CAST_run(c1),
1664
0
                                      const_CAST_run(c2), &result);
1665
0
            return result;
1666
0
1667
0
        case CONTAINER_PAIR(BITSET,ARRAY):
1668
0
            result = bitset_container_create();
1669
0
            *result_type = BITSET_CONTAINER_TYPE;
1670
0
            array_bitset_container_lazy_xor(const_CAST_array(c2),
1671
0
                                            const_CAST_bitset(c1),
1672
0
                                            CAST_bitset(result));
1673
0
            return result;
1674
0
1675
0
        case CONTAINER_PAIR(ARRAY,BITSET):
1676
0
            result = bitset_container_create();
1677
0
            *result_type = BITSET_CONTAINER_TYPE;
1678
0
            array_bitset_container_lazy_xor(const_CAST_array(c1),
1679
0
                                            const_CAST_bitset(c2),
1680
0
                                            CAST_bitset(result));
1681
0
            return result;
1682
0
1683
0
        case CONTAINER_PAIR(BITSET,RUN):
1684
0
            result = bitset_container_create();
1685
0
            run_bitset_container_lazy_xor(const_CAST_run(c2),
1686
0
                                          const_CAST_bitset(c1),
1687
0
                                          CAST_bitset(result));
1688
0
            *result_type = BITSET_CONTAINER_TYPE;
1689
0
            return result;
1690
0
1691
0
        case CONTAINER_PAIR(RUN,BITSET):
1692
0
            result = bitset_container_create();
1693
0
            run_bitset_container_lazy_xor(const_CAST_run(c1),
1694
0
                                          const_CAST_bitset(c2),
1695
0
                                          CAST_bitset(result));
1696
0
            *result_type = BITSET_CONTAINER_TYPE;
1697
0
            return result;
1698
0
1699
0
        case CONTAINER_PAIR(ARRAY,RUN):
1700
0
            result = run_container_create();
1701
0
            array_run_container_lazy_xor(const_CAST_array(c1),
1702
0
                                         const_CAST_run(c2),
1703
0
                                         CAST_run(result));
1704
0
            *result_type = RUN_CONTAINER_TYPE;
1705
0
            // next line skipped since we are lazy
1706
0
            // result = convert_run_to_efficient_container(result, result_type);
1707
0
            return result;
1708
0
1709
0
        case CONTAINER_PAIR(RUN,ARRAY):
1710
0
            result = run_container_create();
1711
0
            array_run_container_lazy_xor(const_CAST_array(c2),
1712
0
                                         const_CAST_run(c1),
1713
0
                                         CAST_run(result));
1714
0
            *result_type = RUN_CONTAINER_TYPE;
1715
0
            // next line skipped since we are lazy
1716
0
            // result = convert_run_to_efficient_container(result, result_type);
1717
0
            return result;
1718
0
1719
0
        default:
1720
0
            assert(false);
1721
0
            roaring_unreachable;
1722
0
            return NULL;  // unreached
1723
0
    }
1724
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL18container_lazy_xorEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL18container_lazy_xorEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL18container_lazy_xorEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL18container_lazy_xorEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL18container_lazy_xorEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL18container_lazy_xorEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL18container_lazy_xorEPKNS_3api11container_sEhS4_hPh
1725
1726
/**
1727
 * Compute the xor between two containers, with result in the first container.
1728
 * If the returned pointer is identical to c1, then the container has been
1729
 * modified.
1730
 * If the returned pointer is different from c1, then a new container has been
1731
 * created and the caller is responsible for freeing it.
1732
 * The type of the first container may change. Returns the modified
1733
 * (and possibly new) container
1734
*/
1735
static inline container_t *container_ixor(
1736
    container_t *c1, uint8_t type1,
1737
    const container_t *c2, uint8_t type2,
1738
    uint8_t *result_type
1739
0
){
1740
0
    c1 = get_writable_copy_if_shared(c1, &type1);
1741
0
    c2 = container_unwrap_shared(c2, &type2);
1742
0
    container_t *result = NULL;
1743
0
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1744
0
        case CONTAINER_PAIR(BITSET,BITSET):
1745
0
            *result_type = bitset_bitset_container_ixor(
1746
0
                                CAST_bitset(c1), const_CAST_bitset(c2), &result)
1747
0
                                    ? BITSET_CONTAINER_TYPE
1748
0
                                    : ARRAY_CONTAINER_TYPE;
1749
0
            return result;
1750
0
1751
0
        case CONTAINER_PAIR(ARRAY,ARRAY):
1752
0
            *result_type = array_array_container_ixor(
1753
0
                                CAST_array(c1), const_CAST_array(c2), &result)
1754
0
                                    ? BITSET_CONTAINER_TYPE
1755
0
                                    : ARRAY_CONTAINER_TYPE;
1756
0
            return result;
1757
0
1758
0
        case CONTAINER_PAIR(RUN,RUN):
1759
0
            *result_type = (uint8_t)run_run_container_ixor(
1760
0
                CAST_run(c1), const_CAST_run(c2), &result);
1761
0
            return result;
1762
0
1763
0
        case CONTAINER_PAIR(BITSET,ARRAY):
1764
0
            *result_type = bitset_array_container_ixor(
1765
0
                                CAST_bitset(c1), const_CAST_array(c2), &result)
1766
0
                                    ? BITSET_CONTAINER_TYPE
1767
0
                                    : ARRAY_CONTAINER_TYPE;
1768
0
            return result;
1769
0
1770
0
        case CONTAINER_PAIR(ARRAY,BITSET):
1771
0
            *result_type = array_bitset_container_ixor(
1772
0
                                CAST_array(c1), const_CAST_bitset(c2), &result)
1773
0
                                    ? BITSET_CONTAINER_TYPE
1774
0
                                    : ARRAY_CONTAINER_TYPE;
1775
0
            return result;
1776
0
1777
0
        case CONTAINER_PAIR(BITSET,RUN):
1778
0
            *result_type =
1779
0
                bitset_run_container_ixor(
1780
0
                    CAST_bitset(c1), const_CAST_run(c2), &result)
1781
0
                        ? BITSET_CONTAINER_TYPE
1782
0
                        : ARRAY_CONTAINER_TYPE;
1783
0
1784
0
            return result;
1785
0
1786
0
        case CONTAINER_PAIR(RUN,BITSET):
1787
0
            *result_type = run_bitset_container_ixor(
1788
0
                                CAST_run(c1), const_CAST_bitset(c2), &result)
1789
0
                                    ? BITSET_CONTAINER_TYPE
1790
0
                                    : ARRAY_CONTAINER_TYPE;
1791
0
            return result;
1792
0
1793
0
        case CONTAINER_PAIR(ARRAY,RUN):
1794
0
            *result_type = (uint8_t)array_run_container_ixor(
1795
0
                                CAST_array(c1), const_CAST_run(c2), &result);
1796
0
            return result;
1797
0
1798
0
        case CONTAINER_PAIR(RUN,ARRAY):
1799
0
            *result_type = (uint8_t)run_array_container_ixor(
1800
0
                                CAST_run(c1), const_CAST_array(c2), &result);
1801
0
            return result;
1802
0
1803
0
        default:
1804
0
            assert(false);
1805
0
            roaring_unreachable;
1806
0
            return NULL;
1807
0
    }
1808
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL14container_ixorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL14container_ixorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL14container_ixorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL14container_ixorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL14container_ixorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL14container_ixorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL14container_ixorEPNS_3api11container_sEhPKS2_hPh
1809
1810
/**
1811
 * Compute the xor between two containers, with result in the first container.
1812
 * If the returned pointer is identical to c1, then the container has been
1813
 * modified.
1814
 * If the returned pointer is different from c1, then a new container has been
1815
 * created and the caller is responsible for freeing it.
1816
 * The type of the first container may change. Returns the modified
1817
 * (and possibly new) container
1818
 *
1819
 * This lazy version delays some operations such as the maintenance of the
1820
 * cardinality. It requires repair later on the generated containers.
1821
*/
1822
static inline container_t *container_lazy_ixor(
1823
    container_t *c1, uint8_t type1,
1824
    const container_t *c2, uint8_t type2,
1825
    uint8_t *result_type
1826
0
){
1827
0
    assert(type1 != SHARED_CONTAINER_TYPE);
1828
0
    // c1 = get_writable_copy_if_shared(c1,&type1);
1829
0
    c2 = container_unwrap_shared(c2, &type2);
1830
0
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1831
0
        case CONTAINER_PAIR(BITSET,BITSET):
1832
0
            bitset_container_xor_nocard(CAST_bitset(c1),
1833
0
                                        const_CAST_bitset(c2),
1834
0
                                        CAST_bitset(c1));  // is lazy
1835
0
            *result_type = BITSET_CONTAINER_TYPE;
1836
0
            return c1;
1837
0
1838
0
        // TODO: other cases being lazy, esp. when we know inplace not likely
1839
0
        // could see the corresponding code for union
1840
0
        default:
1841
0
            // we may have a dirty bitset (without a precomputed cardinality)
1842
0
            // and calling container_ixor on it might be unsafe.
1843
0
            if (type1 == BITSET_CONTAINER_TYPE) {
1844
0
                bitset_container_t *bc = CAST_bitset(c1);
1845
0
                if (bc->cardinality == BITSET_UNKNOWN_CARDINALITY) {
1846
0
                    bc->cardinality = bitset_container_compute_cardinality(bc);
1847
0
                }
1848
0
            }
1849
0
            return container_ixor(c1, type1, c2, type2, result_type);
1850
0
    }
1851
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL19container_lazy_ixorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL19container_lazy_ixorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL19container_lazy_ixorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL19container_lazy_ixorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL19container_lazy_ixorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL19container_lazy_ixorEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL19container_lazy_ixorEPNS_3api11container_sEhPKS2_hPh
1852
1853
/**
1854
 * Compute difference (andnot) between two containers, generate a new
1855
 * container (having type result_type), requires a typecode. This allocates new
1856
 * memory, caller is responsible for deallocation.
1857
 */
1858
static inline container_t *container_andnot(
1859
    const container_t *c1, uint8_t type1,
1860
    const container_t *c2, uint8_t type2,
1861
    uint8_t *result_type
1862
0
){
1863
0
    c1 = container_unwrap_shared(c1, &type1);
1864
0
    c2 = container_unwrap_shared(c2, &type2);
1865
0
    container_t *result = NULL;
1866
0
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1867
0
        case CONTAINER_PAIR(BITSET,BITSET):
1868
0
            *result_type = bitset_bitset_container_andnot(
1869
0
                                const_CAST_bitset(c1),
1870
0
                                const_CAST_bitset(c2), &result)
1871
0
                                    ? BITSET_CONTAINER_TYPE
1872
0
                                    : ARRAY_CONTAINER_TYPE;
1873
0
            return result;
1874
0
1875
0
        case CONTAINER_PAIR(ARRAY,ARRAY):
1876
0
            result = array_container_create();
1877
0
            array_array_container_andnot(const_CAST_array(c1),
1878
0
                                         const_CAST_array(c2),
1879
0
                                         CAST_array(result));
1880
0
            *result_type = ARRAY_CONTAINER_TYPE;
1881
0
            return result;
1882
0
1883
0
        case CONTAINER_PAIR(RUN,RUN):
1884
0
            if (run_container_is_full(const_CAST_run(c2))) {
1885
0
                result = array_container_create();
1886
0
                *result_type = ARRAY_CONTAINER_TYPE;
1887
0
                return result;
1888
0
            }
1889
0
            *result_type =
1890
0
                (uint8_t)run_run_container_andnot(const_CAST_run(c1),
1891
0
                                         const_CAST_run(c2), &result);
1892
0
            return result;
1893
0
1894
0
        case CONTAINER_PAIR(BITSET,ARRAY):
1895
0
            *result_type = bitset_array_container_andnot(
1896
0
                                const_CAST_bitset(c1),
1897
0
                                const_CAST_array(c2), &result)
1898
0
                                    ? BITSET_CONTAINER_TYPE
1899
0
                                    : ARRAY_CONTAINER_TYPE;
1900
0
            return result;
1901
0
1902
0
        case CONTAINER_PAIR(ARRAY,BITSET):
1903
0
            result = array_container_create();
1904
0
            array_bitset_container_andnot(const_CAST_array(c1),
1905
0
                                          const_CAST_bitset(c2),
1906
0
                                          CAST_array(result));
1907
0
            *result_type = ARRAY_CONTAINER_TYPE;
1908
0
            return result;
1909
0
1910
0
        case CONTAINER_PAIR(BITSET,RUN):
1911
0
            if (run_container_is_full(const_CAST_run(c2))) {
1912
0
                result = array_container_create();
1913
0
                *result_type = ARRAY_CONTAINER_TYPE;
1914
0
                return result;
1915
0
            }
1916
0
            *result_type = bitset_run_container_andnot(
1917
0
                                const_CAST_bitset(c1),
1918
0
                                const_CAST_run(c2), &result)
1919
0
                                    ? BITSET_CONTAINER_TYPE
1920
0
                                    : ARRAY_CONTAINER_TYPE;
1921
0
            return result;
1922
0
1923
0
        case CONTAINER_PAIR(RUN,BITSET):
1924
0
            *result_type = run_bitset_container_andnot(
1925
0
                                const_CAST_run(c1),
1926
0
                                const_CAST_bitset(c2), &result)
1927
0
                                    ? BITSET_CONTAINER_TYPE
1928
0
                                    : ARRAY_CONTAINER_TYPE;
1929
0
            return result;
1930
0
1931
0
        case CONTAINER_PAIR(ARRAY,RUN):
1932
0
            if (run_container_is_full(const_CAST_run(c2))) {
1933
0
                result = array_container_create();
1934
0
                *result_type = ARRAY_CONTAINER_TYPE;
1935
0
                return result;
1936
0
            }
1937
0
            result = array_container_create();
1938
0
            array_run_container_andnot(const_CAST_array(c1),
1939
0
                                       const_CAST_run(c2),
1940
0
                                       CAST_array(result));
1941
0
            *result_type = ARRAY_CONTAINER_TYPE;
1942
0
            return result;
1943
0
1944
0
        case CONTAINER_PAIR(RUN,ARRAY):
1945
0
            *result_type = (uint8_t)run_array_container_andnot(
1946
0
                const_CAST_run(c1), const_CAST_array(c2),
1947
0
                &result);
1948
0
            return result;
1949
0
1950
0
        default:
1951
0
            assert(false);
1952
0
            roaring_unreachable;
1953
0
            return NULL;  // unreached
1954
0
    }
1955
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL16container_andnotEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL16container_andnotEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL16container_andnotEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL16container_andnotEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL16container_andnotEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL16container_andnotEPKNS_3api11container_sEhS4_hPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL16container_andnotEPKNS_3api11container_sEhS4_hPh
1956
1957
/**
1958
 * Compute the andnot between two containers, with result in the first
1959
 * container.
1960
 * If the returned pointer is identical to c1, then the container has been
1961
 * modified.
1962
 * If the returned pointer is different from c1, then a new container has been
1963
 * created and the caller is responsible for freeing it.
1964
 * The type of the first container may change. Returns the modified
1965
 * (and possibly new) container
1966
*/
1967
static inline container_t *container_iandnot(
1968
    container_t *c1, uint8_t type1,
1969
    const container_t *c2, uint8_t type2,
1970
    uint8_t *result_type
1971
0
){
1972
0
    c1 = get_writable_copy_if_shared(c1, &type1);
1973
0
    c2 = container_unwrap_shared(c2, &type2);
1974
0
    container_t *result = NULL;
1975
0
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1976
0
        case CONTAINER_PAIR(BITSET,BITSET):
1977
0
            *result_type = bitset_bitset_container_iandnot(
1978
0
                                CAST_bitset(c1),
1979
0
                                const_CAST_bitset(c2), &result)
1980
0
                                    ? BITSET_CONTAINER_TYPE
1981
0
                                    : ARRAY_CONTAINER_TYPE;
1982
0
            return result;
1983
0
1984
0
        case CONTAINER_PAIR(ARRAY,ARRAY):
1985
0
            array_array_container_iandnot(CAST_array(c1),
1986
0
                                          const_CAST_array(c2));
1987
0
            *result_type = ARRAY_CONTAINER_TYPE;
1988
0
            return c1;
1989
0
1990
0
        case CONTAINER_PAIR(RUN,RUN):
1991
0
            *result_type = (uint8_t)run_run_container_iandnot(
1992
0
                CAST_run(c1), const_CAST_run(c2), &result);
1993
0
            return result;
1994
0
1995
0
        case CONTAINER_PAIR(BITSET,ARRAY):
1996
0
            *result_type = bitset_array_container_iandnot(
1997
0
                                CAST_bitset(c1),
1998
0
                                const_CAST_array(c2), &result)
1999
0
                                    ? BITSET_CONTAINER_TYPE
2000
0
                                    : ARRAY_CONTAINER_TYPE;
2001
0
            return result;
2002
0
2003
0
        case CONTAINER_PAIR(ARRAY,BITSET):
2004
0
            *result_type = ARRAY_CONTAINER_TYPE;
2005
0
            array_bitset_container_iandnot(CAST_array(c1),
2006
0
                                           const_CAST_bitset(c2));
2007
0
            return c1;
2008
0
2009
0
        case CONTAINER_PAIR(BITSET,RUN):
2010
0
            *result_type = bitset_run_container_iandnot(
2011
0
                                CAST_bitset(c1),
2012
0
                                const_CAST_run(c2), &result)
2013
0
                                    ? BITSET_CONTAINER_TYPE
2014
0
                                    : ARRAY_CONTAINER_TYPE;
2015
0
            return result;
2016
0
2017
0
        case CONTAINER_PAIR(RUN,BITSET):
2018
0
            *result_type = run_bitset_container_iandnot(
2019
0
                                CAST_run(c1),
2020
0
                                const_CAST_bitset(c2), &result)
2021
0
                                    ? BITSET_CONTAINER_TYPE
2022
0
                                    : ARRAY_CONTAINER_TYPE;
2023
0
            return result;
2024
0
2025
0
        case CONTAINER_PAIR(ARRAY,RUN):
2026
0
            *result_type = ARRAY_CONTAINER_TYPE;
2027
0
            array_run_container_iandnot(CAST_array(c1),
2028
0
                                        const_CAST_run(c2));
2029
0
            return c1;
2030
0
2031
0
        case CONTAINER_PAIR(RUN,ARRAY):
2032
0
            *result_type = (uint8_t)run_array_container_iandnot(
2033
0
                CAST_run(c1), const_CAST_array(c2), &result);
2034
0
            return result;
2035
0
2036
0
        default:
2037
0
            assert(false);
2038
0
            roaring_unreachable;
2039
0
            return NULL;
2040
0
    }
2041
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL17container_iandnotEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL17container_iandnotEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL17container_iandnotEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL17container_iandnotEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL17container_iandnotEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL17container_iandnotEPNS_3api11container_sEhPKS2_hPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL17container_iandnotEPNS_3api11container_sEhPKS2_hPh
2042
2043
/**
2044
 * Visit all values x of the container once, passing (base+x,ptr)
2045
 * to iterator. You need to specify a container and its type.
2046
 * Returns true if the iteration should continue.
2047
 */
2048
static inline bool container_iterate(
2049
    const container_t *c, uint8_t type,
2050
    uint32_t base,
2051
    roaring_iterator iterator, void *ptr
2052
0
){
2053
0
    c = container_unwrap_shared(c, &type);
2054
0
    switch (type) {
2055
0
        case BITSET_CONTAINER_TYPE:
2056
0
            return bitset_container_iterate(const_CAST_bitset(c),
2057
0
                                            base, iterator, ptr);
2058
0
        case ARRAY_CONTAINER_TYPE:
2059
0
            return array_container_iterate(const_CAST_array(c),
2060
0
                                           base, iterator, ptr);
2061
0
        case RUN_CONTAINER_TYPE:
2062
0
            return run_container_iterate(const_CAST_run(c),
2063
0
                                         base, iterator, ptr);
2064
0
        default:
2065
0
            assert(false);
2066
0
            roaring_unreachable;
2067
0
    }
2068
0
    assert(false);
2069
0
    roaring_unreachable;
2070
0
    return false;
2071
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL17container_iterateEPKNS_3api11container_sEhjPFbjPvES5_
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL17container_iterateEPKNS_3api11container_sEhjPFbjPvES5_
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL17container_iterateEPKNS_3api11container_sEhjPFbjPvES5_
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL17container_iterateEPKNS_3api11container_sEhjPFbjPvES5_
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL17container_iterateEPKNS_3api11container_sEhjPFbjPvES5_
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL17container_iterateEPKNS_3api11container_sEhjPFbjPvES5_
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL17container_iterateEPKNS_3api11container_sEhjPFbjPvES5_
2072
2073
static inline bool container_iterate64(
2074
    const container_t *c, uint8_t type,
2075
    uint32_t base,
2076
    roaring_iterator64 iterator,
2077
    uint64_t high_bits, void *ptr
2078
0
){
2079
0
    c = container_unwrap_shared(c, &type);
2080
0
    switch (type) {
2081
0
        case BITSET_CONTAINER_TYPE:
2082
0
            return bitset_container_iterate64(const_CAST_bitset(c), base,
2083
0
                                              iterator, high_bits, ptr);
2084
0
        case ARRAY_CONTAINER_TYPE:
2085
0
            return array_container_iterate64(const_CAST_array(c), base,
2086
0
                                             iterator, high_bits, ptr);
2087
0
        case RUN_CONTAINER_TYPE:
2088
0
            return run_container_iterate64(const_CAST_run(c), base,
2089
0
                                           iterator, high_bits, ptr);
2090
0
        default:
2091
0
            assert(false);
2092
0
            roaring_unreachable;
2093
0
    }
2094
0
    assert(false);
2095
0
    roaring_unreachable;
2096
0
    return false;
2097
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL19container_iterate64EPKNS_3api11container_sEhjPFbmPvEmS5_
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL19container_iterate64EPKNS_3api11container_sEhjPFbmPvEmS5_
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL19container_iterate64EPKNS_3api11container_sEhjPFbmPvEmS5_
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL19container_iterate64EPKNS_3api11container_sEhjPFbmPvEmS5_
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL19container_iterate64EPKNS_3api11container_sEhjPFbmPvEmS5_
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL19container_iterate64EPKNS_3api11container_sEhjPFbmPvEmS5_
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL19container_iterate64EPKNS_3api11container_sEhjPFbmPvEmS5_
2098
2099
static inline container_t *container_not(
2100
    const container_t *c, uint8_t type,
2101
    uint8_t *result_type
2102
0
){
2103
0
    c = container_unwrap_shared(c, &type);
2104
0
    container_t *result = NULL;
2105
0
    switch (type) {
2106
0
        case BITSET_CONTAINER_TYPE:
2107
0
            *result_type = bitset_container_negation(
2108
0
                                const_CAST_bitset(c), &result)
2109
0
                                    ? BITSET_CONTAINER_TYPE
2110
0
                                    : ARRAY_CONTAINER_TYPE;
2111
0
            return result;
2112
0
        case ARRAY_CONTAINER_TYPE:
2113
0
            result = bitset_container_create();
2114
0
            *result_type = BITSET_CONTAINER_TYPE;
2115
0
            array_container_negation(const_CAST_array(c),
2116
0
                                     CAST_bitset(result));
2117
0
            return result;
2118
0
        case RUN_CONTAINER_TYPE:
2119
0
            *result_type =
2120
0
                (uint8_t)run_container_negation(const_CAST_run(c), &result);
2121
0
            return result;
2122
0
2123
0
        default:
2124
0
            assert(false);
2125
0
            roaring_unreachable;
2126
0
    }
2127
0
    assert(false);
2128
0
    roaring_unreachable;
2129
0
    return NULL;
2130
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL13container_notEPKNS_3api11container_sEhPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL13container_notEPKNS_3api11container_sEhPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL13container_notEPKNS_3api11container_sEhPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL13container_notEPKNS_3api11container_sEhPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL13container_notEPKNS_3api11container_sEhPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL13container_notEPKNS_3api11container_sEhPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL13container_notEPKNS_3api11container_sEhPh
2131
2132
static inline container_t *container_not_range(
2133
    const container_t *c, uint8_t type,
2134
    uint32_t range_start, uint32_t range_end,
2135
    uint8_t *result_type
2136
0
){
2137
0
    c = container_unwrap_shared(c, &type);
2138
0
    container_t *result = NULL;
2139
0
    switch (type) {
2140
0
        case BITSET_CONTAINER_TYPE:
2141
0
            *result_type =
2142
0
                bitset_container_negation_range(
2143
0
                        const_CAST_bitset(c), range_start, range_end, &result)
2144
0
                            ? BITSET_CONTAINER_TYPE
2145
0
                            : ARRAY_CONTAINER_TYPE;
2146
0
            return result;
2147
0
        case ARRAY_CONTAINER_TYPE:
2148
0
            *result_type =
2149
0
                array_container_negation_range(
2150
0
                    const_CAST_array(c), range_start, range_end, &result)
2151
0
                        ? BITSET_CONTAINER_TYPE
2152
0
                        : ARRAY_CONTAINER_TYPE;
2153
0
            return result;
2154
0
        case RUN_CONTAINER_TYPE:
2155
0
            *result_type = (uint8_t)run_container_negation_range(
2156
0
                            const_CAST_run(c), range_start, range_end, &result);
2157
0
            return result;
2158
0
2159
0
        default:
2160
0
            assert(false);
2161
0
            roaring_unreachable;
2162
0
    }
2163
0
    assert(false);
2164
0
    roaring_unreachable;
2165
0
    return NULL;
2166
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL19container_not_rangeEPKNS_3api11container_sEhjjPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL19container_not_rangeEPKNS_3api11container_sEhjjPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL19container_not_rangeEPKNS_3api11container_sEhjjPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL19container_not_rangeEPKNS_3api11container_sEhjjPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL19container_not_rangeEPKNS_3api11container_sEhjjPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL19container_not_rangeEPKNS_3api11container_sEhjjPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL19container_not_rangeEPKNS_3api11container_sEhjjPh
2167
2168
static inline container_t *container_inot(
2169
    container_t *c, uint8_t type,
2170
    uint8_t *result_type
2171
0
){
2172
0
    c = get_writable_copy_if_shared(c, &type);
2173
0
    container_t *result = NULL;
2174
0
    switch (type) {
2175
0
        case BITSET_CONTAINER_TYPE:
2176
0
            *result_type = bitset_container_negation_inplace(
2177
0
                                CAST_bitset(c), &result)
2178
0
                                    ? BITSET_CONTAINER_TYPE
2179
0
                                    : ARRAY_CONTAINER_TYPE;
2180
0
            return result;
2181
0
        case ARRAY_CONTAINER_TYPE:
2182
0
            // will never be inplace
2183
0
            result = bitset_container_create();
2184
0
            *result_type = BITSET_CONTAINER_TYPE;
2185
0
            array_container_negation(CAST_array(c),
2186
0
                                     CAST_bitset(result));
2187
0
            array_container_free(CAST_array(c));
2188
0
            return result;
2189
0
        case RUN_CONTAINER_TYPE:
2190
0
            *result_type =
2191
0
                (uint8_t)run_container_negation_inplace(CAST_run(c), &result);
2192
0
            return result;
2193
0
2194
0
        default:
2195
0
            assert(false);
2196
0
            roaring_unreachable;
2197
0
    }
2198
0
    assert(false);
2199
0
    roaring_unreachable;
2200
0
    return NULL;
2201
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL14container_inotEPNS_3api11container_sEhPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL14container_inotEPNS_3api11container_sEhPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL14container_inotEPNS_3api11container_sEhPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL14container_inotEPNS_3api11container_sEhPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL14container_inotEPNS_3api11container_sEhPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL14container_inotEPNS_3api11container_sEhPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL14container_inotEPNS_3api11container_sEhPh
2202
2203
static inline container_t *container_inot_range(
2204
    container_t *c, uint8_t type,
2205
    uint32_t range_start, uint32_t range_end,
2206
    uint8_t *result_type
2207
0
){
2208
0
    c = get_writable_copy_if_shared(c, &type);
2209
0
    container_t *result = NULL;
2210
0
    switch (type) {
2211
0
        case BITSET_CONTAINER_TYPE:
2212
0
            *result_type =
2213
0
                bitset_container_negation_range_inplace(
2214
0
                    CAST_bitset(c), range_start, range_end, &result)
2215
0
                        ? BITSET_CONTAINER_TYPE
2216
0
                        : ARRAY_CONTAINER_TYPE;
2217
0
            return result;
2218
0
        case ARRAY_CONTAINER_TYPE:
2219
0
            *result_type =
2220
0
                array_container_negation_range_inplace(
2221
0
                    CAST_array(c), range_start, range_end, &result)
2222
0
                        ? BITSET_CONTAINER_TYPE
2223
0
                        : ARRAY_CONTAINER_TYPE;
2224
0
            return result;
2225
0
        case RUN_CONTAINER_TYPE:
2226
0
            *result_type = (uint8_t)run_container_negation_range_inplace(
2227
0
                                CAST_run(c), range_start, range_end, &result);
2228
0
            return result;
2229
0
2230
0
        default:
2231
0
            assert(false);
2232
0
            roaring_unreachable;
2233
0
    }
2234
0
    assert(false);
2235
0
    roaring_unreachable;
2236
0
    return NULL;
2237
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL20container_inot_rangeEPNS_3api11container_sEhjjPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL20container_inot_rangeEPNS_3api11container_sEhjjPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL20container_inot_rangeEPNS_3api11container_sEhjjPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL20container_inot_rangeEPNS_3api11container_sEhjjPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL20container_inot_rangeEPNS_3api11container_sEhjjPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL20container_inot_rangeEPNS_3api11container_sEhjjPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL20container_inot_rangeEPNS_3api11container_sEhjjPh
2238
2239
/**
2240
 * If the element of given rank is in this container, supposing that
2241
 * the first
2242
 * element has rank start_rank, then the function returns true and
2243
 * sets element
2244
 * accordingly.
2245
 * Otherwise, it returns false and update start_rank.
2246
 */
2247
static inline bool container_select(
2248
    const container_t *c, uint8_t type,
2249
    uint32_t *start_rank, uint32_t rank,
2250
    uint32_t *element
2251
0
){
2252
0
    c = container_unwrap_shared(c, &type);
2253
0
    switch (type) {
2254
0
        case BITSET_CONTAINER_TYPE:
2255
0
            return bitset_container_select(const_CAST_bitset(c),
2256
0
                                           start_rank, rank, element);
2257
0
        case ARRAY_CONTAINER_TYPE:
2258
0
            return array_container_select(const_CAST_array(c),
2259
0
                                          start_rank, rank, element);
2260
0
        case RUN_CONTAINER_TYPE:
2261
0
            return run_container_select(const_CAST_run(c),
2262
0
                                        start_rank, rank, element);
2263
0
        default:
2264
0
            assert(false);
2265
0
            roaring_unreachable;
2266
0
    }
2267
0
    assert(false);
2268
0
    roaring_unreachable;
2269
0
    return false;
2270
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL16container_selectEPKNS_3api11container_sEhPjjS5_
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL16container_selectEPKNS_3api11container_sEhPjjS5_
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL16container_selectEPKNS_3api11container_sEhPjjS5_
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL16container_selectEPKNS_3api11container_sEhPjjS5_
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL16container_selectEPKNS_3api11container_sEhPjjS5_
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL16container_selectEPKNS_3api11container_sEhPjjS5_
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL16container_selectEPKNS_3api11container_sEhPjjS5_
2271
2272
static inline uint16_t container_maximum(
2273
    const container_t *c, uint8_t type
2274
0
){
2275
0
    c = container_unwrap_shared(c, &type);
2276
0
    switch (type) {
2277
0
        case BITSET_CONTAINER_TYPE:
2278
0
            return bitset_container_maximum(const_CAST_bitset(c));
2279
0
        case ARRAY_CONTAINER_TYPE:
2280
0
            return array_container_maximum(const_CAST_array(c));
2281
0
        case RUN_CONTAINER_TYPE:
2282
0
            return run_container_maximum(const_CAST_run(c));
2283
0
        default:
2284
0
            assert(false);
2285
0
            roaring_unreachable;
2286
0
    }
2287
0
    assert(false);
2288
0
    roaring_unreachable;
2289
0
    return false;
2290
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL17container_maximumEPKNS_3api11container_sEh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL17container_maximumEPKNS_3api11container_sEh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL17container_maximumEPKNS_3api11container_sEh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL17container_maximumEPKNS_3api11container_sEh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL17container_maximumEPKNS_3api11container_sEh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL17container_maximumEPKNS_3api11container_sEh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL17container_maximumEPKNS_3api11container_sEh
2291
2292
static inline uint16_t container_minimum(
2293
    const container_t *c, uint8_t type
2294
0
){
2295
0
    c = container_unwrap_shared(c, &type);
2296
0
    switch (type) {
2297
0
        case BITSET_CONTAINER_TYPE:
2298
0
            return bitset_container_minimum(const_CAST_bitset(c));
2299
0
        case ARRAY_CONTAINER_TYPE:
2300
0
            return array_container_minimum(const_CAST_array(c));
2301
0
        case RUN_CONTAINER_TYPE:
2302
0
            return run_container_minimum(const_CAST_run(c));
2303
0
        default:
2304
0
            assert(false);
2305
0
            roaring_unreachable;
2306
0
    }
2307
0
    assert(false);
2308
0
    roaring_unreachable;
2309
0
    return false;
2310
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL17container_minimumEPKNS_3api11container_sEh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL17container_minimumEPKNS_3api11container_sEh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL17container_minimumEPKNS_3api11container_sEh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL17container_minimumEPKNS_3api11container_sEh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL17container_minimumEPKNS_3api11container_sEh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL17container_minimumEPKNS_3api11container_sEh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL17container_minimumEPKNS_3api11container_sEh
2311
2312
// number of values smaller or equal to x
2313
static inline int container_rank(
2314
    const container_t *c, uint8_t type,
2315
    uint16_t x
2316
0
){
2317
0
    c = container_unwrap_shared(c, &type);
2318
0
    switch (type) {
2319
0
        case BITSET_CONTAINER_TYPE:
2320
0
            return bitset_container_rank(const_CAST_bitset(c), x);
2321
0
        case ARRAY_CONTAINER_TYPE:
2322
0
            return array_container_rank(const_CAST_array(c), x);
2323
0
        case RUN_CONTAINER_TYPE:
2324
0
            return run_container_rank(const_CAST_run(c), x);
2325
0
        default:
2326
0
            assert(false);
2327
0
            roaring_unreachable;
2328
0
    }
2329
0
    assert(false);
2330
0
    roaring_unreachable;
2331
0
    return false;
2332
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL14container_rankEPKNS_3api11container_sEht
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL14container_rankEPKNS_3api11container_sEht
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL14container_rankEPKNS_3api11container_sEht
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL14container_rankEPKNS_3api11container_sEht
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL14container_rankEPKNS_3api11container_sEht
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL14container_rankEPKNS_3api11container_sEht
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL14container_rankEPKNS_3api11container_sEht
2333
2334
// bulk version of container_rank(); return number of consumed elements
2335
static inline uint32_t container_rank_many(
2336
    const container_t *c, uint8_t type,
2337
    uint64_t start_rank, const uint32_t* begin, const uint32_t* end, uint64_t* ans
2338
0
){
2339
0
    c = container_unwrap_shared(c, &type);
2340
0
    switch (type) {
2341
0
        case BITSET_CONTAINER_TYPE:
2342
0
            return bitset_container_rank_many(const_CAST_bitset(c), start_rank, begin, end, ans);
2343
0
        case ARRAY_CONTAINER_TYPE:
2344
0
            return array_container_rank_many(const_CAST_array(c), start_rank, begin, end, ans);
2345
0
        case RUN_CONTAINER_TYPE:
2346
0
            return run_container_rank_many(const_CAST_run(c), start_rank, begin, end, ans);
2347
0
        default:
2348
0
            assert(false);
2349
0
            roaring_unreachable;
2350
0
    }
2351
0
    assert(false);
2352
0
    roaring_unreachable;
2353
0
    return 0;
2354
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL19container_rank_manyEPKNS_3api11container_sEhmPKjS6_Pm
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL19container_rank_manyEPKNS_3api11container_sEhmPKjS6_Pm
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL19container_rank_manyEPKNS_3api11container_sEhmPKjS6_Pm
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL19container_rank_manyEPKNS_3api11container_sEhmPKjS6_Pm
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL19container_rank_manyEPKNS_3api11container_sEhmPKjS6_Pm
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL19container_rank_manyEPKNS_3api11container_sEhmPKjS6_Pm
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL19container_rank_manyEPKNS_3api11container_sEhmPKjS6_Pm
2355
2356
// return the index of x, if not exsist return -1
2357
static inline int container_get_index(const container_t *c, uint8_t type,
2358
0
                                    uint16_t x) {
2359
0
    c = container_unwrap_shared(c, &type);
2360
0
    switch (type) {
2361
0
        case BITSET_CONTAINER_TYPE:
2362
0
            return bitset_container_get_index(const_CAST_bitset(c), x);
2363
0
        case ARRAY_CONTAINER_TYPE:
2364
0
            return array_container_get_index(const_CAST_array(c), x);
2365
0
        case RUN_CONTAINER_TYPE:
2366
0
            return run_container_get_index(const_CAST_run(c), x);
2367
0
        default:
2368
0
            assert(false);
2369
0
            roaring_unreachable;
2370
0
    }
2371
0
    assert(false);
2372
0
    roaring_unreachable;
2373
0
    return false;
2374
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL19container_get_indexEPKNS_3api11container_sEht
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL19container_get_indexEPKNS_3api11container_sEht
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL19container_get_indexEPKNS_3api11container_sEht
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL19container_get_indexEPKNS_3api11container_sEht
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL19container_get_indexEPKNS_3api11container_sEht
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL19container_get_indexEPKNS_3api11container_sEht
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL19container_get_indexEPKNS_3api11container_sEht
2375
2376
/**
2377
 * Add all values in range [min, max] to a given container.
2378
 *
2379
 * If the returned pointer is different from $container, then a new container
2380
 * has been created and the caller is responsible for freeing it.
2381
 * The type of the first container may change. Returns the modified
2382
 * (and possibly new) container.
2383
 */
2384
static inline container_t *container_add_range(
2385
    container_t *c, uint8_t type,
2386
    uint32_t min, uint32_t max,
2387
    uint8_t *result_type
2388
0
){
2389
0
    // NB: when selecting new container type, we perform only inexpensive checks
2390
0
    switch (type) {
2391
0
        case BITSET_CONTAINER_TYPE: {
2392
0
            bitset_container_t *bitset = CAST_bitset(c);
2393
0
2394
0
            int32_t union_cardinality = 0;
2395
0
            union_cardinality += bitset->cardinality;
2396
0
            union_cardinality += max - min + 1;
2397
0
            union_cardinality -= bitset_lenrange_cardinality(bitset->words,
2398
0
                                                             min, max-min);
2399
0
2400
0
            if (union_cardinality == INT32_C(0x10000)) {
2401
0
                *result_type = RUN_CONTAINER_TYPE;
2402
0
                return run_container_create_range(0, INT32_C(0x10000));
2403
0
            } else {
2404
0
                *result_type = BITSET_CONTAINER_TYPE;
2405
0
                bitset_set_lenrange(bitset->words, min, max - min);
2406
0
                bitset->cardinality = union_cardinality;
2407
0
                return bitset;
2408
0
            }
2409
0
        }
2410
0
        case ARRAY_CONTAINER_TYPE: {
2411
0
            array_container_t *array = CAST_array(c);
2412
0
2413
0
            int32_t nvals_greater = count_greater(array->array, array->cardinality, (uint16_t)max);
2414
0
            int32_t nvals_less = count_less(array->array, array->cardinality - nvals_greater, (uint16_t)min);
2415
0
            int32_t union_cardinality = nvals_less + (max - min + 1) + nvals_greater;
2416
0
2417
0
            if (union_cardinality == INT32_C(0x10000)) {
2418
0
                *result_type = RUN_CONTAINER_TYPE;
2419
0
                return run_container_create_range(0, INT32_C(0x10000));
2420
0
            } else if (union_cardinality <= DEFAULT_MAX_SIZE) {
2421
0
                *result_type = ARRAY_CONTAINER_TYPE;
2422
0
                array_container_add_range_nvals(array, min, max, nvals_less, nvals_greater);
2423
0
                return array;
2424
0
            } else {
2425
0
                *result_type = BITSET_CONTAINER_TYPE;
2426
0
                bitset_container_t *bitset = bitset_container_from_array(array);
2427
0
                bitset_set_lenrange(bitset->words, min, max - min);
2428
0
                bitset->cardinality = union_cardinality;
2429
0
                return bitset;
2430
0
            }
2431
0
        }
2432
0
        case RUN_CONTAINER_TYPE: {
2433
0
            run_container_t *run = CAST_run(c);
2434
0
2435
0
            int32_t nruns_greater = rle16_count_greater(run->runs, run->n_runs, (uint16_t)max);
2436
0
            int32_t nruns_less = rle16_count_less(run->runs, run->n_runs - nruns_greater, (uint16_t)min);
2437
0
2438
0
            int32_t run_size_bytes = (nruns_less + 1 + nruns_greater) * sizeof(rle16_t);
2439
0
            int32_t bitset_size_bytes = BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
2440
0
2441
0
            if (run_size_bytes <= bitset_size_bytes) {
2442
0
                run_container_add_range_nruns(run, min, max, nruns_less, nruns_greater);
2443
0
                *result_type = RUN_CONTAINER_TYPE;
2444
0
                return run;
2445
0
            } else {
2446
0
                return container_from_run_range(run, min, max, result_type);
2447
0
            }
2448
0
        }
2449
0
        default:
2450
0
            roaring_unreachable;
2451
0
    }
2452
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL19container_add_rangeEPNS_3api11container_sEhjjPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL19container_add_rangeEPNS_3api11container_sEhjjPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL19container_add_rangeEPNS_3api11container_sEhjjPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL19container_add_rangeEPNS_3api11container_sEhjjPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL19container_add_rangeEPNS_3api11container_sEhjjPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL19container_add_rangeEPNS_3api11container_sEhjjPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL19container_add_rangeEPNS_3api11container_sEhjjPh
2453
2454
/*
2455
 * Removes all elements in range [min, max].
2456
 * Returns one of:
2457
 *   - NULL if no elements left
2458
 *   - pointer to the original container
2459
 *   - pointer to a newly-allocated container (if it is more efficient)
2460
 *
2461
 * If the returned pointer is different from $container, then a new container
2462
 * has been created and the caller is responsible for freeing the original container.
2463
 */
2464
static inline container_t *container_remove_range(
2465
    container_t *c, uint8_t type,
2466
    uint32_t min, uint32_t max,
2467
    uint8_t *result_type
2468
0
){
2469
0
     switch (type) {
2470
0
        case BITSET_CONTAINER_TYPE: {
2471
0
            bitset_container_t *bitset = CAST_bitset(c);
2472
0
2473
0
            int32_t result_cardinality = bitset->cardinality -
2474
0
                bitset_lenrange_cardinality(bitset->words, min, max-min);
2475
0
2476
0
            if (result_cardinality == 0) {
2477
0
                return NULL;
2478
0
            } else if (result_cardinality <= DEFAULT_MAX_SIZE) {
2479
0
                *result_type = ARRAY_CONTAINER_TYPE;
2480
0
                bitset_reset_range(bitset->words, min, max+1);
2481
0
                bitset->cardinality = result_cardinality;
2482
0
                return array_container_from_bitset(bitset);
2483
0
            } else {
2484
0
                *result_type = BITSET_CONTAINER_TYPE;
2485
0
                bitset_reset_range(bitset->words, min, max+1);
2486
0
                bitset->cardinality = result_cardinality;
2487
0
                return bitset;
2488
0
            }
2489
0
        }
2490
0
        case ARRAY_CONTAINER_TYPE: {
2491
0
            array_container_t *array = CAST_array(c);
2492
0
2493
0
            int32_t nvals_greater = count_greater(array->array, array->cardinality, (uint16_t)max);
2494
0
            int32_t nvals_less = count_less(array->array, array->cardinality - nvals_greater, (uint16_t)min);
2495
0
            int32_t result_cardinality = nvals_less + nvals_greater;
2496
0
2497
0
            if (result_cardinality == 0) {
2498
0
                return NULL;
2499
0
            } else {
2500
0
                *result_type = ARRAY_CONTAINER_TYPE;
2501
0
                array_container_remove_range(array, nvals_less,
2502
0
                    array->cardinality - result_cardinality);
2503
0
                return array;
2504
0
            }
2505
0
        }
2506
0
        case RUN_CONTAINER_TYPE: {
2507
0
            run_container_t *run = CAST_run(c);
2508
0
2509
0
            if (run->n_runs == 0) {
2510
0
                return NULL;
2511
0
            }
2512
0
            if (min <= run_container_minimum(run) && max >= run_container_maximum(run)) {
2513
0
                return NULL;
2514
0
            }
2515
0
2516
0
            run_container_remove_range(run, min, max);
2517
0
            return convert_run_to_efficient_container(run, result_type);
2518
0
        }
2519
0
        default:
2520
0
            roaring_unreachable;
2521
0
     }
2522
0
}
Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL22container_remove_rangeEPNS_3api11container_sEhjjPh
Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL22container_remove_rangeEPNS_3api11container_sEhjjPh
Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL22container_remove_rangeEPNS_3api11container_sEhjjPh
Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL22container_remove_rangeEPNS_3api11container_sEhjjPh
Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL22container_remove_rangeEPNS_3api11container_sEhjjPh
Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL22container_remove_rangeEPNS_3api11container_sEhjjPh
Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL22container_remove_rangeEPNS_3api11container_sEhjjPh
2523
2524
#ifdef __cplusplus
2525
} } }  // extern "C" { namespace roaring { namespace internal {
2526
#endif
2527
2528
#endif