groonga 0.9.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. metadata +38 -227
  2. data/AUTHORS +0 -5
  3. data/NEWS.ja.rdoc +0 -114
  4. data/NEWS.rdoc +0 -116
  5. data/README.ja.rdoc +0 -63
  6. data/README.rdoc +0 -64
  7. data/Rakefile +0 -216
  8. data/benchmark/common.rb +0 -49
  9. data/benchmark/read-write-many-small-items.rb +0 -144
  10. data/benchmark/write-many-small-items.rb +0 -135
  11. data/example/bookmark.rb +0 -161
  12. data/example/index-html.rb +0 -89
  13. data/example/search/config.ru +0 -211
  14. data/example/search/public/css/groonga.css +0 -122
  15. data/ext/.gitignore +0 -2
  16. data/ext/rb-grn-accessor.c +0 -52
  17. data/ext/rb-grn-array-cursor.c +0 -36
  18. data/ext/rb-grn-array.c +0 -210
  19. data/ext/rb-grn-column.c +0 -570
  20. data/ext/rb-grn-context.c +0 -655
  21. data/ext/rb-grn-database.c +0 -415
  22. data/ext/rb-grn-encoding-support.c +0 -64
  23. data/ext/rb-grn-encoding.c +0 -257
  24. data/ext/rb-grn-exception.c +0 -1110
  25. data/ext/rb-grn-expression-builder.c +0 -75
  26. data/ext/rb-grn-expression.c +0 -732
  27. data/ext/rb-grn-fix-size-column.c +0 -166
  28. data/ext/rb-grn-hash-cursor.c +0 -38
  29. data/ext/rb-grn-hash.c +0 -294
  30. data/ext/rb-grn-index-column.c +0 -488
  31. data/ext/rb-grn-logger.c +0 -325
  32. data/ext/rb-grn-object.c +0 -1335
  33. data/ext/rb-grn-operation.c +0 -198
  34. data/ext/rb-grn-patricia-trie-cursor.c +0 -39
  35. data/ext/rb-grn-patricia-trie.c +0 -488
  36. data/ext/rb-grn-procedure.c +0 -52
  37. data/ext/rb-grn-query.c +0 -260
  38. data/ext/rb-grn-record.c +0 -40
  39. data/ext/rb-grn-snippet.c +0 -328
  40. data/ext/rb-grn-table-cursor-key-support.c +0 -69
  41. data/ext/rb-grn-table-cursor.c +0 -246
  42. data/ext/rb-grn-table-key-support.c +0 -731
  43. data/ext/rb-grn-table.c +0 -2038
  44. data/ext/rb-grn-type.c +0 -181
  45. data/ext/rb-grn-utils.c +0 -769
  46. data/ext/rb-grn-variable-size-column.c +0 -36
  47. data/ext/rb-grn-variable.c +0 -108
  48. data/ext/rb-grn.h +0 -684
  49. data/ext/rb-groonga.c +0 -113
  50. data/extconf.rb +0 -216
  51. data/html/bar.svg +0 -153
  52. data/html/developer.html +0 -121
  53. data/html/developer.svg +0 -469
  54. data/html/download.svg +0 -253
  55. data/html/favicon.ico +0 -0
  56. data/html/favicon.xcf +0 -0
  57. data/html/footer.html.erb +0 -28
  58. data/html/head.html.erb +0 -4
  59. data/html/header.html.erb +0 -17
  60. data/html/index.html +0 -147
  61. data/html/install.svg +0 -636
  62. data/html/logo.xcf +0 -0
  63. data/html/ranguba.css +0 -248
  64. data/html/tutorial.svg +0 -559
  65. data/lib/groonga.rb +0 -83
  66. data/lib/groonga/expression-builder.rb +0 -285
  67. data/lib/groonga/patricia-trie.rb +0 -53
  68. data/lib/groonga/record.rb +0 -276
  69. data/lib/groonga/schema.rb +0 -916
  70. data/license/GPL +0 -340
  71. data/license/LGPL +0 -504
  72. data/license/RUBY +0 -59
  73. data/misc/grnop2ruby.rb +0 -49
  74. data/pkg-config.rb +0 -333
  75. data/src/rb-grn-table-cursor.c +0 -296
  76. data/test-unit/Rakefile +0 -40
  77. data/test-unit/TODO +0 -5
  78. data/test-unit/bin/testrb +0 -5
  79. data/test-unit/html/classic.html +0 -15
  80. data/test-unit/html/index.html +0 -25
  81. data/test-unit/html/index.html.ja +0 -27
  82. data/test-unit/lib/test/unit.rb +0 -323
  83. data/test-unit/lib/test/unit/assertionfailederror.rb +0 -25
  84. data/test-unit/lib/test/unit/assertions.rb +0 -1230
  85. data/test-unit/lib/test/unit/attribute.rb +0 -125
  86. data/test-unit/lib/test/unit/autorunner.rb +0 -353
  87. data/test-unit/lib/test/unit/collector.rb +0 -36
  88. data/test-unit/lib/test/unit/collector/descendant.rb +0 -23
  89. data/test-unit/lib/test/unit/collector/dir.rb +0 -108
  90. data/test-unit/lib/test/unit/collector/load.rb +0 -136
  91. data/test-unit/lib/test/unit/collector/objectspace.rb +0 -34
  92. data/test-unit/lib/test/unit/color-scheme.rb +0 -102
  93. data/test-unit/lib/test/unit/color.rb +0 -96
  94. data/test-unit/lib/test/unit/diff.rb +0 -724
  95. data/test-unit/lib/test/unit/error.rb +0 -130
  96. data/test-unit/lib/test/unit/exceptionhandler.rb +0 -39
  97. data/test-unit/lib/test/unit/failure.rb +0 -136
  98. data/test-unit/lib/test/unit/fixture.rb +0 -176
  99. data/test-unit/lib/test/unit/notification.rb +0 -129
  100. data/test-unit/lib/test/unit/omission.rb +0 -191
  101. data/test-unit/lib/test/unit/pending.rb +0 -150
  102. data/test-unit/lib/test/unit/priority.rb +0 -181
  103. data/test-unit/lib/test/unit/runner/console.rb +0 -52
  104. data/test-unit/lib/test/unit/runner/emacs.rb +0 -8
  105. data/test-unit/lib/test/unit/runner/tap.rb +0 -8
  106. data/test-unit/lib/test/unit/testcase.rb +0 -476
  107. data/test-unit/lib/test/unit/testresult.rb +0 -89
  108. data/test-unit/lib/test/unit/testsuite.rb +0 -110
  109. data/test-unit/lib/test/unit/ui/console/outputlevel.rb +0 -14
  110. data/test-unit/lib/test/unit/ui/console/testrunner.rb +0 -464
  111. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +0 -63
  112. data/test-unit/lib/test/unit/ui/tap/testrunner.rb +0 -92
  113. data/test-unit/lib/test/unit/ui/testrunner.rb +0 -28
  114. data/test-unit/lib/test/unit/ui/testrunnermediator.rb +0 -77
  115. data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +0 -41
  116. data/test-unit/lib/test/unit/util/backtracefilter.rb +0 -41
  117. data/test-unit/lib/test/unit/util/method-owner-finder.rb +0 -28
  118. data/test-unit/lib/test/unit/util/observable.rb +0 -90
  119. data/test-unit/lib/test/unit/util/procwrapper.rb +0 -48
  120. data/test-unit/lib/test/unit/version.rb +0 -7
  121. data/test-unit/sample/adder.rb +0 -13
  122. data/test-unit/sample/subtracter.rb +0 -12
  123. data/test-unit/sample/test_adder.rb +0 -20
  124. data/test-unit/sample/test_subtracter.rb +0 -20
  125. data/test-unit/sample/test_user.rb +0 -23
  126. data/test-unit/test/collector/test-descendant.rb +0 -133
  127. data/test-unit/test/collector/test-load.rb +0 -329
  128. data/test-unit/test/collector/test_dir.rb +0 -406
  129. data/test-unit/test/collector/test_objectspace.rb +0 -100
  130. data/test-unit/test/run-test.rb +0 -15
  131. data/test-unit/test/test-attribute.rb +0 -86
  132. data/test-unit/test/test-color-scheme.rb +0 -67
  133. data/test-unit/test/test-color.rb +0 -47
  134. data/test-unit/test/test-diff.rb +0 -518
  135. data/test-unit/test/test-emacs-runner.rb +0 -60
  136. data/test-unit/test/test-fixture.rb +0 -287
  137. data/test-unit/test/test-notification.rb +0 -33
  138. data/test-unit/test/test-omission.rb +0 -81
  139. data/test-unit/test/test-pending.rb +0 -70
  140. data/test-unit/test/test-priority.rb +0 -119
  141. data/test-unit/test/test-testcase.rb +0 -554
  142. data/test-unit/test/test_assertions.rb +0 -1151
  143. data/test-unit/test/test_error.rb +0 -26
  144. data/test-unit/test/test_failure.rb +0 -33
  145. data/test-unit/test/test_testresult.rb +0 -113
  146. data/test-unit/test/test_testsuite.rb +0 -129
  147. data/test-unit/test/testunit-test-util.rb +0 -14
  148. data/test-unit/test/ui/test_testrunmediator.rb +0 -20
  149. data/test-unit/test/util/test-method-owner-finder.rb +0 -38
  150. data/test-unit/test/util/test_backtracefilter.rb +0 -41
  151. data/test-unit/test/util/test_observable.rb +0 -102
  152. data/test-unit/test/util/test_procwrapper.rb +0 -36
  153. data/test/.gitignore +0 -1
  154. data/test/groonga-test-utils.rb +0 -106
  155. data/test/run-test.rb +0 -58
  156. data/test/test-array.rb +0 -97
  157. data/test/test-column.rb +0 -298
  158. data/test/test-context.rb +0 -73
  159. data/test/test-database.rb +0 -113
  160. data/test/test-encoding.rb +0 -33
  161. data/test/test-exception.rb +0 -93
  162. data/test/test-expression-builder.rb +0 -156
  163. data/test/test-expression.rb +0 -133
  164. data/test/test-fix-size-column.rb +0 -65
  165. data/test/test-gqtp.rb +0 -70
  166. data/test/test-hash.rb +0 -312
  167. data/test/test-index-column.rb +0 -81
  168. data/test/test-patricia-trie.rb +0 -189
  169. data/test/test-procedure.rb +0 -37
  170. data/test/test-query.rb +0 -22
  171. data/test/test-record.rb +0 -268
  172. data/test/test-remote.rb +0 -53
  173. data/test/test-schema.rb +0 -416
  174. data/test/test-snippet.rb +0 -121
  175. data/test/test-table-cursor.rb +0 -153
  176. data/test/test-table-offset-and-limit.rb +0 -102
  177. data/test/test-table-select-normalize.rb +0 -48
  178. data/test/test-table-select.rb +0 -145
  179. data/test/test-table.rb +0 -642
  180. data/test/test-type.rb +0 -61
  181. data/test/test-variable-size-column.rb +0 -98
  182. data/test/test-variable.rb +0 -28
  183. data/test/test-vector-column.rb +0 -76
  184. data/test/test-version.rb +0 -31
  185. data/text/TUTORIAL.ja.rdoc +0 -392
  186. data/text/expression.rdoc +0 -284
