summaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/fef/rank_program/rank_program_test.cpp
diff options
context:
space:
mode:
authorØyvind Grønnesby <oyving@verizonmedia.com>2019-10-08 13:00:36 +0200
committerØyvind Grønnesby <oyving@verizonmedia.com>2019-10-08 13:00:36 +0200
commit948500c2a4d52aef59ec18706ae4b8d793afb060 (patch)
treece305f94dbf4f90423255adc3b02fd441bcf211b /searchlib/src/tests/fef/rank_program/rank_program_test.cpp
parent0d9892df0aa99e13ff83bfdeb3de8f1e8305bdcd (diff)
parent64d8a699b668a5ed1dae0b86bd88bd3a2b40e48c (diff)
Merge remote-tracking branch 'origin/master' into ogronnesby/let-plugin-get-key-as-parameter
Conflicts: hosted-api/src/main/java/ai/vespa/hosted/api/Properties.java
Diffstat (limited to 'searchlib/src/tests/fef/rank_program/rank_program_test.cpp')
-rw-r--r--searchlib/src/tests/fef/rank_program/rank_program_test.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/searchlib/src/tests/fef/rank_program/rank_program_test.cpp b/searchlib/src/tests/fef/rank_program/rank_program_test.cpp
index 7e28178e5f7..d1b0f8112f3 100644
--- a/searchlib/src/tests/fef/rank_program/rank_program_test.cpp
+++ b/searchlib/src/tests/fef/rank_program/rank_program_test.cpp
@@ -90,6 +90,10 @@ struct Fixture {
value ? "true" : "false");
return *this;
}
+ Fixture &use_fast_forest() {
+ indexEnv.getProperties().add(indexproperties::eval::UseFastForest::NAME, "true");
+ return *this;
+ }
Fixture &add_expr(const vespalib::string &name, const vespalib::string &expr) {
vespalib::string feature_name = expr_feature(name);
vespalib::string expr_name = feature_name + ".rankingScript";
@@ -113,6 +117,11 @@ struct Fixture {
program.setup(*match_data, queryEnv, overrides);
return *this;
}
+ vespalib::string final_executor_name() const {
+ size_t n = program.num_executors();
+ ASSERT_TRUE(n > 0);
+ return program.get_executor(n-1).getClassName();
+ }
double get(uint32_t docid = default_docid) {
auto result = program.get_seeds();
EXPECT_EQUAL(1u, result.num_features());
@@ -360,4 +369,26 @@ TEST_F("require that interpreted ranking expressions are pure", Fixture()) {
EXPECT_EQUAL(f1.get(), 7.0);
}
+const vespalib::string tree_expr = "if(value(1)<2,1,2)+if(value(2)<1,10,20)";
+
+TEST_F("require that fast-forest gbdt evaluation can be enabled", Fixture()) {
+ f1.use_fast_forest().add_expr("rank", tree_expr).compile();
+ EXPECT_EQUAL(f1.get(), 21.0);
+ EXPECT_EQUAL(f1.final_executor_name(), "search::features::FastForestExecutor");
+}
+
+TEST_F("require that fast-forest gbdt evaluation is disabled by default", Fixture()) {
+ f1.add_expr("rank", tree_expr).compile();
+ EXPECT_EQUAL(f1.get(), 21.0);
+ EXPECT_EQUAL(f1.final_executor_name(), "search::features::CompiledRankingExpressionExecutor");
+}
+
+TEST_F("require that fast-forest gbdt evaluation is pure", Fixture()) {
+ f1.use_fast_forest().add_expr("rank", tree_expr).compile();
+ EXPECT_EQUAL(3u, count_features(f1.program));
+ EXPECT_EQUAL(3u, count_const_features(f1.program));
+ EXPECT_EQUAL(f1.get(), 21.0);
+ EXPECT_EQUAL(f1.final_executor_name(), "search::features::FastForestExecutor");
+}
+
TEST_MAIN() { TEST_RUN_ALL(); }