fluent-plugin-droonga 0.8.0 → 0.9.0
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/.gitignore +1 -0
- data/Gemfile +7 -0
- data/benchmark/watch/benchmark-notify.rb +6 -6
- data/benchmark/watch/benchmark-notify.sh +3 -2
- data/bin/grn2jsons +0 -3
- data/doc/text/news.md +13 -0
- data/fluent-plugin-droonga.gemspec +1 -1
- data/lib/droonga/catalog/base.rb +8 -3
- data/lib/droonga/catalog.rb +1 -16
- data/lib/droonga/catalog_observer.rb +57 -0
- data/lib/droonga/collector.rb +1 -1
- data/lib/droonga/dispatcher.rb +3 -1
- data/lib/droonga/distributor_plugin.rb +47 -19
- data/lib/droonga/handler_messenger.rb +26 -2
- data/lib/droonga/message_processing_error.rb +6 -8
- data/lib/droonga/output_message.rb +17 -1
- data/lib/droonga/plugin/collector/basic.rb +44 -81
- data/lib/droonga/plugin/collector/groonga.rb +83 -0
- data/lib/droonga/plugin/collector/search.rb +104 -0
- data/lib/droonga/plugin/distributor/crud.rb +41 -0
- data/lib/droonga/plugin/distributor/distributed_search_planner.rb +4 -4
- data/lib/droonga/plugin/distributor/groonga.rb +38 -0
- data/lib/droonga/plugin/handler/add.rb +4 -1
- data/lib/droonga/plugin/handler/groonga/column_create.rb +7 -0
- data/lib/droonga/plugin/handler/groonga/table_remove.rb +42 -0
- data/lib/droonga/plugin/handler/groonga.rb +17 -2
- data/lib/droonga/plugin/handler/watch.rb +4 -4
- data/lib/droonga/plugin/input_adapter/crud.rb +27 -0
- data/lib/droonga/plugin/input_adapter/groonga.rb +16 -1
- data/lib/droonga/plugin/output_adapter/crud.rb +51 -0
- data/lib/droonga/plugin/output_adapter/groonga.rb +8 -1
- data/lib/droonga/plugin.rb +1 -1
- data/lib/droonga/replier.rb +7 -1
- data/lib/droonga/searcher.rb +168 -74
- data/lib/droonga/session.rb +1 -1
- data/lib/groonga_command_converter.rb +7 -1
- data/test/command/config/default/catalog.json +1 -1
- data/test/command/suite/add/error/invalid-integer.expected +31 -1
- data/test/command/suite/add/error/invalid-time.expected +31 -1
- data/test/command/suite/add/error/missing-key.expected +17 -1
- data/test/command/suite/add/error/missing-table.expected +17 -1
- data/test/command/suite/add/error/unknown-column.expected +31 -1
- data/test/command/suite/add/error/unknown-table.expected +17 -1
- data/test/command/suite/add/minimum.expected +1 -1
- data/test/command/suite/add/with-values.expected +1 -1
- data/test/command/suite/add/without-key.expected +1 -1
- data/test/command/suite/groonga/column_create/scalar.expected +2 -2
- data/test/command/suite/groonga/column_create/unknown-table.expected +18 -0
- data/test/command/suite/groonga/column_create/unknown-table.test +7 -0
- data/test/command/suite/groonga/column_create/vector.expected +2 -2
- data/test/command/suite/groonga/select/minimum.expected +1 -1
- data/test/command/suite/groonga/table_create/array.expected +1 -1
- data/test/command/suite/groonga/table_create/hash.expected +1 -1
- data/test/command/suite/groonga/table_remove/success.expected +17 -0
- data/test/command/suite/groonga/table_remove/success.test +8 -0
- data/test/command/suite/groonga/table_remove/unknown-table.expected +18 -0
- data/test/command/suite/groonga/table_remove/unknown-table.test +7 -0
- data/test/command/suite/message/error/missing-dataset.expected +1 -1
- data/test/command/suite/message/error/unknown-command.expected +1 -1
- data/test/command/suite/message/error/unknown-dataset.expected +1 -1
- data/test/command/suite/search/attributes/array.expected +1 -1
- data/test/command/suite/search/attributes/hash.expected +1 -1
- data/test/command/suite/search/complex.expected +1 -1
- data/test/command/suite/search/condition/nested.expected +1 -1
- data/test/command/suite/search/condition/query.expected +1 -1
- data/test/command/suite/search/condition/script.expected +1 -1
- data/test/command/suite/search/error/cyclic-source.expected +1 -1
- data/test/command/suite/search/error/deeply-cyclic-source.expected +1 -1
- data/test/command/suite/search/error/missing-source-parameter.expected +1 -1
- data/test/command/suite/search/error/unknown-source.expected +1 -1
- data/test/command/suite/search/group/count.expected +1 -1
- data/test/command/suite/search/group/limit.expected +1 -1
- data/test/command/suite/search/group/string.expected +1 -1
- data/test/command/suite/search/multiple/chained.expected +1 -1
- data/test/command/suite/search/multiple/parallel.expected +1 -1
- data/test/command/suite/search/range/only-output.expected +1 -1
- data/test/command/suite/search/range/only-sort.expected +1 -1
- data/test/command/suite/search/range/sort-and-output.expected +1 -1
- data/test/command/suite/search/range/too-large-output-offset.expected +1 -1
- data/test/command/suite/search/range/too-large-sort-offset.expected +1 -1
- data/test/command/suite/search/response/records/value/time.expected +1 -1
- data/test/command/suite/search/simple.expected +1 -1
- data/test/command/suite/search/sort/default-offset-limit.expected +1 -1
- data/test/command/suite/search/sort/invisible-column.expected +1 -1
- data/test/command/suite/watch/subscribe.expected +1 -1
- data/test/command/suite/watch/unsubscribe.expected +1 -1
- data/test/performance/run-test.rb +56 -0
- data/{benchmark → test/performance}/watch/catalog.json +0 -0
- data/test/performance/watch/feed.json +9 -0
- data/{benchmark → test/performance}/watch/fluentd.conf +0 -0
- data/test/performance/watch/subscribe.json +3 -0
- data/test/unit/catalog/test_version1.rb +34 -0
- data/test/unit/plugin/collector/test_basic.rb +300 -479
- data/test/unit/plugin/collector/test_search.rb +814 -0
- data/test/unit/plugin/distributor/test_search.rb +4 -4
- data/test/unit/plugin/distributor/test_search_planner.rb +260 -260
- data/test/unit/plugin/handler/groonga/test_column_create.rb +15 -1
- data/test/unit/plugin/handler/groonga/test_table_create.rb +6 -2
- data/test/unit/plugin/handler/groonga/test_table_remove.rb +58 -0
- data/test/unit/plugin/handler/test_add.rb +3 -1
- data/test/unit/plugin/handler/test_groonga.rb +24 -0
- data/test/unit/plugin/handler/test_search.rb +294 -0
- data/test/unit/plugin/handler/test_watch.rb +1 -1
- data/test/unit/plugin/{adapter → input_adapter}/groonga/test_select.rb +5 -37
- data/test/unit/plugin/output_adapter/groonga/test_select.rb +55 -0
- metadata +38 -6
@@ -16,15 +16,15 @@
|
|
16
16
|
require "droonga/plugin/distributor/distributed_search_planner"
|
17
17
|
|
18
18
|
class DistributedSearchPlannerTest < Test::Unit::TestCase
|
19
|
-
def assert_planned(expected,
|
20
|
-
plan = Droonga::DistributedSearchPlanner.new(
|
19
|
+
def assert_planned(expected, search_request)
|
20
|
+
plan = Droonga::DistributedSearchPlanner.new(search_request)
|
21
21
|
actual = plan.messages
|
22
22
|
assert_equal(expected, actual)
|
23
23
|
end
|
24
24
|
|
25
25
|
class MultipleQueriesTest < self
|
26
26
|
def test_distribute
|
27
|
-
|
27
|
+
request = {
|
28
28
|
"type" => "search",
|
29
29
|
"dataset" => "Droonga",
|
30
30
|
"body" => {
|
@@ -63,10 +63,10 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
63
63
|
},
|
64
64
|
}
|
65
65
|
|
66
|
-
|
66
|
+
expected_plan = []
|
67
67
|
|
68
|
-
|
69
|
-
"type" => "
|
68
|
+
expected_plan << {
|
69
|
+
"type" => "search_reduce",
|
70
70
|
"body" => {
|
71
71
|
"query1" => {
|
72
72
|
"query1_reduced" => {
|
@@ -84,8 +84,8 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
84
84
|
"inputs" => ["query1"],
|
85
85
|
"outputs" => ["query1_reduced"],
|
86
86
|
}
|
87
|
-
|
88
|
-
"type" => "
|
87
|
+
expected_plan << {
|
88
|
+
"type" => "search_reduce",
|
89
89
|
"body" => {
|
90
90
|
"query2" => {
|
91
91
|
"query2_reduced" => {
|
@@ -103,8 +103,8 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
103
103
|
"inputs" => ["query2"],
|
104
104
|
"outputs" => ["query2_reduced"],
|
105
105
|
}
|
106
|
-
|
107
|
-
"type" => "
|
106
|
+
expected_plan << {
|
107
|
+
"type" => "search_reduce",
|
108
108
|
"body" => {
|
109
109
|
"query3" => {
|
110
110
|
"query3_reduced" => {
|
@@ -124,7 +124,7 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
124
124
|
}
|
125
125
|
|
126
126
|
gatherer = {
|
127
|
-
"type" => "
|
127
|
+
"type" => "search_gather",
|
128
128
|
"body" => {
|
129
129
|
"query1_reduced" => {
|
130
130
|
"output" => "query1",
|
@@ -170,7 +170,7 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
170
170
|
],
|
171
171
|
"post" => true,
|
172
172
|
}
|
173
|
-
|
173
|
+
expected_plan << gatherer
|
174
174
|
|
175
175
|
searcher = {
|
176
176
|
"type" => "broadcast",
|
@@ -217,15 +217,15 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
217
217
|
],
|
218
218
|
"replica" => "random",
|
219
219
|
}
|
220
|
-
|
220
|
+
expected_plan << searcher
|
221
221
|
|
222
|
-
assert_planned(
|
222
|
+
assert_planned(expected_plan, request)
|
223
223
|
end
|
224
224
|
end
|
225
225
|
|
226
226
|
class SingleQueryTest < self
|
227
227
|
def test_no_output
|
228
|
-
|
228
|
+
request = {
|
229
229
|
"type" => "search",
|
230
230
|
"dataset" => "Droonga",
|
231
231
|
"body" => {
|
@@ -242,14 +242,14 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
242
242
|
},
|
243
243
|
}
|
244
244
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
assert_planned(
|
245
|
+
expected_plan = []
|
246
|
+
expected_plan << gatherer(request, :no_output => true)
|
247
|
+
expected_plan << searcher(request, :no_output => true)
|
248
|
+
assert_planned(expected_plan, request)
|
249
249
|
end
|
250
250
|
|
251
251
|
def test_no_records_element
|
252
|
-
|
252
|
+
request = {
|
253
253
|
"type" => "search",
|
254
254
|
"dataset" => "Droonga",
|
255
255
|
"body" => {
|
@@ -269,20 +269,20 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
269
269
|
},
|
270
270
|
}
|
271
271
|
|
272
|
-
|
273
|
-
|
272
|
+
expected_plan = []
|
273
|
+
expected_plan << reducer(request, {
|
274
274
|
"count" => {
|
275
275
|
"type" => "sum",
|
276
276
|
},
|
277
277
|
})
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
assert_planned(
|
278
|
+
expected_plan << gatherer(request)
|
279
|
+
expected_plan << searcher(request, :sort_limit => 1,
|
280
|
+
:output_limit => 0)
|
281
|
+
assert_planned(expected_plan, request)
|
282
282
|
end
|
283
283
|
|
284
284
|
def test_no_output_limit
|
285
|
-
|
285
|
+
request = {
|
286
286
|
"type" => "search",
|
287
287
|
"dataset" => "Droonga",
|
288
288
|
"body" => {
|
@@ -298,20 +298,20 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
298
298
|
},
|
299
299
|
}
|
300
300
|
|
301
|
-
|
302
|
-
|
301
|
+
expected_plan = []
|
302
|
+
expected_plan << reducer(request, {
|
303
303
|
"count" => {
|
304
304
|
"type" => "sum",
|
305
305
|
},
|
306
306
|
})
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
assert_planned(
|
307
|
+
expected_plan << gatherer(request)
|
308
|
+
expected_plan << searcher(request, :output_offset => 0,
|
309
|
+
:output_limit => 0)
|
310
|
+
assert_planned(expected_plan, request)
|
311
311
|
end
|
312
312
|
|
313
313
|
def test_have_records
|
314
|
-
|
314
|
+
request = {
|
315
315
|
"type" => "search",
|
316
316
|
"dataset" => "Droonga",
|
317
317
|
"body" => {
|
@@ -330,29 +330,29 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
330
330
|
},
|
331
331
|
}
|
332
332
|
|
333
|
-
|
334
|
-
|
333
|
+
expected_plan = []
|
334
|
+
expected_plan << reducer(request, {
|
335
335
|
"records" => {
|
336
336
|
"type" => "sort",
|
337
337
|
"operators" => [],
|
338
338
|
"limit" => 1,
|
339
339
|
},
|
340
340
|
})
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
assert_planned(
|
341
|
+
expected_plan << gatherer(request, :elements => {
|
342
|
+
"records" => records_mapper(
|
343
|
+
:offset => 0,
|
344
|
+
:limit => 1,
|
345
|
+
:format => "complex",
|
346
|
+
:attributes => ["_key", "name", "age"],
|
347
|
+
),
|
348
|
+
})
|
349
|
+
expected_plan << searcher(request, :output_offset => 0,
|
350
|
+
:output_limit => 1)
|
351
|
+
assert_planned(expected_plan, request)
|
352
352
|
end
|
353
353
|
|
354
354
|
def test_have_output_offset
|
355
|
-
|
355
|
+
request = {
|
356
356
|
"type" => "search",
|
357
357
|
"dataset" => "Droonga",
|
358
358
|
"body" => {
|
@@ -371,29 +371,29 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
371
371
|
},
|
372
372
|
}
|
373
373
|
|
374
|
-
|
375
|
-
|
374
|
+
expected_plan = []
|
375
|
+
expected_plan << reducer(request, {
|
376
376
|
"records" => {
|
377
377
|
"type" => "sort",
|
378
378
|
"operators" => [],
|
379
379
|
"limit" => 2,
|
380
380
|
},
|
381
381
|
})
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
assert_planned(
|
382
|
+
expected_plan << gatherer(request, :elements => {
|
383
|
+
"records" => records_mapper(
|
384
|
+
:offset => 1,
|
385
|
+
:limit => 1,
|
386
|
+
:format => "complex",
|
387
|
+
:attributes => ["_key", "name", "age"],
|
388
|
+
),
|
389
|
+
})
|
390
|
+
expected_plan << searcher(request, :output_offset => 0,
|
391
|
+
:output_limit => 2)
|
392
|
+
assert_planned(expected_plan, request)
|
393
393
|
end
|
394
394
|
|
395
395
|
def test_have_simple_sortBy
|
396
|
-
|
396
|
+
request = {
|
397
397
|
"type" => "search",
|
398
398
|
"dataset" => "Droonga",
|
399
399
|
"body" => {
|
@@ -413,8 +413,8 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
413
413
|
},
|
414
414
|
}
|
415
415
|
|
416
|
-
|
417
|
-
|
416
|
+
expected_plan = []
|
417
|
+
expected_plan << reducer(request, {
|
418
418
|
"records" => {
|
419
419
|
"type" => "sort",
|
420
420
|
"operators" => [
|
@@ -423,21 +423,21 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
423
423
|
"limit" => 1,
|
424
424
|
},
|
425
425
|
})
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
assert_planned(
|
426
|
+
expected_plan << gatherer(request, :elements => {
|
427
|
+
"records" => records_mapper(
|
428
|
+
:offset => 0,
|
429
|
+
:limit => 1,
|
430
|
+
:format => "complex",
|
431
|
+
:attributes => ["_key", "name", "age"],
|
432
|
+
),
|
433
|
+
})
|
434
|
+
expected_plan << searcher(request, :output_offset => 0,
|
435
|
+
:output_limit => 1)
|
436
|
+
assert_planned(expected_plan, request)
|
437
437
|
end
|
438
438
|
|
439
439
|
def test_have_sortBy
|
440
|
-
|
440
|
+
request = {
|
441
441
|
"type" => "search",
|
442
442
|
"dataset" => "Droonga",
|
443
443
|
"body" => {
|
@@ -459,8 +459,8 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
459
459
|
},
|
460
460
|
}
|
461
461
|
|
462
|
-
|
463
|
-
|
462
|
+
expected_plan = []
|
463
|
+
expected_plan << reducer(request, {
|
464
464
|
"records" => {
|
465
465
|
"type" => "sort",
|
466
466
|
"operators" => [
|
@@ -469,23 +469,23 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
469
469
|
"limit" => 1,
|
470
470
|
},
|
471
471
|
})
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
assert_planned(
|
472
|
+
expected_plan << gatherer(request, :elements => {
|
473
|
+
"records" => records_mapper(
|
474
|
+
:offset => 0,
|
475
|
+
:limit => 1,
|
476
|
+
:format => "complex",
|
477
|
+
:attributes => ["_key", "name", "age"],
|
478
|
+
),
|
479
|
+
})
|
480
|
+
expected_plan << searcher(request, :sort_offset => 0,
|
481
|
+
:sort_limit => 1,
|
482
|
+
:output_offset => 0,
|
483
|
+
:output_limit => 1)
|
484
|
+
assert_planned(expected_plan, request)
|
485
485
|
end
|
486
486
|
|
487
487
|
def test_have_sortBy_offset_limit
|
488
|
-
|
488
|
+
request = {
|
489
489
|
"type" => "search",
|
490
490
|
"dataset" => "Droonga",
|
491
491
|
"body" => {
|
@@ -511,8 +511,8 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
511
511
|
|
512
512
|
sort_limit = 1 + 4 + [2, 8].max
|
513
513
|
output_limit = 1 + 4 + [2, 8].min
|
514
|
-
|
515
|
-
|
514
|
+
expected_plan = []
|
515
|
+
expected_plan << reducer(request, {
|
516
516
|
"records" => {
|
517
517
|
"type" => "sort",
|
518
518
|
"operators" => [
|
@@ -521,23 +521,23 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
521
521
|
"limit" => output_limit,
|
522
522
|
},
|
523
523
|
})
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
assert_planned(
|
524
|
+
expected_plan << gatherer(request, :elements => {
|
525
|
+
"records" => records_mapper(
|
526
|
+
:offset => 5,
|
527
|
+
:limit => 2,
|
528
|
+
:format => "complex",
|
529
|
+
:attributes => ["_key", "name", "age"],
|
530
|
+
),
|
531
|
+
})
|
532
|
+
expected_plan << searcher(request, :sort_offset => 0,
|
533
|
+
:sort_limit => sort_limit,
|
534
|
+
:output_offset => 0,
|
535
|
+
:output_limit => output_limit)
|
536
|
+
assert_planned(expected_plan, request)
|
537
537
|
end
|
538
538
|
|
539
539
|
def test_have_sortBy_with_infinity_output_limit
|
540
|
-
|
540
|
+
request = {
|
541
541
|
"type" => "search",
|
542
542
|
"dataset" => "Droonga",
|
543
543
|
"body" => {
|
@@ -562,8 +562,8 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
562
562
|
}
|
563
563
|
|
564
564
|
limit = 1 + 4 + 2
|
565
|
-
|
566
|
-
|
565
|
+
expected_plan = []
|
566
|
+
expected_plan << reducer(request, {
|
567
567
|
"records" => {
|
568
568
|
"type" => "sort",
|
569
569
|
"operators" => [
|
@@ -572,23 +572,23 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
572
572
|
"limit" => limit,
|
573
573
|
},
|
574
574
|
})
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
assert_planned(
|
575
|
+
expected_plan << gatherer(request, :elements => {
|
576
|
+
"records" => records_mapper(
|
577
|
+
:offset => 5,
|
578
|
+
:limit => 2,
|
579
|
+
:format => "complex",
|
580
|
+
:attributes => ["_key", "name", "age"],
|
581
|
+
),
|
582
|
+
})
|
583
|
+
expected_plan << searcher(request, :sort_offset => 0,
|
584
|
+
:sort_limit => limit,
|
585
|
+
:output_offset => 0,
|
586
|
+
:output_limit => limit)
|
587
|
+
assert_planned(expected_plan, request)
|
588
588
|
end
|
589
589
|
|
590
590
|
def test_have_sortBy_with_infinity_sort_limit
|
591
|
-
|
591
|
+
request = {
|
592
592
|
"type" => "search",
|
593
593
|
"dataset" => "Droonga",
|
594
594
|
"body" => {
|
@@ -613,8 +613,8 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
613
613
|
}
|
614
614
|
|
615
615
|
limit = 1 + 4 + 8
|
616
|
-
|
617
|
-
|
616
|
+
expected_plan = []
|
617
|
+
expected_plan << reducer(request, {
|
618
618
|
"records" => {
|
619
619
|
"type" => "sort",
|
620
620
|
"operators" => [
|
@@ -623,23 +623,23 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
623
623
|
"limit" => limit,
|
624
624
|
},
|
625
625
|
})
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
assert_planned(
|
626
|
+
expected_plan << gatherer(request, :elements => {
|
627
|
+
"records" => records_mapper(
|
628
|
+
:offset => 5,
|
629
|
+
:limit => 8,
|
630
|
+
:format => "complex",
|
631
|
+
:attributes => ["_key", "name", "age"],
|
632
|
+
),
|
633
|
+
})
|
634
|
+
expected_plan << searcher(request, :sort_offset => 0,
|
635
|
+
:sort_limit => limit,
|
636
|
+
:output_offset => 0,
|
637
|
+
:output_limit => limit)
|
638
|
+
assert_planned(expected_plan, request)
|
639
639
|
end
|
640
640
|
|
641
641
|
def test_have_sortBy_with_infinity_limit
|
642
|
-
|
642
|
+
request = {
|
643
643
|
"type" => "search",
|
644
644
|
"dataset" => "Droonga",
|
645
645
|
"body" => {
|
@@ -663,8 +663,8 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
663
663
|
},
|
664
664
|
}
|
665
665
|
|
666
|
-
|
667
|
-
|
666
|
+
expected_plan = []
|
667
|
+
expected_plan << reducer(request, {
|
668
668
|
"records" => {
|
669
669
|
"type" => "sort",
|
670
670
|
"operators" => [
|
@@ -673,23 +673,23 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
673
673
|
"limit" => -1,
|
674
674
|
},
|
675
675
|
})
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
assert_planned(
|
676
|
+
expected_plan << gatherer(request, :elements => {
|
677
|
+
"records" => records_mapper(
|
678
|
+
:offset => 5,
|
679
|
+
:limit => -1,
|
680
|
+
:format => "complex",
|
681
|
+
:attributes => ["_key", "name", "age"],
|
682
|
+
),
|
683
|
+
})
|
684
|
+
expected_plan << searcher(request, :sort_offset => 0,
|
685
|
+
:sort_limit => -1,
|
686
|
+
:output_offset => 0,
|
687
|
+
:output_limit => -1)
|
688
|
+
assert_planned(expected_plan, request)
|
689
689
|
end
|
690
690
|
|
691
691
|
def test_have_sortBy_with_multiple_sort_keys
|
692
|
-
|
692
|
+
request = {
|
693
693
|
"type" => "search",
|
694
694
|
"dataset" => "Droonga",
|
695
695
|
"body" => {
|
@@ -711,8 +711,8 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
711
711
|
},
|
712
712
|
}
|
713
713
|
|
714
|
-
|
715
|
-
|
714
|
+
expected_plan = []
|
715
|
+
expected_plan << reducer(request, {
|
716
716
|
"records" => {
|
717
717
|
"type" => "sort",
|
718
718
|
"operators" => [
|
@@ -722,23 +722,23 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
722
722
|
"limit" => -1,
|
723
723
|
},
|
724
724
|
})
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
assert_planned(
|
725
|
+
expected_plan << gatherer(request, :elements => {
|
726
|
+
"records" => records_mapper(
|
727
|
+
:offset => 0,
|
728
|
+
:limit => -1,
|
729
|
+
:format => "complex",
|
730
|
+
:attributes => ["_key", "name", "age"],
|
731
|
+
),
|
732
|
+
})
|
733
|
+
expected_plan << searcher(request, :sort_offset => 0,
|
734
|
+
:sort_limit => -1,
|
735
|
+
:output_offset => 0,
|
736
|
+
:output_limit => -1)
|
737
|
+
assert_planned(expected_plan, request)
|
738
738
|
end
|
739
739
|
|
740
740
|
def test_have_sortBy_with_missing_sort_attributes
|
741
|
-
|
741
|
+
request = {
|
742
742
|
"type" => "search",
|
743
743
|
"dataset" => "Droonga",
|
744
744
|
"body" => {
|
@@ -760,8 +760,8 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
760
760
|
},
|
761
761
|
}
|
762
762
|
|
763
|
-
|
764
|
-
|
763
|
+
expected_plan = []
|
764
|
+
expected_plan << reducer(request, {
|
765
765
|
"records" => {
|
766
766
|
"type" => "sort",
|
767
767
|
"operators" => [
|
@@ -771,24 +771,24 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
771
771
|
"limit" => -1,
|
772
772
|
},
|
773
773
|
})
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
assert_planned(
|
774
|
+
expected_plan << gatherer(request, :elements => {
|
775
|
+
"records" => records_mapper(
|
776
|
+
:offset => 0,
|
777
|
+
:limit => -1,
|
778
|
+
:format => "complex",
|
779
|
+
:attributes => ["_key", "name", "age"],
|
780
|
+
),
|
781
|
+
})
|
782
|
+
expected_plan << searcher(request, :sort_offset => 0,
|
783
|
+
:sort_limit => -1,
|
784
|
+
:output_offset => 0,
|
785
|
+
:output_limit => -1,
|
786
|
+
:extra_attributes => ["public_age", "public_name"])
|
787
|
+
assert_planned(expected_plan, request)
|
788
788
|
end
|
789
789
|
|
790
790
|
def test_hash_attributes
|
791
|
-
|
791
|
+
request = {
|
792
792
|
"type" => "search",
|
793
793
|
"dataset" => "Droonga",
|
794
794
|
"body" => {
|
@@ -814,8 +814,8 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
814
814
|
},
|
815
815
|
}
|
816
816
|
|
817
|
-
|
818
|
-
|
817
|
+
expected_plan = []
|
818
|
+
expected_plan << reducer(request, {
|
819
819
|
"records" => {
|
820
820
|
"type" => "sort",
|
821
821
|
"operators" => [
|
@@ -825,24 +825,24 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
825
825
|
"limit" => -1,
|
826
826
|
},
|
827
827
|
})
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
assert_planned(
|
828
|
+
expected_plan << gatherer(request, :elements => {
|
829
|
+
"records" => records_mapper(
|
830
|
+
:offset => 0,
|
831
|
+
:limit => -1,
|
832
|
+
:format => "complex",
|
833
|
+
:attributes => ["id", "name", "age"],
|
834
|
+
),
|
835
|
+
})
|
836
|
+
expected_plan << searcher(request, :sort_offset => 0,
|
837
|
+
:sort_limit => -1,
|
838
|
+
:output_offset => 0,
|
839
|
+
:output_limit => -1,
|
840
|
+
:extra_attributes => ["public_age", "public_name"])
|
841
|
+
assert_planned(expected_plan, request)
|
842
842
|
end
|
843
843
|
|
844
844
|
def test_groupBy
|
845
|
-
|
845
|
+
request = {
|
846
846
|
"type" => "search",
|
847
847
|
"dataset" => "Droonga",
|
848
848
|
"body" => {
|
@@ -861,8 +861,8 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
861
861
|
},
|
862
862
|
}
|
863
863
|
|
864
|
-
|
865
|
-
|
864
|
+
expected_plan = []
|
865
|
+
expected_plan << reducer(request, {
|
866
866
|
"records" => {
|
867
867
|
"type" => "sort",
|
868
868
|
"operators" => [],
|
@@ -870,22 +870,22 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
870
870
|
"limit" => -1,
|
871
871
|
},
|
872
872
|
})
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
assert_planned(
|
873
|
+
expected_plan << gatherer(request, :elements => {
|
874
|
+
"records" => records_mapper(
|
875
|
+
:offset => 0,
|
876
|
+
:limit => -1,
|
877
|
+
:format => "complex",
|
878
|
+
:attributes => ["_key", "_nsubrecs"],
|
879
|
+
),
|
880
|
+
})
|
881
|
+
expected_plan << searcher(request, :output_offset => 0,
|
882
|
+
:output_limit => -1,
|
883
|
+
:unifiable => true)
|
884
|
+
assert_planned(expected_plan, request)
|
885
885
|
end
|
886
886
|
|
887
887
|
def test_groupBy_count
|
888
|
-
|
888
|
+
request = {
|
889
889
|
"type" => "search",
|
890
890
|
"dataset" => "Droonga",
|
891
891
|
"body" => {
|
@@ -901,8 +901,8 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
901
901
|
},
|
902
902
|
}
|
903
903
|
|
904
|
-
|
905
|
-
|
904
|
+
expected_plan = []
|
905
|
+
expected_plan << reducer(request, {
|
906
906
|
"count" => {
|
907
907
|
"type" => "sum",
|
908
908
|
},
|
@@ -913,23 +913,23 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
913
913
|
"limit" => -1,
|
914
914
|
},
|
915
915
|
})
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
assert_planned(
|
916
|
+
expected_plan << gatherer(request, :elements => {
|
917
|
+
"count" => count_mapper,
|
918
|
+
"records" => records_mapper(
|
919
|
+
:limit => -1,
|
920
|
+
:attributes => ["_key"],
|
921
|
+
:no_output => true,
|
922
|
+
),
|
923
|
+
})
|
924
|
+
expected_plan << searcher(request, :output_limit => -1,
|
925
|
+
:extra_attributes => ["_key"],
|
926
|
+
:extra_elements => ["records"],
|
927
|
+
:unifiable => true)
|
928
|
+
assert_planned(expected_plan, request)
|
929
929
|
end
|
930
930
|
|
931
931
|
def test_groupBy_hash
|
932
|
-
|
932
|
+
request = {
|
933
933
|
"type" => "search",
|
934
934
|
"dataset" => "Droonga",
|
935
935
|
"body" => {
|
@@ -957,8 +957,8 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
957
957
|
},
|
958
958
|
}
|
959
959
|
|
960
|
-
|
961
|
-
|
960
|
+
expected_plan = []
|
961
|
+
expected_plan << reducer(request, {
|
962
962
|
"records" => {
|
963
963
|
"type" => "sort",
|
964
964
|
"operators" => [],
|
@@ -966,28 +966,28 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
966
966
|
"limit" => -1,
|
967
967
|
},
|
968
968
|
})
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
assert_planned(
|
969
|
+
expected_plan << gatherer(request, :elements => {
|
970
|
+
"records" => records_mapper(
|
971
|
+
:offset => 0,
|
972
|
+
:limit => -1,
|
973
|
+
:format => "complex",
|
974
|
+
:attributes => ["family_name", "count", "users"],
|
975
|
+
),
|
976
|
+
})
|
977
|
+
expected_plan << searcher(request, :output_offset => 0,
|
978
|
+
:output_limit => -1,
|
979
|
+
:extra_attributes => ["_key"],
|
980
|
+
:unifiable => true)
|
981
|
+
assert_planned(expected_plan, request)
|
982
982
|
end
|
983
983
|
|
984
984
|
private
|
985
|
-
def reducer(
|
986
|
-
queries =
|
985
|
+
def reducer(search_request, reducer_body)
|
986
|
+
queries = search_request["body"]["queries"]
|
987
987
|
query_name = queries.keys.first
|
988
988
|
|
989
989
|
reducer = {
|
990
|
-
"type" => "
|
990
|
+
"type" => "search_reduce",
|
991
991
|
"body" => {
|
992
992
|
query_name => {
|
993
993
|
"#{query_name}_reduced" => reducer_body,
|
@@ -1022,12 +1022,12 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
1022
1022
|
mapper
|
1023
1023
|
end
|
1024
1024
|
|
1025
|
-
def gatherer(
|
1026
|
-
queries =
|
1025
|
+
def gatherer(search_request, options={})
|
1026
|
+
queries = search_request["body"]["queries"]
|
1027
1027
|
query_name = queries.keys.first
|
1028
1028
|
|
1029
1029
|
gatherer = {
|
1030
|
-
"type" => "
|
1030
|
+
"type" => "search_gather",
|
1031
1031
|
"body" => {
|
1032
1032
|
},
|
1033
1033
|
"inputs" => [
|
@@ -1047,9 +1047,9 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
|
|
1047
1047
|
gatherer
|
1048
1048
|
end
|
1049
1049
|
|
1050
|
-
def searcher(
|
1050
|
+
def searcher(search_request, options={})
|
1051
1051
|
# dup and clone don't copy it deeply...
|
1052
|
-
searcher = Marshal.load(Marshal.dump(
|
1052
|
+
searcher = Marshal.load(Marshal.dump(search_request))
|
1053
1053
|
|
1054
1054
|
queries = searcher["body"]["queries"]
|
1055
1055
|
query_name = queries.keys.first
|