rroonga 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +5 -0
- data/Gemfile +1 -12
- data/Rakefile +4 -57
- data/bin/grndump +11 -1
- data/ext/groonga/extconf.rb +125 -54
- data/ext/groonga/rb-grn-context.c +25 -7
- data/ext/groonga/rb-grn-database.c +25 -0
- data/ext/groonga/rb-grn-object.c +19 -7
- data/ext/groonga/rb-grn-table.c +8 -10
- data/ext/groonga/rb-grn.h +9 -2
- data/lib/groonga/dumper.rb +2 -2
- data/lib/groonga/expression-builder.rb +33 -18
- data/rroonga-build.rb +1 -1
- metadata +97 -180
- data/TODO +0 -0
- data/test/groonga-test-utils.rb +0 -139
- data/test/run-test.rb +0 -60
- data/test/test-accessor.rb +0 -36
- data/test/test-array.rb +0 -123
- data/test/test-column.rb +0 -350
- data/test/test-command-select.rb +0 -147
- data/test/test-context.rb +0 -130
- data/test/test-database-dumper.rb +0 -259
- data/test/test-database.rb +0 -148
- data/test/test-double-array-trie.rb +0 -164
- data/test/test-encoding.rb +0 -33
- data/test/test-exception.rb +0 -96
- data/test/test-expression-builder.rb +0 -269
- data/test/test-expression.rb +0 -134
- data/test/test-fix-size-column.rb +0 -77
- data/test/test-gqtp.rb +0 -70
- data/test/test-hash.rb +0 -344
- data/test/test-index-column.rb +0 -180
- data/test/test-index-cursor.rb +0 -93
- data/test/test-logger.rb +0 -37
- data/test/test-pagination.rb +0 -249
- data/test/test-patricia-trie.rb +0 -415
- data/test/test-plugin.rb +0 -35
- data/test/test-procedure.rb +0 -37
- data/test/test-query-log.rb +0 -258
- data/test/test-record.rb +0 -569
- data/test/test-remote.rb +0 -63
- data/test/test-schema-create-table.rb +0 -267
- data/test/test-schema-dumper.rb +0 -235
- data/test/test-schema-type.rb +0 -208
- data/test/test-schema-view.rb +0 -90
- data/test/test-schema.rb +0 -886
- data/test/test-snippet.rb +0 -130
- data/test/test-table-cursor.rb +0 -187
- data/test/test-table-dumper.rb +0 -83
- data/test/test-table-offset-and-limit.rb +0 -100
- data/test/test-table-select-mecab.rb +0 -80
- data/test/test-table-select-normalize.rb +0 -57
- data/test/test-table-select-weight.rb +0 -123
- data/test/test-table-select.rb +0 -191
- data/test/test-table.rb +0 -675
- data/test/test-type.rb +0 -79
- data/test/test-variable-size-column.rb +0 -147
- data/test/test-variable.rb +0 -28
- data/test/test-vector-column.rb +0 -76
- data/test/test-version.rb +0 -61
- data/test/test-view.rb +0 -72
data/test/test-snippet.rb
DELETED
@@ -1,130 +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 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_execute_with_nil
|
40
|
-
snippet = Groonga::Snippet.new
|
41
|
-
snippet.add_keyword("検索", :open_tag => "[[", :close_tag => "]]")
|
42
|
-
message = "snippet text must be String: <nil>"
|
43
|
-
assert_raise(Groonga::InvalidArgument.new(message)) do
|
44
|
-
snippet.execute(nil)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_invalid_encoding
|
49
|
-
Groonga::Context.default.encoding = :shift_jis
|
50
|
-
snippet = Groonga::Snippet.new
|
51
|
-
snippet.add_keyword("検索")
|
52
|
-
assert_equal([], snippet.execute(text))
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_default_tag
|
56
|
-
snippet = Groonga::Snippet.new(:default_open_tag => "<<",
|
57
|
-
:default_close_tag => ">>")
|
58
|
-
snippet.add_keyword("全文")
|
59
|
-
assert_equal(["groonga は組み込み型の<<全文>>検索エンジンライブラリです。DBMSやスクリプト",
|
60
|
-
"等に組み込むことによって、その<<全文>>検索機能を強化することができます"],
|
61
|
-
snippet.execute(text))
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_width
|
65
|
-
snippet = Groonga::Snippet.new(:width => 30,
|
66
|
-
:default_open_tag => "{",
|
67
|
-
:default_close_tag => "}")
|
68
|
-
snippet.add_keyword("データ")
|
69
|
-
assert_equal(["基づく{データ}ストア機",
|
70
|
-
"高速\nな{データ}ストア"],
|
71
|
-
snippet.execute(text))
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_max_results
|
75
|
-
snippet = Groonga::Snippet.new(:width => 30,
|
76
|
-
:max_results => 1,
|
77
|
-
:default_open_tag => "{",
|
78
|
-
:default_close_tag => "}")
|
79
|
-
snippet.add_keyword("データ")
|
80
|
-
assert_equal(["基づく{データ}ストア機"],
|
81
|
-
snippet.execute(text))
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_normalize
|
85
|
-
options_without_normalize = {
|
86
|
-
:width => 30,
|
87
|
-
:default_open_tag => "{",
|
88
|
-
:default_close_tag => "}",
|
89
|
-
}
|
90
|
-
snippet = Groonga::Snippet.new(options_without_normalize)
|
91
|
-
snippet.add_keyword("処理系等")
|
92
|
-
assert_equal([], snippet.execute(text))
|
93
|
-
|
94
|
-
options_with_normalize = options_without_normalize.merge(:normalize => true)
|
95
|
-
snippet = Groonga::Snippet.new(options_with_normalize)
|
96
|
-
snippet.add_keyword("処理系等")
|
97
|
-
assert_equal(["ト言語{処理\n系等}に組"],
|
98
|
-
snippet.execute(text))
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_html_escape
|
102
|
-
text = "groonga は組み込み型の全文検索エンジン&データストアライブラリです。"
|
103
|
-
options_without_html_escape = {
|
104
|
-
:width => 30,
|
105
|
-
:default_open_tag => "<",
|
106
|
-
:default_close_tag => ">",
|
107
|
-
}
|
108
|
-
snippet = Groonga::Snippet.new(options_without_html_escape)
|
109
|
-
snippet.add_keyword("エンジン")
|
110
|
-
assert_equal(["文検索<エンジン>&デー"],
|
111
|
-
snippet.execute(text))
|
112
|
-
|
113
|
-
options_with_html_escape =
|
114
|
-
options_without_html_escape.merge(:html_escape => true)
|
115
|
-
snippet = Groonga::Snippet.new(options_with_html_escape)
|
116
|
-
snippet.add_keyword("エンジン")
|
117
|
-
assert_equal(["文検索<エンジン>&デー"],
|
118
|
-
snippet.execute(text))
|
119
|
-
end
|
120
|
-
|
121
|
-
private
|
122
|
-
def text
|
123
|
-
<<-EOT
|
124
|
-
groonga は組み込み型の全文検索エンジンライブラリです。DBMSやスクリプト言語処理
|
125
|
-
系等に組み込むことによって、その全文検索機能を強化することができます。また、リ
|
126
|
-
レーショナルモデルに基づくデータストア機能を内包しており、groonga単体でも高速
|
127
|
-
なデータストアサーバとして使用することができます。
|
128
|
-
EOT
|
129
|
-
end
|
130
|
-
end
|
data/test/test-table-cursor.rb
DELETED
@@ -1,187 +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 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
|
-
def test_order_by_id
|
140
|
-
sites = Groonga::PatriciaTrie.create(:name => "Sites")
|
141
|
-
sites.add("http://qwik.jp/senna/")
|
142
|
-
sites.add("http://www.ruby-lang.org/")
|
143
|
-
sites.add("http://groonga.org/")
|
144
|
-
keys = []
|
145
|
-
sites.open_cursor(:order_by => :id) do |cursor|
|
146
|
-
while cursor.next
|
147
|
-
keys << cursor.key
|
148
|
-
end
|
149
|
-
end
|
150
|
-
assert_equal(["http://qwik.jp/senna/",
|
151
|
-
"http://www.ruby-lang.org/",
|
152
|
-
"http://groonga.org/"],
|
153
|
-
keys)
|
154
|
-
end
|
155
|
-
|
156
|
-
def test_order_by_key
|
157
|
-
sites = Groonga::PatriciaTrie.create(:name => "Sites")
|
158
|
-
sites.add("http://www.ruby-lang.org/")
|
159
|
-
sites.add("http://qwik.jp/senna/")
|
160
|
-
sites.add("http://groonga.org/")
|
161
|
-
keys = []
|
162
|
-
sites.open_cursor(:order_by => :key) do |cursor|
|
163
|
-
while cursor.next
|
164
|
-
keys << cursor.key
|
165
|
-
end
|
166
|
-
end
|
167
|
-
assert_equal(["http://groonga.org/",
|
168
|
-
"http://qwik.jp/senna/",
|
169
|
-
"http://www.ruby-lang.org/"],
|
170
|
-
keys)
|
171
|
-
end
|
172
|
-
|
173
|
-
private
|
174
|
-
def create_users
|
175
|
-
users = Groonga::Array.create(:name => "Users")
|
176
|
-
users.define_column("name", "ShortText")
|
177
|
-
users
|
178
|
-
end
|
179
|
-
|
180
|
-
def add_users(users)
|
181
|
-
(0...100).to_a.each do |i|
|
182
|
-
user = users.add
|
183
|
-
user["name"] = "user#{i + 100}"
|
184
|
-
end
|
185
|
-
users
|
186
|
-
end
|
187
|
-
end
|
data/test/test-table-dumper.rb
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
# Copyright (C) 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 TableDumperTest < Test::Unit::TestCase
|
17
|
-
include GroongaTestUtils
|
18
|
-
|
19
|
-
setup :setup_database, :before => :append
|
20
|
-
|
21
|
-
def setup
|
22
|
-
setup_tables
|
23
|
-
end
|
24
|
-
|
25
|
-
def setup_tables
|
26
|
-
Groonga::Schema.define do |schema|
|
27
|
-
schema.create_table("Users",
|
28
|
-
:type => :hash,
|
29
|
-
:key_type => "ShortText") do |table|
|
30
|
-
table.text("name")
|
31
|
-
end
|
32
|
-
|
33
|
-
schema.create_table("Posts") do |table|
|
34
|
-
table.text("title")
|
35
|
-
table.reference("author", "Users")
|
36
|
-
table.integer("rank")
|
37
|
-
table.unsigned_integer("n_goods")
|
38
|
-
table.text("tags", :type => :vector)
|
39
|
-
table.boolean("published")
|
40
|
-
table.time("created_at")
|
41
|
-
end
|
42
|
-
|
43
|
-
schema.change_table("Users") do |table|
|
44
|
-
table.index("Posts.author")
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_empty
|
50
|
-
assert_equal(<<-EOS, dump("Posts"))
|
51
|
-
load --table Posts
|
52
|
-
[
|
53
|
-
["_id","author","created_at","n_goods","published","rank","tags","title"]
|
54
|
-
]
|
55
|
-
EOS
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_with_records
|
59
|
-
posts.add(:author => "mori",
|
60
|
-
:created_at => Time.parse("2010-03-08 16:52 JST"),
|
61
|
-
:n_goods => 4,
|
62
|
-
:published => true,
|
63
|
-
:rank => 10,
|
64
|
-
:tags => ["search", "mori"],
|
65
|
-
:title => "Why search engine find?")
|
66
|
-
assert_equal(<<-EOS, dump("Posts"))
|
67
|
-
load --table Posts
|
68
|
-
[
|
69
|
-
["_id","author","created_at","n_goods","published","rank","tags","title"],
|
70
|
-
[1,"mori",1268034720.0,4,true,10,["search","mori"],"Why search engine find?"]
|
71
|
-
]
|
72
|
-
EOS
|
73
|
-
end
|
74
|
-
|
75
|
-
private
|
76
|
-
def dump(table_name)
|
77
|
-
Groonga::TableDumper.new(context[table_name]).dump
|
78
|
-
end
|
79
|
-
|
80
|
-
def posts
|
81
|
-
context["Posts"]
|
82
|
-
end
|
83
|
-
end
|
@@ -1,100 +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::TooLargeOffset) 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::TooSmallOffset) 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_equal([], ids(:limit => -101))
|
51
|
-
end
|
52
|
-
|
53
|
-
private
|
54
|
-
def create_bookmarks
|
55
|
-
@bookmarks = Groonga::Array.create(:name => "Bookmarks")
|
56
|
-
@bookmarks.define_column("id", "Int32")
|
57
|
-
@bookmarks
|
58
|
-
end
|
59
|
-
|
60
|
-
def add_ids
|
61
|
-
100.times do |i|
|
62
|
-
bookmark = @bookmarks.add
|
63
|
-
bookmark["id"] = i + 100
|
64
|
-
end
|
65
|
-
@bookmarks
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
class TestOffsetAndLimit < Test::Unit::TestCase
|
70
|
-
include GroongaTestUtils
|
71
|
-
def setup
|
72
|
-
setup_database
|
73
|
-
@bookmarks = create_bookmarks
|
74
|
-
add_ids
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
class TestTableCursorOffsetAndLimit < TestOffsetAndLimit
|
79
|
-
include TestOffsetAndLimitSupport
|
80
|
-
|
81
|
-
private
|
82
|
-
def ids(options={})
|
83
|
-
@bookmarks.open_cursor(options) do |cursor|
|
84
|
-
cursor.collect do |record|
|
85
|
-
record["id"]
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
class TestTableSortOffsetAndLimit < TestOffsetAndLimit
|
92
|
-
include TestOffsetAndLimitSupport
|
93
|
-
|
94
|
-
private
|
95
|
-
def ids(options={})
|
96
|
-
@bookmarks.sort([:key => "id", :order => :asc], options).collect do |record|
|
97
|
-
record["id"]
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|