rroonga 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
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
data/test/test-remote.rb DELETED
@@ -1,63 +0,0 @@
1
- # Copyright (C) 2009-2010 Kouhei Sutou <kou@clear-code.com>
2
- #
3
- # This library is free software; you can redistribute it and/or
4
- # modify it under the terms of the GNU Lesser General Public
5
- # License version 2.1 as published by the Free Software Foundation.
6
- #
7
- # This library is distributed in the hope that it will be useful,
8
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
- # Lesser General Public License for more details.
11
- #
12
- # You should have received a copy of the GNU Lesser General Public
13
- # License along with this library; if not, write to the Free Software
14
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
-
16
- class RemoteTest < Test::Unit::TestCase
17
- include GroongaTestUtils
18
-
19
- setup :before => :append
20
- def setup_remote_connection
21
- @process_id = nil
22
-
23
- package_config = PKGConfig.package_config("groonga")
24
- groonga = package_config.variable("groonga")
25
-
26
- @host = "127.0.0.1"
27
- @port = 12345
28
- @remote_database_path = @tmp_dir + "remote-database"
29
- @process_id = Process.fork do
30
- exec(groonga,
31
- "-i", @host,
32
- "-p", @port.to_s,
33
- "-s", "-n", @remote_database_path.to_s)
34
- end
35
- sleep(1)
36
- end
37
-
38
- teardown
39
- def teardown_remote_connection
40
- Process.kill(:TERM, @process_id) if @process_id
41
- end
42
-
43
- def test_send
44
- _context = Groonga::Context.new
45
- _context.connect(:host => @host, :port => @port)
46
- assert_equal(0, _context.send("status"))
47
- id, result = _context.receive
48
- assert_equal(0, id)
49
- values = JSON.load(result)
50
- assert_equal(["alloc_count", "cache_hit_rate", "command_version",
51
- "default_command_version", "max_command_version",
52
- "n_queries", "starttime", "uptime", "version"],
53
- values.keys.sort)
54
- end
55
-
56
- def test_invalid_select
57
- context.connect(:host => @host, :port => @port)
58
-
59
- assert_raise(Groonga::InvalidArgument) do
60
- context.select("bogus", :query => "()()")
61
- end
62
- end
63
- end
@@ -1,267 +0,0 @@
1
- # Copyright (C) 2009-2011 Kouhei Sutou <kou@clear-code.com>
2
- #
3
- # This library is free software; you can redistribute it and/or
4
- # modify it under the terms of the GNU Lesser General Public
5
- # License version 2.1 as published by the Free Software Foundation.
6
- #
7
- # This library is distributed in the hope that it will be useful,
8
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
- # Lesser General Public License for more details.
11
- #
12
- # You should have received a copy of the GNU Lesser General Public
13
- # License along with this library; if not, write to the Free Software
14
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
-
16
- module SchemaCreateTableTests
17
- def test_normal
18
- assert_nil(context["Posts"])
19
- Groonga::Schema.create_table("Posts", options) do |table|
20
- end
21
- assert_not_nil(context["Posts"])
22
- end
23
-
24
- def test_force
25
- Groonga::Schema.create_table("Posts", options) do |table|
26
- table.string("name")
27
- end
28
- assert_not_nil(context["Posts.name"])
29
-
30
- Groonga::Schema.create_table("Posts",
31
- options(:type => differnt_type,
32
- :force => true)) do |table|
33
- end
34
- assert_nil(context["Posts.name"])
35
- end
36
-
37
- def test_different_type
38
- Groonga::Schema.create_table("Posts", options) do |table|
39
- end
40
-
41
- assert_raise(Groonga::Schema::TableCreationWithDifferentOptions) do
42
- Groonga::Schema.create_table("Posts",
43
- options(:type => differnt_type)) do |table|
44
- end
45
- end
46
- end
47
-
48
- def test_same_options
49
- Groonga::Schema.create_table("Posts", options) do |table|
50
- end
51
-
52
- Groonga::Schema.create_table("Posts", options) do |table|
53
- end
54
- assert_not_nil(context["Posts"])
55
- end
56
-
57
- def test_same_value_type
58
- Groonga::Schema.create_table("Posts",
59
- options(:value_type => "UInt32")) do |table|
60
- end
61
-
62
- Groonga::Schema.create_table("Posts",
63
- options(:value_type => "UInt32")) do |table|
64
- end
65
- assert_equal(context["UInt32"], context["Posts"].range)
66
- end
67
-
68
- def test_differnt_value_type
69
- Groonga::Schema.create_table("Posts", options) do |table|
70
- end
71
-
72
- assert_raise(Groonga::Schema::TableCreationWithDifferentOptions) do
73
- Groonga::Schema.create_table("Posts",
74
- options(:value_type => "Int32")) do |table|
75
- end
76
- end
77
- end
78
-
79
- def test_same_sub_records
80
- Groonga::Schema.create_table("Posts",
81
- options(:sub_records => true)) do |table|
82
- end
83
-
84
- Groonga::Schema.create_table("Posts",
85
- options(:sub_records => true)) do |table|
86
- end
87
- assert_true(context["Posts"].support_sub_records?)
88
- end
89
-
90
- def test_different_sub_records
91
- Groonga::Schema.create_table("Posts",
92
- options(:sub_records => true)) do |table|
93
- end
94
-
95
- assert_raise(Groonga::Schema::TableCreationWithDifferentOptions) do
96
- Groonga::Schema.create_table("Posts",
97
- options(:sub_records => false)) do |table|
98
- end
99
- end
100
- end
101
-
102
- def test_default_path
103
- Groonga::Schema.create_table("Posts", options) do |table|
104
- end
105
- assert_equal("#{@database_path}.0000100",
106
- context["Posts"].path)
107
- end
108
-
109
- def test_default_named_path
110
- options_with_named_path = options.merge(:named_path => true)
111
- Groonga::Schema.create_table("Posts", options_with_named_path) do |table|
112
- end
113
- assert_equal("#{@database_path}.tables/Posts",
114
- context["Posts"].path)
115
- end
116
-
117
- private
118
- def options(addional_options={})
119
- default_options.merge(addional_options)
120
- end
121
- end
122
-
123
- module SchemaCreateTableWithKeyTests
124
- def test_same_key_type
125
- Groonga::Schema.create_table("Posts",
126
- options(:key_type => "ShortText")) do |table|
127
- end
128
-
129
- Groonga::Schema.create_table("Posts",
130
- options(:key_type => "ShortText")) do |table|
131
- end
132
- assert_equal(context["ShortText"], context["Posts"].domain)
133
- end
134
-
135
- def test_differnt_key_type
136
- Groonga::Schema.create_table("Posts",
137
- options(:key_type => "Int32")) do |table|
138
- end
139
-
140
- assert_raise(Groonga::Schema::TableCreationWithDifferentOptions) do
141
- Groonga::Schema.create_table("Posts",
142
- options(:key_type => "ShortText")) do |table|
143
- end
144
- end
145
- end
146
-
147
- def test_same_default_tokenizer
148
- _options = options(:key_type => "ShortText",
149
- :default_tokenizer => "TokenBigram")
150
- Groonga::Schema.create_table("Posts", _options) do |table|
151
- end
152
-
153
- Groonga::Schema.create_table("Posts", _options) do |table|
154
- end
155
- assert_equal(context["TokenBigram"], context["Posts"].default_tokenizer)
156
- end
157
-
158
- def test_differnt_default_tokenizer
159
- _options = options(:key_type => "ShortText")
160
- Groonga::Schema.create_table("Posts", _options) do |table|
161
- end
162
-
163
- _options = _options.merge(:default_tokenizer => "TokenBigram")
164
- assert_raise(Groonga::Schema::TableCreationWithDifferentOptions) do
165
- Groonga::Schema.create_table("Posts", _options) do |table|
166
- end
167
- end
168
- end
169
-
170
- def test_same_key_normalize
171
- _options = options(:key_type => "ShortText",
172
- :key_normalize => true)
173
- Groonga::Schema.create_table("Posts", _options) do |table|
174
- end
175
-
176
- Groonga::Schema.create_table("Posts", _options) do |table|
177
- end
178
- assert_true(context["Posts"].normalize_key?)
179
- end
180
-
181
- def test_differnt_key_normalize
182
- _options = options(:key_type => "ShortText",
183
- :key_normalize => true)
184
- Groonga::Schema.create_table("Posts", _options) do |table|
185
- end
186
-
187
- _options = _options.merge(:key_normalize => false)
188
- assert_raise(Groonga::Schema::TableCreationWithDifferentOptions) do
189
- Groonga::Schema.create_table("Posts", _options) do |table|
190
- end
191
- end
192
- end
193
- end
194
-
195
- class SchemaCreateTableArrayTest < Test::Unit::TestCase
196
- include GroongaTestUtils
197
- include SchemaCreateTableTests
198
-
199
- setup :setup_database
200
-
201
- private
202
- def default_options
203
- {}
204
- end
205
-
206
- def differnt_type
207
- :hash
208
- end
209
- end
210
-
211
- class SchemaCreateTableHashTest < Test::Unit::TestCase
212
- include GroongaTestUtils
213
- include SchemaCreateTableTests
214
- include SchemaCreateTableWithKeyTests
215
-
216
- setup :setup_database
217
-
218
- private
219
- def default_options
220
- {:type => :hash}
221
- end
222
-
223
- def differnt_type
224
- :patricia_trie
225
- end
226
- end
227
-
228
- class SchemaCreateTablePatriciaTrieTest < Test::Unit::TestCase
229
- include GroongaTestUtils
230
- include SchemaCreateTableTests
231
- include SchemaCreateTableWithKeyTests
232
-
233
- setup :setup_database
234
-
235
- def test_same_key_with_sis
236
- _options = options(:key_type => "ShortText",
237
- :key_with_sis => true)
238
- Groonga::Schema.create_table("Posts", _options) do |table|
239
- end
240
-
241
- Groonga::Schema.create_table("Posts", _options) do |table|
242
- end
243
- assert_true(context["Posts"].register_key_with_sis?)
244
- end
245
-
246
- def test_differnt_key_with_sis
247
- _options = options(:key_type => "ShortText",
248
- :key_with_sis => true)
249
- Groonga::Schema.create_table("Posts", _options) do |table|
250
- end
251
-
252
- _options = _options.merge(:key_with_sis => false)
253
- assert_raise(Groonga::Schema::TableCreationWithDifferentOptions) do
254
- Groonga::Schema.create_table("Posts", _options) do |table|
255
- end
256
- end
257
- end
258
-
259
- private
260
- def default_options
261
- {:type => :patricia_trie}
262
- end
263
-
264
- def differnt_type
265
- :array
266
- end
267
- end
@@ -1,235 +0,0 @@
1
- # Copyright (C) 2009-2011 Kouhei Sutou <kou@clear-code.com>
2
- #
3
- # This library is free software; you can redistribute it and/or
4
- # modify it under the terms of the GNU Lesser General Public
5
- # License version 2.1 as published by the Free Software Foundation.
6
- #
7
- # This library is distributed in the hope that it will be useful,
8
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
- # Lesser General Public License for more details.
11
- #
12
- # You should have received a copy of the GNU Lesser General Public
13
- # License along with this library; if not, write to the Free Software
14
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
-
16
- class SchemaDumperTest < Test::Unit::TestCase
17
- include GroongaTestUtils
18
-
19
- setup :setup_database
20
-
21
- private
22
- def define_simple_schema
23
- Groonga::Schema.define do |schema|
24
- schema.create_table("Posts") do |table|
25
- table.short_text :title
26
- table.short_text :comments, :type => :vector
27
- end
28
- end
29
- end
30
-
31
- def define_built_in_types_schema
32
- Groonga::Schema.define do |schema|
33
- schema.create_table("Posts") do |table|
34
- table.boolean :public
35
- table.int8 :int8
36
- table.uint8 :uint8
37
- table.int16 :int16
38
- table.uint16 :uint16
39
- table.int32 :int32
40
- table.uint32 :uint32
41
- table.int64 :int64
42
- table.uint64 :uint64
43
- table.float :vote_average
44
- table.time :published_at
45
- table.short_text :title
46
- table.text :content
47
- table.long_text :attachment
48
- table.tokyo_geo_point :location_tokyo
49
- table.wgs84_geo_point :location_wgs84
50
- end
51
- end
52
- end
53
-
54
- def define_reference_schema
55
- Groonga::Schema.define do |schema|
56
- schema.create_table("Items") do |table|
57
- table.short_text("title")
58
- end
59
-
60
- schema.create_table("Users") do |table|
61
- table.short_text("name")
62
- end
63
-
64
- schema.create_table("Comments") do |table|
65
- table.reference("item", "Items")
66
- table.reference("author", "Users")
67
- table.reference("children", "Items", :type => :vector)
68
- table.text("content")
69
- table.time("issued")
70
- end
71
- end
72
- end
73
-
74
- def define_index_schema
75
- Groonga::Schema.define do |schema|
76
- schema.create_table("Items",
77
- :type => :hash,
78
- :key_type => "ShortText") do |table|
79
- table.short_text("title")
80
- end
81
-
82
- schema.create_table("Terms",
83
- :type => :patricia_trie,
84
- :key_type => "ShortText",
85
- :key_normalize => true,
86
- :default_tokenizer => "TokenBigram") do |table|
87
- table.index("Items", "_key")
88
- table.index("Items", "title")
89
- end
90
- end
91
- end
92
-
93
- class RubySyntaxSchemaDumperTest < SchemaDumperTest
94
- def test_simple
95
- define_simple_schema
96
- assert_equal(<<-EOS, dump)
97
- create_table("Posts",
98
- :force => true) do |table|
99
- table.short_text("comments", :type => :vector)
100
- table.short_text("title")
101
- end
102
- EOS
103
- end
104
-
105
- def test_built_in_types
106
- define_built_in_types_schema
107
- assert_equal(<<-EOS, dump)
108
- create_table("Posts",
109
- :force => true) do |table|
110
- table.long_text("attachment")
111
- table.text("content")
112
- table.integer16("int16")
113
- table.integer32("int32")
114
- table.integer64("int64")
115
- table.integer8("int8")
116
- table.tokyo_geo_point("location_tokyo")
117
- table.wgs84_geo_point("location_wgs84")
118
- table.boolean("public")
119
- table.time("published_at")
120
- table.short_text("title")
121
- table.unsigned_integer16("uint16")
122
- table.unsigned_integer32("uint32")
123
- table.unsigned_integer64("uint64")
124
- table.unsigned_integer8("uint8")
125
- table.float("vote_average")
126
- end
127
- EOS
128
- end
129
-
130
- def test_reference
131
- define_reference_schema
132
- assert_equal(<<-EOS, dump)
133
- create_table("Comments",
134
- :force => true) do |table|
135
- table.text("content")
136
- table.time("issued")
137
- end
138
-
139
- create_table("Items",
140
- :force => true) do |table|
141
- table.short_text("title")
142
- end
143
-
144
- create_table("Users",
145
- :force => true) do |table|
146
- table.short_text("name")
147
- end
148
-
149
- change_table("Comments") do |table|
150
- table.reference("author", "Users")
151
- table.reference("children", "Items", :type => :vector)
152
- table.reference("item", "Items")
153
- end
154
- EOS
155
- end
156
-
157
- def test_index
158
- define_index_schema
159
- assert_equal(<<-EOS, dump)
160
- create_table("Items",
161
- :type => :hash,
162
- :key_type => "ShortText",
163
- :force => true) do |table|
164
- table.short_text("title")
165
- end
166
-
167
- create_table("Terms",
168
- :type => :patricia_trie,
169
- :key_type => "ShortText",
170
- :key_normalize => true,
171
- :default_tokenizer => "TokenBigram",
172
- :force => true) do |table|
173
- end
174
-
175
- change_table("Terms") do |table|
176
- table.index("Items", "_key", :name => "Items__key")
177
- table.index("Items", "title", :name => "Items_title")
178
- end
179
- EOS
180
- end
181
-
182
- private
183
- def dump
184
- Groonga::Schema.dump
185
- end
186
- end
187
-
188
- class CommandSyntaxSchemaDumperTest < SchemaDumperTest
189
- def test_simple
190
- define_simple_schema
191
- assert_equal(<<-EOS, dump)
192
- table_create Posts TABLE_NO_KEY
193
- column_create Posts comments COLUMN_VECTOR ShortText
194
- column_create Posts title COLUMN_SCALAR ShortText
195
- EOS
196
- end
197
-
198
- def test_reference
199
- define_reference_schema
200
- assert_equal(<<-EOS, dump)
201
- table_create Comments TABLE_NO_KEY
202
- column_create Comments content COLUMN_SCALAR Text
203
- column_create Comments issued COLUMN_SCALAR Time
204
-
205
- table_create Items TABLE_NO_KEY
206
- column_create Items title COLUMN_SCALAR ShortText
207
-
208
- table_create Users TABLE_NO_KEY
209
- column_create Users name COLUMN_SCALAR ShortText
210
-
211
- column_create Comments author COLUMN_SCALAR Users
212
- column_create Comments children COLUMN_VECTOR Items
213
- column_create Comments item COLUMN_SCALAR Items
214
- EOS
215
- end
216
-
217
- def test_index
218
- define_index_schema
219
- assert_equal(<<-EOS, dump)
220
- table_create Items TABLE_HASH_KEY --key_type ShortText
221
- column_create Items title COLUMN_SCALAR ShortText
222
-
223
- table_create Terms TABLE_PAT_KEY|KEY_NORMALIZE --key_type ShortText --default_tokenizer TokenBigram
224
-
225
- column_create Terms Items__key COLUMN_INDEX|WITH_POSITION Items _key
226
- column_create Terms Items_title COLUMN_INDEX|WITH_POSITION Items title
227
- EOS
228
- end
229
-
230
- private
231
- def dump
232
- Groonga::Schema.dump(:syntax => :command)
233
- end
234
- end
235
- end