[Groonga-commit] groonga/groonga at 2e7f816 [master] select drilldown: support target slice table

Back to archive index

Naoya Murakami null+****@clear*****
Sun Jun 26 21:29:20 JST 2016


Naoya Murakami	2016-06-26 21:29:20 +0900 (Sun, 26 Jun 2016)

  New Revision: 2e7f8166149a930376edce19430a6d7fcf4ba85d
  https://github.com/groonga/groonga/commit/2e7f8166149a930376edce19430a6d7fcf4ba85d

  Merged cc5c9af: Merge pull request #569 from naoa/drilldown-with-slice

  Message:
    select drilldown: support target slice table

  Added files:
    test/command/suite/select/drilldowns/table/slice.expected
    test/command/suite/select/drilldowns/table/slice.test
  Modified files:
    lib/proc/proc_select.c

  Modified: lib/proc/proc_select.c (+24 -8)
===================================================================
--- lib/proc/proc_select.c    2016-06-26 18:21:57 +0900 (b649c95)
+++ lib/proc/proc_select.c    2016-06-26 21:29:20 +0900 (c3143d6)
@@ -1879,14 +1879,30 @@ grn_select_drilldown_execute(grn_ctx *ctx,
                                 drilldown->table_name.length,
                                 NULL);
     if (dependent_id == GRN_ID_NIL) {
-      GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT,
-                       "[select][drilldowns][%.*s][table] "
-                       "nonexistent label: <%.*s>",
-                       (int)(drilldown->label.length),
-                       drilldown->label.value,
-                       (int)(drilldown->table_name.length),
-                       drilldown->table_name.value);
-      return GRN_FALSE;
+      if (data->slices) {
+        grn_slice_data *slice;
+        dependent_id = grn_hash_get(ctx,
+                                    data->slices,
+                                    drilldown->table_name.value,
+                                    drilldown->table_name.length,
+                                    NULL);
+        if (dependent_id) {
+          slice =
+            (grn_slice_data *)grn_hash_get_value_(ctx, data->slices,
+                                                  dependent_id, NULL);
+          target_table = slice->table;
+        }
+      }
+      if (dependent_id == GRN_ID_NIL) {
+        GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT,
+                         "[select][drilldowns][%.*s][table] "
+                         "nonexistent label: <%.*s>",
+                         (int)(drilldown->label.length),
+                         drilldown->label.value,
+                         (int)(drilldown->table_name.length),
+                         drilldown->table_name.value);
+        return GRN_FALSE;
+      }
     } else {
       grn_drilldown_data *dependent_drilldown;
       grn_table_group_result *dependent_result;

  Added: test/command/suite/select/drilldowns/table/slice.expected (+127 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/drilldowns/table/slice.expected    2016-06-26 21:29:20 +0900 (d828cb5)
@@ -0,0 +1,127 @@
+table_create Tags TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+table_create Memos TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Memos date COLUMN_SCALAR Time
+[[0,0.0,0.0],true]
+column_create Memos tag COLUMN_SCALAR Tags
+[[0,0.0,0.0],true]
+column_create Tags memos_tag COLUMN_INDEX Memos tag
+[[0,0.0,0.0],true]
+load --table Memos
+[
+{"_key": "Groonga is fast!", "date": "2016-05-19 12:00:00", "tag": "Groonga"},
+{"_key": "Mroonga is fast!", "date": "2016-05-19 12:00:01", "tag": "Mroonga"},
+{"_key": "Groonga sticker!", "date": "2016-05-19 12:00:02", "tag": "Groonga"},
+{"_key": "Rroonga is fast!", "date": "2016-05-19 12:00:03", "tag": "Rroonga"}
+]
+[[0,0.0,0.0],4]
+select Memos   --filter 'date < "2016-05-19 13:00:02"'   --slices[groonga].filter 'tag @ "Groonga"'   --slices[groonga].sort_keys 'date'   --slices[groonga].output_columns '_key, date, tag'   --drilldowns[tags].table groonga   --drilldowns[tags].keys tag
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        4
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "date",
+          "Time"
+        ],
+        [
+          "tag",
+          "Tags"
+        ]
+      ],
+      [
+        1,
+        "Groonga is fast!",
+        1463626800.0,
+        "Groonga"
+      ],
+      [
+        2,
+        "Mroonga is fast!",
+        1463626801.0,
+        "Mroonga"
+      ],
+      [
+        3,
+        "Groonga sticker!",
+        1463626802.0,
+        "Groonga"
+      ],
+      [
+        4,
+        "Rroonga is fast!",
+        1463626803.0,
+        "Rroonga"
+      ]
+    ],
+    {
+      "groonga": [
+        [
+          2
+        ],
+        [
+          [
+            "_key",
+            "ShortText"
+          ],
+          [
+            "date",
+            "Time"
+          ],
+          [
+            "tag",
+            "Tags"
+          ]
+        ],
+        [
+          "Groonga is fast!",
+          1463626800.0,
+          "Groonga"
+        ],
+        [
+          "Groonga sticker!",
+          1463626802.0,
+          "Groonga"
+        ]
+      ]
+    },
+    {
+      "tags": [
+        [
+          1
+        ],
+        [
+          [
+            "_key",
+            "ShortText"
+          ],
+          [
+            "_nsubrecs",
+            "Int32"
+          ]
+        ],
+        [
+          "Groonga",
+          2
+        ]
+      ]
+    }
+  ]
+]

  Added: test/command/suite/select/drilldowns/table/slice.test (+23 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/drilldowns/table/slice.test    2016-06-26 21:29:20 +0900 (1dda017)
@@ -0,0 +1,23 @@
+table_create Tags TABLE_PAT_KEY ShortText
+
+table_create Memos TABLE_HASH_KEY ShortText
+column_create Memos date COLUMN_SCALAR Time
+column_create Memos tag COLUMN_SCALAR Tags
+
+column_create Tags memos_tag COLUMN_INDEX Memos tag
+
+load --table Memos
+[
+{"_key": "Groonga is fast!", "date": "2016-05-19 12:00:00", "tag": "Groonga"},
+{"_key": "Mroonga is fast!", "date": "2016-05-19 12:00:01", "tag": "Mroonga"},
+{"_key": "Groonga sticker!", "date": "2016-05-19 12:00:02", "tag": "Groonga"},
+{"_key": "Rroonga is fast!", "date": "2016-05-19 12:00:03", "tag": "Rroonga"}
+]
+
+select Memos \
+  --filter 'date < "2016-05-19 13:00:02"' \
+  --slices[groonga].filter 'tag @ "Groonga"' \
+  --slices[groonga].sort_keys 'date' \
+  --slices[groonga].output_columns '_key, date, tag' \
+  --drilldowns[tags].table groonga \
+  --drilldowns[tags].keys tag
-------------- next part --------------
HTML����������������������������...
Télécharger 



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