aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@yahoo-inc.com>2016-12-05 14:41:59 +0000
committerTor Egge <Tor.Egge@yahoo-inc.com>2016-12-05 14:57:42 +0000
commit2951c3ea15ddbe7724de7735f0fe519c87d4818a (patch)
tree103419eb900631b61d2f1262d3bb356c340bae11 /searchlib
parent02ec904493816e66e03423249534ddff03db2899 (diff)
Use same tensor value instance across documents.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/features/tensor_attribute_executor.cpp14
-rw-r--r--searchlib/src/vespa/searchlib/features/tensor_attribute_executor.h4
2 files changed, 10 insertions, 8 deletions
diff --git a/searchlib/src/vespa/searchlib/features/tensor_attribute_executor.cpp b/searchlib/src/vespa/searchlib/features/tensor_attribute_executor.cpp
index 7e9b42f55a7..7c88da2cc90 100644
--- a/searchlib/src/vespa/searchlib/features/tensor_attribute_executor.cpp
+++ b/searchlib/src/vespa/searchlib/features/tensor_attribute_executor.cpp
@@ -4,14 +4,16 @@
#include "tensor_attribute_executor.h"
#include <vespa/searchlib/tensor/tensor_attribute.h>
+using vespalib::eval::TensorValue;
+
namespace search {
namespace features {
TensorAttributeExecutor::
TensorAttributeExecutor(const search::tensor::TensorAttribute *attribute)
: _attribute(attribute),
- _tensor(),
- _emptyTensor(std::make_unique<vespalib::eval::TensorValue>(attribute->getEmptyTensor()))
+ _emptyTensor(attribute->getEmptyTensor()),
+ _tensor(*_emptyTensor)
{
}
@@ -20,11 +22,11 @@ TensorAttributeExecutor::execute(fef::MatchData &data)
{
auto tensor = _attribute->getTensor(data.getDocId());
if (!tensor) {
- *data.resolve_object_feature(outputs()[0]) = *_emptyTensor;
- return;
+ _tensor = TensorValue(*_emptyTensor);
+ } else {
+ _tensor = TensorValue(std::move(tensor));
}
- _tensor = std::make_unique<vespalib::eval::TensorValue>(std::move(tensor));
- *data.resolve_object_feature(outputs()[0]) = *_tensor;
+ *data.resolve_object_feature(outputs()[0]) = _tensor;
}
} // namespace features
diff --git a/searchlib/src/vespa/searchlib/features/tensor_attribute_executor.h b/searchlib/src/vespa/searchlib/features/tensor_attribute_executor.h
index f56f04e4e10..e07198f0ce4 100644
--- a/searchlib/src/vespa/searchlib/features/tensor_attribute_executor.h
+++ b/searchlib/src/vespa/searchlib/features/tensor_attribute_executor.h
@@ -16,8 +16,8 @@ class TensorAttributeExecutor : public fef::FeatureExecutor
{
private:
const search::tensor::TensorAttribute *_attribute;
- vespalib::eval::TensorValue::UP _tensor;
- vespalib::eval::TensorValue::UP _emptyTensor;
+ std::unique_ptr<vespalib::eval::Tensor> _emptyTensor;
+ vespalib::eval::TensorValue _tensor;
public:
TensorAttributeExecutor(const search::tensor::TensorAttribute *attribute);