Kouhei Sutou
null+****@clear*****
Thu Feb 5 19:13:56 JST 2015
Kouhei Sutou 2015-02-05 19:13:56 +0900 (Thu, 05 Feb 2015) New Revision: 63a20598d39ed2dbd9202078b52ad4ec44ec002b https://github.com/groonga/groonga/commit/63a20598d39ed2dbd9202078b52ad4ec44ec002b Message: logical_range_filter: add skelton Added files: plugins/sharding/logical_range_filter.rb test/command/suite/sharding/logical_range_filter/no_condition/multiple_physical_tables.expected test/command/suite/sharding/logical_range_filter/no_condition/multiple_physical_tables.test Modified files: plugins/sharding.rb plugins/sharding/sources.am Modified: plugins/sharding.rb (+1 -0) =================================================================== --- plugins/sharding.rb 2015-02-05 18:43:07 +0900 (a715c96) +++ plugins/sharding.rb 2015-02-05 19:13:56 +0900 (8902d7e) @@ -1,2 +1,3 @@ require "sharding/logical_enumerator" require "sharding/logical_count" +require "sharding/logical_range_filter" Added: plugins/sharding/logical_range_filter.rb (+50 -0) 100644 =================================================================== --- /dev/null +++ plugins/sharding/logical_range_filter.rb 2015-02-05 19:13:56 +0900 (915755f) @@ -0,0 +1,50 @@ +module Groonga + module Sharding + class LogicalRangeFilterCommand < Command + register("logical_range_filter", + [ + "logical_table", + "shard_key", + "min", + "min_border", + "max", + "max_border", + "order", + "filter", + "offset", + "limit", + "output_columns", + ]) + + def run_body(input) + enumerator = LogicalEnumerator.new("logical_range_filter", input) + filter = input[:filter] + offset = input[:offset] || 0 + limit = input[:limit] || 10 + output_columns = input[:output_columns] || "_key, *" + + result_sets = [] + enumerator.each do |table, shard_key, shard_range, cover_type| + # TODO: result_sets << result_set + end + if result_sets.empty? + n_elements = 0 + else + n_elements = 1 # for columns + result_sets.each do |result_set| + n_elements += result_size.size + end + end + writer.array("RESULTSET", n_elements) do + first_result_set = result_sets.first + if first_result_set + # TODO: write columns of first_result_set + end + result_sets.each do |result_set| + # TODO: write records + end + end + end + end + end +end Modified: plugins/sharding/sources.am (+2 -1) =================================================================== --- plugins/sharding/sources.am 2015-02-05 18:43:07 +0900 (8eb9b06) +++ plugins/sharding/sources.am 2015-02-05 19:13:56 +0900 (11b5382) @@ -1,3 +1,4 @@ sharding_scripts = \ logical_count.rb \ - logical_enumerator.rb + logical_enumerator.rb \ + logical_range_filter.rb Added: test/command/suite/sharding/logical_range_filter/no_condition/multiple_physical_tables.expected (+34 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/sharding/logical_range_filter/no_condition/multiple_physical_tables.expected 2015-02-05 19:13:56 +0900 (adb5220) @@ -0,0 +1,34 @@ +register sharding +[[0,0.0,0.0],true] +table_create Logs_20150203 TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Logs_20150203 timestamp COLUMN_SCALAR Time +[[0,0.0,0.0],true] +table_create Logs_20150204 TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Logs_20150204 timestamp COLUMN_SCALAR Time +[[0,0.0,0.0],true] +table_create Logs_20150205 TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Logs_20150205 timestamp COLUMN_SCALAR Time +[[0,0.0,0.0],true] +load --table Logs_20150203 +[ +{"timestamp": "2015-02-03 12:49:00"} +] +[[0,0.0,0.0],1] +load --table Logs_20150204 +[ +{"timestamp": "2015-02-04 13:49:00"}, +{"timestamp": "2015-02-04 13:50:00"} +] +[[0,0.0,0.0],2] +load --table Logs_20150205 +[ +{"timestamp": "2015-02-05 13:49:00"}, +{"timestamp": "2015-02-05 13:50:00"}, +{"timestamp": "2015-02-05 13:51:00"} +] +[[0,0.0,0.0],3] +logical_range_filter Logs timestamp +[[0,0.0,0.0],[]] Added: test/command/suite/sharding/logical_range_filter/no_condition/multiple_physical_tables.test (+32 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/sharding/logical_range_filter/no_condition/multiple_physical_tables.test 2015-02-05 19:13:56 +0900 (86c4059) @@ -0,0 +1,32 @@ +#@on-error omit +register sharding +#@on-error default + +table_create Logs_20150203 TABLE_NO_KEY +column_create Logs_20150203 timestamp COLUMN_SCALAR Time + +table_create Logs_20150204 TABLE_NO_KEY +column_create Logs_20150204 timestamp COLUMN_SCALAR Time + +table_create Logs_20150205 TABLE_NO_KEY +column_create Logs_20150205 timestamp COLUMN_SCALAR Time + +load --table Logs_20150203 +[ +{"timestamp": "2015-02-03 12:49:00"} +] + +load --table Logs_20150204 +[ +{"timestamp": "2015-02-04 13:49:00"}, +{"timestamp": "2015-02-04 13:50:00"} +] + +load --table Logs_20150205 +[ +{"timestamp": "2015-02-05 13:49:00"}, +{"timestamp": "2015-02-05 13:50:00"}, +{"timestamp": "2015-02-05 13:51:00"} +] + +logical_range_filter Logs timestamp -------------- next part -------------- HTML����������������������������...Download