Kouhei Sutou
null+****@clear*****
Thu Feb 21 18:41:20 JST 2013
Kouhei Sutou 2013-02-21 18:41:20 +0900 (Thu, 21 Feb 2013) New Revision: 3cc53b36751554d785592c2b528c76944c37285f https://github.com/groonga/groonga/commit/3cc53b36751554d785592c2b528c76944c37285f Log: Support range search for reference column by index TABLE_PAT_KEY (or TABLE_DAT_KEY) based index of _key like table_create Int8Tables TABLE_PAT_KEY Int8 column_create Int8Tables index COLUMN_INDEX Int8Table _key and ._key in --filter like --filter 'score._key < 2' are required. Added files: test/command/suite/select/index/nested/by_column/range/key.expected test/command/suite/select/index/nested/by_column/range/key.test Modified files: lib/db.c Modified: lib/db.c (+14 -1) =================================================================== --- lib/db.c 2013-02-19 23:01:05 +0900 (15fb098) +++ lib/db.c 2013-02-21 18:41:20 +0900 (46e78f0) @@ -7976,9 +7976,22 @@ grn_column_index_column_range(grn_ctx *ctx, grn_obj *obj, grn_operator op, { int n = 0; grn_obj **ip = indexbuf; + grn_hook_entry hook_entry; grn_hook *hooks; - for (hooks = DB_OBJ(obj)->hooks[GRN_HOOK_SET]; hooks; hooks = hooks->next) { + switch (obj->header.type) { + case GRN_TABLE_HASH_KEY : + case GRN_TABLE_PAT_KEY : + case GRN_TABLE_DAT_KEY : + case GRN_TABLE_NO_KEY : + hook_entry = GRN_HOOK_INSERT; + break; + default : + hook_entry = GRN_HOOK_SET; + break; + } + + for (hooks = DB_OBJ(obj)->hooks[hook_entry]; hooks; hooks = hooks->next) { default_set_value_hook_data *data = (void *)NEXT_ADDR(hooks); grn_obj *target = grn_ctx_at(ctx, data->target); if (target->header.type != GRN_COLUMN_INDEX) { continue; } Added: test/command/suite/select/index/nested/by_column/range/key.expected (+54 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/index/nested/by_column/range/key.expected 2013-02-21 18:41:20 +0900 (1fe8539) @@ -0,0 +1,54 @@ +table_create Int8Table TABLE_PAT_KEY Int8 +[[0,0.0,0.0],true] +table_create Int8Tables TABLE_PAT_KEY Int8 +[[0,0.0,0.0],true] +column_create Int8Tables index COLUMN_INDEX Int8Table _key +[[0,0.0,0.0],true] +table_create Users TABLE_PAT_KEY ShortText +[[0,0.0,0.0],true] +column_create Users score COLUMN_SCALAR Int8Table +[[0,0.0,0.0],true] +table_create Scores TABLE_PAT_KEY Int8Table +[[0,0.0,0.0],true] +column_create Scores users_score COLUMN_INDEX Users score +[[0,0.0,0.0],true] +load --table Users +[ +{"_key": "Alice", "score": 2}, +{"_key": "Bob", "score": 0}, +{"_key": "Carlos", "score": -1} +] +[[0,0.0,0.0],3] +select Users --filter 'score._key < 2 && score._key >= -1' --output_columns '_key, score' +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 2 + ], + [ + [ + "_key", + "ShortText" + ], + [ + "score", + "Int8Table" + ] + ], + [ + "Carlos", + -1 + ], + [ + "Bob", + 0 + ] + ] + ] +] Added: test/command/suite/select/index/nested/by_column/range/key.test (+21 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/index/nested/by_column/range/key.test 2013-02-21 18:41:20 +0900 (6554548) @@ -0,0 +1,21 @@ +table_create Int8Table TABLE_PAT_KEY Int8 + +table_create Int8Tables TABLE_PAT_KEY Int8 +column_create Int8Tables index COLUMN_INDEX Int8Table _key + +table_create Users TABLE_PAT_KEY ShortText +column_create Users score COLUMN_SCALAR Int8Table + +table_create Scores TABLE_PAT_KEY Int8Table +column_create Scores users_score COLUMN_INDEX Users score + +load --table Users +[ +{"_key": "Alice", "score": 2}, +{"_key": "Bob", "score": 0}, +{"_key": "Carlos", "score": -1} +] + +select Users \ + --filter 'score._key < 2 && score._key >= -1' \ + --output_columns '_key, score' -------------- next part -------------- HTML����������������������������...Download