[Groonga-commit] groonga/groonga at 4f8fcc8 [master] object_inspect: support double array trie

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Feb 26 15:13:04 JST 2016


Kouhei Sutou	2016-02-26 15:13:04 +0900 (Fri, 26 Feb 2016)

  New Revision: 4f8fcc8993668b0b728470c459f75a2f9ea6f594
  https://github.com/groonga/groonga/commit/4f8fcc8993668b0b728470c459f75a2f9ea6f594

  Message:
    object_inspect: support double array trie

  Added files:
    test/command/suite/object_inspect/table_dat_key.expected
    test/command/suite/object_inspect/table_dat_key.test
  Modified files:
    lib/proc/proc_object_inspect.c

  Modified: lib/proc/proc_object_inspect.c (+63 -21)
===================================================================
--- lib/proc/proc_object_inspect.c    2016-02-26 15:04:16 +0900 (ecb8279)
+++ lib/proc/proc_object_inspect.c    2016-02-26 15:13:04 +0900 (4fca92b)
@@ -17,11 +17,14 @@
 */
 
 #include "../grn_pat.h"
+#include "../grn_dat.h"
 
 #include "../grn_proc.h"
 
 #include <groonga/plugin.h>
 
+static void command_object_inspect_dispatch(grn_ctx *ctx, grn_obj *obj);
+
 static void
 command_object_inspect_obj_name(grn_ctx *ctx, grn_obj *obj)
 {
@@ -138,6 +141,65 @@ command_object_inspect_table_pat_key(grn_ctx *ctx, grn_obj *obj)
   grn_ctx_output_map_close(ctx);
 }
 
+static void
+command_object_inspect_table_dat_key_key(grn_ctx *ctx, grn_dat *dat)
+{
+  grn_ctx_output_map_open(ctx, "key", 1);
+  {
+    grn_ctx_output_cstr(ctx, "type");
+    command_object_inspect_type(ctx, grn_ctx_at(ctx, dat->obj.header.domain));
+  }
+  grn_ctx_output_map_close(ctx);
+}
+
+static void
+command_object_inspect_table_dat_key(grn_ctx *ctx, grn_obj *obj)
+{
+  grn_dat *dat = (grn_dat *)obj;
+
+  grn_ctx_output_map_open(ctx, "table", 4);
+  {
+    grn_ctx_output_cstr(ctx, "id");
+    grn_ctx_output_uint64(ctx, grn_obj_id(ctx, obj));
+    grn_ctx_output_cstr(ctx, "name");
+    command_object_inspect_obj_name(ctx, obj);
+    grn_ctx_output_cstr(ctx, "type");
+    command_object_inspect_obj_type(ctx, obj->header.type);
+    grn_ctx_output_cstr(ctx, "key");
+    command_object_inspect_table_dat_key_key(ctx, dat);
+  }
+  grn_ctx_output_map_close(ctx);
+}
+
+static void
+command_object_inspect_dispatch(grn_ctx *ctx, grn_obj *obj)
+{
+  switch (obj->header.type) {
+  case GRN_TYPE :
+    command_object_inspect_type(ctx, obj);
+    break;
+  case GRN_TABLE_HASH_KEY :
+    command_object_inspect_table_hash_key(ctx, obj);
+    break;
+  case GRN_TABLE_PAT_KEY :
+    command_object_inspect_table_pat_key(ctx, obj);
+    break;
+  case GRN_TABLE_DAT_KEY :
+    command_object_inspect_table_dat_key(ctx, obj);
+    break;
+  default :
+    {
+      GRN_PLUGIN_ERROR(ctx,
+                       GRN_FUNCTION_NOT_IMPLEMENTED,
+                       "[object][inspect] unsupported type: <%s>(%#x)",
+                       grn_obj_type_to_string(obj->header.type),
+                       obj->header.type);
+      grn_ctx_output_null(ctx);
+      break;
+    }
+  }
+}
+
 static grn_obj *
 command_object_inspect(grn_ctx *ctx,
                        int nargs,
@@ -165,27 +227,7 @@ command_object_inspect(grn_ctx *ctx,
     }
   }
 
-  switch (target->header.type) {
-  case GRN_TYPE :
-    command_object_inspect_type(ctx, target);
-    break;
-  case GRN_TABLE_HASH_KEY :
-    command_object_inspect_table_hash_key(ctx, target);
-    break;
-  case GRN_TABLE_PAT_KEY :
-    command_object_inspect_table_pat_key(ctx, target);
-    break;
-  default :
-    {
-      GRN_PLUGIN_ERROR(ctx,
-                       GRN_FUNCTION_NOT_IMPLEMENTED,
-                       "[object][inspect] unsupported type: <%s>(%#x)",
-                       grn_obj_type_to_string(target->header.type),
-                       target->header.type);
-      grn_ctx_output_null(ctx);
-      break;
-    }
-  }
+  command_object_inspect_dispatch(ctx, target);
 
   return NULL;
 }

  Added: test/command/suite/object_inspect/table_dat_key.expected (+35 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/object_inspect/table_dat_key.expected    2016-02-26 15:13:04 +0900 (b9cdfef)
@@ -0,0 +1,35 @@
+table_create Users TABLE_DAT_KEY ShortText
+[[0,0.0,0.0],true]
+load --table Users
+[
+{"_key": "alice"},
+{"_key": "bob"}
+]
+[[0,0.0,0.0],2]
+object_inspect Users
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  {
+    "id": 256,
+    "name": "Users",
+    "type": {
+      "id": 50,
+      "name": "table:dat_key"
+    },
+    "key": {
+      "type": {
+        "id": 14,
+        "name": "ShortText",
+        "type": {
+          "id": 32,
+          "name": "type"
+        },
+        "size": 4096
+      }
+    }
+  }
+]

  Added: test/command/suite/object_inspect/table_dat_key.test (+9 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/object_inspect/table_dat_key.test    2016-02-26 15:13:04 +0900 (e4c11c3)
@@ -0,0 +1,9 @@
+table_create Users TABLE_DAT_KEY ShortText
+
+load --table Users
+[
+{"_key": "alice"},
+{"_key": "bob"}
+]
+
+object_inspect Users
-------------- next part --------------
HTML����������������������������...
Download 



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