[Groonga-commit] groonga/groonga at 7805b98 [master] schema: support outputting key type

Back to archive index

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


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

  New Revision: 7805b988cbc18b43f30ae4341de51400b2182a82
  https://github.com/groonga/groonga/commit/7805b988cbc18b43f30ae4341de51400b2182a82

  Message:
    schema: support outputting key type

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

  Modified: lib/proc.c (+17 -1)
===================================================================
--- lib/proc.c    2015-10-20 10:48:57 +0900 (1748cd3)
+++ lib/proc.c    2015-10-20 10:57:41 +0900 (7206d6c)
@@ -7501,7 +7501,23 @@ proc_schema_tables(grn_ctx *ctx)
         table->header.domain != GRN_ID_NIL) {
       key_type = grn_ctx_at(ctx, table->header.domain);
     }
-    proc_schema_output_name(ctx, key_type);
+    if (key_type) {
+      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();
+    } else {
+      GRN_OUTPUT_NULL();
+    }
 
     GRN_OUTPUT_MAP_CLOSE();
   }

  Added: test/command/suite/schema/hash_table.expected (+163 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/schema/hash_table.expected    2015-10-20 10:57:41 +0900 (8cc1c85)
@@ -0,0 +1,163 @@
+table_create Users TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+schema
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  {
+    "plugins": {
+    },
+    "types": {
+      "Bool": {
+        "name": "Bool",
+        "size": 1,
+        "can_be_key_type": true
+      },
+      "Float": {
+        "name": "Float",
+        "size": 8,
+        "can_be_key_type": true
+      },
+      "Int16": {
+        "name": "Int16",
+        "size": 2,
+        "can_be_key_type": true
+      },
+      "Int32": {
+        "name": "Int32",
+        "size": 4,
+        "can_be_key_type": true
+      },
+      "Int64": {
+        "name": "Int64",
+        "size": 8,
+        "can_be_key_type": true
+      },
+      "Int8": {
+        "name": "Int8",
+        "size": 1,
+        "can_be_key_type": true
+      },
+      "LongText": {
+        "name": "LongText",
+        "size": 2147483648,
+        "can_be_key_type": false
+      },
+      "Object": {
+        "name": "Object",
+        "size": 8,
+        "can_be_key_type": true
+      },
+      "ShortText": {
+        "name": "ShortText",
+        "size": 4096,
+        "can_be_key_type": true
+      },
+      "Text": {
+        "name": "Text",
+        "size": 65536,
+        "can_be_key_type": false
+      },
+      "Time": {
+        "name": "Time",
+        "size": 8,
+        "can_be_key_type": true
+      },
+      "TokyoGeoPoint": {
+        "name": "TokyoGeoPoint",
+        "size": 8,
+        "can_be_key_type": true
+      },
+      "UInt16": {
+        "name": "UInt16",
+        "size": 2,
+        "can_be_key_type": true
+      },
+      "UInt32": {
+        "name": "UInt32",
+        "size": 4,
+        "can_be_key_type": true
+      },
+      "UInt64": {
+        "name": "UInt64",
+        "size": 8,
+        "can_be_key_type": true
+      },
+      "UInt8": {
+        "name": "UInt8",
+        "size": 1,
+        "can_be_key_type": true
+      },
+      "WGS84GeoPoint": {
+        "name": "WGS84GeoPoint",
+        "size": 8,
+        "can_be_key_type": true
+      }
+    },
+    "tokenizers": {
+      "TokenBigram": {
+        "name": "TokenBigram"
+      },
+      "TokenBigramIgnoreBlank": {
+        "name": "TokenBigramIgnoreBlank"
+      },
+      "TokenBigramIgnoreBlankSplitSymbol": {
+        "name": "TokenBigramIgnoreBlankSplitSymbol"
+      },
+      "TokenBigramIgnoreBlankSplitSymbolAlpha": {
+        "name": "TokenBigramIgnoreBlankSplitSymbolAlpha"
+      },
+      "TokenBigramIgnoreBlankSplitSymbolAlphaDigit": {
+        "name": "TokenBigramIgnoreBlankSplitSymbolAlphaDigit"
+      },
+      "TokenBigramSplitSymbol": {
+        "name": "TokenBigramSplitSymbol"
+      },
+      "TokenBigramSplitSymbolAlpha": {
+        "name": "TokenBigramSplitSymbolAlpha"
+      },
+      "TokenBigramSplitSymbolAlphaDigit": {
+        "name": "TokenBigramSplitSymbolAlphaDigit"
+      },
+      "TokenDelimit": {
+        "name": "TokenDelimit"
+      },
+      "TokenDelimitNull": {
+        "name": "TokenDelimitNull"
+      },
+      "TokenMecab": {
+        "name": "TokenMecab"
+      },
+      "TokenRegexp": {
+        "name": "TokenRegexp"
+      },
+      "TokenTrigram": {
+        "name": "TokenTrigram"
+      },
+      "TokenUnigram": {
+        "name": "TokenUnigram"
+      }
+    },
+    "normalizers": {
+      "NormalizerAuto": {
+        "name": "NormalizerAuto"
+      },
+      "NormalizerNFKC51": {
+        "name": "NormalizerNFKC51"
+      }
+    },
+    "tables": {
+      "Users": {
+        "name": "Users",
+        "type": "hash table",
+        "key_type": {
+          "name": "ShortText",
+          "type": "type"
+        }
+      }
+    }
+  }
+]

  Added: test/command/suite/schema/hash_table.test (+3 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/schema/hash_table.test    2015-10-20 10:57:41 +0900 (c96decf)
@@ -0,0 +1,3 @@
+table_create Users TABLE_HASH_KEY ShortText
+
+schema
-------------- next part --------------
HTML����������������������������...
Download 



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