[Groonga-commit] groonga/groonga at 61f47e1 [master] grn_table_tokenizer -> grn_table_module

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Apr 10 15:01:06 JST 2018


Kouhei Sutou	2018-04-10 15:01:06 +0900 (Tue, 10 Apr 2018)

  New Revision: 61f47e1ef554584e78d9a23857ea3f0102a810e9
  https://github.com/groonga/groonga/commit/61f47e1ef554584e78d9a23857ea3f0102a810e9

  Message:
    grn_table_tokenizer -> grn_table_module

  Modified files:
    lib/dat.cpp
    lib/db.c
    lib/grn_dat.h
    lib/grn_hash.h
    lib/grn_pat.h
    lib/grn_table.h
    lib/hash.c
    lib/pat.c
    lib/table.c

  Modified: lib/dat.cpp (+3 -3)
===================================================================
--- lib/dat.cpp    2018-04-10 14:55:03 +0900 (cce66a586)
+++ lib/dat.cpp    2018-04-10 15:01:06 +0900 (2df9921f4)
@@ -149,7 +149,7 @@ grn_dat_fin(grn_ctx *ctx, grn_dat *dat)
     grn_io_close(ctx, dat->io);
     dat->io = NULL;
   }
-  grn_table_tokenizer_fin(ctx, &(dat->tokenizer));
+  grn_table_module_fin(ctx, &(dat->tokenizer));
   GRN_OBJ_FIN(ctx, &(dat->token_filters));
 }
 
@@ -355,7 +355,7 @@ grn_dat_create(grn_ctx *ctx, const char *path, uint32_t,
     dat->header->normalizer = GRN_ID_NIL;
   }
   dat->encoding = encoding;
-  grn_table_tokenizer_init(ctx, &(dat->tokenizer), GRN_ID_NIL);
+  grn_table_module_init(ctx, &(dat->tokenizer), GRN_ID_NIL);
   GRN_PTR_INIT(&(dat->token_filters), GRN_OBJ_VECTOR, GRN_ID_NIL);
 
   dat->obj.header.flags = dat->header->flags;
@@ -391,7 +391,7 @@ grn_dat_open(grn_ctx *ctx, const char *path)
   }
   dat->file_id = dat->header->file_id;
   dat->encoding = dat->header->encoding;
