summaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests/proton/matching
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2020-10-13 14:11:28 +0000
committerArne Juul <arnej@verizonmedia.com>2020-10-15 08:18:59 +0000
commit08393e9e14635f1c6a6c84650c25023a0db7ed0b (patch)
tree48aae1605140fc6ff7d571084f345d33a3189c62 /searchcore/src/tests/proton/matching
parent61eaea251e8cacd320ac10754ffd1513d8638043 (diff)
handle both engine- and factory-based tensors
* use EngineOrFactory::get() instead of DefaultTensorEngine::ref() * avoid direct use of DenseTensorView etc where possible * use eval::Value instead of tensor::Tensor where possible
Diffstat (limited to 'searchcore/src/tests/proton/matching')
-rw-r--r--searchcore/src/tests/proton/matching/matching_test.cpp5
-rw-r--r--searchcore/src/tests/proton/matching/request_context/request_context_test.cpp13
2 files changed, 11 insertions, 7 deletions
diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp
index 30f83273bd7..11ea6e87233 100644
--- a/searchcore/src/tests/proton/matching/matching_test.cpp
+++ b/searchcore/src/tests/proton/matching/matching_test.cpp
@@ -33,6 +33,7 @@
#include <vespa/searchcore/proton/matching/match_tools.h>
#include <vespa/searchcore/proton/matching/match_context.h>
#include <vespa/eval/eval/tensor_spec.h>
+#include <vespa/eval/eval/engine_or_factory.h>
#include <vespa/eval/tensor/default_tensor_engine.h>
#include <vespa/vespalib/objects/nbostream.h>
@@ -59,7 +60,7 @@ using search::fef::indexproperties::hitcollector::HeapSize;
using vespalib::nbostream;
using vespalib::eval::TensorSpec;
-using vespalib::tensor::DefaultTensorEngine;
+using vespalib::eval::EngineOrFactory;
void inject_match_phase_limiting(Properties &setup, const vespalib::string &attribute, size_t max_hits, bool descending)
{
@@ -666,7 +667,7 @@ TEST("require that summary features are filled") {
EXPECT_TRUE(!f[2].is_double());
EXPECT_TRUE(f[2].is_data());
{
- auto &engine = DefaultTensorEngine::ref();
+ auto engine = EngineOrFactory::get();
nbostream buf(f[2].as_data().data, f[2].as_data().size);
auto actual = engine.to_spec(*engine.decode(buf));
auto expect = TensorSpec("tensor(x[3])").add({{"x", 0}}, 0).add({{"x", 1}}, 1).add({{"x", 2}}, 2);
diff --git a/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp b/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp
index 3b54768f223..90a6e173129 100644
--- a/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp
+++ b/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp
@@ -1,6 +1,7 @@
// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/eval/eval/tensor_spec.h>
+#include <vespa/eval/eval/engine_or_factory.h>
#include <vespa/eval/tensor/default_tensor_engine.h>
#include <vespa/searchcore/proton/matching/requestcontext.h>
#include <vespa/searchlib/attribute/attribute_blueprint_params.h>
@@ -13,9 +14,9 @@ using search::attribute::IAttributeContext;
using search::attribute::IAttributeFunctor;
using search::attribute::IAttributeVector;
using search::fef::Properties;
+using vespalib::eval::EngineOrFactory;
using vespalib::eval::TensorSpec;
using vespalib::eval::Value;
-using vespalib::tensor::DefaultTensorEngine;
using namespace proton;
class MyAttributeContext : public search::attribute::IAttributeContext {
@@ -37,7 +38,7 @@ private:
void insert_tensor_in_properties(const vespalib::string& tensor_name, const Value& tensor_value) {
vespalib::nbostream stream;
- DefaultTensorEngine::ref().encode(tensor_value, stream);
+ EngineOrFactory::get().encode(tensor_value, stream);
_props.add(tensor_name, vespalib::stringref(stream.data(), stream.size()));
}
@@ -48,13 +49,15 @@ public:
_attr_ctx(),
_props(),
_request_ctx(_doom, _attr_ctx, _props, AttributeBlueprintParams()),
- _query_tensor(DefaultTensorEngine::ref().from_spec(TensorSpec("tensor(x[2])")
+ _query_tensor(EngineOrFactory::get().from_spec(TensorSpec("tensor(x[2])")
.add({{"x", 0}}, 3).add({{"x", 1}}, 5)))
{
insert_tensor_in_properties("my_tensor", *_query_tensor);
_props.add("my_string", "foo bar");
}
- TensorSpec expected_query_tensor() const { return DefaultTensorEngine::ref().to_spec(*_query_tensor); }
+ TensorSpec expected_query_tensor() const {
+ return EngineOrFactory::get().to_spec(*_query_tensor);
+ }
Value::UP get_query_tensor(const vespalib::string& tensor_name) const {
return _request_ctx.get_query_tensor(tensor_name);
}
@@ -65,7 +68,7 @@ TEST_F(RequestContextTest, query_tensor_can_be_retrieved)
auto tensor = get_query_tensor("my_tensor");
ASSERT_TRUE(tensor);
EXPECT_TRUE(tensor->is_tensor());
- EXPECT_EQ(expected_query_tensor(), DefaultTensorEngine::ref().to_spec(*tensor));
+ EXPECT_EQ(expected_query_tensor(), EngineOrFactory::get().to_spec(*tensor));
}
TEST_F(RequestContextTest, non_existing_query_tensor_returns_nullptr)