[Groonga-commit] groonga/groonga at 8fb20ec [master] optimizer: reuse constant bulk/vector

Back to archive index
Kouhei Sutou null+****@clear*****
Sat Apr 20 08:57:30 JST 2019


Kouhei Sutou	2019-04-20 08:57:30 +0900 (Sat, 20 Apr 2019)

  Revision: 8fb20ec48c394b537ddc85e0bbba33509396028b
  https://github.com/groonga/groonga/commit/8fb20ec48c394b537ddc85e0bbba33509396028b

  Message:
    optimizer: reuse constant bulk/vector

  Modified files:
    lib/mrb/scripts/expression_tree/constant.rb
    lib/mrb/scripts/expression_tree_builder.rb

  Modified: lib/mrb/scripts/expression_tree/constant.rb (+12 -1)
===================================================================
--- lib/mrb/scripts/expression_tree/constant.rb    2019-04-20 08:57:03 +0900 (626bb332e)
+++ lib/mrb/scripts/expression_tree/constant.rb    2019-04-20 08:57:30 +0900 (0e05611ae)
@@ -3,6 +3,8 @@ module Groonga
     class Constant
       attr_reader :value
       def initialize(value)
+        # Groonga::Bulk, Groonga::Vector or raw Ruby object.
+        # Should we unify to Groonga::*?
         @value = value
       end
 
@@ -15,12 +17,21 @@ module Groonga
       end
 
       def estimate_size(table)
-        if Bulk.true?(@value)
+        if true_value?
           table.size
         else
           0
         end
       end
+
+      private
+      def true_value?
+        if****@value*****_to?(:true?)
+          @value.true?
+        else
+          Bulk.true?(@value)
+        end
+      end
     end
   end
 end

  Modified: lib/mrb/scripts/expression_tree_builder.rb (+1 -1)
===================================================================
--- lib/mrb/scripts/expression_tree_builder.rb    2019-04-20 08:57:03 +0900 (59695581f)
+++ lib/mrb/scripts/expression_tree_builder.rb    2019-04-20 08:57:30 +0900 (c49938c34)
@@ -145,7 +145,7 @@ module Groonga
           when Void
             node = ExpressionTree::Null.new
           else
-            node = ExpressionTree::Constant.new(code.value.value)
+            node = ExpressionTree::Constant.new(code.value)
           end
           stack.push(node)
         when Operator::CALL
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190420/8854adcd/attachment-0001.html>


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