rroonga 2.0.2 → 2.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.
Files changed (62) hide show
  1. data/AUTHORS +5 -0
  2. data/Gemfile +1 -12
  3. data/Rakefile +4 -57
  4. data/bin/grndump +11 -1
  5. data/ext/groonga/extconf.rb +125 -54
  6. data/ext/groonga/rb-grn-context.c +25 -7
  7. data/ext/groonga/rb-grn-database.c +25 -0
  8. data/ext/groonga/rb-grn-object.c +19 -7
  9. data/ext/groonga/rb-grn-table.c +8 -10
  10. data/ext/groonga/rb-grn.h +9 -2
  11. data/lib/groonga/dumper.rb +2 -2
  12. data/lib/groonga/expression-builder.rb +33 -18
  13. data/rroonga-build.rb +1 -1
  14. metadata +97 -180
  15. data/TODO +0 -0
  16. data/test/groonga-test-utils.rb +0 -139
  17. data/test/run-test.rb +0 -60
  18. data/test/test-accessor.rb +0 -36
  19. data/test/test-array.rb +0 -123
  20. data/test/test-column.rb +0 -350
  21. data/test/test-command-select.rb +0 -147
  22. data/test/test-context.rb +0 -130
  23. data/test/test-database-dumper.rb +0 -259
  24. data/test/test-database.rb +0 -148
  25. data/test/test-double-array-trie.rb +0 -164
  26. data/test/test-encoding.rb +0 -33
  27. data/test/test-exception.rb +0 -96
  28. data/test/test-expression-builder.rb +0 -269
  29. data/test/test-expression.rb +0 -134
  30. data/test/test-fix-size-column.rb +0 -77
  31. data/test/test-gqtp.rb +0 -70
  32. data/test/test-hash.rb +0 -344
  33. data/test/test-index-column.rb +0 -180
  34. data/test/test-index-cursor.rb +0 -93
  35. data/test/test-logger.rb +0 -37
  36. data/test/test-pagination.rb +0 -249
  37. data/test/test-patricia-trie.rb +0 -415
  38. data/test/test-plugin.rb +0 -35
  39. data/test/test-procedure.rb +0 -37
  40. data/test/test-query-log.rb +0 -258
  41. data/test/test-record.rb +0 -569
  42. data/test/test-remote.rb +0 -63
  43. data/test/test-schema-create-table.rb +0 -267
  44. data/test/test-schema-dumper.rb +0 -235
  45. data/test/test-schema-type.rb +0 -208
  46. data/test/test-schema-view.rb +0 -90
  47. data/test/test-schema.rb +0 -886
  48. data/test/test-snippet.rb +0 -130
  49. data/test/test-table-cursor.rb +0 -187
  50. data/test/test-table-dumper.rb +0 -83
  51. data/test/test-table-offset-and-limit.rb +0 -100
  52. data/test/test-table-select-mecab.rb +0 -80
  53. data/test/test-table-select-normalize.rb +0 -57
  54. data/test/test-table-select-weight.rb +0 -123
  55. data/test/test-table-select.rb +0 -191
  56. data/test/test-table.rb +0 -675
  57. data/test/test-type.rb +0 -79
  58. data/test/test-variable-size-column.rb +0 -147
  59. data/test/test-variable.rb +0 -28
  60. data/test/test-vector-column.rb +0 -76
  61. data/test/test-version.rb +0 -61
  62. data/test/test-view.rb +0 -72
