groonga-client 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/doc/text/news.md +18 -0
- data/groonga-client.gemspec +1 -1
- data/lib/groonga/client/response/select.rb +27 -7
- data/lib/groonga/client/version.rb +1 -1
- data/test/response/test-select-command-version1.rb +132 -0
- data/test/response/test-select-command-version3.rb +16 -8
- metadata +16 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1d48aabe77a551429a057a3b1ab6146ae0922806
|
|
4
|
+
data.tar.gz: e59ee42028c1c5fa8c41297b6bd12c6ce09ac190
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f037cb0748f6d184a0146767b6560ab46bf1c12d7eb1d9d38fadf04be51490cd4d5ae1056bea4f0f4e55df662b532bbe6e560b93407bd94380df92a89367e1a7
|
|
7
|
+
data.tar.gz: 39c6fbec14c2d83993078458221a73c23dd43a5536ea0a3323fb3854982b5921b21567c365c5c50bb42d1e09edf5a6798868bbbc213893d52aa14c72c24a2253
|
data/doc/text/news.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# NEWS
|
|
2
2
|
|
|
3
|
+
## 0.3.1 - 2016-10-11
|
|
4
|
+
|
|
5
|
+
### Improvements
|
|
6
|
+
|
|
7
|
+
* `Groonga::Client#select`: Supported labeled drilldowns.
|
|
8
|
+
|
|
9
|
+
* `Groonga::Client::Response::Select#drilldowns`: Changed return
|
|
10
|
+
type for the following cases:
|
|
11
|
+
|
|
12
|
+
* Labeled drilldowns are used.
|
|
13
|
+
|
|
14
|
+
* Command version 3 or later is used.
|
|
15
|
+
|
|
16
|
+
It returns `{"label1" => drilldown1, "label2" => drilldown2}`
|
|
17
|
+
instead of `[drilldown1, drilldown2]`. It's a backward
|
|
18
|
+
incompatibility change for command version 3 or later case. But we
|
|
19
|
+
did it because command version 3 is still experimental version.
|
|
20
|
+
|
|
3
21
|
## 0.3.0 - 2016-10-05
|
|
4
22
|
|
|
5
23
|
### Fixes
|
data/groonga-client.gemspec
CHANGED
|
@@ -45,7 +45,7 @@ Gem::Specification.new do |spec|
|
|
|
45
45
|
spec.test_files += Dir.glob("test/**/*")
|
|
46
46
|
|
|
47
47
|
spec.add_runtime_dependency("gqtp", ">= 1.0.4")
|
|
48
|
-
spec.add_runtime_dependency("groonga-command", ">= 1.2.
|
|
48
|
+
spec.add_runtime_dependency("groonga-command", ">= 1.2.8")
|
|
49
49
|
spec.add_runtime_dependency("hashie")
|
|
50
50
|
|
|
51
51
|
spec.add_development_dependency("bundler")
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (C) 2013-
|
|
1
|
+
# Copyright (C) 2013-2016 Kouhei Sutou <kou@clear-code.com>
|
|
2
2
|
# Copyright (C) 2013 Kosuke Asami
|
|
3
3
|
#
|
|
4
4
|
# This library is free software; you can redistribute it and/or
|
|
@@ -27,6 +27,14 @@ module Groonga
|
|
|
27
27
|
# a search condition.
|
|
28
28
|
attr_accessor :n_hits
|
|
29
29
|
attr_accessor :records
|
|
30
|
+
|
|
31
|
+
# @return [::Array<Groonga::Client::Response::Select::Drilldown>,
|
|
32
|
+
# ::Hash<String, Groonga::Client::Response::Select::Drilldown>]
|
|
33
|
+
# If labeled drilldowns are used or command version 3 or
|
|
34
|
+
# later is used, `{"label1" => drilldown1, "label2" => drilldown2}`
|
|
35
|
+
# is returned since 0.3.1.
|
|
36
|
+
#
|
|
37
|
+
# Otherwise, `[drilldown1, drilldown2]` is returned.
|
|
30
38
|
attr_accessor :drilldowns
|
|
31
39
|
|
|
32
40
|
def body=(body)
|
|
@@ -105,18 +113,30 @@ module Groonga
|
|
|
105
113
|
end
|
|
106
114
|
|
|
107
115
|
def parse_drilldowns_v1(raw_drilldowns)
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
116
|
+
request_drilldowns = @command.drilldowns
|
|
117
|
+
if request_drilldowns.empty? and !@command.labeled_drilldowns.empty?
|
|
118
|
+
drilldowns = {}
|
|
119
|
+
(raw_drilldowns[0] || {}).each do |label, raw_drilldown|
|
|
120
|
+
n_hits, records = parse_match_records_v1(raw_drilldown)
|
|
121
|
+
drilldowns[label] = Drilldown.new(label, n_hits, records)
|
|
122
|
+
end
|
|
123
|
+
drilldowns
|
|
124
|
+
else
|
|
125
|
+
(raw_drilldowns || []).collect.with_index do |raw_drilldown, i|
|
|
126
|
+
key = request_drilldowns[i]
|
|
127
|
+
n_hits, records = parse_match_records_v1(raw_drilldown)
|
|
128
|
+
Drilldown.new(key, n_hits, records)
|
|
129
|
+
end
|
|
112
130
|
end
|
|
113
131
|
end
|
|
114
132
|
|
|
115
133
|
def parse_drilldowns_v3(raw_drilldowns)
|
|
116
|
-
|
|
134
|
+
drilldowns = {}
|
|
135
|
+
(raw_drilldowns || {}).each do |key, raw_drilldown|
|
|
117
136
|
n_hits, records = parse_match_records_v3(raw_drilldown)
|
|
118
|
-
Drilldown.new(key, n_hits, records)
|
|
137
|
+
drilldowns[key] = Drilldown.new(key, n_hits, records)
|
|
119
138
|
end
|
|
139
|
+
drilldowns
|
|
120
140
|
end
|
|
121
141
|
|
|
122
142
|
class Drilldown < Struct.new(:key, :n_hits, :records)
|
|
@@ -183,5 +183,137 @@ class TestResponseSelectCommandVersion1 < Test::Unit::TestCase
|
|
|
183
183
|
create_response(body).drilldowns
|
|
184
184
|
end
|
|
185
185
|
end
|
|
186
|
+
|
|
187
|
+
class TestLabeledDrilldowns < self
|
|
188
|
+
def setup
|
|
189
|
+
pair_arguments = {
|
|
190
|
+
"drilldowns[tag].keys" => "tag",
|
|
191
|
+
"drilldowns[tag].output_columns" => "_key,_nsubrecs",
|
|
192
|
+
"drilldowns[author].keys" => "author",
|
|
193
|
+
"drilldowns[author].output_columns" => "_key,_nsubrecs",
|
|
194
|
+
}
|
|
195
|
+
@command = Groonga::Command::Select.new("select", pair_arguments)
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def test_key
|
|
199
|
+
body = [
|
|
200
|
+
[[0], []],
|
|
201
|
+
{
|
|
202
|
+
"tag" => [
|
|
203
|
+
[29],
|
|
204
|
+
[
|
|
205
|
+
["_key", "ShortText"],
|
|
206
|
+
["_nsubrecs", "Int32"],
|
|
207
|
+
],
|
|
208
|
+
["Groonga", 2],
|
|
209
|
+
["Ruby", 9],
|
|
210
|
+
["Rroonga", 1],
|
|
211
|
+
],
|
|
212
|
+
"author" => [
|
|
213
|
+
[4],
|
|
214
|
+
[
|
|
215
|
+
["_key", "ShortText"],
|
|
216
|
+
["_nsubrecs", "Int32"],
|
|
217
|
+
],
|
|
218
|
+
["Alice", 2],
|
|
219
|
+
["Bob", 1],
|
|
220
|
+
["Chris", 4],
|
|
221
|
+
],
|
|
222
|
+
},
|
|
223
|
+
]
|
|
224
|
+
assert_equal({
|
|
225
|
+
"tag" => "tag",
|
|
226
|
+
"author" => "author",
|
|
227
|
+
},
|
|
228
|
+
collect_values(body, &:key))
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def test_n_hits
|
|
232
|
+
body = [
|
|
233
|
+
[[0], []],
|
|
234
|
+
{
|
|
235
|
+
"tag" => [
|
|
236
|
+
[29],
|
|
237
|
+
[
|
|
238
|
+
["_key", "ShortText"],
|
|
239
|
+
["_nsubrecs", "Int32"],
|
|
240
|
+
],
|
|
241
|
+
["Groonga", 2],
|
|
242
|
+
["Ruby", 9],
|
|
243
|
+
["Rroonga", 1],
|
|
244
|
+
],
|
|
245
|
+
"author" => [
|
|
246
|
+
[4],
|
|
247
|
+
[
|
|
248
|
+
["_key", "ShortText"],
|
|
249
|
+
["_nsubrecs", "Int32"],
|
|
250
|
+
],
|
|
251
|
+
["Alice", 2],
|
|
252
|
+
["Bob", 1],
|
|
253
|
+
["Chris", 4],
|
|
254
|
+
],
|
|
255
|
+
},
|
|
256
|
+
]
|
|
257
|
+
assert_equal({
|
|
258
|
+
"tag" => 29,
|
|
259
|
+
"author" => 4,
|
|
260
|
+
},
|
|
261
|
+
collect_values(body, &:n_hits))
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def test_items
|
|
265
|
+
body = [
|
|
266
|
+
[[0], []],
|
|
267
|
+
{
|
|
268
|
+
"tag" => [
|
|
269
|
+
[29],
|
|
270
|
+
[
|
|
271
|
+
["_key", "ShortText"],
|
|
272
|
+
["_nsubrecs", "Int32"],
|
|
273
|
+
],
|
|
274
|
+
["Groonga", 2],
|
|
275
|
+
["Ruby", 9],
|
|
276
|
+
["Rroonga", 1],
|
|
277
|
+
],
|
|
278
|
+
"author" => [
|
|
279
|
+
[4],
|
|
280
|
+
[
|
|
281
|
+
["_key", "ShortText"],
|
|
282
|
+
["_nsubrecs", "Int32"],
|
|
283
|
+
],
|
|
284
|
+
["Alice", 2],
|
|
285
|
+
["Bob", 1],
|
|
286
|
+
["Chris", 4],
|
|
287
|
+
],
|
|
288
|
+
},
|
|
289
|
+
]
|
|
290
|
+
assert_equal({
|
|
291
|
+
"tag" => [
|
|
292
|
+
{"_key" => "Groonga", "_nsubrecs" => 2},
|
|
293
|
+
{"_key" => "Ruby", "_nsubrecs" => 9},
|
|
294
|
+
{"_key" => "Rroonga", "_nsubrecs" => 1},
|
|
295
|
+
],
|
|
296
|
+
"author" => [
|
|
297
|
+
{"_key" => "Alice", "_nsubrecs" => 2},
|
|
298
|
+
{"_key" => "Bob", "_nsubrecs" => 1},
|
|
299
|
+
{"_key" => "Chris", "_nsubrecs" => 4},
|
|
300
|
+
],
|
|
301
|
+
},
|
|
302
|
+
collect_values(body, &:items))
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
private
|
|
306
|
+
def drilldowns(body)
|
|
307
|
+
create_response(body).drilldowns
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
def collect_values(body)
|
|
311
|
+
values = {}
|
|
312
|
+
drilldowns(body).each do |label, drilldown|
|
|
313
|
+
values[label] = yield(drilldown)
|
|
314
|
+
end
|
|
315
|
+
values
|
|
316
|
+
end
|
|
317
|
+
end
|
|
186
318
|
end
|
|
187
319
|
end
|
|
@@ -195,8 +195,8 @@ class TestResponseSelectCommandVersion3 < Test::Unit::TestCase
|
|
|
195
195
|
},
|
|
196
196
|
},
|
|
197
197
|
}
|
|
198
|
-
assert_equal(
|
|
199
|
-
|
|
198
|
+
assert_equal({"tag" => "tag"},
|
|
199
|
+
collect_values(body, &:key))
|
|
200
200
|
end
|
|
201
201
|
|
|
202
202
|
def test_n_hits
|
|
@@ -225,8 +225,8 @@ class TestResponseSelectCommandVersion3 < Test::Unit::TestCase
|
|
|
225
225
|
},
|
|
226
226
|
},
|
|
227
227
|
}
|
|
228
|
-
assert_equal(
|
|
229
|
-
|
|
228
|
+
assert_equal({"tag" => 29},
|
|
229
|
+
collect_values(body, &:n_hits))
|
|
230
230
|
end
|
|
231
231
|
|
|
232
232
|
def test_items
|
|
@@ -255,20 +255,28 @@ class TestResponseSelectCommandVersion3 < Test::Unit::TestCase
|
|
|
255
255
|
},
|
|
256
256
|
},
|
|
257
257
|
}
|
|
258
|
-
assert_equal(
|
|
259
|
-
[
|
|
258
|
+
assert_equal({
|
|
259
|
+
"tag" => [
|
|
260
260
|
{"_key" => "groonga", "_nsubrecs" => 29},
|
|
261
261
|
{"_key" => "Ruby", "_nsubrecs" => 19},
|
|
262
262
|
{"_key" => "rroonga", "_nsubrecs" => 9},
|
|
263
263
|
],
|
|
264
|
-
|
|
265
|
-
|
|
264
|
+
},
|
|
265
|
+
collect_values(body, &:items))
|
|
266
266
|
end
|
|
267
267
|
|
|
268
268
|
private
|
|
269
269
|
def drilldowns(body)
|
|
270
270
|
create_response(body).drilldowns
|
|
271
271
|
end
|
|
272
|
+
|
|
273
|
+
def collect_values(body)
|
|
274
|
+
values = {}
|
|
275
|
+
drilldowns(body).each do |label, drilldown|
|
|
276
|
+
values[label] = yield(drilldown)
|
|
277
|
+
end
|
|
278
|
+
values
|
|
279
|
+
end
|
|
272
280
|
end
|
|
273
281
|
end
|
|
274
282
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: groonga-client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Haruka Yoshihara
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2016-10-
|
|
13
|
+
date: 2016-10-11 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: gqtp
|
|
@@ -32,14 +32,14 @@ dependencies:
|
|
|
32
32
|
requirements:
|
|
33
33
|
- - ">="
|
|
34
34
|
- !ruby/object:Gem::Version
|
|
35
|
-
version: 1.2.
|
|
35
|
+
version: 1.2.8
|
|
36
36
|
type: :runtime
|
|
37
37
|
prerelease: false
|
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
39
39
|
requirements:
|
|
40
40
|
- - ">="
|
|
41
41
|
- !ruby/object:Gem::Version
|
|
42
|
-
version: 1.2.
|
|
42
|
+
version: 1.2.8
|
|
43
43
|
- !ruby/object:Gem::Dependency
|
|
44
44
|
name: hashie
|
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -255,23 +255,22 @@ specification_version: 4
|
|
|
255
255
|
summary: Groonga-client is a client for Groonga (http://groonga.org/) implemented
|
|
256
256
|
with pure Ruby. You can use it without Groonga.
|
|
257
257
|
test_files:
|
|
258
|
+
- test/test-client.rb
|
|
258
259
|
- test/test-script-syntax.rb
|
|
259
|
-
- test/
|
|
260
|
+
- test/test-command.rb
|
|
260
261
|
- test/protocol/test-gqtp.rb
|
|
261
|
-
- test/
|
|
262
|
-
- test/
|
|
263
|
-
- test/response/test-
|
|
264
|
-
- test/response/test-select-command-version3.rb
|
|
265
|
-
- test/response/test-table-list.rb
|
|
262
|
+
- test/protocol/test-http.rb
|
|
263
|
+
- test/run-test.rb
|
|
264
|
+
- test/response/test-base.rb
|
|
266
265
|
- test/response/test-column-list.rb
|
|
267
266
|
- test/response/helper.rb
|
|
268
|
-
- test/response/test-
|
|
269
|
-
- test/response/test-
|
|
267
|
+
- test/response/test-error.rb
|
|
268
|
+
- test/response/test-table-list.rb
|
|
270
269
|
- test/response/test-status.rb
|
|
270
|
+
- test/response/test-schema.rb
|
|
271
|
+
- test/response/test-select-command-version3.rb
|
|
272
|
+
- test/response/test-select-command-version1.rb
|
|
271
273
|
- test/response/test-table-create.rb
|
|
272
|
-
- test/
|
|
274
|
+
- test/response/test-table-remove.rb
|
|
273
275
|
- test/results/test-column-list.rb
|
|
274
|
-
- test/test-
|
|
275
|
-
- test/run-test.rb
|
|
276
|
-
- test/test-client.rb
|
|
277
|
-
has_rdoc:
|
|
276
|
+
- test/results/test-table-list.rb
|