@@ -1,81 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2009 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 IndexColumnTest < Test::Unit::TestCase
19
- include GroongaTestUtils
20
-
21
- def setup
22
- setup_database
23
- end
24
-
25
- def test_array_set_with_record
26
- articles = Groonga::Array.create(:name => "Articles")
27
- articles.define_column("content", "Text")
28
-
29
- terms = Groonga::Hash.create(:name => "Terms",
30
- :default_tokenizer => "TokenBigram")
31
- content_index = terms.define_index_column("content", articles,
32
- :with_section => true)
33
-
34
- content = <<-EOC
35
- groonga は組み込み型の全文検索エンジンライブラリです。
36
- DBMSやスクリプト言語処理系等に組み込むことによって、その
37
- 全文検索機能を強化することができます。また、リレーショナ
38
- ルモデルに基づくデータストア機能を内包しており、groonga
39
- 単体でも高速なデータストアサーバとして使用することができ
40
- ます。
41
-
42
- ■全文検索方式
43
- 転置索引型の全文検索エンジンです。転置索引は圧縮されてファ
44
- イルに格納され、検索時のディスク読み出し量を小さく、かつ
45
- 局所的に抑えるように設計されています。用途に応じて以下の
46
- 索引タイプを選択できます。
47
- EOC
48
-
49
- groonga = articles.add(:content => content)
50
-
51
- content.split(/\n{2,}/).each_with_index do |sentence, i|
52
- content_index[groonga] = {:value => sentence, :section => i + 1}
53
- end
54
- assert_equal([groonga],
55
- content_index.search("エンジン").collect {|record| record.key})
56
- end
57
-
58
- def test_shorter_query_than_ngram
59
- articles = Groonga::Array.create(:name => "Articles")
60
- articles.define_column("content", "Text")
61
-
62
- terms = Groonga::PatriciaTrie.create(:name => "Terms",
63
- :default_tokenizer => "TokenBigram")
64
- content_index = terms.define_index_column("content", articles,
65
- :source => "Articles.content")
66
- articles.add(:content => 'l')
67
- articles.add(:content => 'll')
68
- articles.add(:content => 'hello')
69
-
70
- assert_search(["hello"], content_index, "he")
71
- assert_search(["ll", "hello"], content_index, "ll")
72
- assert_search(["l", "ll", "hello"], content_index, "l")
73
- end
74
-
75
- def assert_search(expected, content_index, keyword)
76
- result = content_index.search(keyword).collect do |entry|
77
- entry.key["content"]
78
- end
79
- assert_equal(expected, result)
80
- end
81
- end
@@ -1,189 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
3
- #
4
- # This library is free software; you can redistribute it and/or
5
- # modify it under the terms of the GNU Lesser General Public
6
- # License version 2.1 as published by the Free Software Foundation.
7
- #
8
- # This library is distributed in the hope that it will be useful,
9
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
- # Lesser General Public License for more details.
12
- #
13
- # You should have received a copy of the GNU Lesser General Public
14
- # License along with this library; if not, write to the Free Software
15
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
-
17
- class PatriciaTrieTest < Test::Unit::TestCase
18
- include GroongaTestUtils
19
-
20
- setup :setup_database
21
-
22
- def test_encoding
23
- assert_equal(Groonga::Encoding.default,
24
- Groonga::PatriciaTrie.create.encoding)
25
- end
26
-
27
- def test_tokenizer
28
- trie = Groonga::PatriciaTrie.create
29
- assert_nil(trie.default_tokenizer)
30
- trie.default_tokenizer = "TokenTrigram"
31
- assert_equal(Groonga::Context.default["TokenTrigram"],
32
- trie.default_tokenizer)
33
- end
34
-
35
- def test_search
36
- users = Groonga::Array.create(:name => "Users")
37
- user_name = users.define_column("name", "ShortText")
38
-
39
- bookmarks = Groonga::PatriciaTrie.create(:name => "Bookmarks",
40
- :key_type => "ShortText")
41
- bookmark_user_id = bookmarks.define_column("user_id", users)
42
-
43
- daijiro = users.add
44
- daijiro["name"] = "daijiro"
45
- gunyarakun = users.add
46
- gunyarakun["name"] = "gunyarakun"
47
-
48
- groonga = bookmarks.add("http://groonga.org/")
49
- groonga["user_id"] = daijiro
50
-
51
- records = bookmarks.search("http://groonga.org/")
52
- assert_equal(["daijiro"],
53
- records.records.collect {|record| record[".user_id.name"]})
54
- end
55
-
56
- def test_add
57
- users = Groonga::PatriciaTrie.create(:name => "Users")
58
- users.define_column("address", "<text>")
59
- me = users.add("me", :address => "me@example.com")
60
- assert_equal("me@example.com", me[:address])
61
- end
62
-
63
- def test_default_tokenizer_on_create
64
- terms = Groonga::PatriciaTrie.create(:name => "Terms",
65
- :default_tokenizer => "TokenUnigram")
66
- assert_equal(context[Groonga::Type::UNIGRAM],
67
- terms.default_tokenizer)
68
- end
69
-
70
- def test_duplicated_name
71
- Groonga::PatriciaTrie.create(:name => "Users")
72
- assert_raise(Groonga::InvalidArgument) do
73
- Groonga::PatriciaTrie.create(:name => "Users")
74
- end
75
- end
76
-
77
- def test_open_same_name
78
- users_created = Groonga::PatriciaTrie.create(:name => "Users")
79
- users_opened = Groonga::PatriciaTrie.open(:name => "Users")
80
- users_opened.add("morita")
81
- assert_equal(1, users_created.size)
82
- end
83
-
84
- def test_has_key?
85
- users = Groonga::PatriciaTrie.create(:name => "Users")
86
- assert_false(users.has_key?("morita"))
87
- users.add("morita")
88
- assert_true(users.has_key?("morita"))
89
- end
90
-
91
- def test_scan
92
- Groonga::Context.default_options = {:encoding => "utf-8"}
93
- words = Groonga::PatriciaTrie.create(:key_type => "ShortText",
94
- :key_normalize => true)
95
- words.add("リンク")
96
- arupaka = words.add("アルパカ")
97
- words.add("アルパカ(生物)")
98
- adventure_of_link = words.add('リンクの冒険')
99
- words.add('冒険')
100
- gaxtu = words.add('ガッ')
101
- muteki = words.add('MUTEKI')
102
- assert_equal([[muteki, "muTEki", 0, 6],
103
- [adventure_of_link, "リンクの冒険", 7, 18],
104
- [arupaka, "アルパカ", 42, 12],
105
- [gaxtu, "ガッ", 55, 6]],
106
- words.scan('muTEki リンクの冒険 ミリバール アルパカ ガッ'))
107
- end
108
-
109
- def test_tag_keys
110
- Groonga::Context.default_options = {:encoding => "utf-8"}
111
- words = Groonga::PatriciaTrie.create(:key_type => "ShortText",
112
- :key_normalize => true)
113
- words.add('リンク')
114
- words.add('リンクの冒険')
115
- words.add('冒険')
116
- words.add('㍊')
117
- words.add('ガッ')
118
- words.add('MUTEKI')
119
-
120
- text = 'muTEki リンクの冒険 マッチしない ミリバール ガッ おわり'
121
- actual = words.tag_keys(text) do |record, word|
122
- "<#{word}(#{record.key})>"
123
- end
124
- assert_equal("<muTEki(muteki)> " +
125
- "<リンクの冒険(リンクの冒険)> " +
126
- "マッチしない " +
127
- "<ミリバール(ミリバール)> " +
128
- "<ガッ(ガッ)> " +
129
- "おわり",
130
- actual)
131
- end
132
-
133
- def test_tag_keys_with_last_match
134
- Groonga::Context.default_options = {:encoding => "utf-8"}
135
- words = Groonga::PatriciaTrie.create(:key_type => "ShortText",
136
- :key_normalize => true)
137
- words.add('ガッ')
138
- words.add('MUTEKI')
139
-
140
- text = 'muTEki マッチしない ガッ'
141
- actual = words.tag_keys(text) do |record, word|
142
- "<#{word}(#{record.key})>"
143
- end
144
- assert_equal("<muTEki(muteki)> " +
145
- "マッチしない " +
146
- "<ガッ(ガッ)>",
147
- actual)
148
- end
149
-
150
- def test_tag_keys_with_no_match
151
- Groonga::Context.default_options = {:encoding => "utf-8"}
152
- words = Groonga::PatriciaTrie.create(:key_type => "ShortText",
153
- :key_normalize => true)
154
-
155
- words.add('無敵')
156
- words.add('BOUKEN')
157
-
158
- text = 'muTEki リンクの冒険'
159
- actual = words.tag_keys(text) do |record, word|
160
- "<#{word}(#{record.key})>"
161
- end
162
- assert_equal(text, actual)
163
- end
164
-
165
- def test_prefix_search
166
- paths = Groonga::PatriciaTrie.create(:name => "Paths",
167
- :key_type => 'ShortText')
168
- root_path = paths.add('/')
169
- tmp_path = paths.add('/tmp')
170
- usr_bin_path = paths.add('/usr/bin')
171
- usr_local_bin_path = paths.add('/usr/local/bin')
172
-
173
- records = paths.prefix_search('/')
174
- assert_equal(["/usr/local/bin", "/usr/bin", "/tmp", "/"],
175
- records.records.collect {|record| record["._key"]})
176
-
177
- records = paths.prefix_search('/usr')
178
- assert_equal(["/usr/local/bin", "/usr/bin"],
179
- records.records.collect {|record| record["._key"]})
180
-
181
- records = paths.prefix_search('/usr/local')
182
- assert_equal(["/usr/local/bin"],
183
- records.records.collect {|record| record["._key"]})
184
-
185
- records = paths.prefix_search('nonexistent')
186
- assert_equal([],
187
- records.records.collect {|record| record["._key"]})
188
- end
189
- end
@@ -1,37 +0,0 @@
1
- # Copyright (C) 2009 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 ProcedureTest < Test::Unit::TestCase
17
- include GroongaTestUtils
18
-
19
- setup :setup_database
20
-
21
- def test_builtins
22
- assert_equal_procedure("TokenDelimit", Groonga::Procedure::DELIMIT)
23
- assert_equal_procedure("TokenUnigram", Groonga::Procedure::UNIGRAM)
24
- assert_equal_procedure("TokenBigram", Groonga::Procedure::BIGRAM)
25
- assert_equal_procedure("TokenTrigram", Groonga::Procedure::TRIGRAM)
26
- assert_equal_procedure("TokenMecab", Groonga::Procedure::MECAB,
27
- :accept_nil => true)
28
- end
29
-
30
- private
31
- def assert_equal_procedure(expected_name, id, options={})
32
- procedure = Groonga::Context.default[id]
33
- expected_name = nil if procedure.nil? and options[:accept_nil]
34
- assert_equal(expected_name,
35
- procedure ? procedure.name : procedure)
36
- end
37
- end
data/test/test-query.rb DELETED
@@ -1,22 +0,0 @@
1
- # Copyright (C) 2009 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 QueryTest < Test::Unit::TestCase
17
- include GroongaTestUtils
18
-
19
- def test_new
20
- Groonga::Query.new("groonga text")
21
- end
22
- end
data/test/test-record.rb DELETED
@@ -1,268 +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 RecordTest < Test::Unit::TestCase
17
- include GroongaTestUtils
18
-
19
- def setup
20
- setup_database
21
-
22
- setup_addresses_table
23
- setup_users_table
24
- setup_bookmarks_table
25
- setup_indexes
26
- end
27
-
28
- def setup_addresses_table
29
- @addresses_path = @tables_dir + "addresses"
30
- @addresses = Groonga::Array.create(:name => "Addresses",
31
- :path => @addresses_path.to_s)
32
-
33
- @addresses_mail_column_path = @columns_dir + "mail"
34
- @addresses_mail_column =
35
- @addresses.define_column("mail", "ShortText",
36
- :path => @addresses_mail_column_path.to_s)
37
- end
38
-
39
- def setup_users_table
40
- @users_path = @tables_dir + "users"
41
- @users = Groonga::Array.create(:name => "Users",
42
- :path => @users_path.to_s)
43
-
44
- @users_name_column_path = @columns_dir + "name"
45
- @users_name_column =
46
- @users.define_column("name", "ShortText",
47
- :path => @users_name_column_path.to_s)
48
-
49
- @users_addresses_column_path = @columns_dir + "addresses"
50
- @users_addresses_column =
51
- @users.define_column("addresses", @addresses,
52
- :path => @users_addresses_column_path.to_s,
53
- :type => "vector")
54
- end
55
-
56
- def setup_bookmarks_table
57
- @bookmarks_path = @tables_dir + "bookmarks"
58
- @bookmarks = Groonga::Array.create(:name => "Bookmarks",
59
- :value_type => "Int32",
60
- :path => @bookmarks_path.to_s)
61
-
62
- @uri_column_path = @columns_dir + "uri"
63
- @bookmarks_uri = @bookmarks.define_column("uri", "ShortText",
64
- :path => @uri_column_path.to_s)
65
-
66
- @rate_column_path = @columns_dir + "rate"
67
- @bookmarks_rate = @bookmarks.define_column("rate", "Int32",
68
- :path => @rate_column_path.to_s)
69
-
70
- @comment_column_path = @columns_dir + "comment"
71
- @bookmarks_comment =
72
- @bookmarks.define_column("comment", "Text",
73
- :path => @comment_column_path.to_s)
74
-
75
- @content_column_path = @columns_dir + "content"
76
- @bookmarks_content = @bookmarks.define_column("content", "LongText")
77
-
78
- @user_column_path = @columns_dir + "user"
79
- @bookmarks_user = @bookmarks.define_column("user", @users)
80
- end
81
-
82
- def setup_indexes
83
- @bookmarks_index_path = @tables_dir + "bookmarks-index"
84
- @bookmarks_index =
85
- Groonga::PatriciaTrie.create(:name => "BookmarksIndex",
86
- :path => @bookmarks_index_path.to_s)
87
- @bookmarks_index.default_tokenizer = "TokenBigram"
88
-
89
- @content_index_column_path = @columns_dir + "content-index"
90
- @bookmarks_content_index =
91
- @bookmarks_index.define_index_column("content", @bookmarks,
92
- :with_section => true,
93
- :with_weight => true,
94
- :with_position => true,
95
- :path => @content_index_column_path.to_s)
96
- @bookmarks_content_index.source = @bookmarks_content
97
-
98
- @uri_index_column_path = @columns_dir + "uri-index"
99
- @bookmarks_uri_index =
100
- @bookmarks_index.define_index_column("uri", @bookmarks,
101
- :with_position => true,
102
- :path => @uri_index_column_path.to_s)
103
- @bookmarks_uri_index.source = @bookmarks_uri
104
- end
105
-
106
- def test_column_accessor
107
- groonga = @bookmarks.add
108
-
109
- groonga["uri"] = "http://groonga.org/"
110
- assert_equal("http://groonga.org/", groonga["uri"])
111
-
112
- groonga["comment"] = "fulltext search engine"
113
- assert_equal("fulltext search engine", groonga["comment"])
114
- end
115
-
116
- def test_have_column?
117
- groonga = @bookmarks.add
118
- assert_true(groonga.have_column?(:uri))
119
- assert_false(groonga.have_column?(:nonexistent))
120
- end
121
-
122
- def test_get_nonexistent_column
123
- groonga = @bookmarks.add
124
- assert_raise(Groonga::NoSuchColumn) do
125
- groonga["nonexistent"]
126
- end
127
- end
128
-
129
- def test_set_nonexistent_column
130
- groonga = @bookmarks.add
131
- assert_raise(Groonga::NoSuchColumn) do
132
- groonga["nonexistent"] = "value"
133
- end
134
- end
135
-
136
- def test_set_object_id
137
- groonga = @bookmarks.add
138
- daijiro = @users.add
139
- daijiro["name"] = "daijiro"
140
- assert_nil(groonga["user"])
141
- groonga["user"] = daijiro.id
142
- assert_equal(daijiro, groonga["user"])
143
- end
144
-
145
- def test_set_nil
146
- groonga = @bookmarks.add
147
- groonga["content"] = nil
148
- assert_nil(groonga["content"])
149
- end
150
-
151
- def test_delete
152
- bookmark1 = @bookmarks.add
153
- bookmark2 = @bookmarks.add
154
- bookmark3 = @bookmarks.add
155
-
156
- assert_equal(3, @bookmarks.size)
157
- bookmark2.delete
158
- assert_equal(2, @bookmarks.size)
159
- end
160
-
161
- def test_key
162
- documents = Groonga::PatriciaTrie.create(:name => "Documents",
163
- :key_type => "ShortText")
164
- reference = documents.add("reference")
165
- assert_equal("reference", reference.key)
166
- end
167
-
168
- def test_value
169
- bookmark = @bookmarks.add
170
- assert_equal(0, bookmark.value)
171
- bookmark.value = 100
172
- assert_equal(100, bookmark.value)
173
- end
174
-
175
- def test_reference_column?
176
- bookmark = @bookmarks.add
177
- assert_false(bookmark.reference_column?("uri"))
178
- assert_true(bookmark.reference_column?("user"))
179
- end
180
-
181
- def test_score
182
- groonga = @bookmarks.add
183
- groonga["content"] = "full text search search search engine."
184
-
185
- google = @bookmarks.add
186
- google["content"] = "Web search engine."
187
-
188
- results = @bookmarks_content_index.search("search")
189
- assert_equal([[groonga.id, 3], [google.id, 1]],
190
- results.collect do |record|
191
- [record.id, record.score]
192
- end)
193
- end
194
-
195
- def test_increment!
196
- groonga = @bookmarks.add
197
- assert_equal(0, groonga["rate"])
198
- groonga.increment!("rate")
199
- assert_equal(1, groonga["rate"])
200
- groonga.increment!("rate", 2)
201
- assert_equal(3, groonga["rate"])
202
- groonga.increment!("rate", -2)
203
- assert_equal(1, groonga["rate"])
204
- end
205
-
206
- def test_decrement!
207
- groonga = @bookmarks.add
208
- assert_equal(0, groonga["rate"])
209
- groonga.decrement!("rate")
210
- assert_equal(-1, groonga["rate"])
211
- groonga.decrement!("rate", 2)
212
- assert_equal(-3, groonga["rate"])
213
- groonga.decrement!("rate", -2)
214
- assert_equal(-1, groonga["rate"])
215
- end
216
-
217
- def test_lock
218
- groonga = @bookmarks.add
219
-
220
- assert_not_predicate(groonga, :locked?)
221
- groonga.lock
222
- assert_predicate(groonga, :locked?)
223
- groonga.unlock
224
- assert_not_predicate(groonga, :locked?)
225
- end
226
-
227
- def test_lock_failed
228
- groonga = @bookmarks.add
229
-
230
- groonga.lock
231
- assert_raise(Groonga::ResourceDeadlockAvoided) do
232
- groonga.lock
233
- end
234
- end
235
-
236
- def test_lock_block
237
- groonga = @bookmarks.add
238
-
239
- assert_not_predicate(groonga, :locked?)
240
- groonga.lock do
241
- assert_predicate(groonga, :locked?)
242
- end
243
- assert_not_predicate(groonga, :locked?)
244
- end
245
-
246
- def test_clear_lock
247
- groonga = @bookmarks.add
248
-
249
- assert_not_predicate(groonga, :locked?)
250
- groonga.lock
251
- assert_predicate(groonga, :locked?)
252
- groonga.clear_lock
253
- assert_not_predicate(groonga, :locked?)
254
- end
255
-
256
- def test_attributes
257
- values = {
258
- "uri" => "http://groonga.org/",
259
- "rate" => 5,
260
- "comment" => "Grate!"
261
- }
262
- groonga = @bookmarks.add(values)
263
- assert_equal(values.merge("id" => groonga.id,
264
- "content" => nil,
265
- "user" => nil),
266
- groonga.attributes)
267
- end
268
- end