[Groonga-commit] groonga/groonga at 3a0393e [master] Support loading token filter options on open

Back to archive index
Kouhei Sutou null+****@clear*****
Mon Oct 29 16:50:05 JST 2018


Kouhei Sutou	2018-10-29 16:50:05 +0900 (Mon, 29 Oct 2018)

  Revision: 3a0393eed760dfe88e212f06c995fdcfd6348725
  https://github.com/groonga/groonga/commit/3a0393eed760dfe88e212f06c995fdcfd6348725

  Message:
    Support loading token filter options on open

  Modified files:
    lib/db.c
    test/command/suite/table_create/token_filters/options/double_array_trie.expected
    test/command/suite/table_create/token_filters/options/double_array_trie.test
    test/command/suite/table_create/token_filters/options/hash.expected
    test/command/suite/table_create/token_filters/options/hash.test
    test/command/suite/table_create/token_filters/options/patricia_trie.expected
    test/command/suite/table_create/token_filters/options/patricia_trie.test

  Modified: lib/db.c (+26 -7)
===================================================================
--- lib/db.c    2018-10-29 16:39:34 +0900 (7671e6c41)
+++ lib/db.c    2018-10-29 16:50:05 +0900 (f48a7a1c6)
@@ -9282,6 +9282,23 @@ grn_obj_set_info_table_module(grn_ctx *ctx,
                                            module_name);
 }
 
