bloombroom 1.0.0 → 1.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.
@@ -0,0 +1,2 @@
1
+ require 'rspec'
2
+ require 'bloombroom'
metadata CHANGED
@@ -1,100 +1,145 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bloombroom
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ prerelease:
5
+ version: 1.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Colin Surprenant
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-09 00:00:00.000000000 Z
12
+ date: 2013-02-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rspec
16
- requirement: !ruby/object:Gem::Requirement
15
+ name: ffi
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: 1.0.0
17
21
  none: false
22
+ requirement: !ruby/object:Gem::Requirement
18
23
  requirements:
19
- - - ~>
24
+ - - ">="
20
25
  - !ruby/object:Gem::Version
21
- version: 2.8.0
22
- type: :development
26
+ version: 1.0.0
27
+ none: false
23
28
  prerelease: false
29
+ type: :runtime
30
+ - !ruby/object:Gem::Dependency
31
+ name: ffi-compiler
24
32
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
33
  requirements:
27
- - - ~>
34
+ - - ">="
28
35
  - !ruby/object:Gem::Version
29
- version: 2.8.0
30
- - !ruby/object:Gem::Dependency
31
- name: ffi
32
- requirement: !ruby/object:Gem::Requirement
36
+ version: !binary |-
37
+ MA==
33
38
  none: false
39
+ requirement: !ruby/object:Gem::Requirement
34
40
  requirements:
35
- - - ! '>='
41
+ - - ">="
36
42
  - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :runtime
43
+ version: !binary |-
44
+ MA==
45
+ none: false
39
46
  prerelease: false
47
+ type: :runtime
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
40
50
  version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.8.0
41
55
  none: false
56
+ requirement: !ruby/object:Gem::Requirement
42
57
  requirements:
43
- - - ! '>='
58
+ - - ">="
44
59
  - !ruby/object:Gem::Version
45
- version: '0'
46
- description: bloombroom has two bloom filter implementations, a standard filter for
47
- bounded key space and a continuous filter for unbounded keys
48
- (stream). also contains fast bit field and bit bucket field (multi
49
- bits), native/C-ext/FFI FNV hashing and benchmarks for all these.
60
+ version: 2.8.0
61
+ none: false
62
+ prerelease: false
63
+ type: :development
64
+ description: bloombroom has two bloom filter implementations, a standard filter for bounded key space and a continuous filter for unbounded keys (stream). also contains fast C/FFI FNV hashing and fast bit field and bit bucket field (multi bits).
50
65
  email:
51
66
  - colin.surprenant@gmail.com
52
67
  executables: []
53
68
  extensions:
54
- - ext/bloombroom/hash/cext/extconf.rb
55
- - ext/bloombroom/hash/ffi/extconf.rb
69
+ - ffi/bloombroom/hash/Rakefile
56
70
  extra_rdoc_files: []
57
71
  files:
72
+ - ".gitignore"
73
+ - ".travis.yml"
74
+ - CHANGELOG.md
75
+ - Gemfile
76
+ - LICENSE.md
77
+ - README.md
78
+ - Rakefile
79
+ - benchmark/bloom_filter.rb
80
+ - benchmark/bloom_filter_memory.rb
81
+ - benchmark/continuous_bloom_filter.rb
82
+ - benchmark/continuous_bloom_filter_memory.rb
83
+ - benchmark/continuous_bloom_filter_stats.rb
84
+ - benchmark/memory.rb
85
+ - bloombroom.gemspec
86
+ - ffi/bloombroom/hash/Rakefile
87
+ - ffi/bloombroom/hash/ffi_fnv.c
88
+ - lib/bloombroom.rb
58
89
  - lib/bloombroom/bits/bit_bucket_field.rb
59
90
  - lib/bloombroom/bits/bit_field.rb
60
91
  - lib/bloombroom/filter/bloom_filter.rb
61
92
  - lib/bloombroom/filter/bloom_helper.rb
62
93
  - lib/bloombroom/filter/continuous_bloom_filter.rb
63
94
  - lib/bloombroom/hash/ffi_fnv.rb
64
- - lib/bloombroom/hash/fnv_a.rb
65
- - lib/bloombroom/hash/fnv_b.rb
66
95
  - lib/bloombroom/version.rb
