triez 1.0.2 → 1.0.3
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/changes +5 -0
- data/ext/hat-trie/ahtable.c +0 -1
- data/ext/hat-trie/hat-trie.c +11 -7
- data/lib/triez.rb +1 -1
- data/test/triez_test.rb +7 -0
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 331dc65dd70b83b8986fe4d07b5242e1cd8264d4
|
4
|
+
data.tar.gz: 8fb8aabd4adabb3388723640b1382bd6f6accae1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bcae2775f541197179171682c27e19e59cdedf92d46da2293b25c2150fdce768a49976479fd400cc318075630e4a191ada4a7041380c2676d6cf0a3d4d98a33
|
7
|
+
data.tar.gz: 9e80343627118747019fe21c5087c979bd33149bdfbad0a056cc291a5cb63f4b3893fa915edc85574c4cfe95aefa82789d7867106208f9fa534cbe6eea7c911f
|
data/changes
CHANGED
data/ext/hat-trie/ahtable.c
CHANGED
data/ext/hat-trie/hat-trie.c
CHANGED
@@ -112,8 +112,9 @@ static inline int hattrie_clrval(hattrie_t *T, node_ptr n)
|
|
112
112
|
}
|
113
113
|
|
114
114
|
/* find node in trie */
|
115
|
-
static node_ptr hattrie_find(hattrie_t* T, const char **key, size_t *len)
|
115
|
+
static node_ptr hattrie_find(hattrie_t* T, const char **key, size_t *len, int* found)
|
116
116
|
{
|
117
|
+
*found = 1;
|
117
118
|
node_ptr parent = T->root;
|
118
119
|
assert(*parent.flag & NODE_TYPE_TRIE);
|
119
120
|
|
@@ -124,7 +125,7 @@ static node_ptr hattrie_find(hattrie_t* T, const char **key, size_t *len)
|
|
124
125
|
/* if the trie node consumes value, use it */
|
125
126
|
if (*node.flag & NODE_TYPE_TRIE) {
|
126
127
|
if (!(node.t->flag & NODE_HAS_VAL)) {
|
127
|
-
|
128
|
+
*found = 0;
|
128
129
|
}
|
129
130
|
return node;
|
130
131
|
}
|
@@ -394,8 +395,9 @@ value_t* hattrie_get(hattrie_t* T, const char* key, size_t len)
|
|
394
395
|
value_t* hattrie_tryget(hattrie_t* T, const char* key, size_t len)
|
395
396
|
{
|
396
397
|
/* find node for given key */
|
397
|
-
|
398
|
-
|
398
|
+
int found;
|
399
|
+
node_ptr node = hattrie_find(T, &key, &len, &found);
|
400
|
+
if (!found) {
|
399
401
|
return NULL;
|
400
402
|
}
|
401
403
|
|
@@ -468,8 +470,9 @@ int hattrie_del(hattrie_t* T, const char* key, size_t len)
|
|
468
470
|
assert(*parent.flag & NODE_TYPE_TRIE);
|
469
471
|
|
470
472
|
/* find node for deletion */
|
471
|
-
|
472
|
-
|
473
|
+
int found;
|
474
|
+
node_ptr node = hattrie_find(T, &key, &len, &found);
|
475
|
+
if (!found) {
|
473
476
|
return -1;
|
474
477
|
}
|
475
478
|
|
@@ -648,7 +651,8 @@ hattrie_iter_t* hattrie_iter_begin(const hattrie_t* T, bool sorted)
|
|
648
651
|
|
649
652
|
hattrie_iter_t* hattrie_iter_with_prefix(const hattrie_t* T, bool sorted, const char* prefix, size_t prefix_len)
|
650
653
|
{
|
651
|
-
|
654
|
+
int found;
|
655
|
+
node_ptr node = hattrie_find((hattrie_t*)T, &prefix, &prefix_len, &found);
|
652
656
|
|
653
657
|
hattrie_iter_t* i = malloc_or_die(sizeof(hattrie_iter_t));
|
654
658
|
i->T = T;
|
data/lib/triez.rb
CHANGED
data/test/triez_test.rb
CHANGED
@@ -213,4 +213,11 @@ class TriezTest < Test::Unit::TestCase
|
|
213
213
|
end
|
214
214
|
assert_equal '一锅鸡', lcs
|
215
215
|
end
|
216
|
+
|
217
|
+
def test_should_not_segfault_when_search_with_prefix
|
218
|
+
t = Triez.new
|
219
|
+
# bursts when 16384
|
220
|
+
16_385.times{ |i| t["a#{i}"] = rand(10)+1 }
|
221
|
+
t.search_with_prefix("a")
|
222
|
+
end
|
216
223
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: triez
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zete Lui
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: fast, efficient, unicode aware HAT trie with prefix / suffix support.
|
14
14
|
email:
|
@@ -17,17 +17,13 @@ extensions:
|
|
17
17
|
- ext/extconf.rb
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- copying
|
21
20
|
- changes
|
22
|
-
-
|
23
|
-
- lib/triez.rb
|
24
|
-
- test/triez_test.rb
|
25
|
-
- ext/triez.cc
|
21
|
+
- copying
|
26
22
|
- ext/common.h
|
27
23
|
- ext/extconf.rb
|
24
|
+
- ext/hat-trie/COPYING
|
28
25
|
- ext/hat-trie/ahtable.c
|
29
26
|
- ext/hat-trie/ahtable.h
|
30
|
-
- ext/hat-trie/COPYING
|
31
27
|
- ext/hat-trie/hat-trie.c
|
32
28
|
- ext/hat-trie/hat-trie.h
|
33
29
|
- ext/hat-trie/misc.c
|
@@ -35,6 +31,10 @@ files:
|
|
35
31
|
- ext/hat-trie/murmurhash3.c
|
36
32
|
- ext/hat-trie/murmurhash3.h
|
37
33
|
- ext/hat-trie/pstdint.h
|
34
|
+
- ext/triez.cc
|
35
|
+
- lib/triez.rb
|
36
|
+
- readme.md
|
37
|
+
- test/triez_test.rb
|
38
38
|
homepage: https://github.com/luikore/triez
|
39
39
|
licenses: []
|
40
40
|
metadata: {}
|
@@ -54,9 +54,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
54
|
version: '0'
|
55
55
|
requirements: []
|
56
56
|
rubyforge_project:
|
57
|
-
rubygems_version: 2.
|
57
|
+
rubygems_version: 2.4.1
|
58
58
|
signing_key:
|
59
59
|
specification_version: 4
|
60
60
|
summary: fast, efficient, unicode aware HAT trie with prefix / suffix support
|
61
61
|
test_files: []
|
62
|
-
has_rdoc: false
|