summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--searchcore/src/tests/proton/matching/request_context/request_context_test.cpp26
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp10
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/requestcontext.h2
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h6
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/irequestcontext.h4
5 files changed, 23 insertions, 25 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)
diff --git a/searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp b/searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp
index 1669b90f97e..918e4a14649 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp
@@ -1,7 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "requestcontext.h"
-#include <vespa/eval/tensor/serialization/typed_binary_format.h>
+#include <vespa/eval/tensor/default_tensor_engine.h>
#include <vespa/searchlib/attribute/attributevector.h>
#include <vespa/searchlib/fef/properties.h>
#include <vespa/vespalib/objects/nbostream.h>
@@ -40,7 +40,7 @@ RequestContext::asyncForAttribute(const vespalib::string &name, std::unique_ptr<
_attributeContext.asyncForAttribute(name, std::move(func));
}
-vespalib::tensor::Tensor::UP
+vespalib::eval::Value::UP
RequestContext::get_query_tensor(const vespalib::string& tensor_name) const
{
auto property = _rank_properties.lookup(tensor_name);
@@ -48,13 +48,13 @@ RequestContext::get_query_tensor(const vespalib::string& tensor_name) const
const vespalib::string& value = property.get();
vespalib::nbostream stream(value.data(), value.size());
try {
- return vespalib::tensor::TypedBinaryFormat::deserialize(stream);
+ return vespalib::tensor::DefaultTensorEngine::ref().decode(stream);
} catch (vespalib::IllegalArgumentException& ex) {
LOG(warning, "Query tensor '%s' could not be deserialized", tensor_name.c_str());
- return vespalib::tensor::Tensor::UP();
+ return vespalib::eval::Value::UP();
}
}
- return vespalib::tensor::Tensor::UP();
+ return vespalib::eval::Value::UP();
}
}
diff --git a/searchcore/src/vespa/searchcore/proton/matching/requestcontext.h b/searchcore/src/vespa/searchcore/proton/matching/requestcontext.h
index 02dd96a9771..0352e28eea2 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/requestcontext.h
+++ b/searchcore/src/vespa/searchcore/proton/matching/requestcontext.h
@@ -27,7 +27,7 @@ public:
const search::attribute::IAttributeVector *getAttributeStableEnum(const vespalib::string &name) const override;
- vespalib::tensor::Tensor::UP get_query_tensor(const vespalib::string& tensor_name) const override;
+ vespalib::eval::Value::UP get_query_tensor(const vespalib::string& tensor_name) const override;
private:
diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h
index 6940438ce43..a553e991f97 100644
--- a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h
+++ b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h
@@ -2,7 +2,7 @@
#pragma once
-#include <vespa/eval/tensor/tensor.h>
+#include <vespa/eval/eval/value.h>
#include <vespa/searchcommon/attribute/iattributecontext.h>
#include <vespa/searchlib/attribute/attributevector.h>
#include <vespa/searchlib/queryeval/irequestcontext.h>
@@ -25,9 +25,9 @@ public:
? _attributeContext->getAttribute(name)
: nullptr;
}
- vespalib::tensor::Tensor::UP get_query_tensor(const vespalib::string& tensor_name) const override {
+ vespalib::eval::Value::UP get_query_tensor(const vespalib::string& tensor_name) const override {
(void) tensor_name;
- return vespalib::tensor::Tensor::UP();
+ return vespalib::eval::Value::UP();
}
private:
diff --git a/searchlib/src/vespa/searchlib/queryeval/irequestcontext.h b/searchlib/src/vespa/searchlib/queryeval/irequestcontext.h
index 88399406292..1c197021998 100644
--- a/searchlib/src/vespa/searchlib/queryeval/irequestcontext.h
+++ b/searchlib/src/vespa/searchlib/queryeval/irequestcontext.h
@@ -6,7 +6,7 @@
#include <vespa/vespalib/stllike/string.h>
namespace search::attribute { class IAttributeVector; }
-namespace vespalib::tensor { class Tensor; }
+namespace vespalib::eval { class Value; }
namespace search::queryeval {
@@ -35,7 +35,7 @@ public:
* Returns the tensor of the given name that was passed with the query.
* Returns nullptr if the tensor is not found or if it is not a tensor.
*/
- virtual std::unique_ptr<vespalib::tensor::Tensor> get_query_tensor(const vespalib::string& tensor_name) const = 0;
+ virtual std::unique_ptr<vespalib::eval::Value> get_query_tensor(const vespalib::string& tensor_name) const = 0;
};
}