@@ -1,80 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2010 Kouhei Sutou <kou@clear-code.com>
4
- #
5
- # This library is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU Lesser General Public
7
- # License version 2.1 as published by the Free Software Foundation.
8
- #
9
- # This library is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
- # Lesser General Public License for more details.
13
- #
14
- # You should have received a copy of the GNU Lesser General Public
15
- # License along with this library; if not, write to the Free Software
16
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
-
18
- class TableSelectMecabTest < Test::Unit::TestCase
19
- include GroongaTestUtils
20
-
21
- setup :setup_database
22
-
23
- setup
24
- def check_mecab_availability
25
- omit("MeCab isn't available") if context["TokenMecab"].nil?
26
- end
27
-
28
- setup
29
- def setup_tables
30
- Groonga::Schema.define do |schema|
31
- schema.create_table("Users", :key_type => "ShortText") do |table|
32
- end
33
-
34
- schema.create_table("Comments", :type => :array) do |table|
35
- table.short_text("title")
36
- table.text("content")
37
- table.time("created_at")
38
- table.reference("user", "Users")
39
- end
40
-
41
- schema.create_table("Terms",
42
- :type => :patricia_trie,
43
- :default_tokenizer => "TokenMecab") do |table|
44
- table.index("Comments.title", :with_section => true)
45
- table.index("Comments.content", :with_section => true)
46
- end
47
- end
48
- end
49
-
50
- setup
51
- def setup_comments
52
- @comments = context["Comments"]
53
- @hello = @comments.add(:title => "Hello",
54
- :content => "Hello Good-bye!",
55
- :created_at => Time.parse("2009-08-09"),
56
- :user => "morita")
57
- @hello_only_in_content =
58
- @comments.add(:title => "(no title)",
59
- :content => "Hello! Hello! Hello!",
60
- :created_at => Time.parse("2009-07-09"))
61
- @test = @comments.add(:title => "title",
62
- :content => "test",
63
- :created_at => Time.parse("2009-06-09"),
64
- :user => "gunyara-kun")
65
- @japanese =
66
- @comments.add(:title => "日本語",
67
- :content => "うちのボロTVはまだ現役です",
68
- :created_at => Time.parse("2009-06-09"),
69
- :user => "darashi")
70
- end
71
-
72
- def test_match
73
- result = @comments.select do |record|
74
- record.content =~ "ボロ"
75
- end
76
- assert_equal_select_result(["日本語"], result) do |record|
77
- record.title
78
- end
79
- end
80
- end
@@ -1,57 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
3
- # Copyright (C) 2009 SHIDARA Yoji <dara@shidara.net>
4
- #
5
- # This library is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU Lesser General Public
7
- # License version 2.1 as published by the Free Software Foundation.
8
- #
9
- # This library is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
- # Lesser General Public License for more details.
13
- #
14
- # You should have received a copy of the GNU Lesser General Public
15
- # License along with this library; if not, write to the Free Software
16
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
-
18
- class TableSelectNormalizeTest < Test::Unit::TestCase
19
- include GroongaTestUtils
20
-
21
- setup :setup_database
22
-
23
- setup
24
- def setup_comments
25
- @comments = Groonga::Array.create(:name => "Comments")
26
- @comments.define_column("content", "Text")
27
- @comments.define_column("created_at", "Time")
28
- options = {
29
- :name => "Terms",
30
- :default_tokenizer => "TokenBigramSplitSymbol",
31
- :key_normalize => true,
32
- }
33
- terms = Groonga::PatriciaTrie.create(options)
34
- terms.define_index_column("comment_content", @comments,
35
- :with_section => true,
36
- :with_position => true,
37
- :source => "Comments.content")
38
- @japanese_comment =
39
- @comments.add(:content => "うちのボロTV(アナログ...)はまだ現役です",
40
- :created_at => Time.parse("2009-06-09"))
41
- end
42
-
43
- def test_select_query_with_japanese
44
- result = @comments.select("content:@ボロTV")
45
- assert_equal_select_result([@japanese_comment], result)
46
- end
47
-
48
- def test_select_query_with_japanese_parenthesis
49
- result = @comments.select("content:@)は")
50
- assert_equal_select_result([@japanese_comment], result)
51
- end
52
-
53
- def test_select_query_only_in_japanese
54
- result = @comments.select("content:@うちの")
55
- assert_equal_select_result([@japanese_comment], result)
56
- end
57
- end
@@ -1,123 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2010-2011 Kouhei Sutou <kou@clear-code.com>
4
- #
5
- # This library is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU Lesser General Public
7
- # License version 2.1 as published by the Free Software Foundation.
8
- #
9
- # This library is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
- # Lesser General Public License for more details.
13
- #
14
- # You should have received a copy of the GNU Lesser General Public
15
- # License along with this library; if not, write to the Free Software
16
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
-
18
- class TableSelectWeightTest < Test::Unit::TestCase
19
- include GroongaTestUtils
20
-
21
- setup :setup_database
22
-
23
- setup
24
- def setup_tables
25
- Groonga::Schema.define do |schema|
26
- schema.create_table("Users",
27
- :type => :hash,
28
- :key_type => "ShortText") do |table|
29
- end
30
-
31
- schema.create_table("Comments") do |table|
32
- table.short_text("title")
33
- table.text("content")
34
- table.time("created_at")
35
- table.reference("user", "Users")
36
- end
37
-
38
- schema.create_table("Terms",
39
- :type => :patricia_trie,
40
- :default_tokenizer => "TokenBigram") do |table|
41
- table.index("Comments.title", :with_section => true)
42
- table.index("Comments.content", :with_section => true)
43
- end
44
-
45
- schema.create_table("Titles",
46
- :type => :hash) do |table|
47
- table.index("Comments.title")
48
- end
49
-
50
- schema.change_table("Users") do |table|
51
- table.index("Comments.user")
52
- end
53
- end
54
- end
55
-
56
- setup
57
- def setup_comments
58
- @comments = context["Comments"]
59
- @hello = @comments.add(:title => "Hello",
60
- :content => "Hello Good-bye!",
61
- :created_at => Time.parse("2009-08-09"),
62
- :user => "morita")
63
- @hello_only_in_content =
64
- @comments.add(:title => "(no title)",
65
- :content => "Hello! Hello! Hello!",
66
- :created_at => Time.parse("2009-07-09"))
67
- @test = @comments.add(:title => "title",
68
- :content => "test",
69
- :created_at => Time.parse("2009-06-09"),
70
- :user => "gunyara-kun")
71
- @japanese =
72
- @comments.add(:title => "日本語",
73
- :content => "うちのボロTVはまだ現役です",
74
- :created_at => Time.parse("2009-06-09"),
75
- :user => "darashi")
76
- end
77
-
78
- def test_full_text_search
79
- result = @comments.select do |record|
80
- record.match("Hello") do |match_record|
81
- (match_record.title * 100) |
82
- match_record.content
83
- end
84
- end
85
- assert_equal_select_result([["Hello", 101], ["(no title)", 3]],
86
- result) do |record|
87
- [record.title, record.score]
88
- end
89
- end
90
-
91
- def test_reference
92
- result = @comments.select do |record|
93
- full_text_match = record.match("Hello") do |match_record|
94
- (match_record.title * 100) |
95
- match_record.content
96
- end
97
- reference_match = record.match("darashi") do |match_record|
98
- match_record.user * 1000
99
- end
100
- full_text_match | reference_match
101
- end
102
- assert_equal_select_result([["Hello", 101],
103
- ["(no title)", 3],
104
- ["日本語", 1000]],
105
- result) do |record|
106
- [record.title, record.score]
107
- end
108
- end
109
-
110
- def test_index
111
- result = @comments.select do |record|
112
- record.match("Hello") do |match_record|
113
- (match_record.index("Titles.Comments_title") * 1000) |
114
- (match_record.index("Terms.Comments_title") * 100) |
115
- match_record.content
116
- end
117
- end
118
- assert_equal_select_result([["Hello", 1101], ["(no title)", 3]],
119
- result) do |record|
120
- [record.title, record.score]
121
- end
122
- end
123
- end
@@ -1,191 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2009-2011 Kouhei Sutou <kou@clear-code.com>
4
- #
5
- # This library is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU Lesser General Public
7
- # License version 2.1 as published by the Free Software Foundation.
8
- #
9
- # This library is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
- # Lesser General Public License for more details.
13
- #
14
- # You should have received a copy of the GNU Lesser General Public
15
- # License along with this library; if not, write to the Free Software
16
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
-
18
- class TableSelectTest < Test::Unit::TestCase
19
- include GroongaTestUtils
20
-
21
- setup :setup_database
22
-
23
- setup
24
- def setup_comments
25
- @users = Groonga::Hash.create(:name => "Users", :key_type => "ShortText")
26
-
27
- @comments = Groonga::Array.create(:name => "Comments")
28
- @comments.define_column("content", "Text")
29
- @comments.define_column("created_at", "Time")
30
- @comments.define_column("user", "Users")
31
-
32
- terms = Groonga::PatriciaTrie.create(:name => "Terms",
33
- :default_tokenizer => "TokenBigram")
34
- terms.define_index_column("comment_content", @comments,
35
- :with_section => true,
36
- :with_position => true,
37
- :source => "content")
38
- terms.define_index_column("users_key", @users,
39
- :with_section => true,
40
- :with_position => true,
41
- :source => "_key")
42
- @comment1 = @comments.add(:content => "Hello Good-bye!",
43
- :created_at => Time.parse("2009-08-09"),
44
- :user => "morita")
45
- @comment2 = @comments.add(:content => "Hello World",
46
- :created_at => Time.parse("2009-07-09"))
47
- @comment3 = @comments.add(:content => "test",
48
- :created_at => Time.parse("2009-06-09"),
49
- :user => "gunyara-kun")
50
- @japanese_comment =
51
- @comments.add(:content => "うちのボロTVはまだ現役です",
52
- :created_at => Time.parse("2009-06-09"),
53
- :user => "darashi")
54
- end
55
-
56
- setup
57
- def setup_variables
58
- @result = nil
59
- end
60
-
61
- def test_sub_expression
62
- @result = @comments.select do |record|
63
- record.match("Hello", "content") &
64
- (record["created_at"] < Time.parse("2009-08-01"))
65
- end
66
- assert_equal_select_result([@comment2], @result)
67
- end
68
-
69
- def test_query
70
- @result = @comments.select("content:@Hello")
71
- assert_equal_select_result([@comment1, @comment2], @result)
72
- end
73
-
74
- def test_query_with_parser
75
- @result = @comments.select("content @ \"Hello\"", :syntax => :script)
76
- assert_equal_select_result([@comment1, @comment2], @result)
77
- end
78
-
79
- def test_query_with_default_column
80
- @result = @comments.select("Hello", {:default_column => 'content'})
81
- assert_equal_select_result([@comment1, @comment2], @result)
82
- end
83
-
84
- def test_expression
85
- expression = Groonga::Expression.new
86
- variable = expression.define_variable(:domain => @comments)
87
- expression.append_object(variable)
88
- expression.parse("content:@Hello", :syntax => :query)
89
- expression.compile
90
- @result = @comments.select(expression)
91
- assert_equal(expression, @result.expression)
92
- assert_equal_select_result([@comment1, @comment2], @result)
93
- end
94
-
95
- def test_query_with_block
96
- @result = @comments.select("content:@Hello") do |record|
97
- record["created_at"] < Time.parse("2009-08-01")
98
- end
99
- assert_equal_select_result([@comment2], @result)
100
- end
101
-
102
- def test_query_with_block_match
103
- @result = @comments.select("content:@Hello") do |record|
104
- record.match("World", "content")
105
- end
106
- assert_equal_select_result([@comment2], @result)
107
- end
108
-
109
- def test_without_block
110
- @result = @comments.select
111
- assert_equal_select_result([@comment1, @comment2,
112
- @comment3, @japanese_comment],
113
- @result)
114
- end
115
-
116
- def test_query_japanese
117
- @result = @comments.select("content:@ボロTV")
118
- assert_equal_select_result([@japanese_comment], @result)
119
- end
120
-
121
- def test_but_query
122
- @result = @comments.select do |record|
123
- record["content"].match "Hello -World"
124
- end
125
- assert_equal_select_result([@comment1], @result)
126
- end
127
-
128
- def test_query_with_three_terms
129
- @result = @comments.select do |record|
130
- record["content"].match "Say Hello World"
131
- end
132
- assert_equal_select_result([], @result)
133
- end
134
-
135
- def test_query_with_brackets
136
- @result = @comments.select do |record|
137
- record["content"].match "Say (Hello World)"
138
- end
139
- assert_equal_select_result([], @result)
140
- end
141
-
142
- def test_equal_reference_column_by_key
143
- @result = @comments.select do |record|
144
- record["user"] == "darashi"
145
- end
146
- assert_equal_select_result([@japanese_comment], @result)
147
- end
148
-
149
- def test_not_equal_reference_column_by_key
150
- @result = @comments.select('user != "darashi"', :syntax => :script)
151
- assert_equal_select_result([@comment1, @comment2, @comment3],
152
- @result)
153
- end
154
-
155
- def test_not_equal_block
156
- only_ruby19
157
- @result = @comments.select do |record|
158
- record.user != "darashi"
159
- end
160
- assert_equal_select_result([@comment1, @comment2, @comment3],
161
- @result)
162
- end
163
-
164
- def test_equal_reference_column_by_nonexistent_key
165
- @result = @comments.select do |record|
166
- record["user"] == "nonexistent"
167
- end
168
- assert_equal_select_result([], @result)
169
- end
170
-
171
- def test_query_key
172
- @result = @users.select do |record|
173
- record["_key"] =~ "mori"
174
- end
175
- assert_equal_select_result([@users["morita"]], @result)
176
- end
177
-
178
- def test_symbol
179
- @result = @comments.select do |record|
180
- record[:content].match("Say Hello World")
181
- end
182
- assert_equal_select_result([], @result)
183
- end
184
-
185
- def test_method
186
- @result = @comments.select do |record|
187
- record.content.match("Say Hello World")
188
- end
189
- assert_equal_select_result([], @result)
190
- end
191
- end