+static void
+grn_token_filters_add(grn_ctx *ctx,
+                      grn_obj *token_filters,
+                      grn_obj *token_filter_procs,
+                      grn_obj *token_filter)
+{
+  grn_table_module *table_module;
+  size_t n;
+
+  grn_bulk_space(ctx, token_filters, sizeof(grn_table_module));
+  n = GRN_BULK_VSIZE(token_filters) / sizeof(grn_table_module);
+  table_module = ((grn_table_module *)GRN_BULK_HEAD(token_filters)) + n - 1;
+  grn_table_module_init(ctx, table_module, grn_obj_id(ctx, token_filter));
+  grn_table_module_set_proc(ctx, table_module, token_filter);
+  GRN_PTR_PUT(ctx, token_filter_procs, token_filter);
+}
+
 static grn_rc
 grn_obj_set_info_table_modules(grn_ctx *ctx,
                                grn_obj *table,
@@ -9349,7 +9366,6 @@ grn_obj_set_info_table_modules(grn_ctx *ctx,
     grn_obj *proc;
     grn_id proc_id;
     grn_bool is_valid_proc = GRN_FALSE;
-    grn_table_module *raw_table_module;
 
     proc = grn_expr_simple_function_calls_get_function(ctx, expression, i);
     GRN_BULK_REWIND(&options);
@@ -9384,11 +9400,7 @@ grn_obj_set_info_table_modules(grn_ctx *ctx,
 
     proc_id = grn_obj_id(ctx, proc);
 
-    grn_bulk_space(ctx, table_modules, sizeof(grn_table_module));
-    raw_table_module = ((grn_table_module *)GRN_BULK_HEAD(table_modules)) + i;
-    grn_table_module_init(ctx, raw_table_module, proc_id);
-    grn_table_module_set_proc(ctx, raw_table_module, proc);
-    GRN_PTR_PUT(ctx, procs, proc);
+    grn_token_filters_add(ctx, table_modules, procs, proc);
 
     switch (type) {
     case GRN_INFO_TOKEN_FILTERS :
@@ -10985,6 +10997,7 @@ grn_db_obj_init(grn_ctx *ctx, grn_obj *db, grn_id id, grn_db_obj *obj)
 static void
 grn_token_filters_unpack(grn_ctx *ctx,
                          grn_obj *token_filters,
+                         grn_obj *token_filter_procs,
                          grn_obj *spec_vector)
 {
   grn_id *token_filter_ids;
@@ -11012,7 +11025,10 @@ grn_token_filters_unpack(grn_ctx *ctx,
           "nonexistent token filter ID: %d", token_filter_id);
       return;
     }
-    GRN_PTR_PUT(ctx, token_filters, token_filter);
+    grn_token_filters_add(ctx,
+                          token_filters,
+                          token_filter_procs,
+                          token_filter);
   }
 }
 
@@ -11170,6 +11186,7 @@ grn_ctx_at(grn_ctx *ctx, grn_id id)
                   UNPACK_INFO(spec, &decoded_spec);
                   vp->ptr->header.flags = flags;
                   grn_token_filters_unpack(ctx,
+                                           &(hash->token_filters),
                                            &(hash->token_filter_procs),
                                            &decoded_spec);
                 }
@@ -11183,6 +11200,7 @@ grn_ctx_at(grn_ctx *ctx, grn_id id)
                   UNPACK_INFO(spec, &decoded_spec);
                   vp->ptr->header.flags = flags;
                   grn_token_filters_unpack(ctx,
+                                           &(pat->token_filters),
                                            &(pat->token_filter_procs),
                                            &decoded_spec);
                   if (pat->tokenizer.proc) {
@@ -11201,6 +11219,7 @@ grn_ctx_at(grn_ctx *ctx, grn_id id)
                   UNPACK_INFO(spec, &decoded_spec);
                   vp->ptr->header.flags = flags;
                   grn_token_filters_unpack(ctx,
+                                           &(dat->token_filters),
                                            &(dat->token_filter_procs),
                                            &decoded_spec);
                 }

  Modified: test/command/suite/table_create/token_filters/options/double_array_trie.expected (+2 -0)
===================================================================
--- test/command/suite/table_create/token_filters/options/double_array_trie.expected    2018-10-29 16:39:34 +0900 (d814bd753)
+++ test/command/suite/table_create/token_filters/options/double_array_trie.expected    2018-10-29 16:50:05 +0900 (df19e5f75)
@@ -2,6 +2,8 @@ plugin_register token_filters/stop_word
 [[0,0.0,0.0],true]
 table_create Terms TABLE_DAT_KEY ShortText   --default_tokenizer TokenBigram   --normalizer NormalizerAuto   --token_filters 'TokenFilterStopWord("column", "ignore")'
 [[0,0.0,0.0],true]
+database_unmap
+[[0,0.0,0.0],true]
 dump
 plugin_register token_filters/stop_word
 

  Modified: test/command/suite/table_create/token_filters/options/double_array_trie.test (+2 -0)
===================================================================
--- test/command/suite/table_create/token_filters/options/double_array_trie.test    2018-10-29 16:39:34 +0900 (b51c27a77)
+++ test/command/suite/table_create/token_filters/options/double_array_trie.test    2018-10-29 16:50:05 +0900 (8f392b9c7)
@@ -5,4 +5,6 @@ table_create Terms TABLE_DAT_KEY ShortText \
   --normalizer NormalizerAuto \
   --token_filters 'TokenFilterStopWord("column", "ignore")'
 
+database_unmap
+
 dump

  Modified: test/command/suite/table_create/token_filters/options/hash.expected (+2 -0)
===================================================================
--- test/command/suite/table_create/token_filters/options/hash.expected    2018-10-29 16:39:34 +0900 (935510df2)
+++ test/command/suite/table_create/token_filters/options/hash.expected    2018-10-29 16:50:05 +0900 (11b6b4d87)
@@ -2,6 +2,8 @@ plugin_register token_filters/stop_word
 [[0,0.0,0.0],true]
 table_create Terms TABLE_HASH_KEY ShortText   --default_tokenizer TokenBigram   --normalizer NormalizerAuto   --token_filters 'TokenFilterStopWord("column", "ignore")'
 [[0,0.0,0.0],true]
+database_unmap
+[[0,0.0,0.0],true]
 dump
 plugin_register token_filters/stop_word
 

  Modified: test/command/suite/table_create/token_filters/options/hash.test (+2 -0)
===================================================================
--- test/command/suite/table_create/token_filters/options/hash.test    2018-10-29 16:39:34 +0900 (064715e36)
+++ test/command/suite/table_create/token_filters/options/hash.test    2018-10-29 16:50:05 +0900 (bd6ff0523)
@@ -5,4 +5,6 @@ table_create Terms TABLE_HASH_KEY ShortText \
   --normalizer NormalizerAuto \
   --token_filters 'TokenFilterStopWord("column", "ignore")'
 
+database_unmap
+
 dump

  Modified: test/command/suite/table_create/token_filters/options/patricia_trie.expected (+2 -0)
===================================================================
--- test/command/suite/table_create/token_filters/options/patricia_trie.expected    2018-10-29 16:39:34 +0900 (d6c700811)
+++ test/command/suite/table_create/token_filters/options/patricia_trie.expected    2018-10-29 16:50:05 +0900 (e751c4dba)
@@ -2,6 +2,8 @@ plugin_register token_filters/stop_word
 [[0,0.0,0.0],true]
 table_create Terms TABLE_PAT_KEY ShortText   --default_tokenizer TokenBigram   --normalizer NormalizerAuto   --token_filters 'TokenFilterStopWord("column", "ignore")'
 [[0,0.0,0.0],true]
+database_unmap
+[[0,0.0,0.0],true]
 dump
 plugin_register token_filters/stop_word
 

  Modified: test/command/suite/table_create/token_filters/options/patricia_trie.test (+2 -0)
===================================================================
--- test/command/suite/table_create/token_filters/options/patricia_trie.test    2018-10-29 16:39:34 +0900 (bd9700c41)
+++ test/command/suite/table_create/token_filters/options/patricia_trie.test    2018-10-29 16:50:05 +0900 (77ae5f3cb)
@@ -5,4 +5,6 @@ table_create Terms TABLE_PAT_KEY ShortText \
   --normalizer NormalizerAuto \
   --token_filters 'TokenFilterStopWord("column", "ignore")'
 
+database_unmap
+
 dump
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20181029/4f2b8ac7/attachment-0001.html>


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