groonga-client 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eaec3aab0752df6b5832fe16cb3c79d107103636b06a603ecb2e453bd6e29bec
4
- data.tar.gz: cc03ea25d9b87599a6fc10cc553716c3bd7e0b885b2887f7a414b0377490e37d
3
+ metadata.gz: 03b68a1a7f59bc34045692dd2e552ce9f794bba69e7093bc6190e51fb0193be7
4
+ data.tar.gz: 14694be087dafa31671b4965b0c8ff04a8dde8c96050c2284215e3d93c5e1c3e
5
5
  SHA512:
6
- metadata.gz: 16a4c67ddfa8bb7f401ff0cd5f49d852f3f279966c3839379ae0ed0f29629b8402ae7b14a87087f263440b8ee0365eb646688a8a3ad7b1cc9979d9ddd3bc61d1
7
- data.tar.gz: 86c7edc062f853a4d56e18b0b43477f6317630471de314d4952ab8dd7b9a85146180ce8d5e93ce7f687e0345ec6a26f938846409b3ad3bdcd45677ec4e0029f2
6
+ metadata.gz: c32a87151621709018d2d2e13e71443558852ff2e2834f3241caacb389534179872d47f7dad739c63b131aadd328a738cd6d571b7859bcaf02393cb42779ef94
7
+ data.tar.gz: b87752ad00e9c4a7bed662ec5c14f0ad7a3f2a0ec4b5394ad7e02c20bb45329800500f555567a7798c424a186240bb44d8340cb749fa6638fbdfa4f9f2444692
@@ -1,5 +1,12 @@
1
1
  # NEWS
2
2
 
3
+ ## 0.6.1 - 2019-07-27
4
+
5
+ ### Improvements
6
+
7
+ * `Groonga::Client::Request::Select`: Added support for drilldowns
8
+ in slice.
9
+
3
10
  ## 0.6.0 - 2018-08-30
4
11
 
5
12
  ### Improvements
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2013-2019 Sutou Kouhei <kou@clear-code.com>
2
2
  # Copyright (C) 2013 Kosuke Asami
3
3
  # Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
4
4
  #
@@ -329,8 +329,19 @@ module Groonga
329
329
  def parse_slices_v1(raw_slices)
330
330
  slices = {}
331
331
  (raw_slices || {}).each do |key, raw_slice|
332
+ if raw_slice.last.is_a?(::Hash)
333
+ raw_drilldowns = raw_slice.last
334
+ raw_slice = raw_slice[0..-2]
335
+ drilldowns = {}
336
+ raw_drilldowns.each do |label, raw_drilldown|
337
+ n_hits, records = parse_match_records_v1(raw_drilldown)
338
+ drilldowns[label] = Drilldown.new(label, n_hits, records)
339
+ end
340
+ else
341
+ drilldowns = {}
342
+ end
332
343
  n_hits, records = parse_match_records_v1(raw_slice)
333
- slices[key] = Slice.new(key, n_hits, records)
344
+ slices[key] = Slice.new(key, n_hits, records, drilldowns)
334
345
  end
335
346
  slices
336
347
  end
@@ -339,7 +350,8 @@ module Groonga
339
350
  slices = {}
340
351
  (raw_slices || {}).each do |key, raw_slice|
341
352
  n_hits, records = parse_match_records_v3(raw_slice)
342
- slices[key] = Slice.new(key, n_hits, records)
353
+ drilldowns = parse_drilldowns_v3(raw_slice["drilldowns"])
354
+ slices[key] = Slice.new(key, n_hits, records, drilldowns)
343
355
  end
344
356
  slices
345
357
  end
@@ -353,7 +365,7 @@ module Groonga
353
365
  alias_method :items, :records
354
366
  end
355
367
 
356
- class Slice < Struct.new(:key, :n_hits, :records)
368
+ class Slice < Struct.new(:key, :n_hits, :records, :drilldowns)
357
369
  end
358
370
  end
359
371
  end
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Groonga
18
18
  class Client
19
- VERSION = "0.6.0"
19
+ VERSION = "0.6.1"
20
20
  end
21
21
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2013-2019 Sutou Kouhei <kou@clear-code.com>
2
2
  # Copyright (C) 2013 Kosuke Asami
3
3
  # Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
4
4
  #
@@ -320,12 +320,14 @@ class TestResponseSelectCommandVersion1 < Test::Unit::TestCase
320
320
  class TestSlices < self
321
321
  def setup
322
322
  pair_arguments = {
323
- "slices[groonga].filter" => 'tag @ "groonga"',
323
+ "slices[groonga].filter" => "tag @ 'groonga'",
324
+ "slices[groonga].limit" => "2",
325
+ "slices[groonga].drilldowns[author].keys" => "author",
324
326
  }
