[Groonga-commit] groonga/groonga at 218e4f4 [master] select: support index used search for filtered tables

アーカイブの一覧に戻る

Kouhei Sutou null+****@clear*****
Tue May 10 14:51:52 JST 2016


Kouhei Sutou	2016-05-10 14:51:52 +0900 (Tue, 10 May 2016)

  New Revision: 218e4f40b53125695b77fd4c376d0f19138de5c6
  https://github.com/groonga/groonga/commit/218e4f40b53125695b77fd4c376d0f19138de5c6

  Message:
    select: support index used search for filtered tables

  Added files:
    test/command/suite/select/column/stage/initial/index.expected
    test/command/suite/select/column/stage/initial/index.test
  Modified files:
    lib/db.c
    test/command/suite/select/scorer/function/query.expected

  Modified: lib/db.c (+21 -0)
===================================================================
--- lib/db.c    2016-05-10 14:42:37 +0900 (f2dd188)
+++ lib/db.c    2016-05-10 14:51:52 +0900 (2d76156)
@@ -12159,6 +12159,27 @@ grn_column_find_index_data_accessor_match(grn_ctx *ctx, grn_obj *obj,
       }
     }
 
+    if (!found &&
+        a->next &&
+        grn_obj_is_table(ctx, a->obj) &&
+        a->obj->header.domain == a->next->obj->header.domain) {
+      grn_obj *index = (grn_obj *)a;
+      int section = 0;
+
+      found = GRN_TRUE;
+      if (section_buf) {
+        *section_buf = section;
+      }
+      if (n < buf_size) {
+        *ip++ = index;
+      }
+      if (n < n_index_data) {
+        index_data[n].index = index;
+        index_data[n].section = section;
+      }
+      n++;
+    }
+
     if (!found) {
       break;
     }

  Added: test/command/suite/select/column/stage/initial/index.expected (+81 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/column/stage/initial/index.expected    2016-05-10 14:51:52 +0900 (3f65f92)
@@ -0,0 +1,81 @@
+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]
+table_create Prices TABLE_PAT_KEY UInt32
+[[0,0.0,0.0],true]
+column_create Prices item_index COLUMN_INDEX Items price
+[[0,0.0,0.0],true]
+load --table Items
+[
+{"_key": "Book",  "price": 1000},
+{"_key": "Note",  "price": 1000},
+{"_key": "Box",   "price":  520},
+{"_key": "Pen",   "price":  510},
+{"_key": "Food",  "price":  500},
+{"_key": "Drink", "price":  300}
+]
+[[0,0.0,0.0],6]
+log_level --level info
+[[0,0.0,0.0],true]
+select Items   --column[price_with_tax].stage initial   --column[price_with_tax].type UInt32   --column[price_with_tax].flags COLUMN_SCALAR   --column[price_with_tax].value 'price * 1.08'   --filter 'price >= 510'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        4
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "price_with_tax",
+          "UInt32"
+        ],
+        [
+          "price",
+          "UInt32"
+        ]
+      ],
+      [
+        4,
+        "Pen",
+        550,
+        510
+      ],
+      [
+        3,
+        "Box",
+        561,
+        520
+      ],
+      [
+        1,
+        "Book",
+        1080,
+        1000
+      ],
+      [
+        2,
+        "Note",
+        1080,
+        1000
+      ]
+    ]
+  ]
+]
+#|i| [table][select][index][range] <Prices>
+#|i| [table][select][index][range][accessor] <Prices.item_index>
+log_level --level notice
+[[0,0.0,0.0],true]

  Added: test/command/suite/select/column/stage/initial/index.test (+26 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/column/stage/initial/index.test    2016-05-10 14:51:52 +0900 (1f3257e)
@@ -0,0 +1,26 @@
+table_create Items TABLE_HASH_KEY ShortText
+column_create Items price COLUMN_SCALAR UInt32
+
+table_create Prices TABLE_PAT_KEY UInt32
+column_create Prices item_index COLUMN_INDEX Items price
+
+load --table Items
+[
+{"_key": "Book",  "price": 1000},
+{"_key": "Note",  "price": 1000},
+{"_key": "Box",   "price":  520},
+{"_key": "Pen",   "price":  510},
+{"_key": "Food",  "price":  500},
+{"_key": "Drink", "price":  300}
+]
+
+#@add-important-log-levels info
+log_level --level info
+select Items \
+  --column[price_with_tax].stage initial \
+  --column[price_with_tax].type UInt32 \
+  --column[price_with_tax].flags COLUMN_SCALAR \
+  --column[price_with_tax].value 'price * 1.08' \
+  --filter 'price >= 510'
+log_level --level notice
+#@remove-important-log-levels info

  Modified: test/command/suite/select/scorer/function/query.expected (+1 -1)
===================================================================
--- test/command/suite/select/scorer/function/query.expected    2016-05-10 14:42:37 +0900 (1b539f0)
+++ test/command/suite/select/scorer/function/query.expected    2016-05-10 14:51:52 +0900 (4621c82)
@@ -12,4 +12,4 @@ load --table Users
 ]
 [[0,0.0,0.0],1]
 select Users   --filter true   --scorer '_score = query("name", "Alice")'   --output_columns _key,_score
-[[0,0.0,0.0],[[[1],[["_key","ShortText"],["_score","Int32"]],["alice",0]]]]
+[[0,0.0,0.0],[[[1],[["_key","ShortText"],["_score","Int32"]],["alice",1]]]]
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る