From f3b69ab71ac7dde197f25ffd67d5851648ebafbc Mon Sep 17 00:00:00 2001 From: Arne Juul Date: Mon, 22 Feb 2021 13:25:19 +0000 Subject: move getting tensor into the attribute code * avoids taking an extra copy of the tensor in the DirectTensorAttribute case --- .../searchcore/proton/common/attribute_updater.cpp | 23 +++------------------- 1 file changed, 3 insertions(+), 20 deletions(-) (limited to 'searchcore') diff --git a/searchcore/src/vespa/searchcore/proton/common/attribute_updater.cpp b/searchcore/src/vespa/searchcore/proton/common/attribute_updater.cpp index 8fb165cb0b8..4d12fdfcf5b 100644 --- a/searchcore/src/vespa/searchcore/proton/common/attribute_updater.cpp +++ b/searchcore/src/vespa/searchcore/proton/common/attribute_updater.cpp @@ -205,23 +205,6 @@ AttributeUpdater::handleUpdate(PredicateAttribute &vec, uint32_t lid, const Valu } } -namespace { - -void -applyTensorUpdate(TensorAttribute &vec, uint32_t lid, const document::TensorUpdate &update, - bool create_empty_if_non_existing) -{ - auto oldTensor = vec.getTensor(lid); - if (!oldTensor && create_empty_if_non_existing) { - oldTensor = vec.getEmptyTensor(); - } - if (oldTensor) { - vec.update_tensor(lid, update, *oldTensor); - } -} - -} - template <> void AttributeUpdater::handleUpdate(TensorAttribute &vec, uint32_t lid, const ValueUpdate &upd) @@ -236,11 +219,11 @@ AttributeUpdater::handleUpdate(TensorAttribute &vec, uint32_t lid, const ValueUp updateValue(vec, lid, assign.getValue()); } } else if (op == ValueUpdate::TensorModifyUpdate) { - applyTensorUpdate(vec, lid, static_cast(upd), false); + vec.update_tensor(lid, static_cast(upd), false); } else if (op == ValueUpdate::TensorAddUpdate) { - applyTensorUpdate(vec, lid, static_cast(upd), true); + vec.update_tensor(lid, static_cast(upd), true); } else if (op == ValueUpdate::TensorRemoveUpdate) { - applyTensorUpdate(vec, lid, static_cast(upd), false); + vec.update_tensor(lid, static_cast(upd), false); } else if (op == ValueUpdate::Clear) { vec.clearDoc(lid); } else { -- cgit v1.2.3