Masafumi Yokoyama
null+****@clear*****
Thu Mar 12 15:04:39 JST 2015
Masafumi Yokoyama 2015-03-12 15:04:39 +0900 (Thu, 12 Mar 2015) New Revision: 7e462b1ffae7e1a5b39c78cde67c5ab44c863b41 https://github.com/groonga/groonga/commit/7e462b1ffae7e1a5b39c78cde67c5ab44c863b41 Merged c49c746: Merge pull request #305 from groonga/fix-score-for-2-items-descending-by-index-of-section Message: Fix score for 2-items descending by index of section Added files: test/command/suite/select/match_columns/section/by_index/2_items/descending.expected test/command/suite/select/match_columns/section/by_index/2_items/descending.test Modified files: lib/expr.c Modified: lib/expr.c (+7 -1) =================================================================== --- lib/expr.c 2015-03-12 14:44:27 +0900 (2e03b83) +++ lib/expr.c 2015-03-12 15:04:39 +0900 (801e04c) @@ -5184,7 +5184,13 @@ grn_table_select_index(grn_ctx *ctx, grn_obj *table, scan_info *si, int32_t weight = wp[1]; if (sid) { int weight_index = sid - 1; - GRN_INT32_SET_AT(ctx, &wv, weight_index, weight); + int current_vector_size; + current_vector_size = GRN_BULK_VSIZE(&wv)/sizeof(int32_t); + if (weight_index < current_vector_size) { + *((int *)GRN_BULK_HEAD(&wv)) = weight; + } else { + GRN_INT32_SET_AT(ctx, &wv, weight_index, weight); + } optarg.weight_vector = &GRN_INT32_VALUE(&wv); optarg.vector_size = GRN_BULK_VSIZE(&wv)/sizeof(int32_t); } else { Added: test/command/suite/select/match_columns/section/by_index/2_items/descending.expected (+54 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/match_columns/section/by_index/2_items/descending.expected 2015-03-12 15:04:39 +0900 (04da67f) @@ -0,0 +1,54 @@ +table_create Memos TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Memos title COLUMN_SCALAR ShortText +[[0,0.0,0.0],true] +column_create Memos content COLUMN_SCALAR ShortText +[[0,0.0,0.0],true] +table_create Lexicon TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram +[[0,0.0,0.0],true] +column_create Lexicon memo_index COLUMN_INDEX|WITH_POSITION|WITH_SECTION Memos title,content +[[0,0.0,0.0],true] +load --table Memos +[ +["title", "content"], +["groonga", "Start groonga!"], +["mroonga", "Start mroonga!"], +["rroonga", "Start rroonga!"], +["Ruby", "Start Ruby!"], +["learn", "Learning Ruby and groonga..."] +] +[[0,0.0,0.0],5] +select Memos --match_columns "Lexicon.memo_index[1] || Lexicon.memo_index[0]" --query rroonga --output_columns "title, content, _score" +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 1 + ], + [ + [ + "title", + "ShortText" + ], + [ + "content", + "ShortText" + ], + [ + "_score", + "Int32" + ] + ], + [ + "rroonga", + "Start rroonga!", + 2 + ] + ] + ] +] Added: test/command/suite/select/match_columns/section/by_index/2_items/descending.test (+22 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/match_columns/section/by_index/2_items/descending.test 2015-03-12 15:04:39 +0900 (5a63fab) @@ -0,0 +1,22 @@ +table_create Memos TABLE_NO_KEY +column_create Memos title COLUMN_SCALAR ShortText +column_create Memos content COLUMN_SCALAR ShortText + +table_create Lexicon TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram +column_create Lexicon memo_index COLUMN_INDEX|WITH_POSITION|WITH_SECTION \ + Memos title,content + +load --table Memos +[ +["title", "content"], +["groonga", "Start groonga!"], +["mroonga", "Start mroonga!"], +["rroonga", "Start rroonga!"], +["Ruby", "Start Ruby!"], +["learn", "Learning Ruby and groonga..."] +] + +select Memos \ + --match_columns "Lexicon.memo_index[1] || Lexicon.memo_index[0]" \ + --query rroonga \ + --output_columns "title, content, _score" -------------- next part -------------- HTML����������������������������...Download