aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/tests/proton/common/attribute_updater/attribute_updater_test.cpp9
-rw-r--r--searchcore/src/vespa/searchcore/proton/common/attribute_updater.cpp3
2 files changed, 11 insertions, 1 deletions
diff --git a/searchcore/src/tests/proton/common/attribute_updater/attribute_updater_test.cpp b/searchcore/src/tests/proton/common/attribute_updater/attribute_updater_test.cpp
index 892be2c874f..8c3ce4c5031 100644
--- a/searchcore/src/tests/proton/common/attribute_updater/attribute_updater_test.cpp
+++ b/searchcore/src/tests/proton/common/attribute_updater/attribute_updater_test.cpp
@@ -436,6 +436,15 @@ TEST_F("require that tensor modify update is applied",
f.assertTensor(TensorSpec(f.type).add({{"x", 0}}, 7).add({{"x", 1}}, 5));
}
+TEST_F("require that tensor modify update with 'create: true' is applied to non-existing tensor",
+ TensorFixture<DenseTensorAttribute>("tensor(x[2])", "dense_tensor"))
+{
+ f.applyValueUpdate(*f.attribute, 1,
+ std::make_unique<TensorModifyUpdate>(TensorModifyUpdate::Operation::ADD,
+ makeTensorFieldValue(TensorSpec("tensor(x{})").add({{"x", "1"}}, 3)), 0.0));
+ f.assertTensor(TensorSpec(f.type).add({{"x", 0}}, 0).add({{"x", 1}}, 3));
+}
+
TEST_F("require that tensor add update is applied",
TensorFixture<SerializedFastValueAttribute>("tensor(x{})", "sparse_tensor"))
{
diff --git a/searchcore/src/vespa/searchcore/proton/common/attribute_updater.cpp b/searchcore/src/vespa/searchcore/proton/common/attribute_updater.cpp
index ef9750b5f4c..2b78cdab966 100644
--- a/searchcore/src/vespa/searchcore/proton/common/attribute_updater.cpp
+++ b/searchcore/src/vespa/searchcore/proton/common/attribute_updater.cpp
@@ -223,7 +223,8 @@ AttributeUpdater::handleUpdate(TensorAttribute &vec, uint32_t lid, const ValueUp
updateValue(vec, lid, assign.getValue());
}
} else if (op == ValueUpdate::TensorModify) {
- vec.update_tensor(lid, static_cast<const TensorModifyUpdate &>(upd), false);
+ const auto& modify = static_cast<const TensorModifyUpdate&>(upd);
+ vec.update_tensor(lid, modify, modify.get_default_cell_value().has_value());
} else if (op == ValueUpdate::TensorAdd) {
vec.update_tensor(lid, static_cast<const TensorAddUpdate &>(upd), true);
} else if (op == ValueUpdate::TensorRemove) {