[Groonga-commit] groonga/groonga at 68052b9 [master] dump: support token filter options

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


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

  Revision: 68052b9aae611ae42970bbf0719b47744c7e68c9
  https://github.com/groonga/groonga/commit/68052b9aae611ae42970bbf0719b47744c7e68c9

  Message:
    dump: support token filter options

  Added files:
    test/command/suite/table_create/token_filters/options/patricia_trie.expected
    test/command/suite/table_create/token_filters/options/patricia_trie.test
  Modified files:
    lib/proc/proc_dump.c

  Modified: lib/proc/proc_dump.c (+8 -15)
===================================================================
--- lib/proc/proc_dump.c    2018-10-29 16:10:13 +0900 (47ab688ed)
+++ lib/proc/proc_dump.c    2018-10-29 16:10:35 +0900 (4d79d9cab)
@@ -1,6 +1,7 @@
 /* -*- c-basic-offset: 2 -*- */
 /*
   Copyright(C) 2009-2018 Brazil
+  Copyright(C) 2018 Kouhei Sutou <kou****@clear*****>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -792,21 +793,13 @@ dump_table(grn_ctx *ctx, grn_dumper *dumper, grn_obj *table)
     dump_optionable_obj_string(ctx, dumper, &sub_output);
     GRN_OBJ_FIN(ctx, &sub_output);
   }
-  if (table->header.type != GRN_TABLE_NO_KEY) {
-    int n_token_filters;
-
-    n_token_filters = GRN_BULK_VSIZE(token_filters) / sizeof(grn_obj *);
-    if (n_token_filters > 0) {
-      int i;
-      GRN_TEXT_PUTS(ctx, dumper->output, " --token_filters ");
-      for (i = 0; i < n_token_filters; i++) {
-        grn_obj *token_filter = GRN_PTR_VALUE_AT(token_filters, i);
-        if (i > 0) {
-          GRN_TEXT_PUTC(ctx, dumper->output, ',');
-        }
-        dump_obj_name(ctx, dumper, token_filter);
-      }
-    }
+  if (token_filters) {
+    grn_obj sub_output;
+    GRN_TEXT_PUTS(ctx, dumper->output, " --token_filters ");
+    GRN_TEXT_INIT(&sub_output, 0);
+    grn_table_get_token_filters_string(ctx, table, &sub_output);
+    dump_optionable_obj_string(ctx, dumper, &sub_output);
+    GRN_OBJ_FIN(ctx, &sub_output);
   }
 
   GRN_TEXT_PUTC(ctx, dumper->output, '\n');

  Added: test/command/suite/table_create/token_filters/options/patricia_trie.expected (+8 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/table_create/token_filters/options/patricia_trie.expected    2018-10-29 16:10:35 +0900 (d6c700811)
@@ -0,0 +1,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]
+dump
+plugin_register token_filters/stop_word
+
+table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto --token_filters "TokenFilterStopWord(\"column\", \"ignore\")"

  Added: test/command/suite/table_create/token_filters/options/patricia_trie.test (+8 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/table_create/token_filters/options/patricia_trie.test    2018-10-29 16:10:35 +0900 (bd9700c41)
@@ -0,0 +1,8 @@
+plugin_register token_filters/stop_word
+
+table_create Terms TABLE_PAT_KEY ShortText \
+  --default_tokenizer TokenBigram \
+  --normalizer NormalizerAuto \
+  --token_filters 'TokenFilterStopWord("column", "ignore")'
+
+dump
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20181029/2f3f034f/attachment-0001.html>


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