[Groonga-commit] groonga/groonga at bc99e35 [master] schema: support normalizers

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Oct 19 15:41:27 JST 2015


Kouhei Sutou	2015-10-19 15:41:27 +0900 (Mon, 19 Oct 2015)

  New Revision: bc99e3532481186ae2713155068bdee3ca99bdb3
  https://github.com/groonga/groonga/commit/bc99e3532481186ae2713155068bdee3ca99bdb3

  Message:
    schema: support normalizers

  Modified files:
    lib/proc.c
    test/command/suite/schema/plugins.expected

  Modified: lib/proc.c (+35 -0)
===================================================================
--- lib/proc.c    2015-10-19 15:40:40 +0900 (1ea0195)
+++ lib/proc.c    2015-10-19 15:41:27 +0900 (a5cd89a)
@@ -7397,6 +7397,40 @@ proc_schema_tokenizers(grn_ctx *ctx)
   GRN_OBJ_FIN(ctx, &tokenizers);
 }
 
+static void
+proc_schema_normalizers(grn_ctx *ctx)
+{
+  grn_obj normalizers;
+  unsigned int i, n;
+
+  GRN_PTR_INIT(&normalizers, GRN_OBJ_VECTOR, GRN_DB_OBJECT);
+
+  grn_ctx_get_all_normalizers(ctx, &normalizers);
+
+  GRN_OUTPUT_CSTR("normalizers");
+
+  n = GRN_BULK_VSIZE(&normalizers) / sizeof(grn_obj *);
+  GRN_OUTPUT_ARRAY_OPEN("normalizers", n);
+  for (i = 0; i < n; i++) {
+    grn_obj *normalizer;
+
+    normalizer = GRN_PTR_VALUE_AT(&normalizers, i);
+
+    GRN_OUTPUT_MAP_OPEN("normalizer", 1);
+    {
+      char name[GRN_TABLE_MAX_KEY_SIZE];
+      unsigned int name_size;
+      name_size = grn_obj_name(ctx, normalizer, name, GRN_TABLE_MAX_KEY_SIZE);
+      GRN_OUTPUT_CSTR("name");
+      GRN_OUTPUT_STR(name, name_size);
+    }
+    GRN_OUTPUT_MAP_CLOSE();
+  }
+  GRN_OUTPUT_ARRAY_CLOSE();
+
+  GRN_OBJ_FIN(ctx, &normalizers);
+}
+
 static grn_obj *
 proc_schema(grn_ctx *ctx, int nargs, grn_obj **args,
             grn_user_data *user_data)
@@ -7405,6 +7439,7 @@ proc_schema(grn_ctx *ctx, int nargs, grn_obj **args,
   proc_schema_plugins(ctx);
   proc_schema_types(ctx);
   proc_schema_tokenizers(ctx);
+  proc_schema_normalizers(ctx);
   GRN_OUTPUT_MAP_CLOSE();
 
   return NULL;

  Modified: test/command/suite/schema/plugins.expected (+8 -0)
===================================================================
--- test/command/suite/schema/plugins.expected    2015-10-19 15:40:40 +0900 (2c38c55)
+++ test/command/suite/schema/plugins.expected    2015-10-19 15:41:27 +0900 (22fabcf)
@@ -143,6 +143,14 @@ schema
       {
         "name": "TokenUnigram"
       }
+    ],
+    "normalizers": [
+      {
+        "name": "NormalizerAuto"
+      },
+      {
+        "name": "NormalizerNFKC51"
+      }
     ]
   }
 ]
-------------- next part --------------
HTML����������������������������...
Download 



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