[Groonga-commit] groonga/groonga at 6d16cd2 [master] Add grn_match_info to grn_search_optarg

Back to archive index

Naoya Murakami null+****@clear*****
Tue Dec 27 20:57:25 JST 2016


Naoya Murakami	2016-12-27 20:57:25 +0900 (Tue, 27 Dec 2016)

  New Revision: 6d16cd2fd8a95178975a3a8deb7ba0412e3a03fe
  https://github.com/groonga/groonga/commit/6d16cd2fd8a95178975a3a8deb7ba0412e3a03fe

  Merged 6142da4: Merge pull request #618 from naoa/ii-set-min-for-and-operator

  Message:
    Add grn_match_info to grn_search_optarg
    
    It will be used for matched infomation such as minimum record id, matched position etc.

  Modified files:
    include/groonga/groonga.h
    lib/expr.c
    lib/grn_ii.h
    lib/ii.c
    lib/proc.c
    lib/proc/proc_fuzzy_search.c
    lib/proc/proc_select.c

  Modified: include/groonga/groonga.h (+10 -1)
===================================================================
--- include/groonga/groonga.h    2016-12-27 19:28:12 +0900 (f3a23cd)
+++ include/groonga/groonga.h    2016-12-27 20:57:25 +0900 (0171659)
@@ -800,6 +800,15 @@ struct _grn_fuzzy_search_optarg {
   int flags;
 };
 
