[Groonga-commit] groonga/groonga at 13c4012 [master] Don't resolve record id on dynamic column

Back to archive index

Naoya Murakami null+****@clear*****
Sun May 8 20:50:29 JST 2016


Naoya Murakami	2016-05-08 20:50:29 +0900 (Sun, 08 May 2016)

  New Revision: 13c4012ab25daa4f5c571dadfd2f8606e13403ef
  https://github.com/groonga/groonga/commit/13c4012ab25daa4f5c571dadfd2f8606e13403ef

  Merged 6929c00: Merge pull request #539 from naoa/dont-resolve-id-of-temp-column

  Message:
    Don't resolve record id on dynamic column

  Added files:
    test/command/suite/select/column/stage/filtered/filter.expected
    test/command/suite/select/column/stage/filtered/filter.test
  Modified files:
    lib/proc/proc_select.c

  Modified: lib/proc/proc_select.c (+2 -5)
===================================================================
--- lib/proc/proc_select.c    2016-05-06 21:55:39 +0900 (34739d2)
+++ lib/proc/proc_select.c    2016-05-08 20:50:29 +0900 (b50ffdc)
@@ -868,6 +868,7 @@ grn_select_apply_columns(grn_ctx *ctx,
     grn_obj *expression;
     grn_obj *record;
     grn_table_cursor *table_cursor;
+    grn_id id;
 
     grn_hash_cursor_get_value(ctx, columns_cursor, (void **)&column_data);
 
@@ -953,13 +954,9 @@ grn_select_apply_columns(grn_ctx *ctx,
       break;
     }
 
-    while (grn_table_cursor_next(ctx, table_cursor) != GRN_ID_NIL) {
-      grn_id id;
-      void *key;
+    while ((id = grn_table_cursor_next(ctx, table_cursor)) != GRN_ID_NIL) {
       grn_obj *value;
 
-      grn_table_cursor_get_key(ctx, table_cursor, &key);
-      id = *((grn_id *)key);
       GRN_RECORD_SET(ctx, record, id);
       value = grn_expr_exec(ctx, expression, 0);
       if (value) {

  Added: test/command/suite/select/column/stage/filtered/filter.expected (+56 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/column/stage/filtered/filter.expected    2016-05-08 20:50:29 +0900 (2e0db39)
@@ -0,0 +1,56 @@
+table_create Items TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Items price COLUMN_SCALAR UInt32
+[[0,0.0,0.0],true]
+load --table Items
+[
+{"_key": "Book",  "price": 1498},
+{"_key": "Food",  "price": 1198},
+{"_key": "Drink", "price": 600}
+]
+[[0,0.0,0.0],3]
+select Items   --filter 'price < 1200'   --output_columns _id,_key,price,filtered   --column[filtered].stage filtered   --column[filtered].type UInt32   --column[filtered].flags COLUMN_SCALAR   --column[filtered].value '_id'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        2
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "price",
+          "UInt32"
+        ],
+        [
+          "filtered",
+          "UInt32"
+        ]
+      ],
+      [
+        2,
+        "Food",
+        1198,
+        2
+      ],
+      [
+        3,
+        "Drink",
+        600,
+        3
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/column/stage/filtered/filter.test (+17 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/column/stage/filtered/filter.test    2016-05-08 20:50:29 +0900 (048a983)
@@ -0,0 +1,17 @@
+table_create Items TABLE_HASH_KEY ShortText
+column_create Items price COLUMN_SCALAR UInt32
+
+load --table Items
+[
+{"_key": "Book",  "price": 1498},
+{"_key": "Food",  "price": 1198},
+{"_key": "Drink", "price": 600}
+]
+
+select Items \
+  --filter 'price < 1200' \
+  --output_columns _id,_key,price,filtered \
+  --column[filtered].stage filtered \
+  --column[filtered].type UInt32 \
+  --column[filtered].flags COLUMN_SCALAR \
+  --column[filtered].value '_id'
-------------- next part --------------
HTML����������������������������...
다운로드 



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