-  grn_table_tokenizer_init(ctx, &(dat->tokenizer), dat->header->tokenizer);
+  grn_table_module_init(ctx, &(dat->tokenizer), dat->header->tokenizer);
   if (dat->header->flags & GRN_OBJ_KEY_NORMALIZE) {
     dat->header->flags &= ~GRN_OBJ_KEY_NORMALIZE;
     dat->normalizer = grn_ctx_get(ctx, GRN_NORMALIZER_AUTO_NAME, -1);

  Modified: lib/db.c (+9 -9)
===================================================================
--- lib/db.c    2018-04-10 14:55:03 +0900 (59c7420a4)
+++ lib/db.c    2018-04-10 15:01:06 +0900 (5938729d4)
@@ -9101,24 +9101,24 @@ grn_obj_set_info_default_tokenizer(grn_ctx *ctx,
   }
   switch (DB_OBJ(table)->header.type) {
   case GRN_TABLE_HASH_KEY :
-    grn_table_tokenizer_set_proc(ctx,
-                                 &(((grn_hash *)table)->tokenizer),
-                                 tokenizer);
+    grn_table_module_set_proc(ctx,
+                              &(((grn_hash *)table)->tokenizer),
+                              tokenizer);
     ((grn_hash *)table)->header.common->tokenizer = tokenizer_id;
     break;
   case GRN_TABLE_PAT_KEY :
-    grn_table_tokenizer_set_proc(ctx,
-                                 &(((grn_pat *)table)->tokenizer),
-                                 tokenizer);
+    grn_table_module_set_proc(ctx,
+                              &(((grn_pat *)table)->tokenizer),
+                              tokenizer);
     ((grn_pat *)table)->header->tokenizer = tokenizer_id;
     grn_pat_cache_enable(ctx,
                          ((grn_pat *)table),
                          GRN_TABLE_PAT_KEY_CACHE_SIZE);
     break;
   case GRN_TABLE_DAT_KEY :
-    grn_table_tokenizer_set_proc(ctx,
-                                 &(((grn_dat *)table)->tokenizer),
-                                 tokenizer);
+    grn_table_module_set_proc(ctx,
+                              &(((grn_dat *)table)->tokenizer),
+                              tokenizer);
     ((grn_dat *)table)->header->tokenizer = tokenizer_id;
     break;
   default :

  Modified: lib/grn_dat.h (+1 -1)
===================================================================
--- lib/grn_dat.h    2018-04-10 14:55:03 +0900 (925c35c30)
+++ lib/grn_dat.h    2018-04-10 15:01:06 +0900 (4df03a5b1)
@@ -34,7 +34,7 @@ struct _grn_dat {
   grn_encoding encoding;
   void *trie;
   void *old_trie;
-  grn_table_tokenizer tokenizer;
+  grn_table_module tokenizer;
   grn_obj *normalizer;
   grn_obj token_filters;
   grn_critical_section lock;

  Modified: lib/grn_hash.h (+1 -1)
===================================================================
--- lib/grn_hash.h    2018-04-10 14:55:03 +0900 (7c90ae356)
+++ lib/grn_hash.h    2018-04-10 15:01:06 +0900 (5fd0d09a4)
@@ -193,7 +193,7 @@ struct _grn_hash {
   uint32_t *n_garbages;
   uint32_t *n_entries;
   uint32_t *max_offset;
-  grn_table_tokenizer tokenizer;
+  grn_table_module tokenizer;
   grn_obj *normalizer;
   grn_obj token_filters;
 

  Modified: lib/grn_pat.h (+2 -2)
===================================================================
--- lib/grn_pat.h    2018-04-10 14:55:03 +0900 (e07644f4f)
+++ lib/grn_pat.h    2018-04-10 15:01:06 +0900 (5ea500410)
@@ -1,6 +1,6 @@
 /* -*- c-basic-offset: 2 -*- */
 /*
-  Copyright(C) 2009-2016 Brazil
+  Copyright(C) 2009-2018 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -37,7 +37,7 @@ struct _grn_pat {
   grn_encoding encoding;
   uint32_t key_size;
   uint32_t value_size;
-  grn_table_tokenizer tokenizer;
+  grn_table_module tokenizer;
   grn_obj *normalizer;
   grn_obj token_filters;
   grn_id *cache;

  Modified: lib/grn_table.h (+15 -15)
===================================================================
--- lib/grn_table.h    2018-04-10 14:55:03 +0900 (eafb3dbe3)
+++ lib/grn_table.h    2018-04-10 15:01:06 +0900 (6111d54b8)
@@ -30,21 +30,21 @@ typedef struct {
   grn_option_revision options_revision;
   grn_close_func options_close_func;
   grn_critical_section lock;
-} grn_table_tokenizer;
-
-void grn_table_tokenizer_init(grn_ctx *ctx,
-                              grn_table_tokenizer *tokenizer,
-                              grn_id tokenizer_id);
-void grn_table_tokenizer_set_proc(grn_ctx *ctx,
-                                  grn_table_tokenizer *tokenizer,
-                                  grn_obj *proc);
-void grn_table_tokenizer_set_options(grn_ctx *ctx,
-                                     grn_table_tokenizer *tokenizer,
-                                     void *options,
-                                     grn_option_revision revision,
-                                     grn_close_func close_func);
-void grn_table_tokenizer_fin(grn_ctx *ctx,
-                             grn_table_tokenizer *tokenizer);
+} grn_table_module;
+
+void grn_table_module_init(grn_ctx *ctx,
+                           grn_table_module *module,
+                           grn_id module_id);
+void grn_table_module_set_proc(grn_ctx *ctx,
+                               grn_table_module *module,
+                               grn_obj *proc);
+void grn_table_module_set_options(grn_ctx *ctx,
+                                  grn_table_module *module,
+                                  void *options,
+                                  grn_option_revision revision,
+                                  grn_close_func close_func);
+void grn_table_module_fin(grn_ctx *ctx,
+                          grn_table_module *module);
 
 #ifdef __cplusplus
 }

  Modified: lib/hash.c (+5 -5)
===================================================================
--- lib/hash.c    2018-04-10 14:55:03 +0900 (a551c1705)
+++ lib/hash.c    2018-04-10 15:01:06 +0900 (dbba68806)
@@ -1726,7 +1726,7 @@ grn_io_hash_init(grn_ctx *ctx, grn_hash *hash, const char *path,
   hash->io = io;
   hash->header.common = header;
   hash->lock = &header->lock;
-  grn_table_tokenizer_init(ctx, &(hash->tokenizer), GRN_ID_NIL);
+  grn_table_module_init(ctx, &(hash->tokenizer), GRN_ID_NIL);
   return GRN_SUCCESS;
 }
 
@@ -1785,7 +1785,7 @@ grn_tiny_hash_init(grn_ctx *ctx, grn_hash *hash, const char *path,
   hash->n_garbages_ = 0;
   hash->n_entries_ = 0;
   hash->garbages = GRN_ID_NIL;
-  grn_table_tokenizer_init(ctx, &(hash->tokenizer), GRN_ID_NIL);
+  grn_table_module_init(ctx, &(hash->tokenizer), GRN_ID_NIL);
   hash->normalizer = NULL;
   GRN_PTR_INIT(&(hash->token_filters), GRN_OBJ_VECTOR, GRN_ID_NIL);
   grn_tiny_array_init(ctx, &hash->a, entry_size, GRN_TINY_ARRAY_CLEAR);
@@ -1853,7 +1853,7 @@ grn_hash_open(grn_ctx *ctx, const char *path)
             hash->io = io;
             hash->header.common = header;
             hash->lock = &header->lock;
-            grn_table_tokenizer_init(ctx, &(hash->tokenizer), header->tokenizer);
+            grn_table_module_init(ctx, &(hash->tokenizer), header->tokenizer);
             if (header->flags & GRN_OBJ_KEY_NORMALIZE) {
               header->flags &= ~GRN_OBJ_KEY_NORMALIZE;
               hash->normalizer = grn_ctx_get(ctx, GRN_NORMALIZER_AUTO_NAME, -1);
@@ -1906,7 +1906,7 @@ grn_io_hash_fin(grn_ctx *ctx, grn_hash *hash)
   grn_rc rc;
 
   rc = grn_io_close(ctx, hash->io);
-  grn_table_tokenizer_fin(ctx, &(hash->tokenizer));
+  grn_table_module_fin(ctx, &(hash->tokenizer));
   GRN_OBJ_FIN(ctx, &(hash->token_filters));
   return rc;
 }
@@ -1918,7 +1918,7 @@ grn_tiny_hash_fin(grn_ctx *ctx, grn_hash *hash)
     return GRN_INVALID_ARGUMENT;
   }
 
-  grn_table_tokenizer_fin(ctx, &(hash->tokenizer));
+  grn_table_module_fin(ctx, &(hash->tokenizer));
   GRN_OBJ_FIN(ctx, &(hash->token_filters));
 
   if (hash->obj.header.flags & GRN_OBJ_KEY_VAR_SIZE) {

  Modified: lib/pat.c (+3 -3)
===================================================================
--- lib/pat.c    2018-04-10 14:55:03 +0900 (42c1656de)
+++ lib/pat.c    2018-04-10 15:01:06 +0900 (eee4a1aa8)
@@ -514,7 +514,7 @@ _grn_pat_create(grn_ctx *ctx, grn_pat *pat,
   pat->header = header;
   pat->key_size = key_size;
   pat->value_size = value_size;
-  grn_table_tokenizer_init(ctx, &(pat->tokenizer), GRN_ID_NIL);
+  grn_table_module_init(ctx, &(pat->tokenizer), GRN_ID_NIL);
   pat->encoding = encoding;
   pat->obj.header.flags = header->flags;
   if (!(node0 = pat_get(ctx, pat, 0))) {
@@ -616,7 +616,7 @@ grn_pat_open(grn_ctx *ctx, const char *path)
   pat->key_size = header->key_size;
   pat->value_size = header->value_size;
   pat->encoding = header->encoding;
-  grn_table_tokenizer_init(ctx, &(pat->tokenizer), header->tokenizer);
+  grn_table_module_init(ctx, &(pat->tokenizer), header->tokenizer);
   if (header->flags & GRN_OBJ_KEY_NORMALIZE) {
     header->flags &= ~GRN_OBJ_KEY_NORMALIZE;
     pat->normalizer = grn_ctx_get(ctx, GRN_NORMALIZER_AUTO_NAME, -1);
@@ -674,7 +674,7 @@ grn_pat_close(grn_ctx *ctx, grn_pat *pat)
   if (rc != GRN_SUCCESS) {
     ERR(rc, "[pat][close] failed to close IO");
   }
-  grn_table_tokenizer_fin(ctx, &(pat->tokenizer));
+  grn_table_module_fin(ctx, &(pat->tokenizer));
   grn_pvector_fin(ctx, &pat->token_filters);
   if (pat->cache) { grn_pat_cache_disable(ctx, pat); }
   GRN_FREE(pat);

  Modified: lib/table.c (+45 -45)
===================================================================
--- lib/table.c    2018-04-10 14:55:03 +0900 (66f179c8b)
+++ lib/table.c    2018-04-10 15:01:06 +0900 (12c90961b)
@@ -127,69 +127,69 @@ grn_table_find_reference_object(grn_ctx *ctx, grn_obj *table)
 }
 
 void
-grn_table_tokenizer_init(grn_ctx *ctx,
-                         grn_table_tokenizer *tokenizer,
-                         grn_id tokenizer_id)
+grn_table_module_init(grn_ctx *ctx,
+                      grn_table_module *module,
+                      grn_id module_id)
 {
-  if (tokenizer_id == GRN_ID_NIL) {
-    tokenizer->proc = NULL;
+  if (module_id == GRN_ID_NIL) {
+    module->proc = NULL;
   } else {
-    tokenizer->proc = grn_ctx_at(ctx, tokenizer_id);
+    module->proc = grn_ctx_at(ctx, module_id);
   }
-  tokenizer->options = NULL;
-  tokenizer->options_revision = GRN_OPTION_REVISION_NONE;
-  tokenizer->options_close_func = NULL;
-  CRITICAL_SECTION_INIT(tokenizer->lock);
+  module->options = NULL;
+  module->options_revision = GRN_OPTION_REVISION_NONE;
+  module->options_close_func = NULL;
+  CRITICAL_SECTION_INIT(module->lock);
 }
 
 static void
-grn_table_tokenizer_fin_options(grn_ctx *ctx,
-                                grn_table_tokenizer *tokenizer)
+grn_table_module_fin_options(grn_ctx *ctx,
+                             grn_table_module *module)
 {
-  if (tokenizer->options && tokenizer->options_close_func) {
-    tokenizer->options_close_func(ctx, tokenizer->options);
-    tokenizer->options = NULL;
-    tokenizer->options_revision = GRN_OPTION_REVISION_NONE;
-    tokenizer->options_close_func = NULL;
+  if (module->options && module->options_close_func) {
+    module->options_close_func(ctx, module->options);
+    module->options = NULL;
+    module->options_revision = GRN_OPTION_REVISION_NONE;
+    module->options_close_func = NULL;
   }
 }
 
 void
-grn_table_tokenizer_fin(grn_ctx *ctx,
-                        grn_table_tokenizer *tokenizer)
+grn_table_module_fin(grn_ctx *ctx,
+                     grn_table_module *module)
 {
-  grn_table_tokenizer_fin_options(ctx, tokenizer);
-  CRITICAL_SECTION_FIN(tokenizer->lock);
+  grn_table_module_fin_options(ctx, module);
+  CRITICAL_SECTION_FIN(module->lock);
 }
 
 void
-grn_table_tokenizer_set_proc(grn_ctx *ctx,
-                             grn_table_tokenizer *tokenizer,
-                             grn_obj *proc)
+grn_table_module_set_proc(grn_ctx *ctx,
+                          grn_table_module *module,
+                          grn_obj *proc)
 {
-  CRITICAL_SECTION_ENTER(tokenizer->lock);
-  grn_table_tokenizer_fin_options(ctx, tokenizer);
+  CRITICAL_SECTION_ENTER(module->lock);
+  grn_table_module_fin_options(ctx, module);
 
-  tokenizer->proc = proc;
-  CRITICAL_SECTION_LEAVE(tokenizer->lock);
+  module->proc = proc;
+  CRITICAL_SECTION_LEAVE(module->lock);
 }
 
 void
-grn_table_tokenizer_set_options(grn_ctx *ctx,
-                                grn_table_tokenizer *tokenizer,
-                                void *options,
-                                grn_option_revision revision,
-                                grn_close_func close_func)
+grn_table_module_set_options(grn_ctx *ctx,
+                             grn_table_module *module,
+                             void *options,
+                             grn_option_revision revision,
+                             grn_close_func close_func)
 {
-  CRITICAL_SECTION_ENTER(tokenizer->lock);
-  grn_table_tokenizer_fin_options(ctx, tokenizer);
+  CRITICAL_SECTION_ENTER(module->lock);
+  grn_table_module_fin_options(ctx, module);
 
-  tokenizer->options = options;
-  tokenizer->options_revision = revision;
+  module->options = options;
+  module->options_revision = revision;
   if (options) {
-    tokenizer->options_close_func = close_func;
+    module->options_close_func = close_func;
   }
-  CRITICAL_SECTION_LEAVE(tokenizer->lock);
+  CRITICAL_SECTION_LEAVE(module->lock);
 }
 
 grn_rc
@@ -270,7 +270,7 @@ grn_table_cache_default_tokenizer_options(grn_ctx *ctx,
                                           grn_close_func close_options_func,
                                           void *user_data)
 {
-  grn_table_tokenizer *tokenizer;
+  grn_table_module *tokenizer;
   grn_option_revision revision;
   grn_obj raw_options;
   void *options;
@@ -314,11 +314,11 @@ grn_table_cache_default_tokenizer_options(grn_ctx *ctx,
   }
 
   options = open_options_func(ctx, table, &raw_options, user_data);
-  grn_table_tokenizer_set_options(ctx,
-                                  tokenizer,
-                                  options,
-                                  revision,
-                                  close_options_func);
+  grn_table_module_set_options(ctx,
+                               tokenizer,
+                               options,
+                               revision,
+                               close_options_func);
 
 exit :
   GRN_OBJ_FIN(ctx, &raw_options);
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180410/98369eaa/attachment-0001.htm 



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