[Groonga-commit] groonga/groonga at 522e4de [master] schema: support column value type

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Oct 20 14:20:57 JST 2015


Kouhei Sutou	2015-10-20 14:20:57 +0900 (Tue, 20 Oct 2015)

  New Revision: 522e4dece94763f90e6feae1d22b0f6dd965308e
  https://github.com/groonga/groonga/commit/522e4dece94763f90e6feae1d22b0f6dd965308e

  Message:
    schema: support column value type

  Modified files:
    lib/proc.c
    test/command/suite/schema/tables/columns/type/scalar.expected
    test/command/suite/schema/tables/columns/type/vector.expected

  Modified: lib/proc.c (+48 -35)
===================================================================
--- lib/proc.c    2015-10-20 14:13:35 +0900 (5098868)
+++ lib/proc.c    2015-10-20 14:20:57 +0900 (80ac314)
@@ -7315,6 +7315,40 @@ proc_schema_output_column_name(grn_ctx *ctx, grn_obj *column)
 }
 
 static void
+proc_schema_output_type(grn_ctx *ctx, const char *type_label, grn_obj *type)
+{
+  if (!type) {
+    GRN_OUTPUT_NULL();
+    return;
+  }
+
+  GRN_OUTPUT_MAP_OPEN(type_label, 2);
+
+  GRN_OUTPUT_CSTR("name");
+  proc_schema_output_name(ctx, type);
+
+  GRN_OUTPUT_CSTR("type");
+  if (grn_obj_is_table(ctx, type)) {
+    GRN_OUTPUT_CSTR("reference");
+  } else {
+    GRN_OUTPUT_CSTR("type");
+  }
+  GRN_OUTPUT_MAP_CLOSE();
+}
+
+static void
+proc_schema_output_key_type(grn_ctx *ctx, grn_obj *key_type)
+{
+  proc_schema_output_type(ctx, "key_type", key_type);
+}
+
+static void
+proc_schema_output_value_type(grn_ctx *ctx, grn_obj *value_type)
+{
+  proc_schema_output_type(ctx, "value_type", value_type);
+}
+
+static void
 proc_schema_output_plugins(grn_ctx *ctx)
 {
   grn_obj plugin_names;
@@ -7520,24 +7554,8 @@ proc_schema_table_output_key_type(grn_ctx *ctx, grn_obj *table)
       table->header.domain != GRN_ID_NIL) {
     key_type = grn_ctx_at(ctx, table->header.domain);
   }
-  if (!key_type) {
-    GRN_OUTPUT_NULL();
-    return;
-  }
 
-  GRN_OUTPUT_MAP_OPEN("key_type", 2);
-
-  GRN_OUTPUT_CSTR("name");
-  proc_schema_output_name(ctx, key_type);
-
-  GRN_OUTPUT_CSTR("type");
-  if (grn_obj_is_table(ctx, key_type)) {
-    GRN_OUTPUT_CSTR("reference");
-  } else {
-    GRN_OUTPUT_CSTR("type");
-  }
-
-  GRN_OUTPUT_MAP_CLOSE();
+  proc_schema_output_key_type(ctx, key_type);
 }
 
 static void
@@ -7552,24 +7570,8 @@ proc_schema_table_output_value_type(grn_ctx *ctx, grn_obj *table)
   if (range != GRN_ID_NIL) {
     value_type = grn_ctx_at(ctx, range);
   }
-  if (!value_type) {
-    GRN_OUTPUT_NULL();
-    return;
-  }
-
-  GRN_OUTPUT_MAP_OPEN("value_type", 2);
-
-  GRN_OUTPUT_CSTR("name");
-  proc_schema_output_name(ctx, value_type);
-
-  GRN_OUTPUT_CSTR("type");
-  if (grn_obj_is_table(ctx, value_type)) {
-    GRN_OUTPUT_CSTR("reference");
-  } else {
-    GRN_OUTPUT_CSTR("type");
-  }
 
-  GRN_OUTPUT_MAP_CLOSE();
+  proc_schema_output_value_type(ctx, value_type);
 }
 
 static void
@@ -7856,6 +7858,14 @@ proc_schema_column_output_type(grn_ctx *ctx, grn_obj *column)
 }
 
 static void
+proc_schema_column_output_value_type(grn_ctx *ctx, grn_obj *column)
+{
+  grn_obj *value_type;
+  value_type = grn_ctx_at(ctx, grn_obj_get_range(ctx, column));
+  proc_schema_output_value_type(ctx, value_type);
+}
+
+static void
 proc_schema_column_output(grn_ctx *ctx, grn_obj *table, grn_obj *column)
 {
   if (!column) {
@@ -7864,7 +7874,7 @@ proc_schema_column_output(grn_ctx *ctx, grn_obj *table, grn_obj *column)
 
   proc_schema_output_column_name(ctx, column);
 
-  GRN_OUTPUT_MAP_OPEN("column", 5);
+  GRN_OUTPUT_MAP_OPEN("column", 6);
 
   GRN_OUTPUT_CSTR("name");
   proc_schema_output_column_name(ctx, column);
@@ -7878,6 +7888,9 @@ proc_schema_column_output(grn_ctx *ctx, grn_obj *table, grn_obj *column)
   GRN_OUTPUT_CSTR("type");
   proc_schema_column_output_type(ctx, column);
 
+  GRN_OUTPUT_CSTR("value_type");
+  proc_schema_column_output_value_type(ctx, column);
+
   GRN_OUTPUT_MAP_CLOSE();
 }
 

  Modified: test/command/suite/schema/tables/columns/type/scalar.expected (+5 -1)
===================================================================
--- test/command/suite/schema/tables/columns/type/scalar.expected    2015-10-20 14:13:35 +0900 (b7af666)
+++ test/command/suite/schema/tables/columns/type/scalar.expected    2015-10-20 14:20:57 +0900 (ffd294e)
@@ -194,7 +194,11 @@ schema
             "name": "message",
             "table": "Logs",
             "full_name": "Logs.message",
-            "type": "scalar"
+            "type": "scalar",
+            "value_type": {
+              "name": "Text",
+              "type": "type"
+            }
           }
         }
       }

  Modified: test/command/suite/schema/tables/columns/type/vector.expected (+5 -1)
===================================================================
--- test/command/suite/schema/tables/columns/type/vector.expected    2015-10-20 14:13:35 +0900 (0d1569f)
+++ test/command/suite/schema/tables/columns/type/vector.expected    2015-10-20 14:20:57 +0900 (5836cde)
@@ -200,7 +200,11 @@ schema
             "name": "tags",
             "table": "Posts",
             "full_name": "Posts.tags",
-            "type": "vector"
+            "type": "vector",
+            "value_type": {
+              "name": "Tags",
+              "type": "reference"
+            }
           }
         }
       },
-------------- next part --------------
HTML����������������������������...
Download 



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