roaring 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f2956df800830dc45bb3b8e63fd1b7795c39a73ab52f5671e651ca1087e1572
4
- data.tar.gz: 74b06f13df663851dd703b2888cd3b465fe788a794dcb0cadca5d1b534db023e
3
+ metadata.gz: c061d28a03b3ba5b386807eb2cf2bde2d1e8309c69316c67bfb3e6d36dd13236
4
+ data.tar.gz: 52a90f348280c88153f31e6b2a2f2a333bfc8094e813314df5d5f84aa41cb831
5
5
  SHA512:
6
- metadata.gz: 18a68702d1d236e6817c542dcbb15d32515f76263b0e5f074837bdde8a5bc9ca5ff88976eba18d67b1cd041307b22a81a72e79f6d7b25124b80b2f14028e9ba0
7
- data.tar.gz: 44ca8c98572f932a23d7488afd87bc05d3c0618062d912bc71b9f319497ba5ac3e824e046011b192198b8c90686ebeda972f1e15104428684cdb2dcc2761dd3d
6
+ metadata.gz: 62b208238f339e10313701dc0272d0cdddccfc407b7f78fdf5e3bc86500f36cb5eb0d98741c69a179af085a800eae60740b194963f2ddec6f5b745ad1d89cfe6
7
+ data.tar.gz: eea3734551e011cb1835d4bf5d3c0d15ddd767dbfa21582f714581e0b8206d1fe608df5eda6d9cb6de71d731c643e3e845fd7ecd6e64be02e37d47f83f5cf1cc
@@ -63,7 +63,7 @@ static VALUE rb_roaring32_cardinality(VALUE self)
63
63
  {
64
64
  roaring_bitmap_t *data = get_bitmap(self);
65
65
  uint64_t cardinality = roaring_bitmap_get_cardinality(data);
66
- return ULONG2NUM(cardinality);
66
+ return ULL2NUM(cardinality);
67
67
  }
68
68
 
69
69
  // Adds an element from the bitmap
@@ -309,6 +309,15 @@ static VALUE rb_roaring32_binary_op_bool(VALUE self, VALUE other, binary_func_bo
309
309
  return RBOOL(result);
310
310
  }
311
311
 
312
+ typedef uint64_t binary_func_cardinality(const roaring_bitmap_t *, const roaring_bitmap_t *);
313
+ static VALUE rb_roaring32_binary_op_cardinality(VALUE self, VALUE other, binary_func_cardinality func) {
314
+ roaring_bitmap_t *self_data = get_bitmap(self);
315
+ roaring_bitmap_t *other_data = get_bitmap(other);
316
+
317
+ uint64_t result = func(self_data, other_data);
318
+ return ULL2NUM(result);
319
+ }
320
+
312
321
  // Inplace version of {and}
313
322
  // @return [self] the modified Bitmap
314
323
  static VALUE rb_roaring32_and_inplace(VALUE self, VALUE other)
@@ -358,6 +367,30 @@ static VALUE rb_roaring32_xor(VALUE self, VALUE other)
358
367
  return rb_roaring32_binary_op(self, other, roaring_bitmap_xor);
359
368
  }
360
369
 
370
+ // Computes the cardinality of the intersection between two bitmaps without
371
+ // materializing the result
372
+ // @return [Integer] the number of elements in both `self` and `other`
373
+ static VALUE rb_roaring32_and_cardinality(VALUE self, VALUE other)
374
+ {
375
+ return rb_roaring32_binary_op_cardinality(self, other, roaring_bitmap_and_cardinality);
376
+ }
377
+
378
+ // Computes the cardinality of the union between two bitmaps without
379
+ // materializing the result
380
+ // @return [Integer] the number of elements in either `self` or `other`
381
+ static VALUE rb_roaring32_or_cardinality(VALUE self, VALUE other)
382
+ {
383
+ return rb_roaring32_binary_op_cardinality(self, other, roaring_bitmap_or_cardinality);
384
+ }
385
+
386
+ // Computes the cardinality of the exclusive or between two bitmaps without
387
+ // materializing the result
388
+ // @return [Integer] the number of elements in one of `self` or `other`, but not both
389
+ static VALUE rb_roaring32_xor_cardinality(VALUE self, VALUE other)
390
+ {
391
+ return rb_roaring32_binary_op_cardinality(self, other, roaring_bitmap_xor_cardinality);
392
+ }
393
+
361
394
  // Computes the difference between two bitmaps
362
395
  // @return [Bitmap32] a new bitmap containing all elements in `self`, but not in `other`
363
396
  static VALUE rb_roaring32_andnot(VALUE self, VALUE other)
@@ -421,6 +454,10 @@ rb_roaring32_init(void)
421
454
  rb_define_method(cRoaringBitmap32, "xor", rb_roaring32_xor, 1);