325
327
  @command = Groonga::Command::Select.new("select", pair_arguments)
326
328
  @body = [
327
329
  [
328
- [3],
330
+ [4],
329
331
  [
330
332
  [
331
333
  "_id",
@@ -339,10 +341,11 @@ class TestResponseSelectCommandVersion1 < Test::Unit::TestCase
339
341
  [1, "groonga"],
340
342
  [2, "rroonga"],
341
343
  [3, "groonga"],
344
+ [4, "groonga"],
342
345
  ],
343
346
  {
344
347
  "groonga" => [
345
- [2],
348
+ [3],
346
349
  [
347
350
  [
348
351
  "_id",
@@ -355,19 +358,55 @@ class TestResponseSelectCommandVersion1 < Test::Unit::TestCase
355
358
  ],
356
359
  [1, "groonga"],
357
360
  [3, "groonga"],
358
- ]
359
- }
361
+ {
362
+ "author" => [
363
+ [3],
364
+ [
365
+ [
366
+ "_key",
367
+ "ShortText",
368
+ ],
369
+ [
370
+ "_nsubrecs",
371
+ "Int32",
372
+ ],
373
+ ],
374
+ [
375
+ "Alice",
376
+ 1,
377
+ ],
378
+ [
379
+ "Bob",
380
+ 1,
381
+ ],
382
+ [
383
+ "Chris",
384
+ 1,
385
+ ],
386
+ ],
387
+ },
388
+ ],
389
+ },
360
390
  ]
361
391
  end
362
392
 
363
393
  def test_slices
364
394
  assert_equal({
365
- "groonga" => [
366
- {"_id" => 1, "tag" => "groonga"},
367
- {"_id" => 3, "tag" => "groonga"},
368
- ]
395
+ "groonga" => {
396
+ records: [
397
+ {"_id" => 1, "tag" => "groonga"},
398
+ {"_id" => 3, "tag" => "groonga"},
399
+ ],
400
+ drilldowns: {
401
+ "author" => [
402
+ {"_key" => "Alice", "_nsubrecs" => 1},
403
+ {"_key" => "Bob", "_nsubrecs" => 1},
404
+ {"_key" => "Chris", "_nsubrecs" => 1},
405
+ ],
406
+ },
407
+ },
369
408
  },
370
- collect_values(@body, &:records))
409
+ collect_values(@body))
371
410
  end
372
411
 
373
412
  private
@@ -375,10 +414,23 @@ class TestResponseSelectCommandVersion1 < Test::Unit::TestCase
375
414
  create_response(body).slices
376
415
  end
377
416
 
417
+ def build_drilldown(label, n_hits, records)
418
+ Groonga::Client::Response::Select::Drilldown.new(label,
419
+ n_hits,
420
+ records)
421
+ end
422
+
378
423
  def collect_values(body)
379
424
  values = {}
380
425
  slices(body).each do |label, slice|
381
- values[label] = yield(slice)
426
+ drilldowns = {}
427
+ slice.drilldowns.each do |label, drilldown|
428
+ drilldowns[label] = drilldown.records
429
+ end
430
+ values[label] = {
431
+ records: slice.records,
432
+ drilldowns: drilldowns,
433
+ }
382
434
  end
383
435
  values
384
436
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2013-2019 Sutou Kouhei <kou@clear-code.com>
2
2
  # Copyright (C) 2013 Kosuke Asami
3
3
  # Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
4
4
  #
@@ -319,7 +319,36 @@ class TestResponseSelectCommandVersion3 < Test::Unit::TestCase
319
319
  "records" => [
320
320
  [1, "groonga"],
321
321
  [3, "groonga"],
322
- ]
322
+ ],
323
+ "drilldowns" => {
324
+ "author" => {
325
+ "n_hits" => 3,
326
+ "columns" => [
327
+ {
328
+ "name" => "_key",
329
+ "type" => "ShortText",
330
+ },
331
+ {
332
+ "name" => "_nsubrecs",
333
+ "type" => "Int32",
334
+ },
335
+ ],
336
+ "records" => [
337
+ [
338
+ "Alice",
339
+ 1,
340
+ ],
341
+ [
342
+ "Bob",
343
+ 1,
344
+ ],
345
+ [
346
+ "Chris",
347
+ 1,
348
+ ],
349
+ ],
350
+ },
351
+ },
323
352
  }
324
353
  }
325
354
  }
@@ -327,12 +356,21 @@ class TestResponseSelectCommandVersion3 < Test::Unit::TestCase
327
356
 
328
357
  def test_slices
