Kouhei Sutou
null+****@clear*****
Thu Mar 16 15:18:08 JST 2017
Kouhei Sutou 2017-03-16 15:18:08 +0900 (Thu, 16 Mar 2017) New Revision: a2e8fba96b203e81dba87c79454077285b871dca https://github.com/groonga/groonga/commit/a2e8fba96b203e81dba87c79454077285b871dca Message: logical_select: support "filtered" stage dynamic columns Added files: test/command/suite/sharding/logical_select/columns/stage/filtered/drilldown.expected test/command/suite/sharding/logical_select/columns/stage/filtered/drilldown.test test/command/suite/sharding/logical_select/columns/stage/filtered/filter.expected test/command/suite/sharding/logical_select/columns/stage/filtered/filter.test test/command/suite/sharding/logical_select/columns/stage/filtered/output_columns.expected test/command/suite/sharding/logical_select/columns/stage/filtered/output_columns.test Modified files: plugins/sharding/logical_select.rb Modified: plugins/sharding/logical_select.rb (+8 -0) =================================================================== --- plugins/sharding/logical_select.rb 2017-03-16 15:17:47 +0900 (216bf74) +++ plugins/sharding/logical_select.rb 2017-03-16 15:18:08 +0900 (1432eb3) @@ -812,6 +812,14 @@ module Groonga return end + @context.dynamic_columns.each_filtered do |dynamic_column| + if result_set ==****@shard***** + @context.temporary_tables << result_set + result_set = create_all_match_table(result_set) + end + dynamic_column.apply(result_set, condition) + end + if @sort_keys.empty? @result_sets << result_set else Added: test/command/suite/sharding/logical_select/columns/stage/filtered/drilldown.expected (+116 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/sharding/logical_select/columns/stage/filtered/drilldown.expected 2017-03-16 15:18:08 +0900 (e3f29bb) @@ -0,0 +1,116 @@ +plugin_register sharding +[[0,0.0,0.0],true] +plugin_register functions/number +[[0,0.0,0.0],true] +table_create Logs_20170315 TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Logs_20170315 timestamp COLUMN_SCALAR Time +[[0,0.0,0.0],true] +column_create Logs_20170315 price COLUMN_SCALAR UInt32 +[[0,0.0,0.0],true] +table_create Logs_20170316 TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Logs_20170316 timestamp COLUMN_SCALAR Time +[[0,0.0,0.0],true] +column_create Logs_20170316 price COLUMN_SCALAR UInt32 +[[0,0.0,0.0],true] +table_create Logs_20170317 TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Logs_20170317 timestamp COLUMN_SCALAR Time +[[0,0.0,0.0],true] +column_create Logs_20170317 price COLUMN_SCALAR UInt32 +[[0,0.0,0.0],true] +load --table Logs_20170315 +[ +{"timestamp": "2017/03/15 00:00:00", "price": 1200}, +{"timestamp": "2017/03/15 01:00:00", "price": 1000} +] +[[0,0.0,0.0],2] +load --table Logs_20170316 +[ +{"timestamp": "2017/03/16 10:00:00", "price": 520}, +{"timestamp": "2017/03/16 11:00:00", "price": 510} +] +[[0,0.0,0.0],2] +load --table Logs_20170317 +[ +{"timestamp": "2017/03/17 20:00:00", "price": 500}, +{"timestamp": "2017/03/17 20:00:00", "price": 300} +] +[[0,0.0,0.0],2] +logical_select Logs --shard_key timestamp --columns[price_range].stage filtered --columns[price_range].type UInt32 --columns[price_range].flags COLUMN_SCALAR --columns[price_range].value 'number_classify(price, 500)' --output_columns price,price_range --drilldown price_range +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 6 + ], + [ + [ + "price", + "UInt32" + ], + [ + "price_range", + "UInt32" + ] + ], + [ + 1200, + 1000 + ], + [ + 1000, + 1000 + ], + [ + 520, + 500 + ], + [ + 510, + 500 + ], + [ + 500, + 500 + ], + [ + 300, + 0 + ] + ], + [ + [ + 3 + ], + [ + [ + "_key", + "UInt32" + ], + [ + "_nsubrecs", + "Int32" + ] + ], + [ + 1000, + 2 + ], + [ + 500, + 3 + ], + [ + 0, + 1 + ] + ] + ] +] Added: test/command/suite/sharding/logical_select/columns/stage/filtered/drilldown.test (+44 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/sharding/logical_select/columns/stage/filtered/drilldown.test 2017-03-16 15:18:08 +0900 (08d79b3) @@ -0,0 +1,44 @@ +#@on-error omit +plugin_register sharding +#@on-error default + +plugin_register functions/number + +table_create Logs_20170315 TABLE_NO_KEY +column_create Logs_20170315 timestamp COLUMN_SCALAR Time +column_create Logs_20170315 price COLUMN_SCALAR UInt32 + +table_create Logs_20170316 TABLE_NO_KEY +column_create Logs_20170316 timestamp COLUMN_SCALAR Time +column_create Logs_20170316 price COLUMN_SCALAR UInt32 + +table_create Logs_20170317 TABLE_NO_KEY +column_create Logs_20170317 timestamp COLUMN_SCALAR Time +column_create Logs_20170317 price COLUMN_SCALAR UInt32 + +load --table Logs_20170315 +[ +{"timestamp": "2017/03/15 00:00:00", "price": 1200}, +{"timestamp": "2017/03/15 01:00:00", "price": 1000} +] + +load --table Logs_20170316 +[ +{"timestamp": "2017/03/16 10:00:00", "price": 520}, +{"timestamp": "2017/03/16 11:00:00", "price": 510} +] + +load --table Logs_20170317 +[ +{"timestamp": "2017/03/17 20:00:00", "price": 500}, +{"timestamp": "2017/03/17 20:00:00", "price": 300} +] + +logical_select Logs \ + --shard_key timestamp \ + --columns[price_range].stage filtered \ + --columns[price_range].type UInt32 \ + --columns[price_range].flags COLUMN_SCALAR \ + --columns[price_range].value 'number_classify(price, 500)' \ + --output_columns price,price_range \ + --drilldown price_range Added: test/command/suite/sharding/logical_select/columns/stage/filtered/filter.expected (+92 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/sharding/logical_select/columns/stage/filtered/filter.expected 2017-03-16 15:18:08 +0900 (3c55a13) @@ -0,0 +1,92 @@ +plugin_register sharding +[[0,0.0,0.0],true] +table_create Logs_20170315 TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Logs_20170315 timestamp COLUMN_SCALAR Time +[[0,0.0,0.0],true] +column_create Logs_20170315 price COLUMN_SCALAR UInt32 +[[0,0.0,0.0],true] +table_create Logs_20170316 TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Logs_20170316 timestamp COLUMN_SCALAR Time +[[0,0.0,0.0],true] +column_create Logs_20170316 price COLUMN_SCALAR UInt32 +[[0,0.0,0.0],true] +table_create Logs_20170317 TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Logs_20170317 timestamp COLUMN_SCALAR Time +[[0,0.0,0.0],true] +column_create Logs_20170317 price COLUMN_SCALAR UInt32 +[[0,0.0,0.0],true] +load --table Logs_20170315 +[ +{"timestamp": "2017/03/15 00:00:00", "price": 1000}, +{"timestamp": "2017/03/15 01:00:00", "price": 900} +] +[[0,0.0,0.0],2] +load --table Logs_20170316 +[ +{"timestamp": "2017/03/16 10:00:00", "price": 520}, +{"timestamp": "2017/03/16 11:00:00", "price": 510} +] +[[0,0.0,0.0],2] +load --table Logs_20170317 +[ +{"timestamp": "2017/03/17 20:00:00", "price": 500}, +{"timestamp": "2017/03/17 20:00:00", "price": 300} +] +[[0,0.0,0.0],2] +logical_select Logs --shard_key timestamp --columns[filtered_id].stage filtered --columns[filtered_id].type UInt32 --columns[filtered_id].flags COLUMN_SCALAR --columns[filtered_id].value '_id' --filter 'price < 910' --output_columns _id,filtered_id,price +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 5 + ], + [ + [ + "_id", + "UInt32" + ], + [ + "filtered_id", + "UInt32" + ], + [ + "price", + "UInt32" + ] + ], + [ + 2, + 2, + 900 + ], + [ + 1, + 1, + 520 + ], + [ + 2, + 2, + 510 + ], + [ + 1, + 1, + 500 + ], + [ + 2, + 2, + 300 + ] + ] + ] +] Added: test/command/suite/sharding/logical_select/columns/stage/filtered/filter.test (+42 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/sharding/logical_select/columns/stage/filtered/filter.test 2017-03-16 15:18:08 +0900 (acb310a) @@ -0,0 +1,42 @@ +#@on-error omit +plugin_register sharding +#@on-error default + +table_create Logs_20170315 TABLE_NO_KEY +column_create Logs_20170315 timestamp COLUMN_SCALAR Time +column_create Logs_20170315 price COLUMN_SCALAR UInt32 + +table_create Logs_20170316 TABLE_NO_KEY +column_create Logs_20170316 timestamp COLUMN_SCALAR Time +column_create Logs_20170316 price COLUMN_SCALAR UInt32 + +table_create Logs_20170317 TABLE_NO_KEY +column_create Logs_20170317 timestamp COLUMN_SCALAR Time +column_create Logs_20170317 price COLUMN_SCALAR UInt32 + +load --table Logs_20170315 +[ +{"timestamp": "2017/03/15 00:00:00", "price": 1000}, +{"timestamp": "2017/03/15 01:00:00", "price": 900} +] + +load --table Logs_20170316 +[ +{"timestamp": "2017/03/16 10:00:00", "price": 520}, +{"timestamp": "2017/03/16 11:00:00", "price": 510} +] + +load --table Logs_20170317 +[ +{"timestamp": "2017/03/17 20:00:00", "price": 500}, +{"timestamp": "2017/03/17 20:00:00", "price": 300} +] + +logical_select Logs \ + --shard_key timestamp \ + --columns[filtered_id].stage filtered \ + --columns[filtered_id].type UInt32 \ + --columns[filtered_id].flags COLUMN_SCALAR \ + --columns[filtered_id].value '_id' \ + --filter 'price < 910' \ + --output_columns _id,filtered_id,price Added: test/command/suite/sharding/logical_select/columns/stage/filtered/output_columns.expected (+65 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/sharding/logical_select/columns/stage/filtered/output_columns.expected 2017-03-16 15:18:08 +0900 (b9a3a3e) @@ -0,0 +1,65 @@ +plugin_register sharding +[[0,0.0,0.0],true] +table_create Memos_20170315 TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Memos_20170315 timestamp COLUMN_SCALAR Time +[[0,0.0,0.0],true] +column_create Memos_20170315 content COLUMN_SCALAR Text +[[0,0.0,0.0],true] +table_create Memos_20170316 TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Memos_20170316 timestamp COLUMN_SCALAR Time +[[0,0.0,0.0],true] +column_create Memos_20170316 content COLUMN_SCALAR Text +[[0,0.0,0.0],true] +table_create Memos_20170317 TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Memos_20170317 timestamp COLUMN_SCALAR Time +[[0,0.0,0.0],true] +column_create Memos_20170317 content COLUMN_SCALAR Text +[[0,0.0,0.0],true] +load --table Memos_20170315 +[ +{"timestamp": "2017/03/15 00:00:00", "content": "Groonga is fast."}, +{"timestamp": "2017/03/15 01:00:00", "content": "Mroonga is fast and easy to use."} +] +[[0,0.0,0.0],2] +load --table Memos_20170316 +[ +{"timestamp": "2017/03/16 10:00:00", "content": "PGroonga is fast and easy to use."}, +{"timestamp": "2017/03/16 11:00:00", "content": "Rroonga is fast and easy to use."} +] +[[0,0.0,0.0],2] +logical_select Memos --shard_key timestamp --query 'content:@fast' --columns[highlighted_content].stage filtered --columns[highlighted_content].type Text --columns[highlighted_content].flags COLUMN_SCALAR --columns[highlighted_content].value 'highlight_html(content)' --output_columns highlighted_content +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 4 + ], + [ + [ + "highlighted_content", + "Text" + ] + ], + [ + "Groonga is <span class=\"keyword\">fast</span>." + ], + [ + "Mroonga is <span class=\"keyword\">fast</span> and easy to use." + ], + [ + "PGroonga is <span class=\"keyword\">fast</span> and easy to use." + ], + [ + "Rroonga is <span class=\"keyword\">fast</span> and easy to use." + ] + ] + ] +] Added: test/command/suite/sharding/logical_select/columns/stage/filtered/output_columns.test (+36 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/sharding/logical_select/columns/stage/filtered/output_columns.test 2017-03-16 15:18:08 +0900 (6981e43) @@ -0,0 +1,36 @@ +#@on-error omit +plugin_register sharding +#@on-error default + +table_create Memos_20170315 TABLE_NO_KEY +column_create Memos_20170315 timestamp COLUMN_SCALAR Time +column_create Memos_20170315 content COLUMN_SCALAR Text + +table_create Memos_20170316 TABLE_NO_KEY +column_create Memos_20170316 timestamp COLUMN_SCALAR Time +column_create Memos_20170316 content COLUMN_SCALAR Text + +table_create Memos_20170317 TABLE_NO_KEY +column_create Memos_20170317 timestamp COLUMN_SCALAR Time +column_create Memos_20170317 content COLUMN_SCALAR Text + +load --table Memos_20170315 +[ +{"timestamp": "2017/03/15 00:00:00", "content": "Groonga is fast."}, +{"timestamp": "2017/03/15 01:00:00", "content": "Mroonga is fast and easy to use."} +] + +load --table Memos_20170316 +[ +{"timestamp": "2017/03/16 10:00:00", "content": "PGroonga is fast and easy to use."}, +{"timestamp": "2017/03/16 11:00:00", "content": "Rroonga is fast and easy to use."} +] + +logical_select Memos \ + --shard_key timestamp \ + --query 'content:@fast' \ + --columns[highlighted_content].stage filtered \ + --columns[highlighted_content].type Text \ + --columns[highlighted_content].flags COLUMN_SCALAR \ + --columns[highlighted_content].value 'highlight_html(content)' \ + --output_columns highlighted_content -------------- next part -------------- HTML����������������������������... 다운로드