67
- - lib/bloombroom.rb
68
- - ext/bloombroom/hash/cext/extconf.rb
69
- - ext/bloombroom/hash/ffi/extconf.rb
70
- - ext/bloombroom/hash/cext/cext_fnv.c
71
- - ext/bloombroom/hash/ffi/ffi_fnv.c
72
- - README.md
73
- - CHANGELOG.md
74
- - LICENSE.md
96
+ - spec/bloombroom/bits/bit_bucket_field_spec.rb
97
+ - spec/bloombroom/bits/bit_field_spec.rb
98
+ - spec/bloombroom/filter/bloom_filter_spec.rb
99
+ - spec/bloombroom/filter/bloom_helper_spec.rb
100
+ - spec/bloombroom/filter/continuous_bloom_filter_spec.rb
101
+ - spec/bloombroom/hash/ffi_fnv_spec.rb
102
+ - spec/bloombroom/hash/test_vectors.rb
103
+ - spec/spec_helper.rb
75
104
  homepage: https://github.com/colinsurprenant/bloombroom
76
- licenses: []
77
- post_install_message:
105
+ licenses:
106
+ - Apache 2.0
107
+ post_install_message:
78
108
  rdoc_options: []
79
109
  require_paths:
80
110
  - lib
81
111
  required_ruby_version: !ruby/object:Gem::Requirement
82
- none: false
83
112
  requirements:
84
- - - ! '>='
113
+ - - ">="
85
114
  - !ruby/object:Gem::Version
86
- version: '0'
87
- required_rubygems_version: !ruby/object:Gem::Requirement
115
+ version: !binary |-
116
+ MA==
117
+ segments:
118
+ - 0
119
+ hash: 2
88
120
  none: false
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
122
  requirements:
90
- - - ! '>='
123
+ - - ">="
91
124
  - !ruby/object:Gem::Version
92
- version: '0'
125
+ version: !binary |-
126
+ MA==
127
+ segments:
128
+ - 0
129
+ hash: 2
130
+ none: false
93
131
  requirements: []
94
- rubyforge_project: bloombroom
132
+ rubyforge_project:
95
133
  rubygems_version: 1.8.24
96
- signing_key:
134
+ signing_key:
97
135
  specification_version: 3
