@@ -242,6 +242,17 @@ bool array_array_container_lazy_union(
242
242
container_t * * dst
243
243
){
244
244
int totalCardinality = src_1 -> cardinality + src_2 -> cardinality ;
245
+ //
246
+ // We assume that operations involving bitset containers will be faster than
247
+ // operations involving solely array containers, except maybe when array containers
248
+ // are small. Indeed, for example, it is cheap to compute the union between an array and
249
+ // a bitset container, generally more so than between a large array and another array.
250
+ // So it is advantageous to favour bitset containers during the computation.
251
+ // Of course, if we convert array containers eagerly to bitset containers, we may later
252
+ // need to revert the bitset containers to array containerr to satisfy the Roaring format requirements,
253
+ // but such one-time conversions at the end may not be overly expensive. We arrived to this design
254
+ // based on extensive benchmarking.
255
+ //
245
256
if (totalCardinality <= ARRAY_LAZY_LOWERBOUND ) {
246
257
* dst = array_container_create_given_capacity (totalCardinality );
247
258
if (* dst != NULL ) {
@@ -269,6 +280,17 @@ bool array_array_container_lazy_inplace_union(
269
280
){
270
281
int totalCardinality = src_1 -> cardinality + src_2 -> cardinality ;
271
282
* dst = NULL ;
283
+ //
284
+ // We assume that operations involving bitset containers will be faster than
285
+ // operations involving solely array containers, except maybe when array containers
286
+ // are small. Indeed, for example, it is cheap to compute the union between an array and
287
+ // a bitset container, generally more so than between a large array and another array.
288
+ // So it is advantageous to favour bitset containers during the computation.
289
+ // Of course, if we convert array containers eagerly to bitset containers, we may later
290
+ // need to revert the bitset containers to array containerr to satisfy the Roaring format requirements,
291
+ // but such one-time conversions at the end may not be overly expensive. We arrived to this design
292
+ // based on extensive benchmarking.
293
+ //
272
294
if (totalCardinality <= ARRAY_LAZY_LOWERBOUND ) {
273
295
if (src_1 -> capacity < totalCardinality ) {
274
296
* dst = array_container_create_given_capacity (2 * totalCardinality ); // be purposefully generous
0 commit comments