[Groonga-commit] groonga/groonga at bdb23d6 [master] Fix an optimization bug for "reference_column >= 'key_value'" case

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Aug 27 11:24:36 JST 2018


Kouhei Sutou	2018-08-27 11:24:36 +0900 (Mon, 27 Aug 2018)

  Revision: bdb23d66aeddf94b95a7a4ff91a95343050ff3f6
  https://github.com/groonga/groonga/commit/bdb23d66aeddf94b95a7a4ff91a95343050ff3f6

  Message:
    Fix an optimization bug for "reference_column >= 'key_value'" case

  Added files:
    test/command/suite/select/filter/no_index/reference/greater_equal/key_string.expected
    test/command/suite/select/filter/no_index/reference/greater_equal/key_string.test
  Modified files:
    lib/expr_executor.c

  Modified: lib/expr_executor.c (+9 -4)
===================================================================
--- lib/expr_executor.c    2018-08-27 11:06:25 +0900 (345369370)
+++ lib/expr_executor.c    2018-08-27 11:24:36 +0900 (ccda1d722)
@@ -3090,9 +3090,14 @@ grn_expr_executor_init_simple_condition_ra(grn_ctx *ctx,
   executor->data.simple_condition_ra.exec = grn_operator_to_exec_func(op);
 
   constant_buffer = &(executor->data.simple_condition_ra.constant_buffer);
-  GRN_VOID_INIT(constant_buffer);
-  grn_obj_reinit_for(ctx, constant_buffer, target);
-  grn_obj_cast(ctx, constant, constant_buffer, GRN_FALSE);
+  if (grn_obj_is_reference_column(ctx, target)) {
+    GRN_OBJ_INIT(constant_buffer, GRN_BULK, 0, constant->header.domain);
+    grn_obj_cast(ctx, constant, constant_buffer, GRN_FALSE);
+  } else {
+    GRN_VOID_INIT(constant_buffer);
+    grn_obj_reinit_for(ctx, constant_buffer, target);
+    grn_obj_cast(ctx, constant, constant_buffer, GRN_FALSE);
+  }
 }
 
 static grn_bool
@@ -3150,7 +3155,7 @@ grn_expr_executor_is_simple_condition_ra(grn_ctx *ctx,
     return GRN_FALSE;
   }
 
-  {
+  if (!grn_obj_is_reference_column(ctx, target->value)) {
     grn_obj constant_buffer;
     grn_rc rc;
     GRN_VOID_INIT(&constant_buffer);

  Added: test/command/suite/select/filter/no_index/reference/greater_equal/key_string.expected (+52 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/no_index/reference/greater_equal/key_string.expected    2018-08-27 11:24:36 +0900 (c317ee80d)
@@ -0,0 +1,52 @@
+table_create types 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 type COLUMN_SCALAR types
+[[0,0.0,0.0],true]
+load --table memos
+[
+{"_key": "a", "type": "10"},
+{"_key": "b", "type": "20"},
+{"_key": "c", "type": "30"}
+]
+[[0,0.0,0.0],3]
+select memos   --filter 'type >= "20"'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        2
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "type",
+          "types"
+        ]
+      ],
+      [
+        2,
+        "b",
+        "20"
+      ],
+      [
+        3,
+        "c",
+        "30"
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/filter/no_index/reference/greater_equal/key_string.test (+14 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/no_index/reference/greater_equal/key_string.test    2018-08-27 11:24:36 +0900 (c6e62124e)
@@ -0,0 +1,14 @@
+table_create types TABLE_PAT_KEY ShortText
+
+table_create memos TABLE_HASH_KEY ShortText
+column_create memos type COLUMN_SCALAR types
+
+load --table memos
+[
+{"_key": "a", "type": "10"},
+{"_key": "b", "type": "20"},
+{"_key": "c", "type": "30"}
+]
+
+select memos \
+  --filter 'type >= "20"'
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180827/7602a758/attachment-0001.htm 



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