Kouhei Sutou
null+****@clear*****
Wed Oct 4 17:23:19 JST 2017
Kouhei Sutou 2017-10-04 17:23:19 +0900 (Wed, 04 Oct 2017) New Revision: 0839cf6d3dc96ebd4e9c90c0ea5cdff33023d374 https://github.com/groonga/groonga/commit/0839cf6d3dc96ebd4e9c90c0ea5cdff33023d374 Message: logical_select: fix a bug that offset over shards reduce limit unexpectedly Added files: test/command/suite/sharding/logical_select/offset/with_limit.expected test/command/suite/sharding/logical_select/offset/with_limit.test Modified files: plugins/sharding/logical_select.rb Modified: plugins/sharding/logical_select.rb (+1 -1) =================================================================== --- plugins/sharding/logical_select.rb 2017-10-04 12:49:54 +0900 (2dfb1b00c) +++ plugins/sharding/logical_select.rb 2017-10-04 17:23:19 +0900 (07ebf9e8e) @@ -155,11 +155,11 @@ module Groonga result_sets.each do |result_set| if result_set.size > current_offset writer.write_table_records(result_set, output_columns, options) + current_limit -= result_set.size end if current_offset > 0 current_offset = [current_offset - result_set.size, 0].max end - current_limit -= result_set.size break if current_limit <= 0 options[:offset] = current_offset options[:limit] = current_limit Added: test/command/suite/sharding/logical_select/offset/with_limit.expected (+119 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/sharding/logical_select/offset/with_limit.expected 2017-10-04 17:23:19 +0900 (a54eedd39) @@ -0,0 +1,119 @@ +plugin_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] +column_create Logs_20150203 memo COLUMN_SCALAR ShortText +[[0,0.0,0.0],true] +table_create Times_20150203 TABLE_PAT_KEY Time +[[0,0.0,0.0],true] +column_create Times_20150203 timestamp_index COLUMN_INDEX Logs_20150203 timestamp +[[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] +column_create Logs_20150204 memo COLUMN_SCALAR ShortText +[[0,0.0,0.0],true] +table_create Times_20150204 TABLE_PAT_KEY Time +[[0,0.0,0.0],true] +column_create Times_20150204 timestamp_index COLUMN_INDEX Logs_20150204 timestamp +[[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] +column_create Logs_20150205 memo COLUMN_SCALAR ShortText +[[0,0.0,0.0],true] +table_create Times_20150205 TABLE_PAT_KEY Time +[[0,0.0,0.0],true] +column_create Times_20150205 timestamp_index COLUMN_INDEX Logs_20150205 timestamp +[[0,0.0,0.0],true] +load --table Logs_20150203 +[ +{ + "timestamp": "2015-02-03 12:49:00", + "memo": "2015-02-03 12:49:00" +}, +{ + "timestamp": "2015-02-03 23:59:59", + "memo": "2015-02-03 23:59:59" +} +] +[[0,0.0,0.0],2] +load --table Logs_20150204 +[ +{ + "timestamp": "2015-02-04 00:00:00", + "memo": "2015-02-04 00:00:00" +}, +{ + "timestamp": "2015-02-04 13:49:00", + "memo": "2015-02-04 13:49:00" +}, +{ + "timestamp": "2015-02-04 13:50:00", + "memo": "2015-02-04 13:50:00" +} +] +[[0,0.0,0.0],3] +load --table Logs_20150205 +[ +{ + "timestamp": "2015-02-05 13:49:00", + "memo": "2015-02-05 13:49:00" +}, +{ + "timestamp": "2015-02-05 13:50:00", + "memo": "2015-02-05 13:50:00" +}, +{ + "timestamp": "2015-02-05 13:51:00", + "memo": "2015-02-05 13:51:00" +}, +{ + "timestamp": "2015-02-05 13:52:00", + "memo": "2015-02-05 13:52:00" +} +] +[[0,0.0,0.0],4] +logical_select Logs timestamp --offset 3 --limit 2 +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 9 + ], + [ + [ + "_id", + "UInt32" + ], + [ + "memo", + "ShortText" + ], + [ + "timestamp", + "Time" + ] + ], + [ + 2, + "2015-02-04 13:49:00", + 1423025340.0 + ], + [ + 3, + "2015-02-04 13:50:00", + 1423025400.0 + ] + ] + ] +] Added: test/command/suite/sharding/logical_select/offset/with_limit.test (+73 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/sharding/logical_select/offset/with_limit.test 2017-10-04 17:23:19 +0900 (e6dd3e1d2) @@ -0,0 +1,73 @@ +#@on-error omit +plugin_register sharding +#@on-error default + +table_create Logs_20150203 TABLE_NO_KEY +column_create Logs_20150203 timestamp COLUMN_SCALAR Time +column_create Logs_20150203 memo COLUMN_SCALAR ShortText +table_create Times_20150203 TABLE_PAT_KEY Time +column_create Times_20150203 timestamp_index COLUMN_INDEX Logs_20150203 timestamp + +table_create Logs_20150204 TABLE_NO_KEY +column_create Logs_20150204 timestamp COLUMN_SCALAR Time +column_create Logs_20150204 memo COLUMN_SCALAR ShortText +table_create Times_20150204 TABLE_PAT_KEY Time +column_create Times_20150204 timestamp_index COLUMN_INDEX Logs_20150204 timestamp + +table_create Logs_20150205 TABLE_NO_KEY +column_create Logs_20150205 timestamp COLUMN_SCALAR Time +column_create Logs_20150205 memo COLUMN_SCALAR ShortText +table_create Times_20150205 TABLE_PAT_KEY Time +column_create Times_20150205 timestamp_index COLUMN_INDEX Logs_20150205 timestamp + +load --table Logs_20150203 +[ +{ + "timestamp": "2015-02-03 12:49:00", + "memo": "2015-02-03 12:49:00" +}, +{ + "timestamp": "2015-02-03 23:59:59", + "memo": "2015-02-03 23:59:59" +} +] + +load --table Logs_20150204 +[ +{ + "timestamp": "2015-02-04 00:00:00", + "memo": "2015-02-04 00:00:00" +}, +{ + "timestamp": "2015-02-04 13:49:00", + "memo": "2015-02-04 13:49:00" +}, +{ + "timestamp": "2015-02-04 13:50:00", + "memo": "2015-02-04 13:50:00" +} +] + +load --table Logs_20150205 +[ +{ + "timestamp": "2015-02-05 13:49:00", + "memo": "2015-02-05 13:49:00" +}, +{ + "timestamp": "2015-02-05 13:50:00", + "memo": "2015-02-05 13:50:00" +}, +{ + "timestamp": "2015-02-05 13:51:00", + "memo": "2015-02-05 13:51:00" +}, +{ + "timestamp": "2015-02-05 13:52:00", + "memo": "2015-02-05 13:52:00" +} +] + +logical_select Logs timestamp \ + --offset 3 \ + --limit 2 -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20171004/4d0cb9e0/attachment-0001.htm