Naoya Murakami
null+****@clear*****
Tue Jan 24 19:22:41 JST 2017
Naoya Murakami 2016-08-21 09:58:21 +0900 (Sun, 21 Aug 2016) New Revision: 5a9cc7f92de254a4f0554c604a58527b2fee39ba https://github.com/groonga/groonga/commit/5a9cc7f92de254a4f0554c604a58527b2fee39ba Merged 38c523c: Merge pull request #629 from naoa/in_values-sequential-for-ref-vector Message: proc in_values: support sequential_search for reference vector column Added files: test/command/suite/select/function/in_values/with_index/sequential_search/reference_vector.test Copied files: test/command/suite/select/function/in_values/with_index/sequential_search/reference.expected (from test/command/suite/select/function/in_values/with_index/sequential_search.expected) Modified files: lib/proc.c Renamed files: test/command/suite/select/function/in_values/with_index/sequential_search/reference.test (from test/command/suite/select/function/in_values/with_index/sequential_search.test) test/command/suite/select/function/in_values/with_index/sequential_search/reference_vector.expected (from test/command/suite/select/function/in_values/with_index/sequential_search.expected) Modified: lib/proc.c (+36 -8) =================================================================== --- lib/proc.c 2017-01-18 23:36:34 +0900 (3894555) +++ lib/proc.c 2016-08-21 09:58:21 +0900 (de58fd9) @@ -2912,10 +2912,16 @@ selector_in_values_sequential_search(grn_ctx *ctx, grn_obj *accessor; char local_source_name[GRN_TABLE_MAX_KEY_SIZE]; int local_source_name_length; + grn_obj_flags source_obj_flags = 0; local_source_name_length = grn_column_name(ctx, source, local_source_name, GRN_TABLE_MAX_KEY_SIZE); + + if ((source->header.flags & GRN_OBJ_COLUMN_TYPE_MASK) == GRN_OBJ_COLUMN_VECTOR) { + source_obj_flags |= GRN_OBJ_VECTOR; + } + grn_obj_unlink(ctx, source); accessor = grn_obj_column(ctx, res, local_source_name, @@ -2924,7 +2930,7 @@ selector_in_values_sequential_search(grn_ctx *ctx, grn_table_cursor *cursor; grn_id id; grn_obj record_value; - GRN_RECORD_INIT(&record_value, 0, grn_obj_id(ctx, res)); + GRN_RECORD_INIT(&record_value, source_obj_flags, grn_obj_id(ctx, res)); cursor = grn_table_cursor_open(ctx, res, NULL, 0, NULL, 0, 0, -1, GRN_CURSOR_ASCENDING); @@ -2935,13 +2941,35 @@ selector_in_values_sequential_search(grn_ctx *ctx, grn_obj_get_value(ctx, accessor, id, &record_value); for (i = 0; i < n_value_ids; i++) { grn_id value_id = GRN_RECORD_VALUE_AT(&value_ids, i); - if (value_id == GRN_RECORD_VALUE(&record_value)) { - grn_posting posting; - posting.rid = *record_id; - posting.sid = 1; - posting.pos = 0; - posting.weight = 0; - grn_ii_posting_add(ctx, &posting, (grn_hash *)res, op); + switch (record_value.header.type) { + case GRN_BULK : + if (value_id == GRN_RECORD_VALUE(&record_value)) { + grn_posting posting; + posting.rid = *record_id; + posting.sid = 1; + posting.pos = 0; + posting.weight = 0; + grn_ii_posting_add(ctx, &posting, (grn_hash *)res, op); + } + break; + case GRN_UVECTOR : + { + int j, n_elements; + n_elements = GRN_BULK_VSIZE(&record_value) / sizeof(grn_id); + for (j = 0; j < n_elements; j++) { + if (value_id == GRN_RECORD_VALUE_AT(&record_value, j)) { + grn_posting posting; + posting.rid = *record_id; + posting.sid = 1; + posting.pos = 0; + posting.weight = 0; + grn_ii_posting_add(ctx, &posting, (grn_hash *)res, op); + } + } + } + break; + default : + break; } } } Copied: test/command/suite/select/function/in_values/with_index/sequential_search/reference.expected (+0 -0) 100% =================================================================== Renamed: test/command/suite/select/function/in_values/with_index/sequential_search/reference.test (+0 -0) 100% =================================================================== Renamed: test/command/suite/select/function/in_values/with_index/sequential_search/reference_vector.expected (+16 -11) 52% =================================================================== --- test/command/suite/select/function/in_values/with_index/sequential_search.expected 2017-01-18 23:36:34 +0900 (8608033) +++ test/command/suite/select/function/in_values/with_index/sequential_search/reference_vector.expected 2016-08-21 09:58:21 +0900 (eba7c91) @@ -2,20 +2,20 @@ table_create Tags TABLE_HASH_KEY ShortText [[0,0.0,0.0],true] table_create Memos TABLE_HASH_KEY ShortText [[0,0.0,0.0],true] -column_create Memos tag COLUMN_SCALAR Tags +column_create Memos tags COLUMN_VECTOR Tags [[0,0.0,0.0],true] load --table Memos [ -{"_key": "Rroonga is fast!", "tag": "Rroonga"}, -{"_key": "Groonga is fast!", "tag": "Groonga"}, -{"_key": "Mroonga is fast!", "tag": "Mroonga"}, -{"_key": "Groonga sticker!", "tag": "Groonga"}, -{"_key": "Groonga is good!", "tag": "Groonga"} +{"_key": "Rroonga is fast!", "tags": ["Rroonga"]}, +{"_key": "Groonga is fast!", "tags": ["Groonga"]}, +{"_key": "Mroonga is fast!", "tags": ["Mroonga"]}, +{"_key": "Groonga sticker!", "tags": ["Sticker", "Groonga"]}, +{"_key": "Groonga is good!", "tags": ["Groonga"]} ] [[0,0.0,0.0],5] -column_create Tags memos_tag COLUMN_INDEX Memos tag +column_create Tags memos_tags COLUMN_INDEX Memos tags [[0,0.0,0.0],true] -select Memos --filter '_id >= 3 && in_values(tag, "Groonga")' --output_columns _id,_score,_key,tag +select Memos --filter '_id >= 3 && in_values(tags, "Groonga")' --output_columns _id,_score,_key,tags [ [ 0, @@ -41,7 +41,7 @@ select Memos --filter '_id >= 3 && in_values(tag, "Groonga")' --output_columns _ "ShortText" ], [ - "tag", + "tags", "Tags" ] ], @@ -49,13 +49,18 @@ select Memos --filter '_id >= 3 && in_values(tag, "Groonga")' --output_columns _ 4, 2, "Groonga sticker!", - "Groonga" + [ + "Sticker", + "Groonga" + ] ], [ 5, 2, "Groonga is good!", - "Groonga" + [ + "Groonga" + ] ] ] ] Added: test/command/suite/select/function/in_values/with_index/sequential_search/reference_vector.test (+19 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/function/in_values/with_index/sequential_search/reference_vector.test 2016-08-21 09:58:21 +0900 (c6aa51b) @@ -0,0 +1,19 @@ +#$GRN_IN_VALUES_TOO_MANY_INDEX_MATCH_RATIO=0.7 + +table_create Tags TABLE_HASH_KEY ShortText + +table_create Memos TABLE_HASH_KEY ShortText +column_create Memos tags COLUMN_VECTOR Tags + +load --table Memos +[ +{"_key": "Rroonga is fast!", "tags": ["Rroonga"]}, +{"_key": "Groonga is fast!", "tags": ["Groonga"]}, +{"_key": "Mroonga is fast!", "tags": ["Mroonga"]}, +{"_key": "Groonga sticker!", "tags": ["Sticker", "Groonga"]}, +{"_key": "Groonga is good!", "tags": ["Groonga"]} +] + +column_create Tags memos_tags COLUMN_INDEX Memos tags + +select Memos --filter '_id >= 3 && in_values(tags, "Groonga")' --output_columns _id,_score,_key,tags -------------- next part -------------- HTML����������������������������... 다운로드