summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLester Solbakken <lesters@users.noreply.github.com>2017-07-03 09:03:47 +0200
committerGitHub <noreply@github.com>2017-07-03 09:03:47 +0200
commitdd197fcfcf15bbdf2cb1ce4067b73dc162948ea6 (patch)
treef799d658f67efa51b48a4d94bafcf4ab182ca787
parentfbaa184957104b7e0e23a4fbf42e16afffd17a39 (diff)
parenta95cb1d3a9ca217d5ac8931737f4412a1ec4d953 (diff)
Merge pull request #2907 from yahoo/havardpe/ranking-expressions-are-pure
make sure ranking expression executors are pure
-rw-r--r--searchlib/src/tests/fef/rank_program/rank_program_test.cpp21
-rw-r--r--searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp3
2 files changed, 24 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 90447b79fc8..8e23731e961 100644
--- a/searchlib/src/tests/fef/rank_program/rank_program_test.cpp
+++ b/searchlib/src/tests/fef/rank_program/rank_program_test.cpp
@@ -336,4 +336,25 @@ TEST_F("require that interpreted ranking expressions are always lazy", Fixture()
EXPECT_EQUAL(f1.track_cnt, 2u);
}
+TEST_F("require that compiled ranking expressions are pure", Fixture()) {
+ f1.lazy_expressions(false).add_expr("rank", "value(7)").compile();
+ EXPECT_EQUAL(2u, count_features(f1.program));
+ EXPECT_EQUAL(2u, count_const_features(f1.program));
+ EXPECT_EQUAL(f1.get(), 7.0);
+}
+
+TEST_F("require that lazy compiled ranking expressions are pure", Fixture()) {
+ f1.lazy_expressions(true).add_expr("rank", "value(7)").compile();
+ EXPECT_EQUAL(2u, count_features(f1.program));
+ EXPECT_EQUAL(2u, count_const_features(f1.program));
+ EXPECT_EQUAL(f1.get(), 7.0);
+}
+
+TEST_F("require that interpreted ranking expressions are pure", Fixture()) {
+ f1.add_expr("rank", "box(value(7))").compile();
+ EXPECT_EQUAL(4u, count_features(f1.program));
+ EXPECT_EQUAL(4u, count_const_features(f1.program));
+ EXPECT_EQUAL(f1.get(), 7.0);
+}
+
TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp b/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp
index f5339dec0e6..c173ee97536 100644
--- a/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp
+++ b/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp
@@ -54,6 +54,7 @@ private:
public:
CompiledRankingExpressionExecutor(const CompiledFunction &compiled_function);
+ bool isPure() override { return true; }
void execute(uint32_t docId) override;
};
@@ -70,6 +71,7 @@ private:
public:
LazyCompiledRankingExpressionExecutor(const CompiledFunction &compiled_function);
+ bool isPure() override { return true; }
void execute(uint32_t docId) override;
};
@@ -102,6 +104,7 @@ private:
public:
InterpretedRankingExpressionExecutor(const InterpretedFunction &function,
ConstArrayRef<char> input_is_object);
+ bool isPure() override { return true; }
void execute(uint32_t docId) override;
};