Kouhei Sutou
null+****@clear*****
Tue Mar 24 16:08:40 JST 2015
Kouhei Sutou 2015-03-24 16:08:40 +0900 (Tue, 24 Mar 2015) New Revision: c317a770025da9a7130fdb06fed4ccf3d70ecf78 https://github.com/groonga/groonga/commit/c317a770025da9a7130fdb06fed4ccf3d70ecf78 Message: logical_range_filter: support no record case At least one shard is required. Added files: test/command/suite/sharding/logical_range_filter/index/no_condition/no_record.expected test/command/suite/sharding/logical_range_filter/index/no_condition/no_record.test test/command/suite/sharding/logical_range_filter/invalid/no_shard.expected test/command/suite/sharding/logical_range_filter/invalid/no_shard.test test/command/suite/sharding/logical_range_filter/no_index/no_condition/no_record.expected test/command/suite/sharding/logical_range_filter/no_index/no_condition/no_record.test Modified files: plugins/sharding/logical_enumerator.rb plugins/sharding/logical_range_filter.rb Modified: plugins/sharding/logical_enumerator.rb (+1 -0) =================================================================== --- plugins/sharding/logical_enumerator.rb 2015-03-24 16:04:35 +0900 (7ad5393) +++ plugins/sharding/logical_enumerator.rb 2015-03-24 16:08:40 +0900 (3e19a19) @@ -2,6 +2,7 @@ module Groonga module Sharding class LogicalEnumerator attr_reader :target_range + attr_reader :logical_table attr_reader :shard_key_name def initialize(command_name, input) @command_name = command_name Modified: plugins/sharding/logical_range_filter.rb (+16 -7) =================================================================== --- plugins/sharding/logical_range_filter.rb 2015-03-24 16:04:35 +0900 (d0d2c52) +++ plugins/sharding/logical_range_filter.rb 2015-03-24 16:08:40 +0900 (d5d4d05) @@ -24,13 +24,9 @@ module Groonga executor.execute result_sets = executor.result_sets - if result_sets.empty? - n_elements = 0 - else - n_elements = 1 # for columns - result_sets.each do |result_set| - n_elements += result_set.size - end + n_elements = 1 # for columns + result_sets.each do |result_set| + n_elements += result_set.size end writer.array("RESULTSET", n_elements) do @@ -68,12 +64,25 @@ module Groonga end def execute + first_table = nil @enumerator.each do |table, shard_key, shard_range| + first_table ||= table filter_shard(table, @filter, shard_key, shard_range, @enumerator.target_range) break if @current_limit == 0 end + if first_table.nil? + message = + "[logical_range_filter] no shard exists: " + + "logical_table: <#{@enumerator.logical_table}>: " + + "shard_key: <#{@enumerator.shard_key_name}>" + raise InvalidArgument, message + end + if @result_sets.empty? + @result_sets << HashTable.create(:flags => ObjectFlags::WITH_SUBREC, + :key_type => first_table) + end end def close Added: test/command/suite/sharding/logical_range_filter/index/no_condition/no_record.expected (+2 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/sharding/logical_range_filter/index/no_condition/no_record.expected 2015-03-24 16:08:40 +0900 (269d7e7) @@ -0,0 +1,2 @@ +logical_range_filter Logs timestamp +[[0,0.0,0.0],[[["memo","ShortText"],["message","Text"],["timestamp","Time"]]]] Added: test/command/suite/sharding/logical_range_filter/index/no_condition/no_record.test (+3 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/sharding/logical_range_filter/index/no_condition/no_record.test 2015-03-24 16:08:40 +0900 (138ab83) @@ -0,0 +1,3 @@ +#@include fixture/sharding/logical_range_filter/index/schema.grn + +logical_range_filter Logs timestamp Added: test/command/suite/sharding/logical_range_filter/invalid/no_shard.expected (+11 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/sharding/logical_range_filter/invalid/no_shard.expected 2015-03-24 16:08:40 +0900 (739b9c9) @@ -0,0 +1,11 @@ +logical_range_filter Logs timestamp +[ + [ + [ + -22, + 0.0, + 0.0 + ], + "[logical_range_filter] no shard exists: logical_table: <Logs>: shard_key: <timestamp>" + ] +] Added: test/command/suite/sharding/logical_range_filter/invalid/no_shard.test (+7 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/sharding/logical_range_filter/invalid/no_shard.test 2015-03-24 16:08:40 +0900 (58d0d7e) @@ -0,0 +1,7 @@ +#@disable-logging +#@on-error omit +register sharding +#@on-error default +#@enable-logging + +logical_range_filter Logs timestamp Added: test/command/suite/sharding/logical_range_filter/no_index/no_condition/no_record.expected (+2 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/sharding/logical_range_filter/no_index/no_condition/no_record.expected 2015-03-24 16:08:40 +0900 (269d7e7) @@ -0,0 +1,2 @@ +logical_range_filter Logs timestamp +[[0,0.0,0.0],[[["memo","ShortText"],["message","Text"],["timestamp","Time"]]]] Added: test/command/suite/sharding/logical_range_filter/no_index/no_condition/no_record.test (+3 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/sharding/logical_range_filter/no_index/no_condition/no_record.test 2015-03-24 16:08:40 +0900 (e167a49) @@ -0,0 +1,3 @@ +#@include fixture/sharding/logical_range_filter/no_index/schema.grn + +logical_range_filter Logs timestamp -------------- next part -------------- HTML����������������������������...Download