[Groonga-commit] groonga/groonga [master] Extract grn_column_index() for column + GRN_OP_MATCH family

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Jan 17 16:16:12 JST 2013


Kouhei Sutou	2013-01-17 16:16:12 +0900 (Thu, 17 Jan 2013)

  New Revision: 7e07c2515911483c69c22c8350c58d0761f11bfd
  https://github.com/groonga/groonga/commit/7e07c2515911483c69c22c8350c58d0761f11bfd

  Log:
    Extract grn_column_index() for column + GRN_OP_MATCH family

  Modified files:
    lib/db.c

  Modified: lib/db.c (+25 -10)
===================================================================
--- lib/db.c    2013-01-17 16:14:24 +0900 (97276de)
+++ lib/db.c    2013-01-17 16:16:12 +0900 (d61b23a)
@@ -7805,6 +7805,29 @@ grn_column_index_column_equal(grn_ctx *ctx, grn_obj *obj, grn_operator op,
 }
 
 static inline int
+grn_column_index_column_match(grn_ctx *ctx, grn_obj *obj, grn_operator op,
+                              grn_obj **indexbuf, int buf_size, int *section)
+{
+  int n = 0;
+  grn_obj **ip = indexbuf;
+  grn_hook *hooks;
+
+  for (hooks = DB_OBJ(obj)->hooks[GRN_HOOK_SET]; hooks; hooks = hooks->next) {
+    default_set_value_hook_data *data = (void *)NEXT_ADDR(hooks);
+    grn_obj *target = grn_ctx_at(ctx, data->target);
+    if (target->header.type != GRN_COLUMN_INDEX) { continue; }
+    if (section) { *section = (MULTI_COLUMN_INDEXP(target)) ? data->section : 0; }
+    if (n < buf_size) {
+      *ip++ = target;
+    }
+    n++;
+  }
+
+  return n;
+}
+
+
+static inline int
 grn_column_index_accessor_match(grn_ctx *ctx, grn_obj *obj, grn_operator op,
                                 grn_obj **indexbuf, int buf_size, int *section)
 {
@@ -7873,16 +7896,8 @@ grn_column_index(grn_ctx *ctx, grn_obj *obj, grn_operator op,
     case GRN_OP_NEAR :
     case GRN_OP_NEAR2 :
     case GRN_OP_SIMILAR :
-      for (hooks = DB_OBJ(obj)->hooks[GRN_HOOK_SET]; hooks; hooks = hooks->next) {
-        default_set_value_hook_data *data = (void *)NEXT_ADDR(hooks);
-        grn_obj *target = grn_ctx_at(ctx, data->target);
-        if (target->header.type != GRN_COLUMN_INDEX) { continue; }
-        if (section) { *section = (MULTI_COLUMN_INDEXP(target)) ? data->section : 0; }
-        if (n < buf_size) {
-          *ip++ = target;
-        }
-        n++;
-      }
+      n = grn_column_index_column_match(ctx, obj, op,
+                                        indexbuf, buf_size, section);
       break;
     case GRN_OP_LESS :
     case GRN_OP_GREATER :
-------------- next part --------------
HTML����������������������������...
Descargar 



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