[Groonga-commit] groonga/groonga at c4e03a6 [master] schema: support indexes output

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Jan 12 16:09:11 JST 2016


Kouhei Sutou	2016-01-12 16:09:11 +0900 (Tue, 12 Jan 2016)

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

  Message:
    schema: support indexes output

  Modified files:
    lib/proc/schema.c
    test/command/suite/schema/tables/columns/compress/lz4.expected
    test/command/suite/schema/tables/columns/compress/zlib.expected
    test/command/suite/schema/tables/columns/type/index.expected
    test/command/suite/schema/tables/columns/type/scalar.expected
    test/command/suite/schema/tables/columns/type/vector.expected
    test/command/suite/schema/tables/normalizer.expected
    test/command/suite/schema/tables/token_filters.expected
    test/command/suite/schema/tables/tokenizer.expected
    test/command/suite/schema/tables/type/array.expected
    test/command/suite/schema/tables/type/hash_table.expected
    test/command/suite/schema/tables/value_type/reference.expected
    test/command/suite/schema/tables/value_type/type.expected

  Modified: lib/proc/schema.c (+66 -2)
===================================================================
--- lib/proc/schema.c    2016-01-12 16:08:26 +0900 (e01ea06)
+++ lib/proc/schema.c    2016-01-12 16:09:11 +0900 (6a142a0)
@@ -671,6 +671,55 @@ command_schema_column_output_sources(grn_ctx *ctx, grn_obj *column)
 }
 
 static void