329
358
  assert_equal({
330
- "groonga" => [
331
- {"_id" => 1, "tag" => "groonga"},
332
- {"_id" => 3, "tag" => "groonga"},
333
- ]
359
+ "groonga" => {
360
+ records: [
361
+ {"_id" => 1, "tag" => "groonga"},
362
+ {"_id" => 3, "tag" => "groonga"},
363
+ ],
364
+ drilldowns: {
365
+ "author" => [
366
+ {"_key" => "Alice", "_nsubrecs" => 1},
367
+ {"_key" => "Bob", "_nsubrecs" => 1},
368
+ {"_key" => "Chris", "_nsubrecs" => 1},
369
+ ],
370
+ },
371
+ },
334
372
  },
335
- collect_values(@body, &:records))
373
+ collect_values(@body))
336
374
  end
337
375
 
338
376
  private
@@ -343,7 +381,14 @@ class TestResponseSelectCommandVersion3 < Test::Unit::TestCase
343
381
  def collect_values(body)
344
382
  values = {}
345
383
  slices(body).each do |label, slice|
346
- values[label] = yield(slice)
384
+ drilldowns = {}
385
+ slice.drilldowns.each do |label, drilldown|
386
+ drilldowns[label] = drilldown.records
387
+ end
388
+ values[label] = {
389
+ records: slice.records,
390
+ drilldowns: drilldowns,
391
+ }
347
392
  end
348
393
  values
349
394
  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.6.0
4
+ version: 0.6.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: 2018-08-30 00:00:00.000000000 Z
13
+ date: 2019-07-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: gqtp
@@ -161,9 +161,9 @@ email:
161
161
  - kou@clear-code.com
162
162
  - tfortress58@gmail.com
163
163
  executables:
164
- - groonga-client
165
- - groonga-client-index-check
166
164
  - groonga-client-index-recreate
165
+ - groonga-client-index-check
166
+ - groonga-client
167
167
  extensions: []
168
168
  extra_rdoc_files: []
169
169
  files:
@@ -283,42 +283,42 @@ required_rubygems_version: !ruby/object:Gem::Requirement
283
283
  version: '0'
284
284
  requirements: []
285
285
  rubyforge_project:
286
- rubygems_version: 3.0.0.beta1
286
+ rubygems_version: 2.7.6.2
287
287
  signing_key:
288
288
  specification_version: 4
289
289
  summary: Groonga-client is a client for Groonga (http://groonga.org/) implemented
290
290
  with pure Ruby. You can use it without Groonga.
291
291
  test_files:
292
+ - test/results/test-table-list.rb
292
293
  - test/test-script-syntax.rb
293
- - test/protocol/test-http.rb
294
- - test/protocol/test-gqtp.rb
295
- - test/response/test-schema.rb
296
- - test/response/test-select-tsv.rb
297
- - test/response/test-error.rb
298
- - test/response/test-table-remove.rb
299
- - test/response/test-select-xml.rb
294
+ - test/response/test-table-create.rb
295
+ - test/response/helper.rb
300
296
  - test/response/test-select-command-version3.rb
301
- - test/response/test-table-list.rb
302
297
  - test/response/test-column-list.rb
298
+ - test/response/test-select-xml.rb
303
299
  - test/response/test-load.rb
304
- - test/response/helper.rb
305
- - test/response/test-base.rb
306
300
  - test/response/test-select-command-version1.rb
301
+ - test/response/test-select-tsv.rb
302
+ - test/response/test-table-list.rb
307
303
  - test/response/test-status.rb
308
- - test/response/test-table-create.rb
309
- - test/results/test-table-list.rb
310
- - test/test-command.rb
304
+ - test/response/test-schema.rb
305
+ - test/response/test-base.rb
306
+ - test/response/test-error.rb
307
+ - test/response/test-table-remove.rb
308
+ - test/command-line/helper.rb
309
+ - test/command-line/test-index-recreate.rb
310
+ - test/command-line/test-index-check.rb
311
311
  - test/run-test.rb
312
- - test/request/test-generic.rb
312
+ - test/test-command.rb
313
+ - test/request/select/test-backward-compatible-sort-keys-parameter.rb
313
314
  - test/request/select/test-values-parameter.rb
314
- - test/request/select/test-output-columns-parameter.rb
315
315
  - test/request/select/test-scorer.rb
316
- - test/request/select/test-backward-compatible-sort-keys-parameter.rb
317
316
  - test/request/select/test-filter.rb
317
+ - test/request/select/test-output-columns-parameter.rb
318
318
  - test/request/select/test-sort-keys-parameter.rb
319
- - test/request/test-select.rb
319
+ - test/request/test-generic.rb
320
320
  - test/request/test-merger.rb
321
+ - test/request/test-select.rb
321
322
  - test/test-client.rb
322
- - test/command-line/test-index-recreate.rb
323
- - test/command-line/helper.rb
324
- - test/command-line/test-index-check.rb
323
+ - test/protocol/test-gqtp.rb
324
+ - test/protocol/test-http.rb