Kouhei Sutou
null+****@clear*****
Tue May 22 16:45:01 JST 2018
Kouhei Sutou 2018-05-22 16:45:01 +0900 (Tue, 22 May 2018) New Revision: 32c5fa626165b8f7df847ae02d5de8c428bd118e https://github.com/groonga/groonga/commit/32c5fa626165b8f7df847ae02d5de8c428bd118e Message: test: add a missing test for in_values() optimization Added files: test/mruby/suite/expression_rewriter/test_in_values.rb Added: test/mruby/suite/expression_rewriter/test_in_values.rb (+65 -0) 100644 =================================================================== --- /dev/null +++ test/mruby/suite/expression_rewriter/test_in_values.rb 2018-05-22 16:45:01 +0900 (c446ad2ca) @@ -0,0 +1,65 @@ +class TestInValues < ExpressionRewriterTestCase + def setup + Groonga::Schema.define do |schema| + schema.create_table("expression_rewriters", + :type => :hash, + :key_type => :short_text) do |table| + table.text("plugin_name") + end + + schema.create_table("Events") do |table| + table.time("timestamp") + table.short_text("tag") + end + end + + @rewriters = Groonga["expression_rewriters"] + @rewriters.add("optimizer", + :plugin_name => "expression_rewriters/optimizer") + + @events = Groonga["Events"] + setup_expression(@events) + end + + def teardown + teardown_expression + end + + def test_only + code = + "tag == 'run' || tag == 'crash' || tag == 'shutdown'" + assert_equal(<<-DUMP, dump_rewritten_plan(code)) +[0] + op: <call> + logical_op: <or> + args[0]: <#<proc:function in_values arguments:[]>> + args[1]: <#<column:var_size Events.tag range:ShortText type:scalar compress:none>> + args[2]: <"run"> + args[3]: <"crash"> + args[4]: <"shutdown"> + expr: <0..5> + DUMP + end + + def test_combined + code = + "tag != 'error' && (tag == 'run' || tag == 'crash' || tag == 'shutdown')" + assert_equal(<<-DUMP, dump_rewritten_plan(code)) +[0] + op: <not_equal> + logical_op: <or> + index: <[]> + query: <"error"> + expr: <0..2> +[1] + op: <call> + logical_op: <and> + args[0]: <#<proc:function in_values arguments:[]>> + args[1]: <#<column:var_size Events.tag range:ShortText type:scalar compress:none>> + args[2]: <"run"> + args[3]: <"crash"> + args[4]: <"shutdown"> + expr: <3..8> + DUMP + end +end -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180522/d441f24d/attachment-0001.htm