422
455
  rb_define_method(cRoaringBitmap32, "andnot", rb_roaring32_andnot, 1);
423
456
 
457
+ rb_define_method(cRoaringBitmap32, "and_cardinality", rb_roaring32_and_cardinality, 1);
458
+ rb_define_method(cRoaringBitmap32, "or_cardinality", rb_roaring32_or_cardinality, 1);
459
+ rb_define_method(cRoaringBitmap32, "xor_cardinality", rb_roaring32_xor_cardinality, 1);
460
+
424
461
  rb_define_method(cRoaringBitmap32, "==", rb_roaring32_eq, 1);
425
462
  rb_define_method(cRoaringBitmap32, "<", rb_roaring32_lt, 1);
426
463
  rb_define_method(cRoaringBitmap32, "<=", rb_roaring32_lte, 1);
@@ -66,7 +66,7 @@ static VALUE rb_roaring64_cardinality(VALUE self)
66
66
  {
67
67
  roaring64_bitmap_t *data = get_bitmap(self);
68
68
  uint64_t cardinality = roaring64_bitmap_get_cardinality(data);
69
- return ULONG2NUM(cardinality);
69
+ return ULL2NUM(cardinality);
70
70
  }
71
71
 
72
72
  static VALUE rb_roaring64_add(VALUE self, VALUE val)
@@ -281,6 +281,15 @@ static VALUE rb_roaring64_binary_op_bool(VALUE self, VALUE other, binary_func_bo
281
281
  return RBOOL(result);
282
282
  }
283
283
 
284
+ typedef uint64_t binary_func_cardinality(const roaring64_bitmap_t *, const roaring64_bitmap_t *);
285
+ static VALUE rb_roaring64_binary_op_cardinality(VALUE self, VALUE other, binary_func_cardinality func) {
286
+ roaring64_bitmap_t *self_data = get_bitmap(self);
287
+ roaring64_bitmap_t *other_data = get_bitmap(other);
288
+
289
+ uint64_t result = func(self_data, other_data);
290
+ return ULL2NUM(result);
291
+ }
292
+
284
293
  static VALUE rb_roaring64_and_inplace(VALUE self, VALUE other)
285
294
  {
286
295
  return rb_roaring64_binary_op_inplace(self, other, roaring64_bitmap_and_inplace);
@@ -316,6 +325,21 @@ static VALUE rb_roaring64_xor(VALUE self, VALUE other)
316
325
  return rb_roaring64_binary_op(self, other, roaring64_bitmap_xor);
317
326
  }
318
327
 
328
+ static VALUE rb_roaring64_and_cardinality(VALUE self, VALUE other)
329
+ {
330
+ return rb_roaring64_binary_op_cardinality(self, other, roaring64_bitmap_and_cardinality);
331
+ }
332
+
333
+ static VALUE rb_roaring64_or_cardinality(VALUE self, VALUE other)
334
+ {
335
+ return rb_roaring64_binary_op_cardinality(self, other, roaring64_bitmap_or_cardinality);
336
+ }
337
+
338
+ static VALUE rb_roaring64_xor_cardinality(VALUE self, VALUE other)
339
+ {
340
+ return rb_roaring64_binary_op_cardinality(self, other, roaring64_bitmap_xor_cardinality);
341
+ }
342
+
319
343
  static VALUE rb_roaring64_andnot(VALUE self, VALUE other)
320
344
  {
321
345
  return rb_roaring64_binary_op(self, other, roaring64_bitmap_andnot);
@@ -370,6 +394,10 @@ rb_roaring64_init(void)
370
394
  rb_define_method(cRoaringBitmap64, "xor", rb_roaring64_xor, 1);
371
395
  rb_define_method(cRoaringBitmap64, "andnot", rb_roaring64_andnot, 1);
372
396
 
397
+ rb_define_method(cRoaringBitmap64, "and_cardinality", rb_roaring64_and_cardinality, 1);
398
+ rb_define_method(cRoaringBitmap64, "or_cardinality", rb_roaring64_or_cardinality, 1);
399
+ rb_define_method(cRoaringBitmap64, "xor_cardinality", rb_roaring64_xor_cardinality, 1);
400
+
373
401
  rb_define_method(cRoaringBitmap64, "==", rb_roaring64_eq, 1);
374
402
  rb_define_method(cRoaringBitmap64, "<", rb_roaring64_lt, 1);
375
403
  rb_define_method(cRoaringBitmap64, "<=", rb_roaring64_lte, 1);
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Roaring
4
- VERSION = "0.4.1"
4
+ VERSION = "0.5.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roaring
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Hawthorn
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  - !ruby/object:Gem::Version
72
72
  version: '0'
73
73
  requirements: []
74
- rubygems_version: 4.0.10
74
+ rubygems_version: 4.0.16
75
75
  specification_version: 4
76
76
  summary: Roaring bitmaps for Ruby
77
77
  test_files: []