ffi-radix_tree 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/ffi/radix_tree.rb +3 -7
- data/lib/ffi/radix_tree/version.rb +1 -1
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 24b341505b1ae9d77943d26730537193ce58cabe2877add54663f86436e7c0ee
|
4
|
+
data.tar.gz: 37d2b07791ed42c53e3ccad80e32fb3522bda0fd65d7a8a917a0576b7b6ced71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5244fc5c7d0828e4cc4907575dbca6b65265f8b35b02127d8bfb709dd057cadcd34a7ed5574d8ed23efe58b6b54f07e15b53a348f21413292f08a837579dcea3
|
7
|
+
data.tar.gz: 3d19a13ba263c5a147fa61be948db117adbf51582cfd3d9a368b27bc1f356ec34d62e37ea9cd08e54c7936d088ea8e448dbdd1086aacf9f525f63ec636116f11
|
data/lib/ffi/radix_tree.rb
CHANGED
@@ -83,15 +83,12 @@ module FFI
|
|
83
83
|
attach_function :has_key, [:pointer, :string], :bool
|
84
84
|
|
85
85
|
class Tree
|
86
|
-
DESTROY_METHOD = ::FFI::RadixTree.method(:destroy)
|
87
|
-
FREE_METHOD = ::FFI::RadixTree.method(:match_free)
|
88
|
-
|
89
86
|
def self.destroy!(tree)
|
90
87
|
tree.destroy! unless tree.nil?
|
91
88
|
end
|
92
89
|
|
93
90
|
def initialize
|
94
|
-
@ptr = ::FFI::
|
91
|
+
@ptr = ::FFI::RadixTree.create
|
95
92
|
@first_character_present = {}
|
96
93
|
end
|
97
94
|
|
@@ -116,7 +113,7 @@ module FFI
|
|
116
113
|
def get(key)
|
117
114
|
return nil unless @first_character_present[key[0]]
|
118
115
|
byte_length = ::FFI::MemoryPointer.new(:int)
|
119
|
-
byte_pointer = ::FFI::
|
116
|
+
byte_pointer = ::FFI::RadixTree.fetch(@ptr, key, byte_length)
|
120
117
|
bytesize = byte_length.read_int
|
121
118
|
return nil if bytesize <= 0
|
122
119
|
::MessagePack.unpack(byte_pointer.get_bytes(0, bytesize))
|
@@ -127,7 +124,6 @@ module FFI
|
|
127
124
|
def longest_prefix(string)
|
128
125
|
return nil unless @first_character_present[string[0]]
|
129
126
|
value, p_out = ::FFI::RadixTree.longest_prefix(@ptr, string)
|
130
|
-
p_out = ::FFI::AutoPointer.new(p_out, FREE_METHOD) unless p_out.nil?
|
131
127
|
value.force_encoding("UTF-8") unless value.nil?
|
132
128
|
value
|
133
129
|
ensure
|
@@ -137,7 +133,7 @@ module FFI
|
|
137
133
|
def longest_prefix_value(string)
|
138
134
|
return nil unless @first_character_present[string[0]]
|
139
135
|
byte_length = ::FFI::MemoryPointer.new(:int)
|
140
|
-
byte_pointer = ::FFI::
|
136
|
+
byte_pointer = ::FFI::RadixTree.longest_prefix_value(@ptr, string, byte_length)
|
141
137
|
bytesize = byte_length.read_int
|
142
138
|
return nil if bytesize <= 0
|
143
139
|
::MessagePack.unpack(byte_pointer.get_bytes(0, bytesize))
|
metadata
CHANGED
@@ -1,80 +1,80 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-radix_tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Dewitt
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: msgpack
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
18
|
version: '0'
|
20
|
-
|
19
|
+
name: msgpack
|
21
20
|
prerelease: false
|
21
|
+
type: :runtime
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: ffi
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
30
|
- - ">="
|
32
31
|
- !ruby/object:Gem::Version
|
33
32
|
version: '0'
|
34
|
-
|
33
|
+
name: ffi
|
35
34
|
prerelease: false
|
35
|
+
type: :runtime
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: bundler
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
44
43
|
requirements:
|
45
44
|
- - "~>"
|
46
45
|
- !ruby/object:Gem::Version
|
47
46
|
version: '1.15'
|
48
|
-
|
47
|
+
name: bundler
|
49
48
|
prerelease: false
|
49
|
+
type: :development
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.15'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: rake
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
58
57
|
requirements:
|
59
58
|
- - "~>"
|
60
59
|
- !ruby/object:Gem::Version
|
61
60
|
version: '10.0'
|
62
|
-
|
61
|
+
name: rake
|
63
62
|
prerelease: false
|
63
|
+
type: :development
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '10.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: minitest
|
71
70
|
requirement: !ruby/object:Gem::Requirement
|
72
71
|
requirements:
|
73
72
|
- - "~>"
|
74
73
|
- !ruby/object:Gem::Version
|
75
74
|
version: '5.0'
|
76
|
-
|
75
|
+
name: minitest
|
77
76
|
prerelease: false
|
77
|
+
type: :development
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
@@ -110,7 +110,7 @@ licenses:
|
|
110
110
|
- MIT
|
111
111
|
metadata:
|
112
112
|
allowed_push_host: https://rubygems.org
|
113
|
-
post_install_message:
|
113
|
+
post_install_message:
|
114
114
|
rdoc_options: []
|
115
115
|
require_paths:
|
116
116
|
- lib
|
@@ -125,9 +125,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '0'
|
127
127
|
requirements: []
|
128
|
-
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
130
|
-
signing_key:
|
128
|
+
rubyforge_project:
|
129
|
+
rubygems_version: 2.6.11
|
130
|
+
signing_key:
|
131
131
|
specification_version: 4
|
132
132
|
summary: radix tree implementation in c++ with FFI bindings
|
133
133
|
test_files: []
|