Kouhei Sutou
null+****@clear*****
Mon Feb 24 12:53:01 JST 2014
Kouhei Sutou 2014-02-24 12:53:01 +0900 (Mon, 24 Feb 2014) New Revision: d57d1a5602044f24c7631ce58d9bec169586a58a https://github.com/groonga/groonga/commit/d57d1a5602044f24c7631ce58d9bec169586a58a Message: select adjuster: factor must be int instead of float Because _score and grn_search_optarg.vector_size are int. Modified files: lib/proc.c test/command/suite/select/adjuster/multiple.expected test/command/suite/select/adjuster/multiple.test test/command/suite/select/adjuster/not_all_match.expected test/command/suite/select/adjuster/not_all_match.test test/command/suite/select/adjuster/one.expected test/command/suite/select/adjuster/one.test Modified: lib/proc.c (+12 -12) =================================================================== --- lib/proc.c 2014-02-24 11:08:49 +0900 (79b0bca) +++ lib/proc.c 2014-02-24 12:53:01 +0900 (16e5efa) @@ -442,26 +442,26 @@ is_output_columns_format_v1(grn_ctx *ctx, return GRN_TRUE; } -static double +static int grn_select_apply_adjuster_ensure_factor(grn_ctx *ctx, grn_obj *factor_object) { if (!factor_object) { - return 1.0; - } else if (factor_object->header.domain == GRN_DB_FLOAT) { - return GRN_FLOAT_VALUE(factor_object); + return 1; + } else if (factor_object->header.domain == GRN_DB_INT32) { + return GRN_INT32_VALUE(factor_object); } else { grn_rc rc; - grn_obj float_object; - double factor; - GRN_FLOAT_INIT(&float_object, 0); - rc = grn_obj_cast(ctx, factor_object, &float_object, GRN_FALSE); + grn_obj int32_object; + int factor; + GRN_INT32_INIT(&int32_object, 0); + rc = grn_obj_cast(ctx, factor_object, &int32_object, GRN_FALSE); if (rc == GRN_SUCCESS) { - factor = GRN_FLOAT_VALUE(&float_object); + factor = GRN_INT32_VALUE(&int32_object); } else { /* TODO: Log or return error? */ - factor = 1.0; + factor = 1; } - GRN_OBJ_FIN(ctx, &float_object); + GRN_OBJ_FIN(ctx, &int32_object); return factor; } } @@ -532,7 +532,7 @@ grn_select_apply_adjuster_adjust(grn_ctx *ctx, grn_obj *table, grn_obj *res, { grn_obj *index; unsigned int n_indexes; - double factor_value; + int factor_value; n_indexes = grn_column_index(ctx, column, GRN_OP_MATCH, &index, 1, NULL); if (n_indexes == 0) { Modified: test/command/suite/select/adjuster/multiple.expected (+4 -4) =================================================================== --- test/command/suite/select/adjuster/multiple.expected 2014-02-24 11:08:49 +0900 (a25d9b0) +++ test/command/suite/select/adjuster/multiple.expected 2014-02-24 12:53:01 +0900 (821d5e4) @@ -29,7 +29,7 @@ load --table Memos } ] [[0,0.0,0.0],3] -select Memos --filter true --adjuster 'tags @ "groonga" * 2.5 + tags @ "mroonga" * 0.5 + tags @ "ruby" * 1.5' --output_columns _key,_score +select Memos --filter true --adjuster 'tags @ "groonga" * 4 + tags @ "mroonga" * 3 + tags @ "ruby" * 2' --output_columns _key,_score [ [ 0, @@ -53,15 +53,15 @@ select Memos --filter true --adjuster 'tags @ "groonga" * 2.5 + tags @ "mroo ], [ "Groonga is fast", - 251 + 401 ], [ "Mroonga is also fast", - 76 + 341 ], [ "Ruby is an object oriented script language", - 151 + 201 ] ] ] Modified: test/command/suite/select/adjuster/multiple.test (+1 -1) =================================================================== --- test/command/suite/select/adjuster/multiple.test 2014-02-24 11:08:49 +0900 (dec0f83) +++ test/command/suite/select/adjuster/multiple.test 2014-02-24 12:53:01 +0900 (ba439b7) @@ -30,5 +30,5 @@ load --table Memos select Memos \ --filter true \ - --adjuster 'tags @ "groonga" * 2.5 + tags @ "mroonga" * 0.5 + tags @ "ruby" * 1.5' \ + --adjuster 'tags @ "groonga" * 4 + tags @ "mroonga" * 3 + tags @ "ruby" * 2' \ --output_columns _key,_score Modified: test/command/suite/select/adjuster/not_all_match.expected (+1 -1) =================================================================== --- test/command/suite/select/adjuster/not_all_match.expected 2014-02-24 11:08:49 +0900 (0f79495) +++ test/command/suite/select/adjuster/not_all_match.expected 2014-02-24 12:53:01 +0900 (93906f0) @@ -32,7 +32,7 @@ load --table Memos } ] [[0,0.0,0.0],4] -select Memos --filter '_id != 1' --adjuster 'tags @ "groonga" * 1.0' --output_columns _key,_score +select Memos --filter '_id != 1' --adjuster 'tags @ "groonga" * 1' --output_columns _key,_score [ [ 0, Modified: test/command/suite/select/adjuster/not_all_match.test (+1 -1) =================================================================== --- test/command/suite/select/adjuster/not_all_match.test 2014-02-24 11:08:49 +0900 (f94c9b7) +++ test/command/suite/select/adjuster/not_all_match.test 2014-02-24 12:53:01 +0900 (3a3a116) @@ -33,5 +33,5 @@ load --table Memos select Memos \ --filter '_id != 1' \ - --adjuster 'tags @ "groonga" * 1.0' \ + --adjuster 'tags @ "groonga" * 1' \ --output_columns _key,_score Modified: test/command/suite/select/adjuster/one.expected (+3 -3) =================================================================== --- test/command/suite/select/adjuster/one.expected 2014-02-24 11:08:49 +0900 (bd16948) +++ test/command/suite/select/adjuster/one.expected 2014-02-24 12:53:01 +0900 (74fe1f7) @@ -29,7 +29,7 @@ load --table Memos } ] [[0,0.0,0.0],3] -select Memos --filter true --adjuster 'tags @ "groonga" * 2.5' --output_columns _key,_score +select Memos --filter true --adjuster 'tags @ "groonga" * 2' --output_columns _key,_score [ [ 0, @@ -53,11 +53,11 @@ select Memos --filter true --adjuster 'tags @ "groonga" * 2.5' --output_co ], [ "Groonga is fast", - 251 + 201 ], [ "Mroonga is also fast", - 26 + 21 ], [ "Ruby is an object oriented script language", Modified: test/command/suite/select/adjuster/one.test (+1 -1) =================================================================== --- test/command/suite/select/adjuster/one.test 2014-02-24 11:08:49 +0900 (bda4b6f) +++ test/command/suite/select/adjuster/one.test 2014-02-24 12:53:01 +0900 (a554cfa) @@ -30,5 +30,5 @@ load --table Memos select Memos \ --filter true \ - --adjuster 'tags @ "groonga" * 2.5' \ + --adjuster 'tags @ "groonga" * 2' \ --output_columns _key,_score -------------- next part -------------- HTML����������������������������...Download