summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2019-06-19 10:18:08 +0000
committerHåvard Pettersen <havardpe@oath.com>2019-06-19 10:18:08 +0000
commitb8e30961b8c5f140823bd2828f87ab9fd906a1d7 (patch)
treefcb7752c120fc0d85995c3bd7cb056d640c7d51d /searchcore
parent90671fd176dda18c44f26c77a396683da2b96b47 (diff)
readjust to a world without ErrorValue
Diffstat (limited to 'searchcore')
-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
7 files changed, 19 insertions, 45 deletions
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;