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
data/test/test-snippet.rb DELETED
@@ -1,121 +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 SnippetTest < Test::Unit::TestCase
19
- include GroongaTestUtils
20
-
21
- def setup_encoding
22
- Groonga::Encoding.default = :utf8
23
- end
24
-
25
- def test_new_without_arguments
26
- assert_nothing_raised do
27
- Groonga::Snippet.new
28
- end
29
- end
30
-
31
- def test_execute
32
- snippet = Groonga::Snippet.new
33
- snippet.add_keyword("検索", :open_tag => "[[", :close_tag => "]]")
34
- assert_equal(["groonga は組み込み型の全文[[検索]]エンジンライブラリです。DBMSやスクリプト",
35
- "組み込むことによって、その全文[[検索]]機能を強化することができます。ま"],
36
- snippet.execute(text))
37
- end
38
-
39
- def test_invalid_encoding
40
- Groonga::Context.default.encoding = :shift_jis
41
- snippet = Groonga::Snippet.new
42
- snippet.add_keyword("検索")
43
- assert_equal([], snippet.execute(text))
44
- end
45
-
46
- def test_default_tag
47
- snippet = Groonga::Snippet.new(:default_open_tag => "<<",
48
- :default_close_tag => ">>")
49
- snippet.add_keyword("全文")
50
- assert_equal(["groonga は組み込み型の<<全文>>検索エンジンライブラリです。DBMSやスクリプト",
51
- "等に組み込むことによって、その<<全文>>検索機能を強化することができます"],
52
- snippet.execute(text))
53
- end
54
-
55
- def test_width
56
- snippet = Groonga::Snippet.new(:width => 30,
57
- :default_open_tag => "{",
58
- :default_close_tag => "}")
59
- snippet.add_keyword("データ")
60
- assert_equal(["基づく{データ}ストア機",
61
- "高速\nな{データ}ストア"],
62
- snippet.execute(text))
63
- end
64
-
65
- def test_max_results
66
- snippet = Groonga::Snippet.new(:width => 30,
67
- :max_results => 1,
68
- :default_open_tag => "{",
69
- :default_close_tag => "}")
70
- snippet.add_keyword("データ")
71
- assert_equal(["基づく{データ}ストア機"],
72
- snippet.execute(text))
73
- end
74
-
75
- def test_normalize
76
- options_without_normalize = {
77
- :width => 30,
78
- :default_open_tag => "{",
79
- :default_close_tag => "}",
80
- }
81
- snippet = Groonga::Snippet.new(options_without_normalize)
82
- snippet.add_keyword("処理系等")
83
- assert_equal([], snippet.execute(text))
84
-
85
- options_with_normalize = options_without_normalize.merge(:normalize => true)
86
- snippet = Groonga::Snippet.new(options_with_normalize)
87
- snippet.add_keyword("処理系等")
88
- assert_equal(["ト言語{処理\n系等}に組"],
89
- snippet.execute(text))
90
- end
91
-
92
- def test_html_escape
93
- text = "groonga は組み込み型の全文検索エンジン&データストアライブラリです。"
94
- options_without_html_escape = {
95
- :width => 30,
96
- :default_open_tag => "<",
97
- :default_close_tag => ">",
98
- }
99
- snippet = Groonga::Snippet.new(options_without_html_escape)
100
- snippet.add_keyword("エンジン")
101
- assert_equal(["文検索<エンジン>&デー"],
102
- snippet.execute(text))
103
-
104
- options_with_html_escape =
105
- options_without_html_escape.merge(:html_escape => true)
106
- snippet = Groonga::Snippet.new(options_with_html_escape)
107
- snippet.add_keyword("エンジン")
108
- assert_equal(["文検索<エンジン>&amp;デー"],
109
- snippet.execute(text))
110
- end
111
-
112
- private
113
- def text
114
- <<-EOT
115
- groonga は組み込み型の全文検索エンジンライブラリです。DBMSやスクリプト言語処理
116
- 系等に組み込むことによって、その全文検索機能を強化することができます。また、リ
117
- レーショナルモデルに基づくデータストア機能を内包しており、groonga単体でも高速
118
- なデータストアサーバとして使用することができます。
119
- EOT
120
- end
121
- end
@@ -1,153 +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 TableCursorTest < Test::Unit::TestCase
17
- include GroongaTestUtils
18
-
19
- def setup
20
- setup_database
21
-
22
- @bookmarks_path = @tables_dir + "table"
23
- @bookmarks = Groonga::PatriciaTrie.create(:name => "Bookmarks",
24
- :path => @bookmarks_path.to_s)
25
- @groonga_bookmark = @bookmarks.add("groonga")
26
- @cutter_bookmark = @bookmarks.add("Cutter")
27
- @ruby_bookmark = @bookmarks.add("Ruby")
28
- end
29
-
30
- def test_open
31
- keys = []
32
- @bookmarks.open_cursor do |cursor|
33
- while cursor.next
34
- keys << cursor.key
35
- end
36
- end
37
- assert_equal(["Cutter", "Ruby", "groonga"],
38
- keys)
39
- end
40
-
41
- def test_open_ascendent
42
- record_and_key_list = []
43
- @bookmarks.open_cursor(:order => :ascending) do |cursor|
44
- record_and_key_list = cursor.collect {|record| [record, cursor.key]}
45
- end
46
- assert_equal([[@cutter_bookmark, "Cutter"],
47
- [@ruby_bookmark, "Ruby"],
48
- [@groonga_bookmark, "groonga"]],
49
- record_and_key_list)
50
- end
51
-
52
- def test_without_limit_and_offset
53
- users = create_users
54
- add_users(users)
55
- results = []
56
- users.open_cursor do |cursor|
57
- cursor.each do |record|
58
- results << record["name"]
59
- end
60
- end
61
-
62
- assert_equal((100..199).collect {|i| "user#{i}"},
63
- results)
64
- end
65
-
66
- def test_with_limit
67
- users = create_users
68
- add_users(users)
69
- results = []
70
- users.open_cursor(:limit => 20) do |cursor|
71
- cursor.each do |record|
72
- results << record["name"]
73
- end
74
- end
75
-
76
- assert_equal((100...120).collect {|i| "user#{i}"},
77
- results)
78
- end
79
-
80
- def test_with_offset
81
- users = create_users
82
- add_users(users)
83
- results = []
84
- users.open_cursor(:offset => 20) do |cursor|
85
- cursor.each do |record|
86
- results << record["name"]
87
- end
88
- end
89
-
90
- assert_equal((120...200).collect {|i| "user#{i}"},
91
- results)
92
- end
93
-
94
- def test_with_limit_and_offset
95
- users = create_users
96
- add_users(users)
97
- results = []
98
- users.open_cursor(:limit => 20, :offset => 20) do |cursor|
99
- cursor.each do |record|
100
- results << record["name"]
101
- end
102
- end
103
-
104
- assert_equal((120...140).collect {|i| "user#{i}"},
105
- results)
106
- end
107
-
108
- def test_delete
109
- users = create_users
110
- add_users(users)
111
-
112
- users.open_cursor(:limit => 20) do |cursor|
113
- 20.times do
114
- cursor.next
115
- cursor.delete
116
- end
117
- end
118
-
119
- results = []
120
- users.open_cursor do |cursor|
121
- cursor.each do |record|
122
- results << record["name"]
123
- end
124
- end
125
-
126
- assert_equal((120...200).collect {|i| "user#{i}"},
127
- results)
128
- end
129
-
130
- def test_patricia_trie_cursor_key
131
- sites = Groonga::PatriciaTrie.create(:name => "Sites")
132
- sites.add("http://groonga.org/")
133
- sites.open_cursor do |cursor|
134
- cursor.next
135
- assert_equal("http://groonga.org/", cursor.key)
136
- end
137
- end
138
-
139
- private
140
- def create_users
141
- users = Groonga::Array.create(:name => "Users")
142
- users.define_column("name", "ShortText")
143
- users
144
- end
145
-
146
- def add_users(users)
147
- (0...100).to_a.each do |i|
148
- user = users.add
149
- user["name"] = "user#{i + 100}"
150
- end
151
- users
152
- end
153
- end
@@ -1,102 +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
- module TestOffsetAndLimitSupport
17
- def test_zero_and_positive_offset
18
- assert_equal(((100 + 0)...200).to_a, ids(:offset => 0))
19
- assert_equal(((100 + 32)...200).to_a, ids(:offset => 32))
20
- assert_equal(((100 + 99)...200).to_a, ids(:offset => 99))
21
- assert_raise(Groonga::InvalidArgument) do
22
- ids(:offset => 100)
23
- end
24
- end
25
-
26
- def test_negative_offset
27
- assert_equal(((200 - 1)...200).to_a, ids(:offset => -1))
28
- assert_equal(((200 - 32)...200).to_a, ids(:offset => -32))
29
- assert_equal(((200 - 100)...200).to_a, ids(:offset => -100))
30
- assert_raise(Groonga::InvalidArgument) do
31
- ids(:offset => -101)
32
- end
33
- end
34
-
35
- def test_zero_and_positive_limit
36
- all_ids = (100...200).to_a
37
- assert_equal(all_ids[0, 0], ids(:limit => 0))
38
- assert_equal(all_ids[0, 32], ids(:limit => 32))
39
- assert_equal(all_ids[0, 100], ids(:limit => 100))
40
- assert_nothing_raised do
41
- ids(:limit => 101)
42
- end
43
- end
44
-
45
- def test_negative_limit
46
- all_ids = (100...200).to_a
47
- assert_equal(all_ids[0..-1], ids(:limit => -1))
48
- assert_equal(all_ids[0..-32], ids(:limit => -32))
49
- assert_equal(all_ids[0..-100], ids(:limit => -100))
50
- assert_raise(Groonga::InvalidArgument) do
51
- ids(:offset => -101)
52
- end
53
- end
54
-
55
- private
56
- def create_bookmarks
57
- @bookmarks = Groonga::Array.create(:name => "Bookmarks")
58
- @bookmarks.define_column("id", "Int32")
59
- @bookmarks
60
- end
61
-
62
- def add_ids
63
- 100.times do |i|
64
- bookmark = @bookmarks.add
65
- bookmark["id"] = i + 100
66
- end
67
- @bookmarks
68
- end
69
- end
70
-
71
- class TestOffsetAndLimit < Test::Unit::TestCase
72
- include GroongaTestUtils
73
- def setup
74
- setup_database
75
- @bookmarks = create_bookmarks
76
- add_ids
77
- end
78
- end
79
-
80
- class TestTableCursorOffsetAndLimit < TestOffsetAndLimit
81
- include TestOffsetAndLimitSupport
82
-
83
- private
84
- def ids(options={})
85
- @bookmarks.open_cursor(options) do |cursor|
86
- cursor.collect do |record|
87
- record["id"]
88
- end
89
- end
90
- end
91
- end
92
-
93
- class TestTableSortOffsetAndLimit < TestOffsetAndLimit
94
- include TestOffsetAndLimitSupport
95
-
96
- private
97
- def ids(options={})
98
- @bookmarks.sort([:key => "id", :order => :asc], options).collect do |record|
99
- record["id"]
100
- end
101
- end
102
- end
@@ -1,48 +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
- terms = Groonga::PatriciaTrie.create(:name => "Terms",
29
- :default_tokenizer => "TokenBigram",
30
- :key_normalize => true)
31
- terms.define_index_column("comment_content", @comments,
32
- :with_section => true,
33
- :source => "Comments.content")
34
- @japanese_comment =
35
- @comments.add(:content => "うちのボロTVはまだ現役です",
36
- :created_at => Time.parse("2009-06-09"))
37
- end
38
-
39
- def test_select_query_with_japanese
40
- result = @comments.select("content:%ボロTV")
41
- assert_equal_select_result([@japanese_comment], result)
42
- end
43
-
44
- def test_select_query_only_in_japanese
45
- result = @comments.select("content:%うちの")
46
- assert_equal_select_result([@japanese_comment], result)
47
- end
48
- end
@@ -1,145 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2009-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 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
- :source => "content")
37
- @comment1 = @comments.add(:content => "Hello Good-bye!",
38
- :created_at => Time.parse("2009-08-09"),
39
- :user => "morita")
40
- @comment2 = @comments.add(:content => "Hello World",
41
- :created_at => Time.parse("2009-07-09"))
42
- @comment3 = @comments.add(:content => "test",
43
- :created_at => Time.parse("2009-06-09"),
44
- :user => "gunyara-kun")
45
- @japanese_comment =
46
- @comments.add(:content => "うちのボロTVはまだ現役です",
47
- :created_at => Time.parse("2009-06-09"),
48
- :user => "darashi")
49
- end
50
-
51
- def test_select_sub_expression
52
- result = @comments.select do |record|
53
- record.match("Hello", "content") &
54
- (record["created_at"] < Time.parse("2009-08-01"))
55
- end
56
- assert_equal_select_result([@comment2], result)
57
- end
58
-
59
- def test_select_query
60
- result = @comments.select("content:%Hello")
61
- assert_equal_select_result([@comment1, @comment2], result)
62
- end
63
-
64
- def test_select_query_with_parser
65
- result = @comments.select("content @ \"Hello\"", :syntax => :script)
66
- assert_equal_select_result([@comment1, @comment2], result)
67
- end
68
-
69
- def test_select_expression
70
- expression = Groonga::Expression.new
71
- variable = expression.define_variable(:domain => @comments)
72
- expression.append_object(variable)
73
- expression.parse("content:%Hello", :syntax => :query)
74
- expression.compile
75
- result = @comments.select(expression)
76
- assert_equal(expression, result.expression)
77
- assert_equal_select_result([@comment1, @comment2], result)
78
- end
79
-
80
- def test_select_query_with_block
81
- result = @comments.select("content:%Hello") do |record|
82
- record["created_at"] < Time.parse("2009-08-01")
83
- end
84
- assert_equal_select_result([@comment2], result)
85
- end
86
-
87
- def test_select_query_with_block_match
88
- result = @comments.select("content:%Hello") do |record|
89
- record.match("World", "content")
90
- end
91
- assert_equal_select_result([@comment2], result)
92
- end
93
-
94
- def test_select_without_block
95
- assert_equal_select_result([@comment1, @comment2,
96
- @comment3, @japanese_comment],
97
- @comments.select)
98
- end
99
-
100
- def test_select_query_japanese
101
- result = @comments.select("content:%ボロTV")
102
- assert_equal_select_result([@japanese_comment], result)
103
- end
104
-
105
- def test_select_but_query
106
- result = @comments.select do |record|
107
- record["content"].match "Hello -World"
108
- end
109
- assert_equal_select_result([@comment1], result)
110
- end
111
-
112
- def test_select_query_with_three_terms
113
- result = @comments.select do |record|
114
- record["content"].match "Say Hello World"
115
- end
116
- assert_equal_select_result([], result)
117
- end
118
-
119
- def test_select_query_with_brackets
120
- result = @comments.select do |record|
121
- record["content"].match "Say (Hello World)"
122
- end
123
- assert_equal_select_result([], result)
124
- end
125
-
126
- def test_select_equal_reference_column_by_key
127
- result = @comments.select do |record|
128
- record["user"] == "darashi"
129
- end
130
- assert_equal_select_result([@japanese_comment], result)
131
- end
132
-
133
- def test_select_not_equal_reference_column_by_key
134
- result = @comments.select('user != "darashi"', :syntax => :script)
135
- assert_equal_select_result([@comment1, @comment2, @comment3],
136
- result)
137
- end
138
-
139
- def test_select_equal_reference_column_by_nonexistent_key
140
- result = @comments.select do |record|
141
- record["user"] == "nonexistent"
142
- end
143
- assert_equal_select_result([], result)
144
- end
145
- end