roaring 0.0.0 → 0.2.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/Gemfile +5 -0
- data/Gemfile.lock +21 -1
- data/LICENSE.txt +201 -21
- data/README.md +38 -17
- data/Rakefile +17 -1
- data/ext/roaring/cext.c +302 -0
- data/ext/roaring/extconf.rb +10 -0
- data/ext/roaring/roaring/LICENSE +235 -0
- data/ext/roaring/roaring/README.md +42 -0
- data/ext/roaring/roaring/roaring.c +19542 -0
- data/ext/roaring/roaring/roaring.h +1031 -0
- data/ext/roaring/roaring/roaring.hh +2016 -0
- data/lib/roaring/version.rb +1 -1
- data/lib/roaring.rb +108 -1
- data/roaring.gemspec +9 -14
- data/sig/roaring.rbs +4 -0
- metadata +32 -11
- data/bin/console +0 -15
- data/bin/setup +0 -8
data/lib/roaring/version.rb
CHANGED
data/lib/roaring.rb
CHANGED
@@ -1,8 +1,115 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "roaring/version"
|
4
|
+
require_relative "roaring/roaring"
|
5
|
+
require "set"
|
4
6
|
|
5
7
|
module Roaring
|
6
8
|
class Error < StandardError; end
|
7
|
-
|
9
|
+
|
10
|
+
class Bitmap
|
11
|
+
include Enumerable
|
12
|
+
|
13
|
+
alias size cardinality
|
14
|
+
alias length cardinality
|
15
|
+
alias count cardinality
|
16
|
+
|
17
|
+
alias + |
|
18
|
+
alias union |
|
19
|
+
alias intersection &
|
20
|
+
alias difference -
|
21
|
+
|
22
|
+
alias delete remove
|
23
|
+
alias delete? remove?
|
24
|
+
|
25
|
+
alias first min
|
26
|
+
alias last max
|
27
|
+
|
28
|
+
alias === include?
|
29
|
+
|
30
|
+
def initialize(enum = nil)
|
31
|
+
return unless enum
|
32
|
+
|
33
|
+
if enum.instance_of?(Roaring::Bitmap)
|
34
|
+
initialize_copy(enum)
|
35
|
+
else
|
36
|
+
enum.each { |x| self << x }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def hash
|
41
|
+
to_a.hash
|
42
|
+
end
|
43
|
+
|
44
|
+
alias eql? ==
|
45
|
+
|
46
|
+
def replace(other)
|
47
|
+
# FIXME: this should probably be initialize_copy and replace should be in C
|
48
|
+
initialize_copy(other)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.[](*args)
|
52
|
+
if args.size == 0
|
53
|
+
new
|
54
|
+
elsif args.size == 1 && !(Integer === args[0])
|
55
|
+
new(args[0])
|
56
|
+
else
|
57
|
+
new(args)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def >(other)
|
62
|
+
other < self
|
63
|
+
end
|
64
|
+
|
65
|
+
def >=(other)
|
66
|
+
other <= self
|
67
|
+
end
|
68
|
+
|
69
|
+
alias subset? <=
|
70
|
+
alias proper_subset? <
|
71
|
+
alias superset? >=
|
72
|
+
alias proper_superset? >
|
73
|
+
|
74
|
+
def <=>(other)
|
75
|
+
if self == other
|
76
|
+
0
|
77
|
+
elsif subset?(other)
|
78
|
+
-1
|
79
|
+
elsif superset?(other)
|
80
|
+
1
|
81
|
+
else
|
82
|
+
nil
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def disjoint?(other)
|
87
|
+
!intersect?(other)
|
88
|
+
end
|
89
|
+
|
90
|
+
def _dump level
|
91
|
+
serialize
|
92
|
+
end
|
93
|
+
|
94
|
+
def self._load args
|
95
|
+
deserialize(args)
|
96
|
+
end
|
97
|
+
|
98
|
+
def to_a
|
99
|
+
map(&:itself)
|
100
|
+
end
|
101
|
+
|
102
|
+
def to_set
|
103
|
+
::Set.new(to_a)
|
104
|
+
end
|
105
|
+
|
106
|
+
def inspect
|
107
|
+
cardinality = self.cardinality
|
108
|
+
if cardinality < 64
|
109
|
+
"#<#{self.class} {#{to_a.join(", ")}}>"
|
110
|
+
else
|
111
|
+
"#<#{self.class} (#{cardinality} values)>"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
8
115
|
end
|
data/roaring.gemspec
CHANGED
@@ -8,30 +8,25 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["John Hawthorn"]
|
9
9
|
spec.email = ["john@hawthorn.email"]
|
10
10
|
|
11
|
-
spec.summary = "
|
12
|
-
spec.description =
|
11
|
+
spec.summary = "Roaring bitmaps for Ruby"
|
12
|
+
spec.description = spec.summary
|
13
13
|
spec.homepage = "https://github.com/jhawthorn/roaring-ruby"
|
14
|
-
spec.license = "
|
14
|
+
spec.license = "Apache-2.0"
|
15
15
|
spec.required_ruby_version = ">= 2.6.0"
|
16
16
|
|
17
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
-
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
-
spec.metadata["changelog_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = spec.metadata["changelog_uri"] = spec.metadata["homepage_uri"] = spec.homepage
|
20
18
|
|
21
19
|
# Specify which files should be added to the gem when it is released.
|
22
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
-
spec.files = Dir.chdir(
|
24
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
-
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
21
|
+
spec.files = Dir.chdir(__dir__) do
|
22
|
+
`git ls-files --recurse-submodules -z`.split("\x0").reject do |f|
|
23
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
26
24
|
end
|
27
25
|
end
|
28
26
|
spec.bindir = "exe"
|
29
27
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
28
|
spec.require_paths = ["lib"]
|
29
|
+
spec.extensions = ["ext/roaring/extconf.rb"]
|
31
30
|
|
32
|
-
|
33
|
-
# spec.add_dependency "example-gem", "~> 1.0"
|
34
|
-
|
35
|
-
# For more information and examples about making a new gem, check out our
|
36
|
-
# guide at: https://bundler.io/guides/creating_gem.html
|
31
|
+
spec.add_development_dependency "prime"
|
37
32
|
end
|
data/sig/roaring.rbs
ADDED
metadata
CHANGED
@@ -1,20 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roaring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.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:
|
12
|
-
dependencies:
|
13
|
-
|
11
|
+
date: 2023-02-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: prime
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Roaring bitmaps for Ruby
|
14
28
|
email:
|
15
29
|
- john@hawthorn.email
|
16
30
|
executables: []
|
17
|
-
extensions:
|
31
|
+
extensions:
|
32
|
+
- ext/roaring/extconf.rb
|
18
33
|
extra_rdoc_files: []
|
19
34
|
files:
|
20
35
|
- CODE_OF_CONDUCT.md
|
@@ -23,18 +38,24 @@ files:
|
|
23
38
|
- LICENSE.txt
|
24
39
|
- README.md
|
25
40
|
- Rakefile
|
26
|
-
-
|
27
|
-
-
|
41
|
+
- ext/roaring/cext.c
|
42
|
+
- ext/roaring/extconf.rb
|
43
|
+
- ext/roaring/roaring/LICENSE
|
44
|
+
- ext/roaring/roaring/README.md
|
45
|
+
- ext/roaring/roaring/roaring.c
|
46
|
+
- ext/roaring/roaring/roaring.h
|
47
|
+
- ext/roaring/roaring/roaring.hh
|
28
48
|
- lib/roaring.rb
|
29
49
|
- lib/roaring/version.rb
|
30
50
|
- roaring.gemspec
|
51
|
+
- sig/roaring.rbs
|
31
52
|
homepage: https://github.com/jhawthorn/roaring-ruby
|
32
53
|
licenses:
|
33
|
-
-
|
54
|
+
- Apache-2.0
|
34
55
|
metadata:
|
35
56
|
homepage_uri: https://github.com/jhawthorn/roaring-ruby
|
36
|
-
source_code_uri: https://github.com/jhawthorn/roaring-ruby
|
37
57
|
changelog_uri: https://github.com/jhawthorn/roaring-ruby
|
58
|
+
source_code_uri: https://github.com/jhawthorn/roaring-ruby
|
38
59
|
post_install_message:
|
39
60
|
rdoc_options: []
|
40
61
|
require_paths:
|
@@ -50,8 +71,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
71
|
- !ruby/object:Gem::Version
|
51
72
|
version: '0'
|
52
73
|
requirements: []
|
53
|
-
rubygems_version: 3.
|
74
|
+
rubygems_version: 3.4.6
|
54
75
|
signing_key:
|
55
76
|
specification_version: 4
|
56
|
-
summary:
|
77
|
+
summary: Roaring bitmaps for Ruby
|
57
78
|
test_files: []
|
data/bin/console
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "bundler/setup"
|
5
|
-
require "roaring"
|
6
|
-
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
9
|
-
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
# require "pry"
|
12
|
-
# Pry.start
|
13
|
-
|
14
|
-
require "irb"
|
15
|
-
IRB.start(__FILE__)
|