[Groonga-commit] groonga/groonga [master] table: add tests for find command and match command.

Back to archive index

null+****@clear***** null+****@clear*****
2012年 6月 25日 (月) 11:21:15 JST


Daijiro MORI	2012-06-25 11:21:15 +0900 (Mon, 25 Jun 2012)

  New Revision: 5a10e5d2cf342394b293eff87080371df2e41a36
  https://github.com/groonga/groonga/commit/5a10e5d2cf342394b293eff87080371df2e41a36

  Log:
    table: add tests for find command and match command.

  Added files:
    test/function/suite/table/find.expected
    test/function/suite/table/find.test
    test/function/suite/table/match.expected
    test/function/suite/table/match.test
  Modified files:
    plugins/table/table.c

  Modified: plugins/table/table.c (+3 -3)
===================================================================
--- plugins/table/table.c    2012-06-25 11:11:57 +0900 (b058308)
+++ plugins/table/table.c    2012-06-25 11:21:15 +0900 (9d5e80a)
@@ -123,9 +123,9 @@ command_match(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
         result_set = grn_ctx_get_table_by_name_or_id(ctx, TEXT_VALUE_LEN(VAR(3)));
       } else {
         result_set = grn_table_create(ctx, NULL, 0, NULL,
-                                GRN_TABLE_HASH_KEY|
-                                GRN_OBJ_WITH_SUBREC,
-                                table, NULL);
+                                      GRN_TABLE_HASH_KEY|
+                                      GRN_OBJ_WITH_SUBREC,
+                                      table, NULL);
       }
       if (result_set) {
         grn_table_select(ctx, table, query, result_set,

  Added: test/function/suite/table/find.expected (+97 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/table/find.expected    2012-06-25 11:21:15 +0900 (1e17bf2)
@@ -0,0 +1,97 @@
+register table/table
+[[0,0.0,0.0],true]
+table_create Shops TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+table_create Tags TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Shops tags COLUMN_VECTOR Tags
+[[0,0.0,0.0],true]
+column_create Tags shops_tag COLUMN_INDEX Shops tags
+[[0,0.0,0.0],true]
+add Shops '{"_key":"くりこあん","tags":["たいやき","養殖"]}'
+[[0,0.0,0.0],true]
+add Shops '{"_key":"なか一","tags":["季節料理"]}'
+[[0,0.0,0.0],true]
+add Shops '{"_key":"魚寅食堂","tags":["漁師","季節料理"]}'
+[[0,0.0,0.0],true]
+add Shops '{"_key":"DRAGON飯店","tags":["中華"]}'
+[[0,0.0,0.0],true]
+add Shops '{"_key":"魚浜","tags":["回転寿司"]}'
+[[0,0.0,0.0],true]
+add Shops '{"_key":"beanDaisy","tags":["caffe","カプチーノ"]}'
+[[0,0.0,0.0],true]
+add Shops '{"_key":"維新","tags":["麺や"]}'
+[[0,0.0,0.0],true]
+add Shops '{"_key":"ひづめ","tags":["とんかつ"]}'
+[[0,0.0,0.0],true]
+add Shops '{"_key":"和互","tags":["魚"]}'
+[[0,0.0,0.0],true]
+find Shops tags match 季節料理
+[[0,0.0,0.0],2147483651]
+output 2147483651 _id,_key
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      2
+    ],
+    [
+      [
+        "_id",
+        "UInt32"
+      ],
+      [
+        "_key",
+        "ShortText"
+      ]
+    ],
+    [
+      2,
+      "なか一"
+    ],
+    [
+      3,
+      "魚寅食堂"
+    ]
+  ]
+]
+output 2147483651 _id,tags
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      2
+    ],
+    [
+      [
+        "_id",
+        "UInt32"
+      ],
+      [
+        "tags",
+        "Tags"
+      ]
+    ],
+    [
+      2,
+      [
+        "季節料理"
+      ]
+    ],
+    [
+      3,
+      [
+        "漁師",
+        "季節料理"
+      ]
+    ]
+  ]
+]

  Added: test/function/suite/table/find.test (+18 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/table/find.test    2012-06-25 11:21:15 +0900 (8086192)
@@ -0,0 +1,18 @@
+register table/table
+table_create Shops TABLE_PAT_KEY ShortText
+table_create Tags TABLE_PAT_KEY ShortText
+column_create Shops tags COLUMN_VECTOR Tags
+column_create Tags shops_tag COLUMN_INDEX Shops tags
+
+add Shops '{"_key":"くりこあん","tags":["たいやき","養殖"]}'
+add Shops '{"_key":"なか一","tags":["季節料理"]}'
+add Shops '{"_key":"魚寅食堂","tags":["漁師","季節料理"]}'
+add Shops '{"_key":"DRAGON飯店","tags":["中華"]}'
+add Shops '{"_key":"魚浜","tags":["回転寿司"]}'
+add Shops '{"_key":"beanDaisy","tags":["caffe","カプチーノ"]}'
+add Shops '{"_key":"維新","tags":["麺や"]}'
+add Shops '{"_key":"ひづめ","tags":["とんかつ"]}'
+add Shops '{"_key":"和互","tags":["魚"]}'
+find Shops tags match 季節料理
+output 2147483651 _id,_key
+output 2147483651 _id,tags

  Added: test/function/suite/table/match.expected (+72 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/table/match.expected    2012-06-25 11:21:15 +0900 (681dfbd)
@@ -0,0 +1,72 @@
+register table/table
+[[0,0.0,0.0],true]
+table_create Shops TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+table_create Tags TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Shops tags COLUMN_VECTOR Tags
+[[0,0.0,0.0],true]
+column_create Tags shops_tag COLUMN_INDEX Shops tags
+[[0,0.0,0.0],true]
+add Shops '{"_key":"くりこあん","tags":["たいやき","養殖"]}'
+[[0,0.0,0.0],true]
+add Shops '{"_key":"なか一","tags":["季節料理"]}'
+[[0,0.0,0.0],true]
+add Shops '{"_key":"魚寅食堂","tags":["漁師","季節料理"]}'
+[[0,0.0,0.0],true]
+add Shops '{"_key":"DRAGON飯店","tags":["中華"]}'
+[[0,0.0,0.0],true]
+add Shops '{"_key":"魚浜","tags":["回転寿司"]}'
+[[0,0.0,0.0],true]
+add Shops '{"_key":"beanDaisy","tags":["caffe","カプチーノ"]}'
+[[0,0.0,0.0],true]
+add Shops '{"_key":"維新","tags":["麺や"]}'
+[[0,0.0,0.0],true]
+add Shops '{"_key":"ひづめ","tags":["とんかつ"]}'
+[[0,0.0,0.0],true]
+add Shops '{"_key":"和互","tags":["魚"]}'
+[[0,0.0,0.0],true]
+match Shops tags "季節料理"
+[[0,0.0,0.0],2147483651]
+output 2147483651 _id,_key,tags
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      2
+    ],
+    [
+      [
+        "_id",
+        "UInt32"
+      ],
+      [
+        "_key",
+        "ShortText"
+      ],
+      [
+        "tags",
+        "Tags"
+      ]
+    ],
+    [
+      2,
+      "なか一",
+      [
+        "季節料理"
+      ]
+    ],
+    [
+      3,
+      "魚寅食堂",
+      [
+        "漁師",
+        "季節料理"
+      ]
+    ]
+  ]
+]

  Added: test/function/suite/table/match.test (+17 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/table/match.test    2012-06-25 11:21:15 +0900 (7f6ed93)
@@ -0,0 +1,17 @@
+register table/table
+table_create Shops TABLE_PAT_KEY ShortText
+table_create Tags TABLE_PAT_KEY ShortText
+column_create Shops tags COLUMN_VECTOR Tags
+column_create Tags shops_tag COLUMN_INDEX Shops tags
+
+add Shops '{"_key":"くりこあん","tags":["たいやき","養殖"]}'
+add Shops '{"_key":"なか一","tags":["季節料理"]}'
+add Shops '{"_key":"魚寅食堂","tags":["漁師","季節料理"]}'
+add Shops '{"_key":"DRAGON飯店","tags":["中華"]}'
+add Shops '{"_key":"魚浜","tags":["回転寿司"]}'
+add Shops '{"_key":"beanDaisy","tags":["caffe","カプチーノ"]}'
+add Shops '{"_key":"維新","tags":["麺や"]}'
+add Shops '{"_key":"ひづめ","tags":["とんかつ"]}'
+add Shops '{"_key":"和互","tags":["魚"]}'
+match Shops tags "季節料理"
+output 2147483651 _id,_key,tags
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Download 



Groonga-commit メーリングリストの案内
Back to archive index