[Groonga-commit] groonga/groonga at 00936c4 [master] ii: use element index of vector as position for no tokenizer lexicon

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Feb 5 19:16:11 JST 2016


Kouhei Sutou	2016-02-05 19:16:11 +0900 (Fri, 05 Feb 2016)

  New Revision: 00936c40dbda0bf85e08b57e955aebd1a409df13
  https://github.com/groonga/groonga/commit/00936c40dbda0bf85e08b57e955aebd1a409df13

  Message:
    ii: use element index of vector as position for no tokenizer lexicon

  Modified files:
    lib/ii.c

  Modified: lib/ii.c (+10 -1)
===================================================================
--- lib/ii.c    2016-02-05 18:43:52 +0900 (bf84a7a)
+++ lib/ii.c    2016-02-05 19:16:11 +0900 (ae8ca06)
@@ -5140,10 +5140,13 @@ grn_uvector2updspecs_data(grn_ctx *ctx, grn_ii *ii, grn_id rid,
   n = grn_uvector_size(ctx, in);
   element_size = grn_uvector_element_size(ctx, in);
   for (i = 0; i < n; i++) {
+    grn_obj *tokenizer;
     grn_token_cursor *token_cursor;
     unsigned int token_flags = 0;
     const char *element;
 
+    tokenizer = grn_obj_get_info(ctx, lexicon, GRN_INFO_DEFAULT_TOKENIZER, NULL);
+
     element = GRN_BULK_HEAD(in) + (element_size * i);
     token_cursor = grn_token_cursor_open(ctx, lexicon,
                                          element, element_size,
@@ -5156,6 +5159,7 @@ grn_uvector2updspecs_data(grn_ctx *ctx, grn_ii *ii, grn_id rid,
       grn_id tid;
       if ((tid = grn_token_cursor_next(ctx, token_cursor))) {
         grn_ii_updspec **u;
+        int pos;
 
         if (posting) { GRN_RECORD_PUT(ctx, posting, tid); }
         if (!grn_hash_add(ctx, h, &tid, sizeof(grn_id), (void **)&u, NULL)) {
@@ -5169,7 +5173,12 @@ grn_uvector2updspecs_data(grn_ctx *ctx, grn_ii *ii, grn_id rid,
             return GRN_NO_MEMORY_AVAILABLE;
           }
         }
-        if (grn_ii_updspec_add(ctx, *u, token_cursor->pos, 0)) {
+        if (tokenizer) {
+          pos = token_cursor->pos;
+        } else {
+          pos = i;
+        }
+        if (grn_ii_updspec_add(ctx, *u, pos, 0)) {
           GRN_LOG(ctx, GRN_LOG_ALERT,
                   "grn_ii_updspec_add on grn_uvector2updspecs failed!");
           grn_token_cursor_close(ctx, token_cursor);
-------------- next part --------------
HTML����������������������������...
다운로드 



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