roaring 0.4.0 → 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 +4 -4
- data/ext/roaring/bitmap32.c +47 -1
- data/ext/roaring/bitmap64.c +36 -1
- data/lib/roaring/version.rb +1 -1
- data/lib/roaring.rb +1 -1
- metadata +3 -7
- data/Gemfile.lock +0 -46
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c061d28a03b3ba5b386807eb2cf2bde2d1e8309c69316c67bfb3e6d36dd13236
|
|
4
|
+
data.tar.gz: 52a90f348280c88153f31e6b2a2f2a333bfc8094e813314df5d5f84aa41cb831
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 62b208238f339e10313701dc0272d0cdddccfc407b7f78fdf5e3bc86500f36cb5eb0d98741c69a179af085a800eae60740b194963f2ddec6f5b745ad1d89cfe6
|
|
7
|
+
data.tar.gz: eea3734551e011cb1835d4bf5d3c0d15ddd767dbfa21582f714581e0b8206d1fe608df5eda6d9cb6de71d731c643e3e845fd7ecd6e64be02e37d47f83f5cf1cc
|
data/ext/roaring/bitmap32.c
CHANGED
|
@@ -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
|
|
66
|
+
return ULL2NUM(cardinality);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
// Adds an element from the bitmap
|
|
@@ -229,10 +229,19 @@ static VALUE rb_roaring32_serialize(VALUE self)
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
// Loads a previously serialized bitmap
|
|
232
|
+
// @param str [String] a string previously returned from {#serialize}
|
|
233
|
+
// @raise [ArgumentError] if the string isn't a valid serialized bitmap
|
|
232
234
|
// @return [Bitmap32]
|
|
233
235
|
static VALUE rb_roaring32_deserialize(VALUE self, VALUE str)
|
|
234
236
|
{
|
|
237
|
+
StringValue(str);
|
|
238
|
+
|
|
235
239
|
roaring_bitmap_t *bitmap = roaring_bitmap_portable_deserialize_safe(RSTRING_PTR(str), RSTRING_LEN(str));
|
|
240
|
+
RB_GC_GUARD(str);
|
|
241
|
+
|
|
242
|
+
if (!bitmap) {
|
|
243
|
+
rb_raise(rb_eArgError, "invalid Roaring::Bitmap32 serialization");
|
|
244
|
+
}
|
|
236
245
|
|
|
237
246
|
return TypedData_Wrap_Struct(cRoaringBitmap32, &roaring_type, bitmap);
|
|
238
247
|
}
|
|
@@ -300,6 +309,15 @@ static VALUE rb_roaring32_binary_op_bool(VALUE self, VALUE other, binary_func_bo
|
|
|
300
309
|
return RBOOL(result);
|
|
301
310
|
}
|
|
302
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
|
+
|
|
303
321
|
// Inplace version of {and}
|
|
304
322
|
// @return [self] the modified Bitmap
|
|
305
323
|
static VALUE rb_roaring32_and_inplace(VALUE self, VALUE other)
|
|
@@ -349,6 +367,30 @@ static VALUE rb_roaring32_xor(VALUE self, VALUE other)
|
|
|
349
367
|
return rb_roaring32_binary_op(self, other, roaring_bitmap_xor);
|
|
350
368
|
}
|
|
351
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
|
+
|
|
352
394
|
// Computes the difference between two bitmaps
|
|
353
395
|
// @return [Bitmap32] a new bitmap containing all elements in `self`, but not in `other`
|
|
354
396
|
static VALUE rb_roaring32_andnot(VALUE self, VALUE other)
|
|
@@ -412,6 +454,10 @@ rb_roaring32_init(void)
|
|
|
412
454
|
rb_define_method(cRoaringBitmap32, "xor", rb_roaring32_xor, 1);
|
|
413
455
|
rb_define_method(cRoaringBitmap32, "andnot", rb_roaring32_andnot, 1);
|
|
414
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
|
+
|
|
415
461
|
rb_define_method(cRoaringBitmap32, "==", rb_roaring32_eq, 1);
|
|
416
462
|
rb_define_method(cRoaringBitmap32, "<", rb_roaring32_lt, 1);
|
|
417
463
|
rb_define_method(cRoaringBitmap32, "<=", rb_roaring32_lte, 1);
|
data/ext/roaring/bitmap64.c
CHANGED
|
@@ -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
|
|
69
|
+
return ULL2NUM(cardinality);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
static VALUE rb_roaring64_add(VALUE self, VALUE val)
|
|
@@ -208,7 +208,14 @@ static VALUE rb_roaring64_serialize(VALUE self)
|
|
|
208
208
|
|
|
209
209
|
static VALUE rb_roaring64_deserialize(VALUE self, VALUE str)
|
|
210
210
|
{
|
|
211
|
+
StringValue(str);
|
|
212
|
+
|
|
211
213
|
roaring64_bitmap_t *bitmap = roaring64_bitmap_portable_deserialize_safe(RSTRING_PTR(str), RSTRING_LEN(str));
|
|
214
|
+
RB_GC_GUARD(str);
|
|
215
|
+
|
|
216
|
+
if (!bitmap) {
|
|
217
|
+
rb_raise(rb_eArgError, "invalid Roaring::Bitmap64 serialization");
|
|
218
|
+
}
|
|
212
219
|
|
|
213
220
|
return TypedData_Wrap_Struct(cRoaringBitmap64, &roaring64_type, bitmap);
|
|
214
221
|
}
|
|
@@ -274,6 +281,15 @@ static VALUE rb_roaring64_binary_op_bool(VALUE self, VALUE other, binary_func_bo
|
|
|
274
281
|
return RBOOL(result);
|
|
275
282
|
}
|
|
276
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
|
+
|
|
277
293
|
static VALUE rb_roaring64_and_inplace(VALUE self, VALUE other)
|
|
278
294
|
{
|
|
279
295
|
return rb_roaring64_binary_op_inplace(self, other, roaring64_bitmap_and_inplace);
|
|
@@ -309,6 +325,21 @@ static VALUE rb_roaring64_xor(VALUE self, VALUE other)
|
|
|
309
325
|
return rb_roaring64_binary_op(self, other, roaring64_bitmap_xor);
|
|
310
326
|
}
|
|
311
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
|
+
|
|
312
343
|
static VALUE rb_roaring64_andnot(VALUE self, VALUE other)
|
|
313
344
|
{
|
|
314
345
|
return rb_roaring64_binary_op(self, other, roaring64_bitmap_andnot);
|
|
@@ -363,6 +394,10 @@ rb_roaring64_init(void)
|
|
|
363
394
|
rb_define_method(cRoaringBitmap64, "xor", rb_roaring64_xor, 1);
|
|
364
395
|
rb_define_method(cRoaringBitmap64, "andnot", rb_roaring64_andnot, 1);
|
|
365
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
|
+
|
|
366
401
|
rb_define_method(cRoaringBitmap64, "==", rb_roaring64_eq, 1);
|
|
367
402
|
rb_define_method(cRoaringBitmap64, "<", rb_roaring64_lt, 1);
|
|
368
403
|
rb_define_method(cRoaringBitmap64, "<=", rb_roaring64_lte, 1);
|
data/lib/roaring/version.rb
CHANGED
data/lib/roaring.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: roaring
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Hawthorn
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: prime
|
|
@@ -35,7 +34,6 @@ files:
|
|
|
35
34
|
- ".yardopts"
|
|
36
35
|
- CODE_OF_CONDUCT.md
|
|
37
36
|
- Gemfile
|
|
38
|
-
- Gemfile.lock
|
|
39
37
|
- LICENSE.txt
|
|
40
38
|
- README.md
|
|
41
39
|
- Rakefile
|
|
@@ -59,7 +57,6 @@ metadata:
|
|
|
59
57
|
homepage_uri: https://github.com/jhawthorn/roaring-ruby
|
|
60
58
|
changelog_uri: https://github.com/jhawthorn/roaring-ruby
|
|
61
59
|
source_code_uri: https://github.com/jhawthorn/roaring-ruby
|
|
62
|
-
post_install_message:
|
|
63
60
|
rdoc_options: []
|
|
64
61
|
require_paths:
|
|
65
62
|
- lib
|
|
@@ -74,8 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
74
71
|
- !ruby/object:Gem::Version
|
|
75
72
|
version: '0'
|
|
76
73
|
requirements: []
|
|
77
|
-
rubygems_version:
|
|
78
|
-
signing_key:
|
|
74
|
+
rubygems_version: 4.0.16
|
|
79
75
|
specification_version: 4
|
|
80
76
|
summary: Roaring bitmaps for Ruby
|
|
81
77
|
test_files: []
|
data/Gemfile.lock
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
roaring (0.3.0)
|
|
5
|
-
|
|
6
|
-
GEM
|
|
7
|
-
remote: https://rubygems.org/
|
|
8
|
-
specs:
|
|
9
|
-
benchmark-ips (2.13.0)
|
|
10
|
-
debug (1.6.2)
|
|
11
|
-
irb (>= 1.3.6)
|
|
12
|
-
reline (>= 0.3.1)
|
|
13
|
-
forwardable (1.3.2)
|
|
14
|
-
io-console (0.5.11)
|
|
15
|
-
irb (1.4.1)
|
|
16
|
-
reline (>= 0.3.0)
|
|
17
|
-
minitest (5.16.3)
|
|
18
|
-
prime (0.1.2)
|
|
19
|
-
forwardable
|
|
20
|
-
singleton
|
|
21
|
-
rake (13.0.6)
|
|
22
|
-
rake-compiler (1.2.0)
|
|
23
|
-
rake
|
|
24
|
-
reline (0.3.1)
|
|
25
|
-
io-console (~> 0.5)
|
|
26
|
-
singleton (0.1.1)
|
|
27
|
-
yard (0.9.36)
|
|
28
|
-
|
|
29
|
-
PLATFORMS
|
|
30
|
-
arm64-darwin-23
|
|
31
|
-
arm64-darwin-24
|
|
32
|
-
ruby
|
|
33
|
-
x86_64-linux
|
|
34
|
-
|
|
35
|
-
DEPENDENCIES
|
|
36
|
-
benchmark-ips
|
|
37
|
-
debug
|
|
38
|
-
minitest (~> 5.0)
|
|
39
|
-
prime
|
|
40
|
-
rake (~> 13.0)
|
|
41
|
-
rake-compiler
|
|
42
|
-
roaring!
|
|
43
|
-
yard
|
|
44
|
-
|
|
45
|
-
BUNDLED WITH
|
|
46
|
-
2.3.4
|