summaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests/proton/matching
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2019-11-20 15:27:10 +0000
committerGeir Storli <geirst@verizonmedia.com>2019-11-20 15:29:37 +0000
commitda518a09b86d7ea210d419ab803b1cf4417764a6 (patch)
tree4626dc4a4faccae0c60ab83ff1e67a295be0bc52 /searchcore/src/tests/proton/matching
parent95bdc81ea132c3d1375e6c0c7dbc1833534b208a (diff)
Change get_query_tensor() to return vespalib::eval::Value::UP and use default tensor engine more.
Diffstat (limited to 'searchcore/src/tests/proton/matching')
-rw-r--r--searchcore/src/tests/proton/matching/request_context/request_context_test.cpp26
1 files changed, 12 insertions, 14 deletions
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 98173066f93..be70bacb4b1 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,9 +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/tensor/serialization/typed_binary_format.h>
-#include <vespa/eval/tensor/tensor.h>
-#include <vespa/eval/tensor/test/test_utils.h>
+#include <vespa/eval/tensor/default_tensor_engine.h>
#include <vespa/searchcore/proton/matching/requestcontext.h>
#include <vespa/searchlib/fef/properties.h>
#include <vespa/vespalib/gtest/gtest.h>
@@ -14,9 +12,8 @@ using search::attribute::IAttributeFunctor;
using search::attribute::IAttributeVector;
using search::fef::Properties;
using vespalib::eval::TensorSpec;
-using vespalib::tensor::Tensor;
-using vespalib::tensor::TypedBinaryFormat;
-using vespalib::tensor::test::makeTensor;
+using vespalib::eval::Value;
+using vespalib::tensor::DefaultTensorEngine;
using namespace proton;
class MyAttributeContext : public search::attribute::IAttributeContext {
@@ -34,11 +31,11 @@ private:
MyAttributeContext _attr_ctx;
Properties _props;
RequestContext _request_ctx;
- Tensor::UP _query_tensor;
+ Value::UP _query_tensor;
- void insert_tensor_in_properties(const vespalib::string& tensor_name, const Tensor& tensor) {
+ void insert_tensor_in_properties(const vespalib::string& tensor_name, const Value& tensor_value) {
vespalib::nbostream stream;
- TypedBinaryFormat::serialize(stream, tensor);
+ DefaultTensorEngine::ref().encode(tensor_value, stream);
_props.add(tensor_name, vespalib::stringref(stream.c_str(), stream.size()));
}
@@ -49,14 +46,14 @@ public:
_attr_ctx(),
_props(),
_request_ctx(_doom, _attr_ctx, _props),
- _query_tensor(makeTensor<Tensor>(TensorSpec("tensor(x[2])")
- .add({{"x", 0}}, 3).add({{"x", 1}}, 5)))
+ _query_tensor(DefaultTensorEngine::ref().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");
}
- const Tensor& expected_query_tensor() const { return *_query_tensor; }
- Tensor::UP get_query_tensor(const vespalib::string& tensor_name) const {
+ TensorSpec expected_query_tensor() const { return DefaultTensorEngine::ref().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 +62,8 @@ TEST_F(RequestContextTest, query_tensor_can_be_retrieved)
{
auto tensor = get_query_tensor("my_tensor");
ASSERT_TRUE(tensor);
- EXPECT_EQUAL(expected_query_tensor(), *tensor);
+ EXPECT_TRUE(tensor->is_tensor());
+ EXPECT_EQ(expected_query_tensor(), DefaultTensorEngine::ref().to_spec(*tensor));
}
TEST_F(RequestContextTest, non_existing_query_tensor_returns_nullptr)