summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne H Juul <arnej27959@users.noreply.github.com>2019-06-20 08:40:26 +0200
committerGitHub <noreply@github.com>2019-06-20 08:40:26 +0200
commitfbfa616f345941455991819f7916320d15392204 (patch)
tree9738c4d3d47f4461d5b940df7fa011eac2c00e9f
parent28f7f7932fc91516276a7468c73325a5a2dafe60 (diff)
parentb8e30961b8c5f140823bd2828f87ab9fd906a1d7 (diff)
Merge pull request #9840 from vespa-engine/havardpe/remove-error-value
Havardpe/remove error value
-rw-r--r--eval/src/tests/eval/interpreted_function/interpreted_function_test.cpp8
-rw-r--r--eval/src/tests/eval/tensor_function/tensor_function_test.cpp3
-rw-r--r--eval/src/tests/eval/value_cache/tensor_loader_test.cpp5
-rw-r--r--eval/src/vespa/eval/eval/basic_nodes.cpp4
-rw-r--r--eval/src/vespa/eval/eval/interpreted_function.cpp4
-rw-r--r--eval/src/vespa/eval/eval/make_tensor_function.cpp4
-rw-r--r--eval/src/vespa/eval/eval/simple_tensor_engine.cpp12
-rw-r--r--eval/src/vespa/eval/eval/test/tensor_conformance.cpp1
-rw-r--r--eval/src/vespa/eval/eval/value.cpp3
-rw-r--r--eval/src/vespa/eval/eval/value.h12
-rw-r--r--eval/src/vespa/eval/eval/value_cache/constant_tensor_loader.cpp14
-rw-r--r--eval/src/vespa/eval/eval/value_cache/constant_value.h9
-rw-r--r--eval/src/vespa/eval/tensor/default_tensor_engine.cpp63
-rw-r--r--searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp15
-rw-r--r--searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp3
-rw-r--r--searchcore/src/tests/proton/matching/constant_value_repo/constant_value_repo_test.cpp13
-rw-r--r--searchcore/src/tests/proton/matching/matching_test.cpp3
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/constant_value_repo.cpp3
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/error_constant_value.h25
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/i_constant_value_repo.h2
-rw-r--r--searchlib/src/vespa/searchlib/fef/test/indexenvironment.cpp10
21 files changed, 77 insertions, 139 deletions
diff --git a/eval/src/tests/eval/interpreted_function/interpreted_function_test.cpp b/eval/src/tests/eval/interpreted_function/interpreted_function_test.cpp
index 714eb870b3e..9112a8b1712 100644
--- a/eval/src/tests/eval/interpreted_function/interpreted_function_test.cpp
+++ b/eval/src/tests/eval/interpreted_function/interpreted_function_test.cpp
@@ -100,16 +100,10 @@ TEST_FF("require that compiled evaluation passes all conformance tests", MyEvalT
//-----------------------------------------------------------------------------
-TEST("require that invalid function evaluates to a error") {
+TEST("require that invalid function is tagged with error") {
std::vector<vespalib::string> params({"x", "y", "z", "w"});
Function function = Function::parse(params, "x & y");
EXPECT_TRUE(function.has_error());
- InterpretedFunction ifun(SimpleTensorEngine::ref(), function, NodeTypes());
- InterpretedFunction::Context ctx(ifun);
- SimpleParams my_params({1,2,3,4});
- const Value &result = ifun.eval(ctx, my_params);
- EXPECT_TRUE(result.is_error());
- EXPECT_EQUAL(error_value, result.as_double());
}
//-----------------------------------------------------------------------------
diff --git a/eval/src/tests/eval/tensor_function/tensor_function_test.cpp b/eval/src/tests/eval/tensor_function/tensor_function_test.cpp
index 741b756e46f..7bca3d14c28 100644
--- a/eval/src/tests/eval/tensor_function/tensor_function_test.cpp
+++ b/eval/src/tests/eval/tensor_function/tensor_function_test.cpp
@@ -15,13 +15,12 @@ using namespace vespalib::eval::tensor_function;
struct EvalCtx {
const TensorEngine &engine;
Stash stash;
- ErrorValue error;
std::vector<Value::UP> tensors;
std::vector<Value::CREF> params;
InterpretedFunction::UP ifun;
std::unique_ptr<InterpretedFunction::Context> ictx;
EvalCtx(const TensorEngine &engine_in)
- : engine(engine_in), stash(), error(), tensors(), params(), ifun(), ictx() {}
+ : engine(engine_in), stash(), tensors(), params(), ifun(), ictx() {}
~EvalCtx() {}
size_t add_tensor(Value::UP tensor) {
size_t id = params.size();
diff --git a/eval/src/tests/eval/value_cache/tensor_loader_test.cpp b/eval/src/tests/eval/value_cache/tensor_loader_test.cpp
index 8180a7daef8..5dfde15a0ee 100644
--- a/eval/src/tests/eval/value_cache/tensor_loader_test.cpp
+++ b/eval/src/tests/eval/value_cache/tensor_loader_test.cpp
@@ -39,11 +39,10 @@ void verify_tensor(const TensorSpec &expect, ConstantValue::UP actual) {
}
void verify_invalid(ConstantValue::UP actual) {
- EXPECT_EQUAL(actual->type(), ValueType::double_type());
- EXPECT_EQUAL(actual->value().as_double(), 0.0);
+ EXPECT_TRUE(actual->type().is_error());
}
-TEST_F("require that invalid types loads an empty double", ConstantTensorLoader(SimpleTensorEngine::ref())) {
+TEST_F("require that invalid types gives bad constant value", ConstantTensorLoader(SimpleTensorEngine::ref())) {
TEST_DO(verify_invalid(f1.create(TEST_PATH("dense.json"), "invalid type spec")));
}
diff --git a/eval/src/vespa/eval/eval/basic_nodes.cpp b/eval/src/vespa/eval/eval/basic_nodes.cpp
index 85e00e76803..6138f9ac073 100644
--- a/eval/src/vespa/eval/eval/basic_nodes.cpp
+++ b/eval/src/vespa/eval/eval/basic_nodes.cpp
@@ -21,8 +21,8 @@ struct Frame {
};
struct NoParams : LazyParams {
- const Value &resolve(size_t, Stash &stash) const override {
- return stash.create<ErrorValue>();
+ const Value &resolve(size_t, Stash &) const override {
+ abort();
}
};
diff --git a/eval/src/vespa/eval/eval/interpreted_function.cpp b/eval/src/vespa/eval/eval/interpreted_function.cpp
index e362faadf46..208b2db4c3a 100644
--- a/eval/src/vespa/eval/eval/interpreted_function.cpp
+++ b/eval/src/vespa/eval/eval/interpreted_function.cpp
@@ -91,9 +91,7 @@ InterpretedFunction::eval(Context &ctx, const LazyParams &params) const
while (state.program_offset < _program.size()) {
_program[state.program_offset++].perform(state);
}
- if (state.stack.size() != 1) {
- state.stack.push_back(state.stash.create<ErrorValue>());
- }
+ assert(state.stack.size() == 1);
return state.stack.back();
}
diff --git a/eval/src/vespa/eval/eval/make_tensor_function.cpp b/eval/src/vespa/eval/eval/make_tensor_function.cpp
index d84d9f53749..ebf065f32a1 100644
--- a/eval/src/vespa/eval/eval/make_tensor_function.cpp
+++ b/eval/src/vespa/eval/eval/make_tensor_function.cpp
@@ -142,8 +142,8 @@ struct TensorFunctionBuilder : public NodeVisitor, public NodeTraverser {
void visit(const If &node) override {
make_if(node);
}
- void visit(const Error &node) override {
- make_const(node, ErrorValue::instance);
+ void visit(const Error &) override {
+ abort();
}
void visit(const TensorMap &node) override {
const auto &token = stash.create<CompileCache::Token::UP>(CompileCache::compile(node.lambda(), PassParams::SEPARATE));
diff --git a/eval/src/vespa/eval/eval/simple_tensor_engine.cpp b/eval/src/vespa/eval/eval/simple_tensor_engine.cpp
index c8c9a82d267..25fc98fc00a 100644
--- a/eval/src/vespa/eval/eval/simple_tensor_engine.cpp
+++ b/eval/src/vespa/eval/eval/simple_tensor_engine.cpp
@@ -40,22 +40,14 @@ const Value &to_value(std::unique_ptr<SimpleTensor> tensor, Stash &stash) {
if (tensor->type().is_tensor()) {
return *stash.create<Value::UP>(std::move(tensor));
}
- if (tensor->type().is_double()) {
- return stash.create<DoubleValue>(tensor->as_double());
- }
- assert(tensor->type().is_error());
- return ErrorValue::instance;
+ return stash.create<DoubleValue>(tensor->as_double());
}
Value::UP to_value(std::unique_ptr<SimpleTensor> tensor) {
if (tensor->type().is_tensor()) {
return tensor;
}
- if (tensor->type().is_double()) {
- return std::make_unique<DoubleValue>(tensor->as_double());
- }
- assert(tensor->type().is_error());
- return std::make_unique<ErrorValue>();
+ return std::make_unique<DoubleValue>(tensor->as_double());
}
} // namespace vespalib::eval::<unnamed>
diff --git a/eval/src/vespa/eval/eval/test/tensor_conformance.cpp b/eval/src/vespa/eval/eval/test/tensor_conformance.cpp
index 8cbc7507592..7e512bb5bf1 100644
--- a/eval/src/vespa/eval/eval/test/tensor_conformance.cpp
+++ b/eval/src/vespa/eval/eval/test/tensor_conformance.cpp
@@ -298,7 +298,6 @@ struct TestContext {
}
void test_tensor_create_type() {
- TEST_DO(verify_create_type("error"));
TEST_DO(verify_create_type("double"));
TEST_DO(verify_create_type("tensor(x{})"));
TEST_DO(verify_create_type("tensor(x{},y{})"));
diff --git a/eval/src/vespa/eval/eval/value.cpp b/eval/src/vespa/eval/eval/value.cpp
index 4bfd758f9cd..3629a5ad698 100644
--- a/eval/src/vespa/eval/eval/value.cpp
+++ b/eval/src/vespa/eval/eval/value.cpp
@@ -6,9 +6,6 @@
namespace vespalib {
namespace eval {
-ValueType ErrorValue::_type = ValueType::error_type();
-const ErrorValue ErrorValue::instance;
-
ValueType DoubleValue::_type = ValueType::double_type();
} // namespace vespalib::eval
diff --git a/eval/src/vespa/eval/eval/value.h b/eval/src/vespa/eval/eval/value.h
index f14034968be..15df44efbac 100644
--- a/eval/src/vespa/eval/eval/value.h
+++ b/eval/src/vespa/eval/eval/value.h
@@ -20,7 +20,6 @@ constexpr double error_value = 31212.0;
struct Value {
typedef std::unique_ptr<Value> UP;
typedef std::reference_wrapper<const Value> CREF;
- virtual bool is_error() const { return false; }
virtual bool is_double() const { return false; }
virtual bool is_tensor() const { return false; }
virtual double as_double() const { return 0.0; }
@@ -30,17 +29,6 @@ struct Value {
virtual ~Value() {}
};
-class ErrorValue : public Value
-{
-private:
- static ValueType _type;
-public:
- static const ErrorValue instance;
- bool is_error() const override { return true; }
- double as_double() const override { return error_value; }
- const ValueType &type() const override { return _type; }
-};
-
class DoubleValue : public Value
{
private:
diff --git a/eval/src/vespa/eval/eval/value_cache/constant_tensor_loader.cpp b/eval/src/vespa/eval/eval/value_cache/constant_tensor_loader.cpp
index afc8471bdb4..2005caa18ec 100644
--- a/eval/src/vespa/eval/eval/value_cache/constant_tensor_loader.cpp
+++ b/eval/src/vespa/eval/eval/value_cache/constant_tensor_loader.cpp
@@ -75,13 +75,17 @@ ConstantTensorLoader::create(const vespalib::string &path, const vespalib::strin
ValueType value_type = ValueType::from_spec(type);
if (value_type.is_error()) {
LOG(warning, "invalid type specification: %s", type.c_str());
- return std::make_unique<SimpleConstantValue>(_engine.from_spec(TensorSpec("double")));
+ return std::make_unique<BadConstantValue>();
}
if (ends_with(path, ".tbf")) {
vespalib::MappedFileInput file(path);
vespalib::Memory content = file.get();
vespalib::nbostream stream(content.data, content.size);
- return std::make_unique<SimpleConstantValue>(_engine.decode(stream));
+ try {
+ return std::make_unique<SimpleConstantValue>(_engine.decode(stream));
+ } catch (std::exception &) {
+ return std::make_unique<BadConstantValue>();
+ }
}
Slime slime;
decode_json(path, slime);
@@ -99,7 +103,11 @@ ConstantTensorLoader::create(const vespalib::string &path, const vespalib::strin
cells[i]["address"].traverse(extractor);
spec.add(address, cells[i]["value"].asDouble());
}
- return std::make_unique<SimpleConstantValue>(_engine.from_spec(spec));
+ try {
+ return std::make_unique<SimpleConstantValue>(_engine.from_spec(spec));
+ } catch (std::exception &) {
+ return std::make_unique<BadConstantValue>();
+ }
}
} // namespace vespalib::eval
diff --git a/eval/src/vespa/eval/eval/value_cache/constant_value.h b/eval/src/vespa/eval/eval/value_cache/constant_value.h
index ba7fe6fcf3d..a288ad70b53 100644
--- a/eval/src/vespa/eval/eval/value_cache/constant_value.h
+++ b/eval/src/vespa/eval/eval/value_cache/constant_value.h
@@ -30,6 +30,15 @@ public:
const Value &value() const override { return *_value; }
};
+class BadConstantValue : public ConstantValue {
+private:
+ const ValueType _type;
+public:
+ BadConstantValue() : _type(ValueType::error_type()) {}
+ const ValueType &type() const override { return _type; }
+ const Value &value() const override { abort(); }
+};
+
/**
* An abstract factory of constant values. The typical use-case for
* this will be to load constant values from file with a cache on top
diff --git a/eval/src/vespa/eval/tensor/default_tensor_engine.cpp b/eval/src/vespa/eval/tensor/default_tensor_engine.cpp
index 2206cde49a9..a265ae5ae85 100644
--- a/eval/src/vespa/eval/tensor/default_tensor_engine.cpp
+++ b/eval/src/vespa/eval/tensor/default_tensor_engine.cpp
@@ -33,7 +33,6 @@ namespace vespalib::tensor {
using eval::Aggr;
using eval::Aggregator;
using eval::DoubleValue;
-using eval::ErrorValue;
using eval::TensorFunction;
using eval::TensorSpec;
using eval::Value;
@@ -83,7 +82,7 @@ const Value &to_default(const Value &value, Stash &stash) {
const Value &to_value(std::unique_ptr<Tensor> tensor, Stash &stash) {
if (!tensor) {
- return ErrorValue::instance;
+ return stash.create<DoubleValue>(eval::error_value);
}
if (tensor->type().is_tensor()) {
return *stash.create<Value::UP>(std::move(tensor));
@@ -93,7 +92,7 @@ const Value &to_value(std::unique_ptr<Tensor> tensor, Stash &stash) {
Value::UP to_value(std::unique_ptr<Tensor> tensor) {
if (!tensor) {
- return std::make_unique<ErrorValue>();
+ return std::make_unique<DoubleValue>(eval::error_value);
}
if (tensor->type().is_tensor()) {
return tensor;
@@ -171,7 +170,7 @@ DefaultTensorEngine::from_spec(const TensorSpec &spec) const
{
ValueType type = ValueType::from_spec(spec.type());
if (type.is_error()) {
- return std::make_unique<ErrorValue>();
+ bad_spec(spec);
} else if (type.is_double()) {
double value = spec.cells().empty() ? 0.0 : spec.cells().begin()->second.value;
return std::make_unique<DoubleValue>(value);
@@ -273,9 +272,7 @@ DefaultTensorEngine::optimize(const TensorFunction &expr, Stash &stash) const
const Value &
DefaultTensorEngine::map(const Value &a, map_fun_t function, Stash &stash) const
{
- if (a.is_double()) {
- return stash.create<DoubleValue>(function(a.as_double()));
- } else if (auto tensor = a.as_tensor()) {
+ if (auto tensor = a.as_tensor()) {
assert(&tensor->engine() == this);
const tensor::Tensor &my_a = static_cast<const tensor::Tensor &>(*tensor);
if (!tensor::Tensor::supported({my_a.type()})) {
@@ -284,63 +281,49 @@ DefaultTensorEngine::map(const Value &a, map_fun_t function, Stash &stash) const
CellFunctionFunAdapter cell_function(function);
return to_value(my_a.apply(cell_function), stash);
} else {
- return ErrorValue::instance;
+ return stash.create<DoubleValue>(function(a.as_double()));
}
}
const Value &
DefaultTensorEngine::join(const Value &a, const Value &b, join_fun_t function, Stash &stash) const
{
- if (a.is_double()) {
- if (b.is_double()) {
- return stash.create<DoubleValue>(function(a.as_double(), b.as_double()));
- } else if (auto tensor_b = b.as_tensor()) {
+ if (auto tensor_a = a.as_tensor()) {
+ assert(&tensor_a->engine() == this);
+ const tensor::Tensor &my_a = static_cast<const tensor::Tensor &>(*tensor_a);
+ if (auto tensor_b = b.as_tensor()) {
assert(&tensor_b->engine() == this);
const tensor::Tensor &my_b = static_cast<const tensor::Tensor &>(*tensor_b);
- if (!tensor::Tensor::supported({my_b.type()})) {
+ if (!tensor::Tensor::supported({my_a.type(), my_b.type()})) {
return fallback_join(a, b, function, stash);
}
- CellFunctionBindLeftAdapter cell_function(function, a.as_double());
- return to_value(my_b.apply(cell_function), stash);
+ return to_value(my_a.join(function, my_b), stash);
} else {
- return ErrorValue::instance;
- }
- } else if (auto tensor_a = a.as_tensor()) {
- assert(&tensor_a->engine() == this);
- const tensor::Tensor &my_a = static_cast<const tensor::Tensor &>(*tensor_a);
- if (b.is_double()) {
if (!tensor::Tensor::supported({my_a.type()})) {
return fallback_join(a, b, function, stash);
}
CellFunctionBindRightAdapter cell_function(function, b.as_double());
return to_value(my_a.apply(cell_function), stash);
- } else if (auto tensor_b = b.as_tensor()) {
+ }
+ } else {
+ if (auto tensor_b = b.as_tensor()) {
assert(&tensor_b->engine() == this);
const tensor::Tensor &my_b = static_cast<const tensor::Tensor &>(*tensor_b);
- if (!tensor::Tensor::supported({my_a.type(), my_b.type()})) {
+ if (!tensor::Tensor::supported({my_b.type()})) {
return fallback_join(a, b, function, stash);
}
- return to_value(my_a.join(function, my_b), stash);
+ CellFunctionBindLeftAdapter cell_function(function, a.as_double());
+ return to_value(my_b.apply(cell_function), stash);
} else {
- return ErrorValue::instance;
+ return stash.create<DoubleValue>(function(a.as_double(), b.as_double()));
}
- } else {
- return ErrorValue::instance;
}
}
const Value &
DefaultTensorEngine::reduce(const Value &a, Aggr aggr, const std::vector<vespalib::string> &dimensions, Stash &stash) const
{
- if (a.is_double()) {
- if (dimensions.empty()) {
- Aggregator &aggregator = Aggregator::create(aggr, stash);
- aggregator.first(a.as_double());
- return stash.create<DoubleValue>(aggregator.result());
- } else {
- return ErrorValue::instance;
- }
- } else if (auto tensor = a.as_tensor()) {
+ if (auto tensor = a.as_tensor()) {
assert(&tensor->engine() == this);
const tensor::Tensor &my_a = static_cast<const tensor::Tensor &>(*tensor);
if (!tensor::Tensor::supported({my_a.type()})) {
@@ -360,7 +343,13 @@ DefaultTensorEngine::reduce(const Value &a, Aggr aggr, const std::vector<vespali
return fallback_reduce(a, aggr, dimensions, stash);
}
} else {
- return ErrorValue::instance;
+ if (dimensions.empty()) {
+ Aggregator &aggregator = Aggregator::create(aggr, stash);
+ aggregator.first(a.as_double());
+ return stash.create<DoubleValue>(aggregator.result());
+ } else {
+ return stash.create<DoubleValue>(eval::error_value);
+ }
}
}
diff --git a/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp b/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp
index f60863ef0b0..721ee9978b0 100644
--- a/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp
+++ b/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp
@@ -12,7 +12,6 @@
#include <vespa/eval/tensor/default_tensor_engine.h>
#include <vespa/searchcommon/common/schemaconfigurer.h>
#include <vespa/searchcore/config/config-ranking-constants.h>
-#include <vespa/searchcore/proton/matching/error_constant_value.h>
#include <vespa/searchcore/proton/matching/indexenvironment.h>
#include <vespa/searchlib/features/setup.h>
#include <vespa/searchlib/fef/fef.h>
@@ -34,11 +33,11 @@ using vespa::config::search::IndexschemaConfig;
using vespa::config::search::RankProfilesConfig;
using vespa::config::search::core::RankingConstantsConfig;
using vespalib::eval::ConstantValue;
-using vespalib::eval::ErrorValue;
using vespalib::eval::TensorSpec;
using vespalib::eval::ValueType;
using vespalib::tensor::DefaultTensorEngine;
using vespalib::eval::SimpleConstantValue;
+using vespalib::eval::BadConstantValue;
class App : public FastOS_Application
{
@@ -61,13 +60,17 @@ struct DummyConstantValueRepo : IConstantValueRepo {
DummyConstantValueRepo(const RankingConstantsConfig &cfg_in) : cfg(cfg_in) {}
virtual vespalib::eval::ConstantValue::UP getConstant(const vespalib::string &name) const override {
for (const auto &entry: cfg.constant) {
- if (entry.name == name) {
+ if (entry.name == name) {
const auto &engine = DefaultTensorEngine::ref();
- auto tensor = engine.from_spec(TensorSpec(entry.type));
- return std::make_unique<SimpleConstantValue>(std::move(tensor));
+ try {
+ auto tensor = engine.from_spec(TensorSpec(entry.type));
+ return std::make_unique<SimpleConstantValue>(std::move(tensor));
+ } catch (std::exception &) {
+ return std::make_unique<BadConstantValue>();
+ }
}
}
- return std::make_unique<SimpleConstantValue>(std::make_unique<ErrorValue>());
+ return vespalib::eval::ConstantValue::UP(nullptr);
}
};
diff --git a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp
index aba879e5a44..3154b420789 100644
--- a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp
@@ -9,7 +9,6 @@
#include <vespa/searchcore/proton/docsummary/summarymanager.h>
#include <vespa/searchcore/proton/documentmetastore/documentmetastore.h>
#include <vespa/searchcore/proton/documentmetastore/lidreusedelayer.h>
-#include <vespa/searchcore/proton/matching/error_constant_value.h>
#include <vespa/searchcore/proton/index/index_writer.h>
#include <vespa/searchcore/proton/index/indexmanager.h>
#include <vespa/searchcore/proton/reprocessing/attribute_reprocessing_initializer.h>
@@ -138,7 +137,7 @@ ViewSet::~ViewSet() {}
struct EmptyConstantValueFactory : public vespalib::eval::ConstantValueFactory {
virtual vespalib::eval::ConstantValue::UP create(const vespalib::string &, const vespalib::string &) const override {
- return std::make_unique<ErrorConstantValue>();
+ return vespalib::eval::ConstantValue::UP(nullptr);
}
};
diff --git a/searchcore/src/tests/proton/matching/constant_value_repo/constant_value_repo_test.cpp b/searchcore/src/tests/proton/matching/constant_value_repo/constant_value_repo_test.cpp
index acc16f41872..68959d8e20f 100644
--- a/searchcore/src/tests/proton/matching/constant_value_repo/constant_value_repo_test.cpp
+++ b/searchcore/src/tests/proton/matching/constant_value_repo/constant_value_repo_test.cpp
@@ -3,7 +3,6 @@
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/searchcore/proton/matching/constant_value_repo.h>
-#include <vespa/searchcore/proton/matching/error_constant_value.h>
#include <vespa/eval/eval/value_cache/constant_value.h>
using namespace proton::matching;
@@ -36,7 +35,7 @@ public:
if (itr != _map.end()) {
return std::make_unique<DoubleConstantValue>(itr->second);
}
- return std::make_unique<ErrorConstantValue>();
+ return std::make_unique<BadConstantValue>();
}
};
@@ -58,14 +57,14 @@ TEST_F("require that constant value can be retrieved from repo", Fixture)
EXPECT_EQUAL(3, f.repo.getConstant("foo")->value().as_double());
}
-TEST_F("require that non-existing constant value in repo returns error value", Fixture)
+TEST_F("require that non-existing constant value in repo returns nullptr", Fixture)
{
- EXPECT_TRUE(f.repo.getConstant("none")->value().is_error());
+ EXPECT_TRUE(f.repo.getConstant("none").get() == nullptr);
}
-TEST_F("require that non-existing constant value in factory returns error value", Fixture)
+TEST_F("require that non-existing constant value in factory returns bad constant", Fixture)
{
- EXPECT_TRUE(f.repo.getConstant("bar")->value().is_error());
+ EXPECT_TRUE(f.repo.getConstant("bar")->type().is_error());
}
TEST_F("require that reconfigure replaces existing constant values in repo", Fixture)
@@ -73,7 +72,7 @@ TEST_F("require that reconfigure replaces existing constant values in repo", Fix
f.repo.reconfigure(RankingConstants({{"bar", "double", "path_3"},
{"baz", "double", "path_2"}}));
f.factory.add("path_3", "double", 7);
- EXPECT_TRUE(f.repo.getConstant("foo")->value().is_error());
+ EXPECT_TRUE(f.repo.getConstant("foo").get() == nullptr);
EXPECT_EQUAL(7, f.repo.getConstant("bar")->value().as_double());
EXPECT_EQUAL(5, f.repo.getConstant("baz")->value().as_double());
}
diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp
index 967d8bfd0aa..e46ed997d0f 100644
--- a/searchcore/src/tests/proton/matching/matching_test.cpp
+++ b/searchcore/src/tests/proton/matching/matching_test.cpp
@@ -6,7 +6,6 @@
#include <vespa/searchcommon/attribute/iattributecontext.h>
#include <vespa/searchcore/proton/test/bucketfactory.h>
#include <vespa/searchcore/proton/documentmetastore/documentmetastore.h>
-#include <vespa/searchcore/proton/matching/error_constant_value.h>
#include <vespa/searchcore/proton/matching/fakesearchcontext.h>
#include <vespa/searchcore/proton/matching/i_constant_value_repo.h>
#include <vespa/searchcore/proton/matching/isearchcontext.h>
@@ -105,7 +104,7 @@ const uint32_t NUM_DOCS = 1000;
struct EmptyConstantValueRepo : public proton::matching::IConstantValueRepo {
virtual vespalib::eval::ConstantValue::UP getConstant(const vespalib::string &) const override {
- return std::make_unique<proton::matching::ErrorConstantValue>();
+ return vespalib::eval::ConstantValue::UP(nullptr);
}
};
diff --git a/searchcore/src/vespa/searchcore/proton/matching/constant_value_repo.cpp b/searchcore/src/vespa/searchcore/proton/matching/constant_value_repo.cpp
index 7e355da041c..bdfa4013c86 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/constant_value_repo.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/constant_value_repo.cpp
@@ -1,7 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "constant_value_repo.h"
-#include "error_constant_value.h"
using vespalib::eval::ConstantValue;
@@ -27,7 +26,7 @@ ConstantValueRepo::getConstant(const vespalib::string &name) const
if (constant != nullptr) {
return _factory.create(constant->filePath, constant->type);
}
- return std::make_unique<ErrorConstantValue>();
+ return ConstantValue::UP(nullptr);
}
}
diff --git a/searchcore/src/vespa/searchcore/proton/matching/error_constant_value.h b/searchcore/src/vespa/searchcore/proton/matching/error_constant_value.h
deleted file mode 100644
index 9b0b688085d..00000000000
--- a/searchcore/src/vespa/searchcore/proton/matching/error_constant_value.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#pragma once
-
-#include <vespa/eval/eval/value_cache/constant_value.h>
-
-namespace proton {
-namespace matching {
-
-/**
- * Class representing an error constant value.
- * Typically used to indicate that a named constant value does not exists.
- */
-class ErrorConstantValue : public vespalib::eval::ConstantValue {
-private:
- vespalib::eval::ErrorValue _value;
- vespalib::eval::ValueType _type;
-public:
- ErrorConstantValue() : _value(), _type(vespalib::eval::ValueType::error_type()) {}
- virtual const vespalib::eval::Value &value() const override { return _value; }
- virtual const vespalib::eval::ValueType &type() const override { return _type; }
-};
-
-}
-}
diff --git a/searchcore/src/vespa/searchcore/proton/matching/i_constant_value_repo.h b/searchcore/src/vespa/searchcore/proton/matching/i_constant_value_repo.h
index faa368c734b..5ac4fd14802 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/i_constant_value_repo.h
+++ b/searchcore/src/vespa/searchcore/proton/matching/i_constant_value_repo.h
@@ -9,7 +9,7 @@ namespace matching {
/**
* Interface for retrieving a named constant rank value to be used by features in the rank framework.
- * If the given value is not found an vespalib::eval::ErrorValue should be returned.
+ * If the given value is not found a nullptr should be returned.
*/
struct IConstantValueRepo {
virtual vespalib::eval::ConstantValue::UP getConstant(const vespalib::string &name) const = 0;
diff --git a/searchlib/src/vespa/searchlib/fef/test/indexenvironment.cpp b/searchlib/src/vespa/searchlib/fef/test/indexenvironment.cpp
index 755245438f2..e998e4d18bd 100644
--- a/searchlib/src/vespa/searchlib/fef/test/indexenvironment.cpp
+++ b/searchlib/src/vespa/searchlib/fef/test/indexenvironment.cpp
@@ -7,14 +7,6 @@
namespace search::fef::test {
using vespalib::eval::ValueType;
-using vespalib::eval::ErrorValue;
-
-namespace {
-
-IndexEnvironment::Constant notFoundError(ValueType::error_type(),
- std::make_unique<ErrorValue>());
-
-}
IndexEnvironment::IndexEnvironment() = default;
@@ -46,7 +38,7 @@ IndexEnvironment::getConstantValue(const vespalib::string &name) const
if (it != _constants.end()) {
return std::make_unique<ConstantRef>(it->second);
} else {
- return std::make_unique<ConstantRef>(notFoundError);
+ return vespalib::eval::ConstantValue::UP(nullptr);
}
}