98
- summary: bloom filters for bounded and unbounded (streaming) data, FNV hashing and
99
- bit fields
100
- test_files: []
136
+ summary: bloom filters for bounded and unbounded (streaming) data, fast C/FFI FNV hashing and bit fields
137
+ test_files:
138
+ - spec/bloombroom/bits/bit_bucket_field_spec.rb
139
+ - spec/bloombroom/bits/bit_field_spec.rb
140
+ - spec/bloombroom/filter/bloom_filter_spec.rb
141
+ - spec/bloombroom/filter/bloom_helper_spec.rb
142
+ - spec/bloombroom/filter/continuous_bloom_filter_spec.rb
143
+ - spec/bloombroom/hash/ffi_fnv_spec.rb
144
+ - spec/bloombroom/hash/test_vectors.rb
145
+ - spec/spec_helper.rb
@@ -1,91 +0,0 @@
1
- /*
2
- * based on https://github.com/robey/rbfnv with various fixes from forks
3
- */
4
-
5
- #include <stdint.h>
6
- #include "ruby.h"
7
-
8
- #define PRIME32 16777619
9
- #define PRIME64 1099511628211ULL
10
-
11
- /**
12
- * FNV fast hashing algorithm in 32 bits.
13
- * @see http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash
14
- */
15
- uint32_t fnv1_32(const char *data, uint64_t len) {
16
- uint32_t rv = 0x811c9dc5U;
17
- uint64_t i;
18
- for (i = 0; i < len; i++) {
19
- rv = (rv * PRIME32) ^ (unsigned char)(data[i]);
20
- }
21
- return rv;
22
- }
23
-
24
- /**
25
- * FNV fast hashing algorithm in 32 bits, variant with operations reversed.
26
- * @see http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash
27
- */
28
- uint32_t fnv1a_32(const char *data, uint64_t len) {
29
- uint32_t rv = 0x811c9dc5U;
30
- uint64_t i;
31
- for (i = 0; i < len; i++) {
32
- rv = (rv ^ (unsigned char)data[i]) * PRIME32;
33
- }
34
- return rv;
35
- }
36
-
37
- /**
38
- * FNV fast hashing algorithm in 64 bits.
39
- * @see http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash
40
- */
41
- uint64_t fnv1_64(const char *data, uint64_t len) {
42
- uint64_t rv = 0xcbf29ce484222325ULL;
43
- uint64_t i;
44
- for (i = 0; i < len; i++) {
45
- rv = (rv * PRIME64) ^ (unsigned char)data[i];
46
- }
47
- return rv;
48
- }
49
-
50
- /**
51
- * FNV fast hashing algorithm in 64 bits, variant with operations reversed.
52
- * @see http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash
53
- */
54
- uint64_t fnv1a_64(const char *data, uint64_t len) {
55
- uint64_t rv = 0xcbf29ce484222325ULL;
56
- uint64_t i;
57
- for (i = 0; i < len; i++) {
58
- rv = (rv ^ (unsigned char)data[i]) * PRIME64;
59
- }
60
- return rv;
61
- }
62
-
63
- /* ----- ruby bindings ----- */
64
-
65
- VALUE rb_fnv1_32(VALUE self, VALUE data) {
66
- return UINT2NUM(fnv1_32(RSTRING_PTR(data), RSTRING_LEN(data)));
67
- }
68
-
69
- VALUE rb_fnv1a_32(VALUE self, VALUE data) {
70
- return UINT2NUM(fnv1a_32(RSTRING_PTR(data), RSTRING_LEN(data)));
71
- }
72
-
73
- VALUE rb_fnv1_64(VALUE self, VALUE data) {
74
- return ULL2NUM(fnv1_64(RSTRING_PTR(data), RSTRING_LEN(data)));
75
- }
76
-
77
- VALUE rb_fnv1a_64(VALUE self, VALUE data) {
78
- return ULL2NUM(fnv1a_64(RSTRING_PTR(data), RSTRING_LEN(data)));
79
- }
80
-
81
- VALUE rb_class;
82
- VALUE rb_module;
83
-
84
- void Init_cext_fnv() {
85
- rb_module = rb_define_module("Bloombroom");
86
- rb_class = rb_define_class_under(rb_module, "FNVEXT", rb_cObject);
87
- rb_define_singleton_method(rb_class, "fnv1_32", rb_fnv1_32, 1);
88
- rb_define_singleton_method(rb_class, "fnv1a_32", rb_fnv1a_32, 1);
89
- rb_define_singleton_method(rb_class, "fnv1_64", rb_fnv1_64, 1);
90
- rb_define_singleton_method(rb_class, "fnv1a_64", rb_fnv1a_64, 1);
91
- }
@@ -1,3 +0,0 @@
1
- require 'mkmf'
2
-
3
- create_makefile 'bloombroom/hash/cext_fnv'
@@ -1,3 +0,0 @@
1
- require 'mkmf'
2
-
3
- create_makefile 'bloombroom/hash/ffi_fnv'
@@ -1,100 +0,0 @@
1
- # based on https://github.com/andyjeffries/digestfnv
2
-
3
- module Bloombroom
4
- class FNVA
5
-
6
- OFFSET32 = 2166136261
7
- OFFSET64 = 14695981039346656037
8
- OFFSET128 = 144066263297769815596495629667062367629
9
- OFFSET256 = 100029257958052580907070968620625704837092796014241193945225284501741471925557
10
- OFFSET512 = 9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785
11
- OFFSET1024 = 14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915
12
-
13
- PRIME32 = 16777619
14
- PRIME64 = 1099511628211
15
- PRIME128 = 309485009821345068724781371
16
- PRIME256 = 374144419156711147060143317175368453031918731002211
17
- PRIME512 = 35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759
18
- PRIME1024 = 5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573
19
-
20
- MASK32 = (2 ** 32) - 1
21
- MASK64 = (2 ** 64) - 1
22
- MASK128 = (2 ** 128) - 1
23
- MASK256 = (2 ** 256) - 1
24
- MASK512 = (2 ** 512) - 1
25
- MASK1024 = (2 ** 1024) - 1
26
-
27
- def self.fnv1_32(input)
28
- hash = OFFSET32
29
- input.each_byte { |b| hash = (hash * PRIME32) ^ b }
30
- hash & MASK32
31
- end
32
-
33
- def self.fnv1_64(input)
34
- hash = OFFSET64
35
- input.each_byte { |b| hash = (hash * PRIME64) ^ b }
36
- hash & MASK64
37
- end
38
-
39
- def self.fnv1_128(input)
40
- hash = OFFSET128
41
- input.each_byte { |b| hash = (hash * PRIME128) ^ b }
42
- hash & MASK128
43
- end
44
-
45
- def self.fnv1_256(input)
46
- hash = OFFSET256
47
- input.each_byte { |b| hash = (hash * PRIME256) ^ b }
48
- hash & MASK256
49
- end
50
-
51
- def self.fnv1_512(input)
52
- hash = OFFSET512
53
- input.each_byte { |b| hash = (hash * PRIME512) ^ b }
54
- hash & MASK512
55
- end
56
-
57
- def self.fnv1_1024(input)
58
- hash = OFFSET1024
59
- input.each_byte { |b| hash = (hash * PRIME1024) ^ b }
60
- hash & MASK1024
61
- end
62
-
63
- def self.fnv1a_32(input)
64
- hash = OFFSET32
65
- input.each_byte { |b| hash = (hash ^ b) * PRIME32 }
66
- hash & MASK32
67
- end
68
-
69
- def self.fnv1a_64(input)
70
- hash = OFFSET64
71
- input.each_byte { |b| hash = (hash ^ b) * PRIME64 }
72
- hash & MASK64
73
- end
74
-
75
- def self.fnv1a_128(input)
76
- hash = OFFSET128
77
- input.each_byte { |b| hash = (hash ^ b) * PRIME128 }
78
- hash & MASK128
79
- end
80
-
81
- def self.fnv1a_256(input)
82
- hash = OFFSET256
83
- input.each_byte { |b| hash = (hash ^ b) * PRIME256 }
84
- hash & MASK256
85
- end
86
-
87
- def self.fnv1a_512(input)
88
- hash = OFFSET512
89
- input.each_byte { |b| hash = (hash ^ b) * PRIME512 }
90
- hash & MASK512
91
- end
92
-
93
- def self.fnv1a_1024(input)
94
- hash = OFFSET1024
95
- input.each_byte { |b| hash = (hash ^ b) * PRIME1024 }
96
- hash & MASK1024
97
- end
98
-
99
- end
100
- end
@@ -1,56 +0,0 @@
1
- # based on https://github.com/jakedouglas/fnv-ruby
2
-
3
- module Bloombroom
4
- class FNVB
5
- INIT32 = 0x811c9dc5
6
- INIT64 = 0xcbf29ce484222325
7
- PRIME32 = 0x01000193
8
- PRIME64 = 0x100000001b3
9
- MOD32 = 2 ** 32
10
- MOD64 = 2 ** 64
11
-
12
- def self.fnv1_32(data)
13
- hash = INIT32
14
-
15
- data.each_byte do |byte|
16
- hash = (hash * PRIME32) % MOD32
17
- hash = hash ^ byte
18
- end
19
-
20
- hash
21
- end
22
-
23
- def self.fnv1_64(data)
24
- hash = INIT64
25
-
26
- data.each_byte do |byte|
27
- hash = (hash * PRIME64) % MOD64
28
- hash = hash ^ byte
29
- end
30
-
31
- hash
32
- end
33
-
34
- def self.fnv1a_32(data)
35
- hash = INIT32
36
-
37
- data.each_byte do |byte|
38
- hash = hash ^ byte
39
- hash = (hash * PRIME32) % MOD32
40
- end
41
-
42
- hash
43
- end
44
-
45
- def self.fnv1a_64(data)
46
- hash = INIT64
47
-
48
- data.each_byte do |byte|
49
- hash = hash ^ byte
50
- hash = (hash * PRIME64) % MOD64
51
- end
52
-
53
- hash
54
- end
55
- end
56
- end