[Groonga-commit] groonga/groonga at 147c4af [master] mruby: support regexp pattern for estimating size

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Apr 2 13:19:08 JST 2015


Kouhei Sutou	2015-04-02 13:19:08 +0900 (Thu, 02 Apr 2015)

  New Revision: 147c4af55627c4cf7cdfc9c95f00aa057de6b9f1
  https://github.com/groonga/groonga/commit/147c4af55627c4cf7cdfc9c95f00aa057de6b9f1

  Message:
    mruby: support regexp pattern for estimating size

  Modified files:
    lib/mrb/scripts/expression_size_estimator.rb

  Modified: lib/mrb/scripts/expression_size_estimator.rb (+14 -0)
===================================================================
--- lib/mrb/scripts/expression_size_estimator.rb    2015-04-02 13:03:17 +0900 (c1a84de)
+++ lib/mrb/scripts/expression_size_estimator.rb    2015-04-02 13:19:08 +0900 (722fcd3)
@@ -55,6 +55,8 @@ module Groonga
         case data.op
         when Operator::MATCH
           size = estimate_match(data, search_index)
+        when Operator::REGEXP
+          size = estimate_regexp(data, search_index)
         when Operator::EQUAL
           size = estimate_equal(data, search_index)
         when Operator::LESS,
@@ -82,6 +84,18 @@ module Groonga
       index_column.estimate_size(:query => data.query.value)
     end
 
+    def estimate_regexp(data, search_index)
+      index_column = search_index.index_column
+      while index_column.is_a?(Accessor)
+        index_info = index_column.find_index(Operator::REGEXP)
+        return nil if index_info.nil?
+        index_column = index_info.index
+      end
+
+      index_column.estimate_size(:query => data.query.value,
+                                 :mode => Operator::REGEXP)
+    end
+
     def estimate_equal(data, search_index)
       index_column = search_index.index_column
       if index_column.is_a?(Accessor)
-------------- next part --------------
HTML����������������������������...
Download 



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