+#define GRN_MATCH_INFO_GET_MIN_RECORD_ID                           (0x01)
+
+typedef struct _grn_match_info grn_match_info;
+
+struct _grn_match_info {
+  int flags;
+  grn_id *min;
+};
+
 typedef struct _grn_search_optarg grn_search_optarg;
 
 struct _grn_search_optarg {
@@ -814,7 +823,7 @@ struct _grn_search_optarg {
   grn_obj *scorer_args_expr;
   unsigned int scorer_args_expr_offset;
   grn_fuzzy_search_optarg fuzzy;
-  grn_id *min;
+  grn_match_info match_info;
 };
 
 GRN_API grn_rc grn_obj_search(grn_ctx *ctx, grn_obj *obj, grn_obj *query,

  Modified: lib/expr.c (+2 -1)
===================================================================
--- lib/expr.c    2016-12-27 19:28:12 +0900 (23e37a2)
+++ lib/expr.c    2016-12-27 20:57:25 +0900 (5dada58)
@@ -6689,6 +6689,7 @@ grn_table_select_index(grn_ctx *ctx, grn_obj *table, scan_info *si,
         optarg.max_size = 0;
         if (min) {
           previous_min = *min;
+          optarg.match_info.flags |= GRN_MATCH_INFO_GET_MIN_RECORD_ID;
         }
         ctx->flags |= GRN_CTX_TEMPORARY_DISABLE_II_RESOLVE_SEL_AND;
         for (j = 0; j < n_indexes; j++, ip++, wp += 2) {
@@ -6697,7 +6698,7 @@ grn_table_select_index(grn_ctx *ctx, grn_obj *table, scan_info *si,
           grn_id current_min;
           if (min) {
             current_min = previous_min;
-            optarg.min = &current_min;
+            optarg.match_info.min = &current_min;
           }
           if (sid) {
             int weight_index = sid - 1;

  Modified: lib/grn_ii.h (+1 -1)
===================================================================
--- lib/grn_ii.h    2016-12-27 19:28:12 +0900 (ea25474)
+++ lib/grn_ii.h    2016-12-27 20:57:25 +0900 (6c1930e)
@@ -154,7 +154,7 @@ struct _grn_select_optarg {
   grn_obj *scorer_args_expr;
   unsigned int scorer_args_expr_offset;
   grn_fuzzy_search_optarg fuzzy;
-  grn_id *min;
+  grn_match_info match_info;
 };
 
 GRN_API grn_rc grn_ii_column_update(grn_ctx *ctx, grn_ii *ii, grn_id id,

  Modified: lib/ii.c (+8 -6)
===================================================================
--- lib/ii.c    2016-12-27 19:28:12 +0900 (19030aa)
+++ lib/ii.c    2016-12-27 20:57:25 +0900 (25c408c)
@@ -7802,8 +7802,8 @@ grn_ii_select(grn_ctx *ctx, grn_ii *ii,
     } else if (optarg->vector_size) {
       wvm = optarg->weight_vector ? grn_wv_static : grn_wv_constant;
     }
-    if (optarg->min) {
-      previous_min = *optarg->min;
+    if (optarg->match_info.flags & GRN_MATCH_INFO_GET_MIN_RECORD_ID) {
+      previous_min = *(optarg->match_info.min);
       set_min_enable_for_and_query = GRN_TRUE;
     }
   }
@@ -8054,7 +8054,7 @@ exit :
 
   if (set_min_enable_for_and_query) {
     if (current_min > previous_min) {
-      *optarg->min = current_min;
+      *(optarg->match_info.min) = current_min;
     }
   }
 
@@ -8149,8 +8149,8 @@ grn_ii_estimate_size_for_query(grn_ctx *ctx, grn_ii *ii,
     default :
       break;
     }
-    if (optarg->min) {
-      min = *optarg->min;
+    if (optarg->match_info.flags & GRN_MATCH_INFO_GET_MIN_RECORD_ID) {
+      min = *(optarg->match_info.min);
     }
   }
 
@@ -8266,7 +8266,9 @@ grn_ii_sel(grn_ctx *ctx, grn_ii *ii, const char *string, unsigned int string_len
       arg.scorer = optarg->scorer;
       arg.scorer_args_expr = optarg->scorer_args_expr;
       arg.scorer_args_expr_offset = optarg->scorer_args_expr_offset;
-      arg.min = optarg->min;
+      if (optarg->match_info.flags) {
+        arg.match_info = optarg->match_info;
+      }
     }
     /* todo : support subrec
     grn_rset_init(ctx, s, grn_rec_document, 0, grn_rec_none, 0, 0);

  Modified: lib/proc.c (+0 -1)
===================================================================
--- lib/proc.c    2016-12-27 19:28:12 +0900 (a639055)
+++ lib/proc.c    2016-12-27 20:57:25 +0900 (b59a23f)
@@ -2855,7 +2855,6 @@ selector_in_values(grn_ctx *ctx, grn_obj *table, grn_obj *index,
     search_options.proc = NULL;
     search_options.max_size = 0;
     search_options.scorer = NULL;
-    search_options.min = NULL;
     if (i == n_values - 1) {
       ctx->flags &= ~GRN_CTX_TEMPORARY_DISABLE_II_RESOLVE_SEL_AND;
     }

  Modified: lib/proc/proc_fuzzy_search.c (+0 -1)
===================================================================
--- lib/proc/proc_fuzzy_search.c    2016-12-27 19:28:12 +0900 (dd1ef41)
+++ lib/proc/proc_fuzzy_search.c    2016-12-27 20:57:25 +0900 (bb1b6a6)
@@ -447,7 +447,6 @@ selector_fuzzy_search(grn_ctx *ctx, grn_obj *table, grn_obj *index,
     options.fuzzy.max_distance = max_distance;
     options.fuzzy.max_expansion = max_expansion;
     options.fuzzy.flags = flags;
-    options.min = NULL;
     grn_obj_search(ctx, target, query, res, op, &options);
   }
 

  Modified: lib/proc/proc_select.c (+0 -1)
===================================================================
--- lib/proc/proc_select.c    2016-12-27 19:28:12 +0900 (f37c232)
+++ lib/proc/proc_select.c    2016-12-27 20:57:25 +0900 (a78dbde)
@@ -1517,7 +1517,6 @@ grn_select_apply_adjuster_execute_adjust(grn_ctx *ctx,
     options.proc = NULL;
     options.max_size = 0;
     options.scorer = NULL;
-    options.min = NULL;
 
     grn_obj_search(ctx, index, value, table, GRN_OP_ADJUST, &options);
   }
-------------- next part --------------
HTML����������������������������...
Download 



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