[Groonga-commit] groonga/groonga at 755b90e [master] optimizer: add a test for case </<= and >/>= aren't neighbor

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Apr 7 17:28:40 JST 2016


Kouhei Sutou	2016-04-07 17:28:40 +0900 (Thu, 07 Apr 2016)

  New Revision: 755b90e326689b34e15914a7fbf8f734725d16bb
  https://github.com/groonga/groonga/commit/755b90e326689b34e15914a7fbf8f734725d16bb

  Message:
    optimizer: add a test for case </<= and >/>= aren't neighbor

  Modified files:
    lib/mrb/scripts/expression_tree/constant.rb
    test/mruby/suite/expression_rewriter/test_between.rb

  Modified: lib/mrb/scripts/expression_tree/constant.rb (+8 -0)
===================================================================
--- lib/mrb/scripts/expression_tree/constant.rb    2016-04-07 17:23:46 +0900 (8e7e0cc)
+++ lib/mrb/scripts/expression_tree/constant.rb    2016-04-07 17:28:40 +0900 (228a1fc)
@@ -9,6 +9,14 @@ module Groonga
       def build(expression)
         expression.append_constant(@value, Operator::PUSH, 1)
       end
+
+      def estimate_size(table)
+        if Bulk.true?(@value)
+          table.size
+        else
+          0
+        end
+      end
     end
   end
 end

  Modified: test/mruby/suite/expression_rewriter/test_between.rb (+31 -1)
===================================================================
--- test/mruby/suite/expression_rewriter/test_between.rb    2016-04-07 17:23:46 +0900 (bff2819)
+++ test/mruby/suite/expression_rewriter/test_between.rb    2016-04-07 17:28:40 +0900 (fc21af3)
@@ -24,7 +24,7 @@ class TestBetween < ExpressionRewriterTestCase
     teardown_expression
   end
 
-  def test_optimizable
+  def test_neighbor
     code =
       "timestamp >= '2015-10-01 00:00:00' && " +
       "timestamp <  '2015-11-00 00:00:00'"
@@ -41,4 +41,34 @@ class TestBetween < ExpressionRewriterTestCase
   expr:       <0..6>
     DUMP
   end
+
+  def test_spread
+    code =
+      "timestamp <  '2015-11-00 00:00:00' && " +
+      "1 == 1 && " +
+      "true && " +
+      "timestamp >= '2015-10-01 00:00:00'"
+    assert_equal(<<-DUMP, dump_rewritten_plan(code))
+[0]
+  op:         <call>
+  logical_op: <or>
+  args[0]:    <#<proc:function between arguments:[]>>
+  args[1]:    <#<column:fix_size Logs.timestamp range:Time type:scalar compress:none>>
+  args[2]:    <"2015-10-01 00:00:00">
+  args[3]:    <"include">
+  args[4]:    <"2015-11-00 00:00:00">
+  args[5]:    <"exclude">
+  expr:       <0..6>
+[1]
+  op:         <equal>
+  logical_op: <and>
+  query:      <1>
+  expr:       <7..9>
+[2]
+  op:         <push>
+  logical_op: <and>
+  query:      <(NULL)>
+  expr:       <11..11>
+    DUMP
+  end
 end
-------------- next part --------------
HTML����������������������������...
다운로드 



More information about the Groonga-commit mailing list
Back to archive index