null+****@clear*****
null+****@clear*****
2012年 6月 16日 (土) 13:26:51 JST
Kouhei Sutou 2012-06-16 13:26:51 +0900 (Sat, 16 Jun 2012)
New Revision: a80eac8e65a4ab17a646b39673bdd347f236f58f
https://github.com/groonga/groonga/commit/a80eac8e65a4ab17a646b39673bdd347f236f58f
Log:
Support suffix search by index
Added files:
test/function/suite/select/query/suffix_search/column_short_text.expected
test/function/suite/select/query/suffix_search/column_short_text.test
test/function/suite/select/query/suffix_search/double_array_trie_key.expected
test/function/suite/select/query/suffix_search/double_array_trie_key.test
test/function/suite/select/query/suffix_search/hash_key.expected
test/function/suite/select/query/suffix_search/hash_key.test
test/function/suite/select/query/suffix_search/patricia_trie_index_with_sis.expected
test/function/suite/select/query/suffix_search/patricia_trie_index_with_sis.test
test/function/suite/select/query/suffix_search/patricia_trie_key_with_sis.expected
test/function/suite/select/query/suffix_search/patricia_trie_key_with_sis.test
test/function/suite/select/query/suffix_search/patricia_trie_key_without_sis.expected
test/function/suite/select/query/suffix_search/patricia_trie_key_without_sis.test
Modified files:
lib/expr.c
Modified: lib/expr.c (+16 -0)
===================================================================
--- lib/expr.c 2012-06-16 12:15:38 +0900 (81385a9)
+++ lib/expr.c 2012-06-16 13:26:51 +0900 (5e5a7b3)
@@ -4060,6 +4060,22 @@ grn_table_select(grn_ctx *ctx, grn_obj *table, grn_obj *expr,
done++;
}
break;
+ case GRN_OP_SUFFIX :
+ {
+ grn_obj *domain;
+ if (si->flags & SCAN_ACCESSOR) {
+ domain = table;
+ } else {
+ domain = grn_ctx_at(ctx, index->header.domain);
+ }
+ if (domain->header.type != GRN_TABLE_PAT_KEY) {
+ break;
+ }
+ if (!(domain->header.flags & GRN_OBJ_KEY_WITH_SIS)) {
+ break;
+ }
+ }
+ /* fallthru */
case GRN_OP_PREFIX :
if (si->flags & SCAN_ACCESSOR) {
if (index->header.type == GRN_ACCESSOR &&
Added: test/function/suite/select/query/suffix_search/column_short_text.expected (+45 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/select/query/suffix_search/column_short_text.expected 2012-06-16 13:26:51 +0900 (6e30ccc)
@@ -0,0 +1,45 @@
+table_create People TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create People name COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table People
+[
+{"name": "ひろゆき"},
+{"name": "まろゆき"},
+{"name": "ひろあき"},
+{"name": "ゆきひろ"}
+]
+[[0,0.0,0.0],4]
+select --table People --query name:$ゆき
+[
+ [
+ 0,
+ 0.0,
+ 0.0
+ ],
+ [
+ [
+ [
+ 2
+ ],
+ [
+ [
+ "_id",
+ "UInt32"
+ ],
+ [
+ "name",
+ "ShortText"
+ ]
+ ],
+ [
+ 1,
+ "ひろゆき"
+ ],
+ [
+ 2,
+ "まろゆき"
+ ]
+ ]
+ ]
+]
Added: test/function/suite/select/query/suffix_search/column_short_text.test (+11 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/select/query/suffix_search/column_short_text.test 2012-06-16 13:26:51 +0900 (c7f1768)
@@ -0,0 +1,11 @@
+table_create People TABLE_NO_KEY
+column_create People name COLUMN_SCALAR ShortText
+
+load --table People
+[
+{"name": "ひろゆき"},
+{"name": "まろゆき"},
+{"name": "ひろあき"},
+{"name": "ゆきひろ"}
+]
+select --table People --query name:$ゆき
Added: test/function/suite/select/query/suffix_search/double_array_trie_key.expected (+43 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/select/query/suffix_search/double_array_trie_key.expected 2012-06-16 13:26:51 +0900 (1b0ace0)
@@ -0,0 +1,43 @@
+table_create Names TABLE_DAT_KEY ShortText
+[[0,0.0,0.0],true]
+load --table Names
+[
+{"_key": "ひろゆき"},
+{"_key": "まろゆき"},
+{"_key": "ひろあき"},
+{"_key": "ゆきひろ"}
+]
+[[0,0.0,0.0],4]
+select --table Names --query _key:$ゆき
+[
+ [
+ 0,
+ 0.0,
+ 0.0
+ ],
+ [
+ [
+ [
+ 2
+ ],
+ [
+ [
+ "_id",
+ "UInt32"
+ ],
+ [
+ "_key",
+ "ShortText"
+ ]
+ ],
+ [
+ 1,
+ "ひろゆき"
+ ],
+ [
+ 2,
+ "まろゆき"
+ ]
+ ]
+ ]
+]
Added: test/function/suite/select/query/suffix_search/double_array_trie_key.test (+9 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/select/query/suffix_search/double_array_trie_key.test 2012-06-16 13:26:51 +0900 (6271c1b)
@@ -0,0 +1,9 @@
+table_create Names TABLE_DAT_KEY ShortText
+load --table Names
+[
+{"_key": "ひろゆき"},
+{"_key": "まろゆき"},
+{"_key": "ひろあき"},
+{"_key": "ゆきひろ"}
+]
+select --table Names --query _key:$ゆき
Added: test/function/suite/select/query/suffix_search/hash_key.expected (+43 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/select/query/suffix_search/hash_key.expected 2012-06-16 13:26:51 +0900 (f2b4362)
@@ -0,0 +1,43 @@
+table_create Names TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+load --table Names
+[
+{"_key": "ひろゆき"},
+{"_key": "まろゆき"},
+{"_key": "ひろあき"},
+{"_key": "ゆきひろ"}
+]
+[[0,0.0,0.0],4]
+select --table Names --query _key:$ゆき
+[
+ [
+ 0,
+ 0.0,
+ 0.0
+ ],
+ [
+ [
+ [
+ 2
+ ],
+ [
+ [
+ "_id",
+ "UInt32"
+ ],
+ [
+ "_key",
+ "ShortText"
+ ]
+ ],
+ [
+ 1,
+ "ひろゆき"
+ ],
+ [
+ 2,
+ "まろゆき"
+ ]
+ ]
+ ]
+]
Added: test/function/suite/select/query/suffix_search/hash_key.test (+9 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/select/query/suffix_search/hash_key.test 2012-06-16 13:26:51 +0900 (4568d8b)
@@ -0,0 +1,9 @@
+table_create Names TABLE_HASH_KEY ShortText
+load --table Names
+[
+{"_key": "ひろゆき"},
+{"_key": "まろゆき"},
+{"_key": "ひろあき"},
+{"_key": "ゆきひろ"}
+]
+select --table Names --query _key:$ゆき
Added: test/function/suite/select/query/suffix_search/patricia_trie_index_with_sis.expected (+49 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/select/query/suffix_search/patricia_trie_index_with_sis.expected 2012-06-16 13:26:51 +0900 (ce36a24)
@@ -0,0 +1,49 @@
+table_create People TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create People name COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+table_create Names TABLE_PAT_KEY|KEY_WITH_SIS ShortText
+[[0,0.0,0.0],true]
+column_create Names people_index COLUMN_INDEX People name
+[[0,0.0,0.0],true]
+load --table People
+[
+{"name": "ひろゆき"},
+{"name": "まろゆき"},
+{"name": "ひろあき"},
+{"name": "ゆきひろ"}
+]
+[[0,0.0,0.0],4]
+select --table People --query name:$ゆき
+[
+ [
+ 0,
+ 0.0,
+ 0.0
+ ],
+ [
+ [
+ [
+ 2
+ ],
+ [
+ [
+ "_id",
+ "UInt32"
+ ],
+ [
+ "name",
+ "ShortText"
+ ]
+ ],
+ [
+ 2,
+ "まろゆき"
+ ],
+ [
+ 1,
+ "ひろゆき"
+ ]
+ ]
+ ]
+]
Added: test/function/suite/select/query/suffix_search/patricia_trie_index_with_sis.test (+13 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/select/query/suffix_search/patricia_trie_index_with_sis.test 2012-06-16 13:26:51 +0900 (6cf2c0d)
@@ -0,0 +1,13 @@
+table_create People TABLE_NO_KEY
+column_create People name COLUMN_SCALAR ShortText
+table_create Names TABLE_PAT_KEY|KEY_WITH_SIS ShortText
+column_create Names people_index COLUMN_INDEX People name
+
+load --table People
+[
+{"name": "ひろゆき"},
+{"name": "まろゆき"},
+{"name": "ひろあき"},
+{"name": "ゆきひろ"}
+]
+select --table People --query name:$ゆき
Added: test/function/suite/select/query/suffix_search/patricia_trie_key_with_sis.expected (+61 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/select/query/suffix_search/patricia_trie_key_with_sis.expected 2012-06-16 13:26:51 +0900 (ba800b3)
@@ -0,0 +1,61 @@
+table_create Names TABLE_PAT_KEY|KEY_WITH_SIS ShortText
+[[0,0.0,0.0],true]
+column_create Names original COLUMN_SCALAR Bool
+[[0,0.0,0.0],true]
+load --table Names
+[
+{"_key": "ひろゆき", "original": true},
+{"_key": "まろゆき", "original": true},
+{"_key": "ひろあき", "original": true},
+{"_key": "ゆきひろ", "original": true}
+]
+[[0,0.0,0.0],4]
+select --table Names --query _key:$ゆき
+[
+ [
+ 0,
+ 0.0,
+ 0.0
+ ],
+ [
+ [
+ [
+ 4
+ ],
+ [
+ [
+ "_id",
+ "UInt32"
+ ],
+ [
+ "_key",
+ "ShortText"
+ ],
+ [
+ "original",
+ "Bool"
+ ]
+ ],
+ [
+ 3,
+ "ゆき",
+ false
+ ],
+ [
+ 2,
+ "ろゆき",
+ false
+ ],
+ [
+ 5,
+ "まろゆき",
+ true
+ ],
+ [
+ 1,
+ "ひろゆき",
+ true
+ ]
+ ]
+ ]
+]
Added: test/function/suite/select/query/suffix_search/patricia_trie_key_with_sis.test (+10 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/select/query/suffix_search/patricia_trie_key_with_sis.test 2012-06-16 13:26:51 +0900 (ca34ae0)
@@ -0,0 +1,10 @@
+table_create Names TABLE_PAT_KEY|KEY_WITH_SIS ShortText
+column_create Names original COLUMN_SCALAR Bool
+load --table Names
+[
+{"_key": "ひろゆき", "original": true},
+{"_key": "まろゆき", "original": true},
+{"_key": "ひろあき", "original": true},
+{"_key": "ゆきひろ", "original": true}
+]
+select --table Names --query _key:$ゆき
Added: test/function/suite/select/query/suffix_search/patricia_trie_key_without_sis.expected (+43 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/select/query/suffix_search/patricia_trie_key_without_sis.expected 2012-06-16 13:26:51 +0900 (10a5c7d)
@@ -0,0 +1,43 @@
+table_create Names TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+load --table Names
+[
+{"_key": "ひろゆき"},
+{"_key": "まろゆき"},
+{"_key": "ひろあき"},
+{"_key": "ゆきひろ"}
+]
+[[0,0.0,0.0],4]
+select --table Names --query _key:$ゆき
+[
+ [
+ 0,
+ 0.0,
+ 0.0
+ ],
+ [
+ [
+ [
+ 2
+ ],
+ [
+ [
+ "_id",
+ "UInt32"
+ ],
+ [
+ "_key",
+ "ShortText"
+ ]
+ ],
+ [
+ 1,
+ "ひろゆき"
+ ],
+ [
+ 2,
+ "まろゆき"
+ ]
+ ]
+ ]
+]
Added: test/function/suite/select/query/suffix_search/patricia_trie_key_without_sis.test (+9 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/select/query/suffix_search/patricia_trie_key_without_sis.test 2012-06-16 13:26:51 +0900 (bd39af5)
@@ -0,0 +1,9 @@
+table_create Names TABLE_PAT_KEY ShortText
+load --table Names
+[
+{"_key": "ひろゆき"},
+{"_key": "まろゆき"},
+{"_key": "ひろあき"},
+{"_key": "ゆきひろ"}
+]
+select --table Names --query _key:$ゆき