[Groonga-commit] groonga/groonga at 2925361 [master] mrb: implement resolving index for match in mruby

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jun 11 22:35:02 JST 2014


Kouhei Sutou	2014-06-11 22:35:02 +0900 (Wed, 11 Jun 2014)

  New Revision: 292536167bb52934af2755f4e41799c8eaab57c8
  https://github.com/groonga/groonga/commit/292536167bb52934af2755f4e41799c8eaab57c8

  Message:
    mrb: implement resolving index for match in mruby

  Modified files:
    lib/mrb/mrb_expr.c
    lib/mrb/scripts/scan_info.rb

  Modified: lib/mrb/mrb_expr.c (+1 -22)
===================================================================
--- lib/mrb/mrb_expr.c    2014-06-11 15:16:49 +0900 (fa3840b)
+++ lib/mrb/mrb_expr.c    2014-06-11 22:35:02 +0900 (194aa7c)
@@ -173,28 +173,7 @@ scan_info_build(grn_ctx *ctx, grn_obj *expr, int *n,
       mrb_funcall(mrb, mrb_si, "op=", 1, mrb_fixnum_value(c->op));
       mrb_funcall(mrb, mrb_si, "end=", 1, mrb_fixnum_value(c - e->codes));
       sis[i++] = si;
-      {
-        int k;
-        grn_obj *arg, **p = &arg;
-        for (k = 0; (arg = grn_scan_info_get_arg(ctx, si, k)) ; k++) {
-          if ((*p)->header.type == GRN_EXPR) {
-            mrb_value mrb_expr;
-            mrb_expr = grn_mrb_value_from_grn_obj(mrb, *p);
-            mrb_funcall(mrb, mrb_si, "match_resolve_index_expression",
-                        1, mrb_expr);
-          } else if (GRN_DB_OBJP(*p)) {
-            mrb_value mrb_db_obj = grn_mrb_value_from_grn_obj(mrb, *p);
-            mrb_funcall(mrb, mrb_si, "match_resolve_index_db_obj", 1, mrb_db_obj);
-          } else if (GRN_ACCESSORP(*p)) {
-            mrb_value mrb_accessor = grn_mrb_value_from_grn_obj(mrb, *p);
-            mrb_funcall(mrb, mrb_si, "match_resolve_index_accessor", 1, mrb_accessor);
-          } else {
-            mrb_value mrb_query;
-            mrb_query = grn_mrb_value_from_grn_obj(mrb, *p);
-            mrb_funcall(mrb, mrb_si, "query=", 1, mrb_query);
-          }
-        }
-      }
+      mrb_funcall(mrb, mrb_si, "match_resolve_index", 0);
       si = NULL;
       break;
     case GRN_OP_AND :

  Modified: lib/mrb/scripts/scan_info.rb (+15 -0)
===================================================================
--- lib/mrb/scripts/scan_info.rb    2014-06-11 15:16:49 +0900 (18636c1)
+++ lib/mrb/scripts/scan_info.rb    2014-06-11 22:35:02 +0900 (3ef7def)
@@ -18,6 +18,21 @@ module Groonga
       nil
     end
 
+    def match_resolve_index
+      each_arg do |arg|
+        case arg
+        when Expression
+          match_resolve_index_expression(arg)
+        when Accessor
+          match_resolve_index_accessor(arg)
+        when Object
+          match_resolve_index_db_obj(arg)
+        else
+          self.query = arg
+        end
+      end
+    end
+
     def match_resolve_index_expression(expression)
       codes = expression.codes
       n_codes = codes.size
-------------- next part --------------
HTML����������������������������...
下载 



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