+command_schema_column_output_indexes(grn_ctx *ctx, grn_obj *column)
+{
+  uint32_t i;
+  grn_index_datum *index_data = NULL;
+  uint32_t n_index_data = 0;
+
+  if (column) {
+    n_index_data = grn_column_get_all_index_data(ctx, column, NULL, 0);
+    if (n_index_data > 0) {
+      index_data = GRN_PLUGIN_MALLOC(ctx,
+                                     sizeof(grn_index_datum) * n_index_data);
+      if (!index_data) {
+        GRN_PLUGIN_ERROR(ctx, GRN_NO_MEMORY_AVAILABLE,
+                         "[schema] failed to allocate memory for indexes");
+        return;
+      }
+      grn_column_get_all_index_data(ctx, column, index_data, n_index_data);
+    }
+  }
+
+  grn_ctx_output_array_open(ctx, "indexes", n_index_data);
+  for (i = 0; i < n_index_data; i++) {
+    grn_obj *lexicon;
+
+    grn_ctx_output_map_open(ctx, "index", 4);
+
+    grn_ctx_output_cstr(ctx, "full_name");
+    command_schema_output_name(ctx, index_data[i].index);
+
+    grn_ctx_output_cstr(ctx, "table");
+    lexicon = grn_ctx_at(ctx, index_data[i].index->header.domain);
+    command_schema_output_name(ctx, lexicon);
+
+    grn_ctx_output_cstr(ctx, "name");
+    command_schema_output_column_name(ctx, index_data[i].index);
+
+    grn_ctx_output_cstr(ctx, "section");
+    grn_ctx_output_uint64(ctx, index_data[i].section);
+
+    grn_ctx_output_map_close(ctx);
+  }
+  grn_ctx_output_array_close(ctx);
+
+  if (index_data) {
+    GRN_PLUGIN_FREE(ctx, index_data);
+  }
+}
+
+static void
 command_schema_column_command_collect_arguments(grn_ctx *ctx,
                                              grn_obj *table,
                                              grn_obj *column,
@@ -788,7 +837,7 @@ command_schema_column_output(grn_ctx *ctx, grn_obj *table, grn_obj *column)
 
   command_schema_output_column_name(ctx, column);
 
-  grn_ctx_output_map_open(ctx, "column", 11);
+  grn_ctx_output_map_open(ctx, "column", 12);
 
   grn_ctx_output_cstr(ctx, "name");
   command_schema_output_column_name(ctx, column);
@@ -820,6 +869,9 @@ command_schema_column_output(grn_ctx *ctx, grn_obj *table, grn_obj *column)
   grn_ctx_output_cstr(ctx, "sources");
   command_schema_column_output_sources(ctx, column);
 
+  grn_ctx_output_cstr(ctx, "indexes");
+  command_schema_column_output_indexes(ctx, column);
+
   grn_ctx_output_cstr(ctx, "command");
   command_schema_column_output_command(ctx, table, column);
 
@@ -874,7 +926,7 @@ command_schema_output_tables(grn_ctx *ctx)
 
     command_schema_output_name(ctx, table);
 
-    grn_ctx_output_map_open(ctx, "table", 9);
+    grn_ctx_output_map_open(ctx, "table", 10);
 
     grn_ctx_output_cstr(ctx, "name");
     command_schema_output_name(ctx, table);
@@ -897,6 +949,18 @@ command_schema_output_tables(grn_ctx *ctx)
     grn_ctx_output_cstr(ctx, "token_filters");
     command_schema_table_output_token_filters(ctx, table);
 
+    grn_ctx_output_cstr(ctx, "indexes");
+    if (table->header.type == GRN_TABLE_NO_KEY) {
+      command_schema_column_output_indexes(ctx, NULL);
+    } else {
+      grn_obj *key_column;
+      key_column = grn_obj_column(ctx, table,
+                                  GRN_COLUMN_NAME_KEY,
+                                  GRN_COLUMN_NAME_KEY_LEN);
+      command_schema_column_output_indexes(ctx, key_column);
+      grn_obj_unlink(ctx, key_column);
+    }
+
     grn_ctx_output_cstr(ctx, "command");
     command_schema_table_output_command(ctx, table);
 

  Modified: test/command/suite/schema/tables/columns/compress/lz4.expected (+6 -0)
===================================================================
--- test/command/suite/schema/tables/columns/compress/lz4.expected    2016-01-12 16:08:26 +0900 (4bd39f0)
+++ test/command/suite/schema/tables/columns/compress/lz4.expected    2016-01-12 16:09:11 +0900 (85e951d)
@@ -181,6 +181,9 @@ schema
         "token_filters": [
 
         ],
+        "indexes": [
+
+        ],
         "command": {
           "name": "table_create",
           "arguments": {
@@ -206,6 +209,9 @@ schema
             "sources": [
 
             ],
+            "indexes": [
+
+            ],
             "command": {
               "name": "column_create",
               "arguments": {

  Modified: test/command/suite/schema/tables/columns/compress/zlib.expected (+6 -0)
===================================================================
--- test/command/suite/schema/tables/columns/compress/zlib.expected    2016-01-12 16:08:26 +0900 (1a546aa)
+++ test/command/suite/schema/tables/columns/compress/zlib.expected    2016-01-12 16:09:11 +0900 (bf5b912)
@@ -181,6 +181,9 @@ schema
         "token_filters": [
 
         ],
+        "indexes": [
+
+        ],
         "command": {
           "name": "table_create",
           "arguments": {
@@ -206,6 +209,9 @@ schema
             "sources": [
 
             ],
+            "indexes": [
+
+            ],
             "command": {
               "name": "column_create",
               "arguments": {

  Modified: test/command/suite/schema/tables/columns/type/index.expected (+30 -0)
===================================================================
--- test/command/suite/schema/tables/columns/type/index.expected    2016-01-12 16:08:26 +0900 (f4d7619)
+++ test/command/suite/schema/tables/columns/type/index.expected    2016-01-12 16:09:11 +0900 (9dac624)
@@ -190,6 +190,14 @@ schema
         "token_filters": [
 
         ],
+        "indexes": [
+          {
+            "full_name": "Terms.index",
+            "table": "Terms",
+            "name": "index",
+            "section": 1
+          }
+        ],
         "command": {
           "name": "table_create",
           "arguments": {
@@ -216,6 +224,14 @@ schema
             "sources": [
 
             ],
+            "indexes": [
+              {
+                "full_name": "Terms.index",
+                "table": "Terms",
+                "name": "index",
+                "section": 3
+              }
+            ],
             "command": {
               "name": "column_create",
               "arguments": {
@@ -243,6 +259,14 @@ schema
             "sources": [
 
             ],
+            "indexes": [
+              {
+                "full_name": "Terms.index",
+                "table": "Terms",
+                "name": "index",
+                "section": 2
+              }
+            ],
             "command": {
               "name": "column_create",
               "arguments": {
@@ -273,6 +297,9 @@ schema
         "token_filters": [
 
         ],
+        "indexes": [
+
+        ],
         "command": {
           "name": "table_create",
           "arguments": {
@@ -315,6 +342,9 @@ schema
                 "full_name": "Posts.content"
               }
             ],
+            "indexes": [
+
+            ],
             "command": {
               "name": "column_create",
               "arguments": {

  Modified: test/command/suite/schema/tables/columns/type/scalar.expected (+6 -0)
===================================================================
--- test/command/suite/schema/tables/columns/type/scalar.expected    2016-01-12 16:08:26 +0900 (c07a4e1)
+++ test/command/suite/schema/tables/columns/type/scalar.expected    2016-01-12 16:09:11 +0900 (2274572)
@@ -181,6 +181,9 @@ schema
         "token_filters": [
 
         ],
+        "indexes": [
+
+        ],
         "command": {
           "name": "table_create",
           "arguments": {
@@ -206,6 +209,9 @@ schema
             "sources": [
 
             ],
+            "indexes": [
+
+            ],
             "command": {
               "name": "column_create",
               "arguments": {

  Modified: test/command/suite/schema/tables/columns/type/vector.expected (+9 -0)
===================================================================
--- test/command/suite/schema/tables/columns/type/vector.expected    2016-01-12 16:08:26 +0900 (99f9123)
+++ test/command/suite/schema/tables/columns/type/vector.expected    2016-01-12 16:09:11 +0900 (cb4231e)
@@ -186,6 +186,9 @@ schema
         "token_filters": [
 
         ],
+        "indexes": [
+
+        ],
         "command": {
           "name": "table_create",
           "arguments": {
@@ -212,6 +215,9 @@ schema
             "sources": [
 
             ],
+            "indexes": [
+
+            ],
             "command": {
               "name": "column_create",
               "arguments": {
@@ -240,6 +246,9 @@ schema
         "token_filters": [
 
         ],
+        "indexes": [
+
+        ],
         "command": {
           "name": "table_create",
           "arguments": {

  Modified: test/command/suite/schema/tables/normalizer.expected (+3 -0)
===================================================================
--- test/command/suite/schema/tables/normalizer.expected    2016-01-12 16:08:26 +0900 (cd72767)
+++ test/command/suite/schema/tables/normalizer.expected    2016-01-12 16:09:11 +0900 (d5744e7)
@@ -184,6 +184,9 @@ schema
         "token_filters": [
 
         ],
+        "indexes": [
+
+        ],
         "command": {
           "name": "table_create",
           "arguments": {

  Modified: test/command/suite/schema/tables/token_filters.expected (+3 -0)
===================================================================
--- test/command/suite/schema/tables/token_filters.expected    2016-01-12 16:08:26 +0900 (aa514dd)
+++ test/command/suite/schema/tables/token_filters.expected    2016-01-12 16:09:11 +0900 (8563c86)
@@ -194,6 +194,9 @@ schema
             "name": "TokenFilterStopWord"
           }
         ],
+        "indexes": [
+
+        ],
         "command": {
           "name": "table_create",
           "arguments": {

  Modified: test/command/suite/schema/tables/tokenizer.expected (+3 -0)
===================================================================
--- test/command/suite/schema/tables/tokenizer.expected    2016-01-12 16:08:26 +0900 (02b846d)
+++ test/command/suite/schema/tables/tokenizer.expected    2016-01-12 16:09:11 +0900 (1318b12)
@@ -184,6 +184,9 @@ schema
         "token_filters": [
 
         ],
+        "indexes": [
+
+        ],
         "command": {
           "name": "table_create",
           "arguments": {

  Modified: test/command/suite/schema/tables/type/array.expected (+3 -0)
===================================================================
--- test/command/suite/schema/tables/type/array.expected    2016-01-12 16:08:26 +0900 (7b06048)
+++ test/command/suite/schema/tables/type/array.expected    2016-01-12 16:09:11 +0900 (41060af)
@@ -179,6 +179,9 @@ schema
         "token_filters": [
 
         ],
+        "indexes": [
+
+        ],
         "command": {
           "name": "table_create",
           "arguments": {

  Modified: test/command/suite/schema/tables/type/hash_table.expected (+3 -0)
===================================================================
--- test/command/suite/schema/tables/type/hash_table.expected    2016-01-12 16:08:26 +0900 (65612ac)
+++ test/command/suite/schema/tables/type/hash_table.expected    2016-01-12 16:09:11 +0900 (db9c421)
@@ -182,6 +182,9 @@ schema
         "token_filters": [
 
         ],
+        "indexes": [
+
+        ],
         "command": {
           "name": "table_create",
           "arguments": {

  Modified: test/command/suite/schema/tables/value_type/reference.expected (+6 -0)
===================================================================
--- test/command/suite/schema/tables/value_type/reference.expected    2016-01-12 16:08:26 +0900 (d257144)
+++ test/command/suite/schema/tables/value_type/reference.expected    2016-01-12 16:09:11 +0900 (18e86f9)
@@ -184,6 +184,9 @@ schema
         "token_filters": [
 
         ],
+        "indexes": [
+
+        ],
         "command": {
           "name": "table_create",
           "arguments": {
@@ -209,6 +212,9 @@ schema
         "token_filters": [
 
         ],
+        "indexes": [
+
+        ],
         "command": {
           "name": "table_create",
           "arguments": {

  Modified: test/command/suite/schema/tables/value_type/type.expected (+3 -0)
===================================================================
--- test/command/suite/schema/tables/value_type/type.expected    2016-01-12 16:08:26 +0900 (75e4a4d)
+++ test/command/suite/schema/tables/value_type/type.expected    2016-01-12 16:09:11 +0900 (8320320)
@@ -182,6 +182,9 @@ schema
         "token_filters": [
 
         ],
+        "indexes": [
+
+        ],
         "command": {
           "name": "table_create",
           "arguments": {
-------------- next part --------------
HTML����������������������������...
Download 



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