/var/local/thirdparty/installed/include/roaring/containers/run.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * run.h |
3 | | * |
4 | | */ |
5 | | |
6 | | #ifndef INCLUDE_CONTAINERS_RUN_H_ |
7 | | #define INCLUDE_CONTAINERS_RUN_H_ |
8 | | |
9 | | #include <assert.h> |
10 | | #include <stdbool.h> |
11 | | #include <stdint.h> |
12 | | #include <string.h> |
13 | | |
14 | | #include <roaring/portability.h> |
15 | | #include <roaring/roaring_types.h> // roaring_iterator |
16 | | #include <roaring/array_util.h> // binarySearch()/memequals() for inlining |
17 | | |
18 | | #include <roaring/containers/container_defs.h> // container_t, perfparameters |
19 | | |
20 | | #ifdef __cplusplus |
21 | | extern "C" { namespace roaring { |
22 | | |
23 | | // Note: in pure C++ code, you should avoid putting `using` in header files |
24 | | using api::roaring_iterator; |
25 | | using api::roaring_iterator64; |
26 | | |
27 | | namespace internal { |
28 | | #endif |
29 | | |
30 | | /* struct rle16_s - run length pair |
31 | | * |
32 | | * @value: start position of the run |
33 | | * @length: length of the run is `length + 1` |
34 | | * |
35 | | * An RLE pair {v, l} would represent the integers between the interval |
36 | | * [v, v+l+1], e.g. {3, 2} = [3, 4, 5]. |
37 | | */ |
38 | | struct rle16_s { |
39 | | uint16_t value; |
40 | | uint16_t length; |
41 | | }; |
42 | | |
43 | | typedef struct rle16_s rle16_t; |
44 | | |
45 | | #ifdef __cplusplus |
46 | | #define MAKE_RLE16(val,len) \ |
47 | | {(uint16_t)(val), (uint16_t)(len)} // no tagged structs until c++20 |
48 | | #else |
49 | | #define MAKE_RLE16(val,len) \ |
50 | | (rle16_t){.value = (uint16_t)(val), .length = (uint16_t)(len)} |
51 | | #endif |
52 | | |
53 | | /* struct run_container_s - run container bitmap |
54 | | * |
55 | | * @n_runs: number of rle_t pairs in `runs`. |
56 | | * @capacity: capacity in rle_t pairs `runs` can hold. |
57 | | * @runs: pairs of rle_t. |
58 | | */ |
59 | | STRUCT_CONTAINER(run_container_s) { |
60 | | int32_t n_runs; |
61 | | int32_t capacity; |
62 | | rle16_t *runs; |
63 | | }; |
64 | | |
65 | | typedef struct run_container_s run_container_t; |
66 | | |
67 | | #define CAST_run(c) CAST(run_container_t *, c) // safer downcast |
68 | | #define const_CAST_run(c) CAST(const run_container_t *, c) |
69 | | #define movable_CAST_run(c) movable_CAST(run_container_t **, c) |
70 | | |
71 | | /* Create a new run container. Return NULL in case of failure. */ |
72 | | run_container_t *run_container_create(void); |
73 | | |
74 | | /* Create a new run container with given capacity. Return NULL in case of |
75 | | * failure. */ |
76 | | run_container_t *run_container_create_given_capacity(int32_t size); |
77 | | |
78 | | /* |
79 | | * Shrink the capacity to the actual size, return the number of bytes saved. |
80 | | */ |
81 | | int run_container_shrink_to_fit(run_container_t *src); |
82 | | |
83 | | /* Free memory owned by `run'. */ |
84 | | void run_container_free(run_container_t *run); |
85 | | |
86 | | /* Duplicate container */ |
87 | | run_container_t *run_container_clone(const run_container_t *src); |
88 | | |
89 | | /* |
90 | | * Effectively deletes the value at index index, repacking data. |
91 | | */ |
92 | 0 | static inline void recoverRoomAtIndex(run_container_t *run, uint16_t index) { |
93 | 0 | memmove(run->runs + index, run->runs + (1 + index), |
94 | 0 | (run->n_runs - index - 1) * sizeof(rle16_t)); |
95 | 0 | run->n_runs--; |
96 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL18recoverRoomAtIndexEPNS0_15run_container_sEt Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL18recoverRoomAtIndexEPNS0_15run_container_sEt Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL18recoverRoomAtIndexEPNS0_15run_container_sEt Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL18recoverRoomAtIndexEPNS0_15run_container_sEt Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL18recoverRoomAtIndexEPNS0_15run_container_sEt Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL18recoverRoomAtIndexEPNS0_15run_container_sEt Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL18recoverRoomAtIndexEPNS0_15run_container_sEt |
97 | | |
98 | | /** |
99 | | * Good old binary search through rle data |
100 | | */ |
101 | | inline int32_t interleavedBinarySearch(const rle16_t *array, int32_t lenarray, |
102 | 0 | uint16_t ikey) { |
103 | 0 | int32_t low = 0; |
104 | 0 | int32_t high = lenarray - 1; |
105 | 0 | while (low <= high) { |
106 | 0 | int32_t middleIndex = (low + high) >> 1; |
107 | 0 | uint16_t middleValue = array[middleIndex].value; |
108 | 0 | if (middleValue < ikey) { |
109 | 0 | low = middleIndex + 1; |
110 | 0 | } else if (middleValue > ikey) { |
111 | 0 | high = middleIndex - 1; |
112 | 0 | } else { |
113 | 0 | return middleIndex; |
114 | 0 | } |
115 | 0 | } |
116 | 0 | return -(low + 1); |
117 | 0 | } |
118 | | |
119 | | /* |
120 | | * Returns index of the run which contains $ikey |
121 | | */ |
122 | | static inline int32_t rle16_find_run(const rle16_t *array, int32_t lenarray, |
123 | 0 | uint16_t ikey) { |
124 | 0 | int32_t low = 0; |
125 | 0 | int32_t high = lenarray - 1; |
126 | 0 | while (low <= high) { |
127 | 0 | int32_t middleIndex = (low + high) >> 1; |
128 | 0 | uint16_t min = array[middleIndex].value; |
129 | 0 | uint16_t max = array[middleIndex].value + array[middleIndex].length; |
130 | 0 | if (ikey > max) { |
131 | 0 | low = middleIndex + 1; |
132 | 0 | } else if (ikey < min) { |
133 | 0 | high = middleIndex - 1; |
134 | 0 | } else { |
135 | 0 | return middleIndex; |
136 | 0 | } |
137 | 0 | } |
138 | 0 | return -(low + 1); |
139 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL14rle16_find_runEPKNS0_7rle16_sEit Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL14rle16_find_runEPKNS0_7rle16_sEit Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL14rle16_find_runEPKNS0_7rle16_sEit Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL14rle16_find_runEPKNS0_7rle16_sEit Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL14rle16_find_runEPKNS0_7rle16_sEit Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL14rle16_find_runEPKNS0_7rle16_sEit Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL14rle16_find_runEPKNS0_7rle16_sEit |
140 | | |
141 | | |
142 | | /** |
143 | | * Returns number of runs which can'be be merged with the key because they |
144 | | * are less than the key. |
145 | | * Note that [5,6,7,8] can be merged with the key 9 and won't be counted. |
146 | | */ |
147 | | static inline int32_t rle16_count_less(const rle16_t* array, int32_t lenarray, |
148 | 0 | uint16_t key) { |
149 | 0 | if (lenarray == 0) return 0; |
150 | 0 | int32_t low = 0; |
151 | 0 | int32_t high = lenarray - 1; |
152 | 0 | while (low <= high) { |
153 | 0 | int32_t middleIndex = (low + high) >> 1; |
154 | 0 | uint16_t min_value = array[middleIndex].value; |
155 | 0 | uint16_t max_value = array[middleIndex].value + array[middleIndex].length; |
156 | 0 | if (max_value + UINT32_C(1) < key) { // uint32 arithmetic |
157 | 0 | low = middleIndex + 1; |
158 | 0 | } else if (key < min_value) { |
159 | 0 | high = middleIndex - 1; |
160 | 0 | } else { |
161 | 0 | return middleIndex; |
162 | 0 | } |
163 | 0 | } |
164 | 0 | return low; |
165 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL16rle16_count_lessEPKNS0_7rle16_sEit Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL16rle16_count_lessEPKNS0_7rle16_sEit Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL16rle16_count_lessEPKNS0_7rle16_sEit Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL16rle16_count_lessEPKNS0_7rle16_sEit Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL16rle16_count_lessEPKNS0_7rle16_sEit Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL16rle16_count_lessEPKNS0_7rle16_sEit Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL16rle16_count_lessEPKNS0_7rle16_sEit |
166 | | |
167 | | static inline int32_t rle16_count_greater(const rle16_t* array, int32_t lenarray, |
168 | 0 | uint16_t key) { |
169 | 0 | if (lenarray == 0) return 0; |
170 | 0 | int32_t low = 0; |
171 | 0 | int32_t high = lenarray - 1; |
172 | 0 | while (low <= high) { |
173 | 0 | int32_t middleIndex = (low + high) >> 1; |
174 | 0 | uint16_t min_value = array[middleIndex].value; |
175 | 0 | uint16_t max_value = array[middleIndex].value + array[middleIndex].length; |
176 | 0 | if (max_value < key) { |
177 | 0 | low = middleIndex + 1; |
178 | 0 | } else if (key + UINT32_C(1) < min_value) { // uint32 arithmetic |
179 | 0 | high = middleIndex - 1; |
180 | 0 | } else { |
181 | 0 | return lenarray - (middleIndex + 1); |
182 | 0 | } |
183 | 0 | } |
184 | 0 | return lenarray - low; |
185 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL19rle16_count_greaterEPKNS0_7rle16_sEit Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL19rle16_count_greaterEPKNS0_7rle16_sEit Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL19rle16_count_greaterEPKNS0_7rle16_sEit Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL19rle16_count_greaterEPKNS0_7rle16_sEit Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL19rle16_count_greaterEPKNS0_7rle16_sEit Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL19rle16_count_greaterEPKNS0_7rle16_sEit Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL19rle16_count_greaterEPKNS0_7rle16_sEit |
186 | | |
187 | | /** |
188 | | * increase capacity to at least min. Whether the |
189 | | * existing data needs to be copied over depends on copy. If "copy" is false, |
190 | | * then the new content will be uninitialized, otherwise a copy is made. |
191 | | */ |
192 | | void run_container_grow(run_container_t *run, int32_t min, bool copy); |
193 | | |
194 | | /** |
195 | | * Moves the data so that we can write data at index |
196 | | */ |
197 | 0 | static inline void makeRoomAtIndex(run_container_t *run, uint16_t index) { |
198 | 0 | /* This function calls realloc + memmove sequentially to move by one index. |
199 | 0 | * Potentially copying twice the array. |
200 | 0 | */ |
201 | 0 | if (run->n_runs + 1 > run->capacity) |
202 | 0 | run_container_grow(run, run->n_runs + 1, true); |
203 | 0 | memmove(run->runs + 1 + index, run->runs + index, |
204 | 0 | (run->n_runs - index) * sizeof(rle16_t)); |
205 | 0 | run->n_runs++; |
206 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL15makeRoomAtIndexEPNS0_15run_container_sEt Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL15makeRoomAtIndexEPNS0_15run_container_sEt Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL15makeRoomAtIndexEPNS0_15run_container_sEt Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL15makeRoomAtIndexEPNS0_15run_container_sEt Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL15makeRoomAtIndexEPNS0_15run_container_sEt Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL15makeRoomAtIndexEPNS0_15run_container_sEt Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL15makeRoomAtIndexEPNS0_15run_container_sEt |
207 | | |
208 | | /* Add `pos' to `run'. Returns true if `pos' was not present. */ |
209 | | bool run_container_add(run_container_t *run, uint16_t pos); |
210 | | |
211 | | /* Remove `pos' from `run'. Returns true if `pos' was present. */ |
212 | 0 | static inline bool run_container_remove(run_container_t *run, uint16_t pos) { |
213 | 0 | int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos); |
214 | 0 | if (index >= 0) { |
215 | 0 | int32_t le = run->runs[index].length; |
216 | 0 | if (le == 0) { |
217 | 0 | recoverRoomAtIndex(run, (uint16_t)index); |
218 | 0 | } else { |
219 | 0 | run->runs[index].value++; |
220 | 0 | run->runs[index].length--; |
221 | 0 | } |
222 | 0 | return true; |
223 | 0 | } |
224 | 0 | index = -index - 2; // points to preceding value, possibly -1 |
225 | 0 | if (index >= 0) { // possible match |
226 | 0 | int32_t offset = pos - run->runs[index].value; |
227 | 0 | int32_t le = run->runs[index].length; |
228 | 0 | if (offset < le) { |
229 | 0 | // need to break in two |
230 | 0 | run->runs[index].length = (uint16_t)(offset - 1); |
231 | 0 | // need to insert |
232 | 0 | uint16_t newvalue = pos + 1; |
233 | 0 | int32_t newlength = le - offset - 1; |
234 | 0 | makeRoomAtIndex(run, (uint16_t)(index + 1)); |
235 | 0 | run->runs[index + 1].value = newvalue; |
236 | 0 | run->runs[index + 1].length = (uint16_t)newlength; |
237 | 0 | return true; |
238 | 0 |
|
239 | 0 | } else if (offset == le) { |
240 | 0 | run->runs[index].length--; |
241 | 0 | return true; |
242 | 0 | } |
243 | 0 | } |
244 | 0 | // no match |
245 | 0 | return false; |
246 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL20run_container_removeEPNS0_15run_container_sEt Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL20run_container_removeEPNS0_15run_container_sEt Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL20run_container_removeEPNS0_15run_container_sEt Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL20run_container_removeEPNS0_15run_container_sEt Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL20run_container_removeEPNS0_15run_container_sEt Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL20run_container_removeEPNS0_15run_container_sEt Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL20run_container_removeEPNS0_15run_container_sEt |
247 | | |
248 | | /* Check whether `pos' is present in `run'. */ |
249 | 0 | inline bool run_container_contains(const run_container_t *run, uint16_t pos) { |
250 | 0 | int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos); |
251 | 0 | if (index >= 0) return true; |
252 | 0 | index = -index - 2; // points to preceding value, possibly -1 |
253 | 0 | if (index != -1) { // possible match |
254 | 0 | int32_t offset = pos - run->runs[index].value; |
255 | 0 | int32_t le = run->runs[index].length; |
256 | 0 | if (offset <= le) return true; |
257 | 0 | } |
258 | 0 | return false; |
259 | 0 | } |
260 | | |
261 | | /* |
262 | | * Check whether all positions in a range of positions from pos_start (included) |
263 | | * to pos_end (excluded) is present in `run'. |
264 | | */ |
265 | | static inline bool run_container_contains_range(const run_container_t *run, |
266 | 0 | uint32_t pos_start, uint32_t pos_end) { |
267 | 0 | uint32_t count = 0; |
268 | 0 | int32_t index = interleavedBinarySearch(run->runs, run->n_runs, (uint16_t)pos_start); |
269 | 0 | if (index < 0) { |
270 | 0 | index = -index - 2; |
271 | 0 | if ((index == -1) || ((pos_start - run->runs[index].value) > run->runs[index].length)){ |
272 | 0 | return false; |
273 | 0 | } |
274 | 0 | } |
275 | 0 | for (int32_t i = index; i < run->n_runs; ++i) { |
276 | 0 | const uint32_t stop = run->runs[i].value + run->runs[i].length; |
277 | 0 | if (run->runs[i].value >= pos_end) break; |
278 | 0 | if (stop >= pos_end) { |
279 | 0 | count += (((pos_end - run->runs[i].value) > 0) ? (pos_end - run->runs[i].value) : 0); |
280 | 0 | break; |
281 | 0 | } |
282 | 0 | const uint32_t min = (stop - pos_start) > 0 ? (stop - pos_start) : 0; |
283 | 0 | count += (min < run->runs[i].length) ? min : run->runs[i].length; |
284 | 0 | } |
285 | 0 | return count >= (pos_end - pos_start - 1); |
286 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL28run_container_contains_rangeEPKNS0_15run_container_sEjj Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL28run_container_contains_rangeEPKNS0_15run_container_sEjj Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL28run_container_contains_rangeEPKNS0_15run_container_sEjj Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL28run_container_contains_rangeEPKNS0_15run_container_sEjj Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL28run_container_contains_rangeEPKNS0_15run_container_sEjj Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL28run_container_contains_rangeEPKNS0_15run_container_sEjj Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL28run_container_contains_rangeEPKNS0_15run_container_sEjj |
287 | | |
288 | | /* Get the cardinality of `run'. Requires an actual computation. */ |
289 | | int run_container_cardinality(const run_container_t *run); |
290 | | |
291 | | /* Card > 0?, see run_container_empty for the reverse */ |
292 | | static inline bool run_container_nonzero_cardinality( |
293 | 0 | const run_container_t *run) { |
294 | 0 | return run->n_runs > 0; // runs never empty |
295 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL33run_container_nonzero_cardinalityEPKNS0_15run_container_sE Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL33run_container_nonzero_cardinalityEPKNS0_15run_container_sE Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL33run_container_nonzero_cardinalityEPKNS0_15run_container_sE Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL33run_container_nonzero_cardinalityEPKNS0_15run_container_sE Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL33run_container_nonzero_cardinalityEPKNS0_15run_container_sE Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL33run_container_nonzero_cardinalityEPKNS0_15run_container_sE Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL33run_container_nonzero_cardinalityEPKNS0_15run_container_sE |
296 | | |
297 | | /* Card == 0?, see run_container_nonzero_cardinality for the reverse */ |
298 | | static inline bool run_container_empty( |
299 | 0 | const run_container_t *run) { |
300 | 0 | return run->n_runs == 0; // runs never empty |
301 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL19run_container_emptyEPKNS0_15run_container_sE Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL19run_container_emptyEPKNS0_15run_container_sE Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL19run_container_emptyEPKNS0_15run_container_sE Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL19run_container_emptyEPKNS0_15run_container_sE Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL19run_container_emptyEPKNS0_15run_container_sE Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL19run_container_emptyEPKNS0_15run_container_sE Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL19run_container_emptyEPKNS0_15run_container_sE |
302 | | |
303 | | |
304 | | |
305 | | /* Copy one container into another. We assume that they are distinct. */ |
306 | | void run_container_copy(const run_container_t *src, run_container_t *dst); |
307 | | |
308 | | /** |
309 | | * Append run described by vl to the run container, possibly merging. |
310 | | * It is assumed that the run would be inserted at the end of the container, no |
311 | | * check is made. |
312 | | * It is assumed that the run container has the necessary capacity: caller is |
313 | | * responsible for checking memory capacity. |
314 | | * |
315 | | * |
316 | | * This is not a safe function, it is meant for performance: use with care. |
317 | | */ |
318 | | static inline void run_container_append(run_container_t *run, rle16_t vl, |
319 | 0 | rle16_t *previousrl) { |
320 | 0 | const uint32_t previousend = previousrl->value + previousrl->length; |
321 | 0 | if (vl.value > previousend + 1) { // we add a new one |
322 | 0 | run->runs[run->n_runs] = vl; |
323 | 0 | run->n_runs++; |
324 | 0 | *previousrl = vl; |
325 | 0 | } else { |
326 | 0 | uint32_t newend = vl.value + vl.length + UINT32_C(1); |
327 | 0 | if (newend > previousend) { // we merge |
328 | 0 | previousrl->length = (uint16_t)(newend - 1 - previousrl->value); |
329 | 0 | run->runs[run->n_runs - 1] = *previousrl; |
330 | 0 | } |
331 | 0 | } |
332 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL20run_container_appendEPNS0_15run_container_sENS0_7rle16_sEPS3_ Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL20run_container_appendEPNS0_15run_container_sENS0_7rle16_sEPS3_ Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL20run_container_appendEPNS0_15run_container_sENS0_7rle16_sEPS3_ Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL20run_container_appendEPNS0_15run_container_sENS0_7rle16_sEPS3_ Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL20run_container_appendEPNS0_15run_container_sENS0_7rle16_sEPS3_ Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL20run_container_appendEPNS0_15run_container_sENS0_7rle16_sEPS3_ Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL20run_container_appendEPNS0_15run_container_sENS0_7rle16_sEPS3_ |
333 | | |
334 | | /** |
335 | | * Like run_container_append but it is assumed that the content of run is empty. |
336 | | */ |
337 | | static inline rle16_t run_container_append_first(run_container_t *run, |
338 | 0 | rle16_t vl) { |
339 | 0 | run->runs[run->n_runs] = vl; |
340 | 0 | run->n_runs++; |
341 | 0 | return vl; |
342 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL26run_container_append_firstEPNS0_15run_container_sENS0_7rle16_sE Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL26run_container_append_firstEPNS0_15run_container_sENS0_7rle16_sE Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL26run_container_append_firstEPNS0_15run_container_sENS0_7rle16_sE Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL26run_container_append_firstEPNS0_15run_container_sENS0_7rle16_sE Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL26run_container_append_firstEPNS0_15run_container_sENS0_7rle16_sE Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL26run_container_append_firstEPNS0_15run_container_sENS0_7rle16_sE Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL26run_container_append_firstEPNS0_15run_container_sENS0_7rle16_sE |
343 | | |
344 | | /** |
345 | | * append a single value given by val to the run container, possibly merging. |
346 | | * It is assumed that the value would be inserted at the end of the container, |
347 | | * no check is made. |
348 | | * It is assumed that the run container has the necessary capacity: caller is |
349 | | * responsible for checking memory capacity. |
350 | | * |
351 | | * This is not a safe function, it is meant for performance: use with care. |
352 | | */ |
353 | | static inline void run_container_append_value(run_container_t *run, |
354 | | uint16_t val, |
355 | 0 | rle16_t *previousrl) { |
356 | 0 | const uint32_t previousend = previousrl->value + previousrl->length; |
357 | 0 | if (val > previousend + 1) { // we add a new one |
358 | 0 | *previousrl = MAKE_RLE16(val, 0); |
359 | 0 | run->runs[run->n_runs] = *previousrl; |
360 | 0 | run->n_runs++; |
361 | 0 | } else if (val == previousend + 1) { // we merge |
362 | 0 | previousrl->length++; |
363 | 0 | run->runs[run->n_runs - 1] = *previousrl; |
364 | 0 | } |
365 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL26run_container_append_valueEPNS0_15run_container_sEtPNS0_7rle16_sE Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL26run_container_append_valueEPNS0_15run_container_sEtPNS0_7rle16_sE Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL26run_container_append_valueEPNS0_15run_container_sEtPNS0_7rle16_sE Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL26run_container_append_valueEPNS0_15run_container_sEtPNS0_7rle16_sE Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL26run_container_append_valueEPNS0_15run_container_sEtPNS0_7rle16_sE Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL26run_container_append_valueEPNS0_15run_container_sEtPNS0_7rle16_sE Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL26run_container_append_valueEPNS0_15run_container_sEtPNS0_7rle16_sE |
366 | | |
367 | | /** |
368 | | * Like run_container_append_value but it is assumed that the content of run is |
369 | | * empty. |
370 | | */ |
371 | | static inline rle16_t run_container_append_value_first(run_container_t *run, |
372 | 0 | uint16_t val) { |
373 | 0 | rle16_t newrle = MAKE_RLE16(val, 0); |
374 | 0 | run->runs[run->n_runs] = newrle; |
375 | 0 | run->n_runs++; |
376 | 0 | return newrle; |
377 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL32run_container_append_value_firstEPNS0_15run_container_sEt Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL32run_container_append_value_firstEPNS0_15run_container_sEt Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL32run_container_append_value_firstEPNS0_15run_container_sEt Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL32run_container_append_value_firstEPNS0_15run_container_sEt Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL32run_container_append_value_firstEPNS0_15run_container_sEt Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL32run_container_append_value_firstEPNS0_15run_container_sEt Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL32run_container_append_value_firstEPNS0_15run_container_sEt |
378 | | |
379 | | /* Check whether the container spans the whole chunk (cardinality = 1<<16). |
380 | | * This check can be done in constant time (inexpensive). */ |
381 | 0 | static inline bool run_container_is_full(const run_container_t *run) { |
382 | 0 | rle16_t vl = run->runs[0]; |
383 | 0 | return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF); |
384 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL21run_container_is_fullEPKNS0_15run_container_sE Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL21run_container_is_fullEPKNS0_15run_container_sE Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL21run_container_is_fullEPKNS0_15run_container_sE Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL21run_container_is_fullEPKNS0_15run_container_sE Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL21run_container_is_fullEPKNS0_15run_container_sE Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL21run_container_is_fullEPKNS0_15run_container_sE Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL21run_container_is_fullEPKNS0_15run_container_sE |
385 | | |
386 | | /* Compute the union of `src_1' and `src_2' and write the result to `dst' |
387 | | * It is assumed that `dst' is distinct from both `src_1' and `src_2'. */ |
388 | | void run_container_union(const run_container_t *src_1, |
389 | | const run_container_t *src_2, run_container_t *dst); |
390 | | |
391 | | /* Compute the union of `src_1' and `src_2' and write the result to `src_1' */ |
392 | | void run_container_union_inplace(run_container_t *src_1, |
393 | | const run_container_t *src_2); |
394 | | |
395 | | /* Compute the intersection of src_1 and src_2 and write the result to |
396 | | * dst. It is assumed that dst is distinct from both src_1 and src_2. */ |
397 | | void run_container_intersection(const run_container_t *src_1, |
398 | | const run_container_t *src_2, |
399 | | run_container_t *dst); |
400 | | |
401 | | /* Compute the size of the intersection of src_1 and src_2 . */ |
402 | | int run_container_intersection_cardinality(const run_container_t *src_1, |
403 | | const run_container_t *src_2); |
404 | | |
405 | | /* Check whether src_1 and src_2 intersect. */ |
406 | | bool run_container_intersect(const run_container_t *src_1, |
407 | | const run_container_t *src_2); |
408 | | |
409 | | /* Compute the symmetric difference of `src_1' and `src_2' and write the result |
410 | | * to `dst' |
411 | | * It is assumed that `dst' is distinct from both `src_1' and `src_2'. */ |
412 | | void run_container_xor(const run_container_t *src_1, |
413 | | const run_container_t *src_2, run_container_t *dst); |
414 | | |
415 | | /* |
416 | | * Write out the 16-bit integers contained in this container as a list of 32-bit |
417 | | * integers using base |
418 | | * as the starting value (it might be expected that base has zeros in its 16 |
419 | | * least significant bits). |
420 | | * The function returns the number of values written. |
421 | | * The caller is responsible for allocating enough memory in out. |
422 | | */ |
423 | | int run_container_to_uint32_array(void *vout, const run_container_t *cont, |
424 | | uint32_t base); |
425 | | |
426 | | /* |
427 | | * Print this container using printf (useful for debugging). |
428 | | */ |
429 | | void run_container_printf(const run_container_t *v); |
430 | | |
431 | | /* |
432 | | * Print this container using printf as a comma-separated list of 32-bit |
433 | | * integers starting at base. |
434 | | */ |
435 | | void run_container_printf_as_uint32_array(const run_container_t *v, |
436 | | uint32_t base); |
437 | | |
438 | | bool run_container_validate(const run_container_t *run, const char **reason); |
439 | | |
440 | | /** |
441 | | * Return the serialized size in bytes of a container having "num_runs" runs. |
442 | | */ |
443 | 0 | static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) { |
444 | 0 | return sizeof(uint16_t) + |
445 | 0 | sizeof(rle16_t) * num_runs; // each run requires 2 2-byte entries. |
446 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL38run_container_serialized_size_in_bytesEi Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL38run_container_serialized_size_in_bytesEi Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL38run_container_serialized_size_in_bytesEi Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL38run_container_serialized_size_in_bytesEi Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL38run_container_serialized_size_in_bytesEi Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL38run_container_serialized_size_in_bytesEi Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL38run_container_serialized_size_in_bytesEi |
447 | | |
448 | | bool run_container_iterate(const run_container_t *cont, uint32_t base, |
449 | | roaring_iterator iterator, void *ptr); |
450 | | bool run_container_iterate64(const run_container_t *cont, uint32_t base, |
451 | | roaring_iterator64 iterator, uint64_t high_bits, |
452 | | void *ptr); |
453 | | |
454 | | /** |
455 | | * Writes the underlying array to buf, outputs how many bytes were written. |
456 | | * This is meant to be byte-by-byte compatible with the Java and Go versions of |
457 | | * Roaring. |
458 | | * The number of bytes written should be run_container_size_in_bytes(container). |
459 | | */ |
460 | | int32_t run_container_write(const run_container_t *container, char *buf); |
461 | | |
462 | | /** |
463 | | * Reads the instance from buf, outputs how many bytes were read. |
464 | | * This is meant to be byte-by-byte compatible with the Java and Go versions of |
465 | | * Roaring. |
466 | | * The number of bytes read should be bitset_container_size_in_bytes(container). |
467 | | * The cardinality parameter is provided for consistency with other containers, |
468 | | * but |
469 | | * it might be effectively ignored.. |
470 | | */ |
471 | | int32_t run_container_read(int32_t cardinality, run_container_t *container, |
472 | | const char *buf); |
473 | | |
474 | | /** |
475 | | * Return the serialized size in bytes of a container (see run_container_write). |
476 | | * This is meant to be compatible with the Java and Go versions of Roaring. |
477 | | */ |
478 | | static inline int32_t run_container_size_in_bytes( |
479 | 0 | const run_container_t *container) { |
480 | 0 | return run_container_serialized_size_in_bytes(container->n_runs); |
481 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL27run_container_size_in_bytesEPKNS0_15run_container_sE Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL27run_container_size_in_bytesEPKNS0_15run_container_sE Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL27run_container_size_in_bytesEPKNS0_15run_container_sE Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL27run_container_size_in_bytesEPKNS0_15run_container_sE Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL27run_container_size_in_bytesEPKNS0_15run_container_sE Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL27run_container_size_in_bytesEPKNS0_15run_container_sE Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL27run_container_size_in_bytesEPKNS0_15run_container_sE |
482 | | |
483 | | /** |
484 | | * Return true if the two containers have the same content. |
485 | | */ |
486 | | ALLOW_UNALIGNED |
487 | | static inline bool run_container_equals(const run_container_t *container1, |
488 | 0 | const run_container_t *container2) { |
489 | 0 | if (container1->n_runs != container2->n_runs) { |
490 | 0 | return false; |
491 | 0 | } |
492 | 0 | return memequals(container1->runs, container2->runs, |
493 | 0 | container1->n_runs * sizeof(rle16_t)); |
494 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL20run_container_equalsEPKNS0_15run_container_sES3_ Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL20run_container_equalsEPKNS0_15run_container_sES3_ Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL20run_container_equalsEPKNS0_15run_container_sES3_ Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL20run_container_equalsEPKNS0_15run_container_sES3_ Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL20run_container_equalsEPKNS0_15run_container_sES3_ Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL20run_container_equalsEPKNS0_15run_container_sES3_ Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL20run_container_equalsEPKNS0_15run_container_sES3_ |
495 | | |
496 | | /** |
497 | | * Return true if container1 is a subset of container2. |
498 | | */ |
499 | | bool run_container_is_subset(const run_container_t *container1, |
500 | | const run_container_t *container2); |
501 | | |
502 | | /** |
503 | | * Used in a start-finish scan that appends segments, for XOR and NOT |
504 | | */ |
505 | | |
506 | | void run_container_smart_append_exclusive(run_container_t *src, |
507 | | const uint16_t start, |
508 | | const uint16_t length); |
509 | | |
510 | | /** |
511 | | * The new container consists of a single run [start,stop). |
512 | | * It is required that stop>start, the caller is responsability for this check. |
513 | | * It is required that stop <= (1<<16), the caller is responsability for this check. |
514 | | * The cardinality of the created container is stop - start. |
515 | | * Returns NULL on failure |
516 | | */ |
517 | | static inline run_container_t *run_container_create_range(uint32_t start, |
518 | 0 | uint32_t stop) { |
519 | 0 | run_container_t *rc = run_container_create_given_capacity(1); |
520 | 0 | if (rc) { |
521 | 0 | rle16_t r; |
522 | 0 | r.value = (uint16_t)start; |
523 | 0 | r.length = (uint16_t)(stop - start - 1); |
524 | 0 | run_container_append_first(rc, r); |
525 | 0 | } |
526 | 0 | return rc; |
527 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL26run_container_create_rangeEjj Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL26run_container_create_rangeEjj Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL26run_container_create_rangeEjj Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL26run_container_create_rangeEjj Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL26run_container_create_rangeEjj Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL26run_container_create_rangeEjj Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL26run_container_create_rangeEjj |
528 | | |
529 | | /** |
530 | | * If the element of given rank is in this container, supposing that the first |
531 | | * element has rank start_rank, then the function returns true and sets element |
532 | | * accordingly. |
533 | | * Otherwise, it returns false and update start_rank. |
534 | | */ |
535 | | bool run_container_select(const run_container_t *container, |
536 | | uint32_t *start_rank, uint32_t rank, |
537 | | uint32_t *element); |
538 | | |
539 | | /* Compute the difference of src_1 and src_2 and write the result to |
540 | | * dst. It is assumed that dst is distinct from both src_1 and src_2. */ |
541 | | |
542 | | void run_container_andnot(const run_container_t *src_1, |
543 | | const run_container_t *src_2, run_container_t *dst); |
544 | | |
545 | | void run_container_offset(const run_container_t *c, |
546 | | container_t **loc, container_t **hic, |
547 | | uint16_t offset); |
548 | | |
549 | | /* Returns the smallest value (assumes not empty) */ |
550 | 0 | inline uint16_t run_container_minimum(const run_container_t *run) { |
551 | 0 | if (run->n_runs == 0) return 0; |
552 | 0 | return run->runs[0].value; |
553 | 0 | } |
554 | | |
555 | | /* Returns the largest value (assumes not empty) */ |
556 | 0 | inline uint16_t run_container_maximum(const run_container_t *run) { |
557 | 0 | if (run->n_runs == 0) return 0; |
558 | 0 | return run->runs[run->n_runs - 1].value + run->runs[run->n_runs - 1].length; |
559 | 0 | } |
560 | | |
561 | | /* Returns the number of values equal or smaller than x */ |
562 | | int run_container_rank(const run_container_t *arr, uint16_t x); |
563 | | |
564 | | /* bulk version of run_container_rank(); return number of consumed elements */ |
565 | | uint32_t run_container_rank_many(const run_container_t *arr, uint64_t start_rank, |
566 | | const uint32_t* begin, const uint32_t* end, uint64_t* ans); |
567 | | |
568 | | /* Returns the index of x, if not exsist return -1 */ |
569 | | int run_container_get_index(const run_container_t *arr, uint16_t x); |
570 | | |
571 | | /* Returns the index of the first run containing a value at least as large as x, or -1 */ |
572 | 0 | inline int run_container_index_equalorlarger(const run_container_t *arr, uint16_t x) { |
573 | 0 | int32_t index = interleavedBinarySearch(arr->runs, arr->n_runs, x); |
574 | 0 | if (index >= 0) return index; |
575 | 0 | index = -index - 2; // points to preceding run, possibly -1 |
576 | 0 | if (index != -1) { // possible match |
577 | 0 | int32_t offset = x - arr->runs[index].value; |
578 | 0 | int32_t le = arr->runs[index].length; |
579 | 0 | if (offset <= le) return index; |
580 | 0 | } |
581 | 0 | index += 1; |
582 | 0 | if(index < arr->n_runs) { |
583 | 0 | return index; |
584 | 0 | } |
585 | 0 | return -1; |
586 | 0 | } |
587 | | |
588 | | /* |
589 | | * Add all values in range [min, max] using hint. |
590 | | */ |
591 | | static inline void run_container_add_range_nruns(run_container_t* run, |
592 | | uint32_t min, uint32_t max, |
593 | | int32_t nruns_less, |
594 | 0 | int32_t nruns_greater) { |
595 | 0 | int32_t nruns_common = run->n_runs - nruns_less - nruns_greater; |
596 | 0 | if (nruns_common == 0) { |
597 | 0 | makeRoomAtIndex(run, (uint16_t)nruns_less); |
598 | 0 | run->runs[nruns_less].value = (uint16_t)min; |
599 | 0 | run->runs[nruns_less].length = (uint16_t)(max - min); |
600 | 0 | } else { |
601 | 0 | uint32_t common_min = run->runs[nruns_less].value; |
602 | 0 | uint32_t common_max = run->runs[nruns_less + nruns_common - 1].value + |
603 | 0 | run->runs[nruns_less + nruns_common - 1].length; |
604 | 0 | uint32_t result_min = (common_min < min) ? common_min : min; |
605 | 0 | uint32_t result_max = (common_max > max) ? common_max : max; |
606 | 0 |
|
607 | 0 | run->runs[nruns_less].value = (uint16_t)result_min; |
608 | 0 | run->runs[nruns_less].length = (uint16_t)(result_max - result_min); |
609 | 0 |
|
610 | 0 | memmove(&(run->runs[nruns_less + 1]), |
611 | 0 | &(run->runs[run->n_runs - nruns_greater]), |
612 | 0 | nruns_greater*sizeof(rle16_t)); |
613 | 0 | run->n_runs = nruns_less + 1 + nruns_greater; |
614 | 0 | } |
615 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL29run_container_add_range_nrunsEPNS0_15run_container_sEjjii Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL29run_container_add_range_nrunsEPNS0_15run_container_sEjjii Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL29run_container_add_range_nrunsEPNS0_15run_container_sEjjii Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL29run_container_add_range_nrunsEPNS0_15run_container_sEjjii Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL29run_container_add_range_nrunsEPNS0_15run_container_sEjjii Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL29run_container_add_range_nrunsEPNS0_15run_container_sEjjii Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL29run_container_add_range_nrunsEPNS0_15run_container_sEjjii |
616 | | |
617 | | /** |
618 | | * Add all values in range [min, max]. This function is currently unused |
619 | | * and left as documentation. |
620 | | */ |
621 | | /*static inline void run_container_add_range(run_container_t* run, |
622 | | uint32_t min, uint32_t max) { |
623 | | int32_t nruns_greater = rle16_count_greater(run->runs, run->n_runs, max); |
624 | | int32_t nruns_less = rle16_count_less(run->runs, run->n_runs - nruns_greater, min); |
625 | | run_container_add_range_nruns(run, min, max, nruns_less, nruns_greater); |
626 | | }*/ |
627 | | |
628 | | /** |
629 | | * Shifts last $count elements either left (distance < 0) or right (distance > 0) |
630 | | */ |
631 | | static inline void run_container_shift_tail(run_container_t* run, |
632 | 0 | int32_t count, int32_t distance) { |
633 | 0 | if (distance > 0) { |
634 | 0 | if (run->capacity < count+distance) { |
635 | 0 | run_container_grow(run, count+distance, true); |
636 | 0 | } |
637 | 0 | } |
638 | 0 | int32_t srcpos = run->n_runs - count; |
639 | 0 | int32_t dstpos = srcpos + distance; |
640 | 0 | memmove(&(run->runs[dstpos]), &(run->runs[srcpos]), sizeof(rle16_t) * count); |
641 | 0 | run->n_runs += distance; |
642 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL24run_container_shift_tailEPNS0_15run_container_sEii Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL24run_container_shift_tailEPNS0_15run_container_sEii Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL24run_container_shift_tailEPNS0_15run_container_sEii Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL24run_container_shift_tailEPNS0_15run_container_sEii Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL24run_container_shift_tailEPNS0_15run_container_sEii Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL24run_container_shift_tailEPNS0_15run_container_sEii Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL24run_container_shift_tailEPNS0_15run_container_sEii |
643 | | |
644 | | /** |
645 | | * Remove all elements in range [min, max] |
646 | | */ |
647 | 0 | static inline void run_container_remove_range(run_container_t *run, uint32_t min, uint32_t max) { |
648 | 0 | int32_t first = rle16_find_run(run->runs, run->n_runs, (uint16_t)min); |
649 | 0 | int32_t last = rle16_find_run(run->runs, run->n_runs, (uint16_t)max); |
650 | 0 |
|
651 | 0 | if (first >= 0 && min > run->runs[first].value && |
652 | 0 | max < ((uint32_t)run->runs[first].value + (uint32_t)run->runs[first].length)) { |
653 | 0 | // split this run into two adjacent runs |
654 | 0 |
|
655 | 0 | // right subinterval |
656 | 0 | makeRoomAtIndex(run, (uint16_t)(first+1)); |
657 | 0 | run->runs[first+1].value = (uint16_t)(max + 1); |
658 | 0 | run->runs[first+1].length = (uint16_t)((run->runs[first].value + run->runs[first].length) - (max + 1)); |
659 | 0 |
|
660 | 0 | // left subinterval |
661 | 0 | run->runs[first].length = (uint16_t)((min - 1) - run->runs[first].value); |
662 | 0 |
|
663 | 0 | return; |
664 | 0 | } |
665 | 0 |
|
666 | 0 | // update left-most partial run |
667 | 0 | if (first >= 0) { |
668 | 0 | if (min > run->runs[first].value) { |
669 | 0 | run->runs[first].length = (uint16_t)((min - 1) - run->runs[first].value); |
670 | 0 | first++; |
671 | 0 | } |
672 | 0 | } else { |
673 | 0 | first = -first-1; |
674 | 0 | } |
675 | 0 |
|
676 | 0 | // update right-most run |
677 | 0 | if (last >= 0) { |
678 | 0 | uint16_t run_max = run->runs[last].value + run->runs[last].length; |
679 | 0 | if (run_max > max) { |
680 | 0 | run->runs[last].value = (uint16_t)(max + 1); |
681 | 0 | run->runs[last].length = (uint16_t)(run_max - (max + 1)); |
682 | 0 | last--; |
683 | 0 | } |
684 | 0 | } else { |
685 | 0 | last = (-last-1) - 1; |
686 | 0 | } |
687 | 0 |
|
688 | 0 | // remove intermediate runs |
689 | 0 | if (first <= last) { |
690 | 0 | run_container_shift_tail(run, run->n_runs - (last+1), -(last-first+1)); |
691 | 0 | } |
692 | 0 | } Unexecuted instantiation: bkd_writer.cpp:_ZN7roaring8internalL26run_container_remove_rangeEPNS0_15run_container_sEjj Unexecuted instantiation: bkd_reader.cpp:_ZN7roaring8internalL26run_container_remove_rangeEPNS0_15run_container_sEjj Unexecuted instantiation: packed_index_tree.cpp:_ZN7roaring8internalL26run_container_remove_rangeEPNS0_15run_container_sEjj Unexecuted instantiation: index_tree.cpp:_ZN7roaring8internalL26run_container_remove_rangeEPNS0_15run_container_sEjj Unexecuted instantiation: legacy_index_tree.cpp:_ZN7roaring8internalL26run_container_remove_rangeEPNS0_15run_container_sEjj Unexecuted instantiation: docids_writer.cpp:_ZN7roaring8internalL26run_container_remove_rangeEPNS0_15run_container_sEjj Unexecuted instantiation: IndexWriter.cpp:_ZN7roaring8internalL26run_container_remove_rangeEPNS0_15run_container_sEjj |
693 | | |
694 | | #ifdef __cplusplus |
695 | | } } } // extern "C" { namespace roaring { namespace internal { |
696 | | #endif |
697 | | |
698 | | #endif /* INCLUDE_CONTAINERS_RUN_H_ */ |