roaring 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +11 -2
- data/Rakefile +11 -1
- data/ext/roaring/bitmap32.c +294 -0
- data/ext/roaring/bitmap64.c +300 -0
- data/ext/roaring/cext.c +4 -267
- data/ext/roaring/extconf.rb +1 -4
- data/ext/roaring/roaring.c +25908 -0
- data/ext/roaring/roaring.h +2949 -0
- data/ext/roaring/roaring_ruby.h +17 -0
- data/lib/roaring/version.rb +1 -1
- data/lib/roaring.rb +91 -23
- data/roaring.gemspec +1 -1
- metadata +8 -3
@@ -0,0 +1,17 @@
|
|
1
|
+
#ifndef ROARING_RUBY_H
|
2
|
+
#define ROARING_RUBY_H
|
3
|
+
|
4
|
+
#include <ruby.h>
|
5
|
+
|
6
|
+
#include "roaring.h"
|
7
|
+
|
8
|
+
#ifndef RBOOL
|
9
|
+
#define RBOOL(x) ((x) ? Qtrue : Qfalse)
|
10
|
+
#endif
|
11
|
+
|
12
|
+
extern VALUE rb_mRoaring;
|
13
|
+
|
14
|
+
void rb_roaring32_init();
|
15
|
+
void rb_roaring64_init();
|
16
|
+
|
17
|
+
#endif
|
data/lib/roaring/version.rb
CHANGED
data/lib/roaring.rb
CHANGED
@@ -7,36 +7,71 @@ require "set"
|
|
7
7
|
module Roaring
|
8
8
|
class Error < StandardError; end
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
module BitmapCommon
|
11
|
+
def self.included(base)
|
12
|
+
super
|
13
|
+
|
14
|
+
base.extend ClassMethods
|
15
|
+
|
16
|
+
base.alias_method :size, :cardinality
|
17
|
+
base.alias_method :length, :cardinality
|
18
|
+
base.alias_method :count, :cardinality
|
19
|
+
|
20
|
+
base.alias_method :+, :|
|
21
|
+
base.alias_method :union, :|
|
22
|
+
base.alias_method :intersection, :&
|
23
|
+
base.alias_method :difference, :-
|
24
|
+
|
25
|
+
base.alias_method :delete, :remove
|
26
|
+
base.alias_method :delete?, :remove?
|
12
27
|
|
13
|
-
|
14
|
-
|
15
|
-
alias count cardinality
|
28
|
+
base.alias_method :first, :min
|
29
|
+
base.alias_method :last, :max
|
16
30
|
|
17
|
-
|
31
|
+
base.alias_method :eql?, :==
|
18
32
|
|
19
|
-
|
20
|
-
|
33
|
+
base.alias_method :===, :include?
|
34
|
+
|
35
|
+
base.alias_method :subset?, :<=
|
36
|
+
base.alias_method :proper_subset?, :<
|
37
|
+
base.alias_method :superset?, :>=
|
38
|
+
base.alias_method :proper_superset?, :>
|
39
|
+
end
|
40
|
+
|
41
|
+
module ClassMethods
|
42
|
+
def [](*args)
|
43
|
+
if args.size == 0
|
44
|
+
new
|
45
|
+
elsif args.size == 1 && !(Integer === args[0])
|
46
|
+
new(args[0])
|
47
|
+
else
|
48
|
+
new(args)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def _load args
|
53
|
+
deserialize(args)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
include Enumerable
|
21
58
|
|
22
59
|
def initialize(enum = nil)
|
23
60
|
return unless enum
|
24
61
|
|
25
|
-
if enum.instance_of?(
|
26
|
-
|
62
|
+
if enum.instance_of?(self.class)
|
63
|
+
replace(enum)
|
27
64
|
else
|
28
65
|
enum.each { |x| self << x }
|
29
66
|
end
|
30
67
|
end
|
31
68
|
|
32
|
-
def
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
new(args)
|
39
|
-
end
|
69
|
+
def hash
|
70
|
+
to_a.hash
|
71
|
+
end
|
72
|
+
|
73
|
+
def initialize_copy(other)
|
74
|
+
replace(other)
|
40
75
|
end
|
41
76
|
|
42
77
|
def >(other)
|
@@ -47,12 +82,24 @@ module Roaring
|
|
47
82
|
other <= self
|
48
83
|
end
|
49
84
|
|
50
|
-
def
|
51
|
-
|
85
|
+
def <=>(other)
|
86
|
+
if self == other
|
87
|
+
0
|
88
|
+
elsif subset?(other)
|
89
|
+
-1
|
90
|
+
elsif superset?(other)
|
91
|
+
1
|
92
|
+
else
|
93
|
+
nil
|
94
|
+
end
|
52
95
|
end
|
53
96
|
|
54
|
-
def
|
55
|
-
|
97
|
+
def disjoint?(other)
|
98
|
+
!intersect?(other)
|
99
|
+
end
|
100
|
+
|
101
|
+
def _dump level
|
102
|
+
serialize
|
56
103
|
end
|
57
104
|
|
58
105
|
def to_a
|
@@ -64,7 +111,28 @@ module Roaring
|
|
64
111
|
end
|
65
112
|
|
66
113
|
def inspect
|
67
|
-
|
114
|
+
cardinality = self.cardinality
|
115
|
+
if cardinality < 64
|
116
|
+
"#<#{self.class} {#{to_a.join(", ")}}>"
|
117
|
+
else
|
118
|
+
"#<#{self.class} (#{cardinality} values)>"
|
119
|
+
end
|
68
120
|
end
|
69
121
|
end
|
122
|
+
|
123
|
+
class Bitmap32
|
124
|
+
include BitmapCommon
|
125
|
+
|
126
|
+
MIN = 0
|
127
|
+
MAX = (2**32) - 1
|
128
|
+
RANGE = MIN..MAX
|
129
|
+
end
|
130
|
+
|
131
|
+
class Bitmap64
|
132
|
+
include BitmapCommon
|
133
|
+
|
134
|
+
MIN = 0
|
135
|
+
MAX = (2**64) - 1
|
136
|
+
RANGE = MIN..MAX
|
137
|
+
end
|
70
138
|
end
|
data/roaring.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
# Specify which files should be added to the gem when it is released.
|
20
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
21
|
spec.files = Dir.chdir(__dir__) do
|
22
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
22
|
+
`git ls-files --recurse-submodules -z`.split("\x0").reject do |f|
|
23
23
|
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
24
24
|
end
|
25
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roaring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Hawthorn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: prime
|
@@ -38,8 +38,13 @@ files:
|
|
38
38
|
- LICENSE.txt
|
39
39
|
- README.md
|
40
40
|
- Rakefile
|
41
|
+
- ext/roaring/bitmap32.c
|
42
|
+
- ext/roaring/bitmap64.c
|
41
43
|
- ext/roaring/cext.c
|
42
44
|
- ext/roaring/extconf.rb
|
45
|
+
- ext/roaring/roaring.c
|
46
|
+
- ext/roaring/roaring.h
|
47
|
+
- ext/roaring/roaring_ruby.h
|
43
48
|
- lib/roaring.rb
|
44
49
|
- lib/roaring/version.rb
|
45
50
|
- roaring.gemspec
|
@@ -66,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
71
|
- !ruby/object:Gem::Version
|
67
72
|
version: '0'
|
68
73
|
requirements: []
|
69
|
-
rubygems_version: 3.
|
74
|
+
rubygems_version: 3.5.9
|
70
75
|
signing_key:
|
71
76
|
specification_version: 4
|
72
77
|
summary: Roaring bitmaps for Ruby
|