diff options
author | Lester Solbakken <lesters@oath.com> | 2018-06-14 13:16:10 +0200 |
---|---|---|
committer | Lester Solbakken <lesters@oath.com> | 2018-06-14 13:16:10 +0200 |
commit | 68c62a5d2a1b35c3c2859cd5838928c371127f27 (patch) | |
tree | 8b9e31d6a68bb3d9164cc3eb1c4bc442da1d13b0 | |
parent | 03f71b36ce970a0207108702e4d1b6bf9b1fcabb (diff) |
Fix random normal match test
-rw-r--r-- | searchlib/src/tests/features/prod_features.cpp | 27 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/features/random_normal_feature.cpp | 12 |
2 files changed, 31 insertions, 8 deletions
diff --git a/searchlib/src/tests/features/prod_features.cpp b/searchlib/src/tests/features/prod_features.cpp index 80211192ad5..7f22d779a9e 100644 --- a/searchlib/src/tests/features/prod_features.cpp +++ b/searchlib/src/tests/features/prod_features.cpp @@ -1770,15 +1770,30 @@ Test::testRandomNormal() } } { // Test executor (randomNormal.match) - FtFeatureTest ft(_factory, "randomNormal.match"); - ASSERT_TRUE(ft.setup()); - RankResult rr; + FtFeatureTest ft1(_factory, "randomNormal.match"); + FtFeatureTest ft2(_factory, "randomNormal.match"); + ASSERT_TRUE(ft1.setup()); + ASSERT_TRUE(ft2.setup()); + RankResult rr1; + RankResult rr2; for (uint32_t i = 0; i < 5; ++i) { - rr.clear(); - ASSERT_TRUE(ft.executeOnly(rr, i + 1)); - ASSERT_TRUE(ft.execute(rr.getScore("randomNormal.match"), EPS, i + 1)); + rr1.clear(); + rr2.clear(); + ASSERT_TRUE(ft1.executeOnly(rr1, i + 1)); + ASSERT_TRUE(ft2.executeOnly(rr2, i + 1)); + + feature_t rn1 = rr1.getScore("randomNormal"); + feature_t rn2 = rr2.getScore("randomNormal"); + LOG(info, "randomNormal: %f - %f", rn1, rn2); + ASSERT_NOT_EQUAL(rn1, rn2); + + feature_t rnm1 = rr1.getScore("randomNormal.match"); + feature_t rnm2 = rr2.getScore("randomNormal.match"); + LOG(info, "randomNormalMatch: %f - %f", rnm1, rnm2); + ASSERT_EQUAL(rnm1, rnm2); } } + } void diff --git a/searchlib/src/vespa/searchlib/features/random_normal_feature.cpp b/searchlib/src/vespa/searchlib/features/random_normal_feature.cpp index ddf9f9f016a..40ff8db229e 100644 --- a/searchlib/src/vespa/searchlib/features/random_normal_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/random_normal_feature.cpp @@ -26,9 +26,17 @@ RandomNormalExecutor::RandomNormalExecutor(uint64_t seed, uint64_t matchSeed, do void RandomNormalExecutor::execute(uint32_t docId) { - outputs().set_number(0, _mean + _stddev * _rnd.next()); _matchRnd.seed(_matchSeed + docId); - outputs().set_number(0, _mean + _stddev * _matchRnd.next(false)); + + feature_t out = _mean + _stddev * _rnd.next(); + feature_t match = _mean + _stddev * _matchRnd.next(false); + + outputs().set_number(0, out); + outputs().set_number(1, match); + + // Note: calculating match here almost triples the cost for generating the non-match + // value. If this turns out to be too costly, we should consider creating an own + // feature executor for the match. } RandomNormalBlueprint::RandomNormalBlueprint() : |