summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2020-10-14 14:29:16 +0000
committerArne Juul <arnej@verizonmedia.com>2020-10-14 15:05:32 +0000
commit3d2645d8593874be4da8e5f73cd5a7e2cecfd399 (patch)
tree4cc3248c65d6abe0a56b06d71ed345ededda16c3 /document
parent5ab1a8b97842b3a87fc0d3fec5cb631b1d356ab9 (diff)
getAsTensorPtr() method can return "pointer to tensor"
Diffstat (limited to 'document')
-rw-r--r--document/src/tests/documentupdatetestcase.cpp4
-rw-r--r--document/src/tests/serialization/vespadocumentserializer_test.cpp2
-rw-r--r--document/src/vespa/document/fieldvalue/tensorfieldvalue.h4
-rw-r--r--document/src/vespa/document/serialization/vespadocumentserializer.cpp2
-rw-r--r--document/src/vespa/document/update/tensor_add_update.cpp4
-rw-r--r--document/src/vespa/document/update/tensor_modify_update.cpp8
-rw-r--r--document/src/vespa/document/update/tensor_remove_update.cpp8
7 files changed, 16 insertions, 16 deletions
diff --git a/document/src/tests/documentupdatetestcase.cpp b/document/src/tests/documentupdatetestcase.cpp
index 18001c35da5..9d2567e93ed 100644
--- a/document/src/tests/documentupdatetestcase.cpp
+++ b/document/src/tests/documentupdatetestcase.cpp
@@ -789,7 +789,7 @@ makeTensorFieldValue(const TensorSpec &spec, const TensorDataType &dataType)
const Tensor &asTensor(const FieldValue &fieldValue) {
auto &tensorFieldValue = dynamic_cast<const TensorFieldValue &>(fieldValue);
- auto &tensor = tensorFieldValue.getAsTensorPtr();
+ auto tensor = tensorFieldValue.getAsTensorPtr();
assert(tensor);
return *tensor;
}
@@ -876,7 +876,7 @@ struct TensorUpdateFixture {
auto field = getTensor();
auto tensor_field = dynamic_cast<TensorFieldValue*>(field.get());
ASSERT_TRUE(tensor_field);
- EXPECT_TRUE(tensor_field->getAsTensorPtr().get() == nullptr);
+ EXPECT_TRUE(tensor_field->getAsTensorPtr() == nullptr);
}
void assertTensor(const TensorSpec &expSpec) {
diff --git a/document/src/tests/serialization/vespadocumentserializer_test.cpp b/document/src/tests/serialization/vespadocumentserializer_test.cpp
index c0ebdad6373..02f170cd5f1 100644
--- a/document/src/tests/serialization/vespadocumentserializer_test.cpp
+++ b/document/src/tests/serialization/vespadocumentserializer_test.cpp
@@ -919,7 +919,7 @@ DeserializedTensorDoc::setup(const DocumentTypeRepo &docTypeRepo, const vespalib
const Tensor *
DeserializedTensorDoc::getTensor() const
{
- return dynamic_cast<const TensorFieldValue &>(*_fieldValue).getAsTensorPtr().get();
+ return dynamic_cast<const TensorFieldValue &>(*_fieldValue).getAsTensorPtr();
}
TEST("Require that wrong tensor type hides tensor")
diff --git a/document/src/vespa/document/fieldvalue/tensorfieldvalue.h b/document/src/vespa/document/fieldvalue/tensorfieldvalue.h
index ea3f8dea9be..30cc10558b5 100644
--- a/document/src/vespa/document/fieldvalue/tensorfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/tensorfieldvalue.h
@@ -39,8 +39,8 @@ public:
const std::string& indent) const override;
virtual void printXml(XmlOutputStream& out) const override;
virtual FieldValue &assign(const FieldValue &value) override;
- const std::unique_ptr<vespalib::tensor::Tensor> &getAsTensorPtr() const {
- return _tensor;
+ const vespalib::tensor::Tensor *getAsTensorPtr() const {
+ return _tensor.get();
}
void assignDeserialized(std::unique_ptr<vespalib::tensor::Tensor> rhs);
virtual int compare(const FieldValue& other) const override;
diff --git a/document/src/vespa/document/serialization/vespadocumentserializer.cpp b/document/src/vespa/document/serialization/vespadocumentserializer.cpp
index eadbd4b5a8a..6d9c08578e7 100644
--- a/document/src/vespa/document/serialization/vespadocumentserializer.cpp
+++ b/document/src/vespa/document/serialization/vespadocumentserializer.cpp
@@ -368,7 +368,7 @@ VespaDocumentSerializer::write(const WeightedSetFieldValue &value) {
void
VespaDocumentSerializer::write(const TensorFieldValue &value) {
vespalib::nbostream tmpStream;
- auto &tensor = value.getAsTensorPtr();
+ auto tensor = value.getAsTensorPtr();
if (tensor) {
vespalib::tensor::TypedBinaryFormat::serialize(tmpStream, *tensor);
assert( ! tmpStream.empty());
diff --git a/document/src/vespa/document/update/tensor_add_update.cpp b/document/src/vespa/document/update/tensor_add_update.cpp
index 2e5fa194c20..d9bec7762b6 100644
--- a/document/src/vespa/document/update/tensor_add_update.cpp
+++ b/document/src/vespa/document/update/tensor_add_update.cpp
@@ -81,7 +81,7 @@ TensorAddUpdate::checkCompatibility(const Field& field) const
std::unique_ptr<Tensor>
TensorAddUpdate::applyTo(const Tensor &tensor) const
{
- auto &addTensor = _tensor->getAsTensorPtr();
+ auto addTensor = _tensor->getAsTensorPtr();
if (addTensor) {
return tensor.add(*addTensor);
}
@@ -94,7 +94,7 @@ TensorAddUpdate::applyTo(FieldValue& value) const
if (value.inherits(TensorFieldValue::classId)) {
TensorFieldValue &tensorFieldValue = static_cast<TensorFieldValue &>(value);
tensorFieldValue.make_empty_if_not_existing();
- auto &oldTensor = tensorFieldValue.getAsTensorPtr();
+ auto oldTensor = tensorFieldValue.getAsTensorPtr();
auto newTensor = applyTo(*oldTensor);
if (newTensor) {
tensorFieldValue = std::move(newTensor);
diff --git a/document/src/vespa/document/update/tensor_modify_update.cpp b/document/src/vespa/document/update/tensor_modify_update.cpp
index dfc7479e5cd..5fbdc2467b3 100644
--- a/document/src/vespa/document/update/tensor_modify_update.cpp
+++ b/document/src/vespa/document/update/tensor_modify_update.cpp
@@ -159,7 +159,7 @@ TensorModifyUpdate::checkCompatibility(const Field& field) const
std::unique_ptr<Tensor>
TensorModifyUpdate::applyTo(const Tensor &tensor) const
{
- auto &cellsTensor = _tensor->getAsTensorPtr();
+ auto cellsTensor = _tensor->getAsTensorPtr();
if (cellsTensor) {
// Cells tensor being sparse was validated during deserialize().
vespalib::tensor::CellValues cellValues(static_cast<const vespalib::tensor::SparseTensor &>(*cellsTensor));
@@ -173,7 +173,7 @@ TensorModifyUpdate::applyTo(FieldValue& value) const
{
if (value.inherits(TensorFieldValue::classId)) {
TensorFieldValue &tensorFieldValue = static_cast<TensorFieldValue &>(value);
- auto &oldTensor = tensorFieldValue.getAsTensorPtr();
+ auto oldTensor = tensorFieldValue.getAsTensorPtr();
if (oldTensor) {
auto newTensor = applyTo(*oldTensor);
if (newTensor) {
@@ -207,9 +207,9 @@ TensorModifyUpdate::print(std::ostream& out, bool verbose, const std::string& in
namespace {
void
-verifyCellsTensorIsSparse(const std::unique_ptr<Tensor> &cellsTensor)
+verifyCellsTensorIsSparse(const Tensor *cellsTensor)
{
- if (cellsTensor && !dynamic_cast<const vespalib::tensor::SparseTensor *>(cellsTensor.get())) {
+ if (cellsTensor && !dynamic_cast<const vespalib::tensor::SparseTensor *>(cellsTensor)) {
vespalib::string err = make_string("Expected cell values tensor to be sparse, but has type '%s'",
cellsTensor->type().to_spec().c_str());
throw IllegalStateException(err, VESPA_STRLOC);
diff --git a/document/src/vespa/document/update/tensor_remove_update.cpp b/document/src/vespa/document/update/tensor_remove_update.cpp
index 91b4c0a6ca3..34a6223e185 100644
--- a/document/src/vespa/document/update/tensor_remove_update.cpp
+++ b/document/src/vespa/document/update/tensor_remove_update.cpp
@@ -105,7 +105,7 @@ TensorRemoveUpdate::checkCompatibility(const Field &field) const
std::unique_ptr<Tensor>
TensorRemoveUpdate::applyTo(const Tensor &tensor) const
{
- auto &addressTensor = _tensor->getAsTensorPtr();
+ auto addressTensor = _tensor->getAsTensorPtr();
if (addressTensor) {
// Address tensor being sparse was validated during deserialize().
vespalib::tensor::CellValues cellAddresses(static_cast<const vespalib::tensor::SparseTensor &>(*addressTensor));
@@ -119,7 +119,7 @@ TensorRemoveUpdate::applyTo(FieldValue &value) const
{
if (value.inherits(TensorFieldValue::classId)) {
TensorFieldValue &tensorFieldValue = static_cast<TensorFieldValue &>(value);
- auto &oldTensor = tensorFieldValue.getAsTensorPtr();
+ auto oldTensor = tensorFieldValue.getAsTensorPtr();
if (oldTensor) {
auto newTensor = applyTo(*oldTensor);
if (newTensor) {
@@ -153,9 +153,9 @@ TensorRemoveUpdate::print(std::ostream &out, bool verbose, const std::string &in
namespace {
void
-verifyAddressTensorIsSparse(const std::unique_ptr<Tensor> &addressTensor)
+verifyAddressTensorIsSparse(const Tensor *addressTensor)
{
- if (addressTensor && !dynamic_cast<const vespalib::tensor::SparseTensor *>(addressTensor.get())) {
+ if (addressTensor && !dynamic_cast<const vespalib::tensor::SparseTensor *>(addressTensor)) {
vespalib::string err = make_string("Expected address tensor to be sparse, but has type '%s'",
addressTensor->type().to_spec().c_str());
throw IllegalStateException(err, VESPA_STRLOC);