summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2019-02-01 15:49:55 +0100
committerGitHub <noreply@github.com>2019-02-01 15:49:55 +0100
commit597afd85869374ed41d5b807e784e6de4c548163 (patch)
tree3cea313289552bebe8b753ad1c6079d19476e984
parent8d7c5530b96c6fa87324ce8a09c541d4544519f7 (diff)
parent28190fa018f26cace2b4572c4698d55de81d52f1 (diff)
Merge pull request #8345 from vespa-engine/geirst/apply-tensor-modify-update-to-tensor-attribute
Geirst/apply tensor modify update to tensor attribute (MERGEOK)
-rw-r--r--document/src/vespa/document/update/tensormodifyupdate.cpp23
-rw-r--r--document/src/vespa/document/update/tensormodifyupdate.h3
-rw-r--r--document/src/vespa/document/update/valueupdate.h3
-rw-r--r--indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/FieldUpdateAdapter.java2
-rw-r--r--indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/FieldUpdateHelper.java3
-rw-r--r--searchcore/src/tests/applyattrupdates/applyattrupdates.cpp4
-rw-r--r--searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.cpp8
-rw-r--r--searchcore/src/vespa/searchcore/proton/common/CMakeLists.txt2
-rw-r--r--searchcore/src/vespa/searchcore/proton/common/attribute_updater.cpp (renamed from searchcore/src/vespa/searchcore/proton/common/attrupdate.cpp)95
-rw-r--r--searchcore/src/vespa/searchcore/proton/common/attribute_updater.h (renamed from searchcore/src/vespa/searchcore/proton/common/attrupdate.h)5
11 files changed, 101 insertions, 51 deletions
diff --git a/document/src/vespa/document/update/tensormodifyupdate.cpp b/document/src/vespa/document/update/tensormodifyupdate.cpp
index 5529adaf5ce..a02379e4991 100644
--- a/document/src/vespa/document/update/tensormodifyupdate.cpp
+++ b/document/src/vespa/document/update/tensormodifyupdate.cpp
@@ -1,15 +1,15 @@
// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "tensormodifyupdate.h"
-#include <vespa/document/base/field.h>
#include <vespa/document/base/exceptions.h>
+#include <vespa/document/base/field.h>
#include <vespa/document/fieldvalue/document.h>
#include <vespa/document/fieldvalue/tensorfieldvalue.h>
-#include <vespa/document/util/serializableexceptions.h>
#include <vespa/document/serialization/vespadocumentdeserializer.h>
+#include <vespa/document/util/serializableexceptions.h>
#include <vespa/eval/eval/operation.h>
-#include <vespa/eval/tensor/tensor.h>
#include <vespa/eval/tensor/cell_values.h>
+#include <vespa/eval/tensor/tensor.h>
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/util/stringfmt.h>
@@ -117,16 +117,25 @@ TensorModifyUpdate::checkCompatibility(const Field& field) const
}
}
+std::unique_ptr<Tensor>
+TensorModifyUpdate::applyTo(const Tensor &tensor) const
+{
+ auto &cellTensor = _tensor->getAsTensorPtr();
+ if (cellTensor) {
+ vespalib::tensor::CellValues cellValues(static_cast<const vespalib::tensor::SparseTensor &>(*cellTensor));
+ return tensor.modify(getJoinFunction(_operation), cellValues);
+ }
+ return std::unique_ptr<Tensor>();
+}
+
bool
TensorModifyUpdate::applyTo(FieldValue& value) const
{
if (value.inherits(TensorFieldValue::classId)) {
TensorFieldValue &tensorFieldValue = static_cast<TensorFieldValue &>(value);
auto &oldTensor = tensorFieldValue.getAsTensorPtr();
- auto &cellTensor = _tensor->getAsTensorPtr();
- if (cellTensor) {
- vespalib::tensor::CellValues cellValues(static_cast<const vespalib::tensor::SparseTensor &>(*cellTensor));
- auto newTensor = oldTensor->modify(getJoinFunction(_operation), cellValues);
+ auto newTensor = applyTo(*oldTensor);
+ if (newTensor) {
tensorFieldValue = std::move(newTensor);
}
} else {
diff --git a/document/src/vespa/document/update/tensormodifyupdate.h b/document/src/vespa/document/update/tensormodifyupdate.h
index fd89c9da47b..dcb9bcf0470 100644
--- a/document/src/vespa/document/update/tensormodifyupdate.h
+++ b/document/src/vespa/document/update/tensormodifyupdate.h
@@ -2,6 +2,8 @@
#include "valueupdate.h"
+namespace vespalib::tensor { class Tensor; }
+
namespace document {
class TensorFieldValue;
@@ -37,6 +39,7 @@ public:
Operation getOperation() const { return _operation; }
const TensorFieldValue &getTensor() const { return *_tensor; }
void checkCompatibility(const Field &field) const override;
+ std::unique_ptr<vespalib::tensor::Tensor> applyTo(const vespalib::tensor::Tensor &tensor) const;
bool applyTo(FieldValue &value) const override;
void printXml(XmlOutputStream &xos) const override;
void print(std::ostream &out, bool verbose, const std::string &indent) const override;
diff --git a/document/src/vespa/document/update/valueupdate.h b/document/src/vespa/document/update/valueupdate.h
index 963e1ad1d96..ceb711074f4 100644
--- a/document/src/vespa/document/update/valueupdate.h
+++ b/document/src/vespa/document/update/valueupdate.h
@@ -53,7 +53,8 @@ public:
Assign = IDENTIFIABLE_CLASSID(AssignValueUpdate),
Clear = IDENTIFIABLE_CLASSID(ClearValueUpdate),
Map = IDENTIFIABLE_CLASSID(MapValueUpdate),
- Remove = IDENTIFIABLE_CLASSID(RemoveValueUpdate)
+ Remove = IDENTIFIABLE_CLASSID(RemoveValueUpdate),
+ TensorModifyUpdate = IDENTIFIABLE_CLASSID(TensorModifyUpdate)
};
ValueUpdate()
diff --git a/indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/FieldUpdateAdapter.java b/indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/FieldUpdateAdapter.java
index 303c973aa63..0e3970db7fa 100644
--- a/indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/FieldUpdateAdapter.java
+++ b/indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/FieldUpdateAdapter.java
@@ -137,6 +137,8 @@ public class FieldUpdateAdapter implements UpdateAdapter {
} else {
// do nothing
}
+ } else if (upd instanceof TensorModifyUpdate) {
+ lst.add(upd);
} else {
throw new UnsupportedOperationException(
"Value update type " + upd.getClass().getName() + " not supported.");
diff --git a/indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/FieldUpdateHelper.java b/indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/FieldUpdateHelper.java
index 43c7ebc6f7a..61e38bd8bc6 100644
--- a/indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/FieldUpdateHelper.java
+++ b/indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/FieldUpdateHelper.java
@@ -90,6 +90,9 @@ public abstract class FieldUpdateHelper {
} else {
throw new IllegalArgumentException("Expected multi-value data type, got " + val.getDataType().getName() + ".");
}
+ } else if (upd instanceof TensorModifyUpdate) {
+ // TODO: apply update to field value when supported in TensorModifyUpdate in Java.
+ return val;
}
throw new UnsupportedOperationException("Value update type " + upd.getClass().getName() + " not supported.");
}
diff --git a/searchcore/src/tests/applyattrupdates/applyattrupdates.cpp b/searchcore/src/tests/applyattrupdates/applyattrupdates.cpp
index 48c02215732..a1cbed20036 100644
--- a/searchcore/src/tests/applyattrupdates/applyattrupdates.cpp
+++ b/searchcore/src/tests/applyattrupdates/applyattrupdates.cpp
@@ -15,7 +15,7 @@
#include <vespa/document/update/documentupdate.h>
#include <vespa/document/update/removevalueupdate.h>
#include <vespa/document/update/mapvalueupdate.h>
-#include <vespa/searchcore/proton/common/attrupdate.h>
+#include <vespa/searchcore/proton/common/attribute_updater.h>
#include <vespa/searchlib/attribute/attributefactory.h>
#include <vespa/searchlib/attribute/attributevector.hpp>
#include <vespa/searchlib/attribute/reference_attribute.h>
@@ -110,7 +110,7 @@ private:
void applyValueUpdate(AttributeVector & vec, uint32_t docId, const ValueUpdate & upd) {
FieldUpdate fupd(_docType->getField(vec.getName()));
fupd.addUpdate(upd);
- search::AttrUpdate::handleUpdate(vec, docId, fupd);
+ search::AttributeUpdater::handleUpdate(vec, docId, fupd);
vec.commit();
}
diff --git a/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp b/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp
index 9ab60f06f21..ad5ac55c5e9 100644
--- a/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp
+++ b/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp
@@ -8,7 +8,7 @@
#include <vespa/persistence/spi/docentry.h>
#include <vespa/persistence/spi/result.h>
#include <vespa/persistence/spi/test.h>
-#include <vespa/searchcore/proton/common/attrupdate.h>
+#include <vespa/searchcore/proton/common/attribute_updater.h>
#include <vespa/searchcore/proton/persistenceengine/document_iterator.h>
#include <vespa/searchcore/proton/server/commit_and_wait_document_retriever.h>
#include <vespa/searchlib/attribute/attributecontext.h>
@@ -233,7 +233,7 @@ struct AttrUnitDR : public UnitDR
template <class FieldValType, typename FieldValArg>
void addAttribute(AttributeVector &av, const FieldValArg &val) {
- search::AttrUpdate::handleValue(av, docid, FieldValType(val));
+ search::AttributeUpdater::handleValue(av, docid, FieldValType(val));
av.commit();
}
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.cpp
index 442d04d30c8..9aa2921adf5 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.cpp
@@ -5,7 +5,7 @@
#include "attributemanager.h"
#include "document_field_extractor.h"
#include <vespa/searchcore/proton/attribute/imported_attributes_repo.h>
-#include <vespa/searchcore/proton/common/attrupdate.h>
+#include <vespa/searchcore/proton/common/attribute_updater.h>
#include <vespa/searchlib/attribute/attributevector.hpp>
#include <vespa/searchlib/attribute/imported_attribute_vector.h>
#include <vespa/searchlib/common/isequencedtaskexecutor.h>
@@ -102,7 +102,7 @@ applyPutToAttribute(SerialNum serialNum, const FieldValue::UP &fieldValue, Docum
{
ensureLidSpace(serialNum, lid, attr);
if (fieldValue.get()) {
- AttrUpdate::handleValue(attr, lid, *fieldValue);
+ AttributeUpdater::handleValue(attr, lid, *fieldValue);
} else {
attr.clearDoc(lid);
}
@@ -127,7 +127,7 @@ applyUpdateToAttribute(SerialNum serialNum, const FieldUpdate &fieldUpd,
DocumentIdT lid, AttributeVector &attr)
{
ensureLidSpace(serialNum, lid, attr);
- AttrUpdate::handleUpdate(attr, lid, fieldUpd);
+ AttributeUpdater::handleUpdate(attr, lid, fieldUpd);
}
void
@@ -135,7 +135,7 @@ applyUpdateToAttributeAndCommit(SerialNum serialNum, const FieldUpdate &fieldUpd
DocumentIdT lid, AttributeVector &attr)
{
ensureLidSpace(serialNum, lid, attr);
- AttrUpdate::handleUpdate(attr, lid, fieldUpd);
+ AttributeUpdater::handleUpdate(attr, lid, fieldUpd);
attr.commit(serialNum, serialNum);
}
diff --git a/searchcore/src/vespa/searchcore/proton/common/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/common/CMakeLists.txt
index c2f74c01c2f..84d1cfb471a 100644
--- a/searchcore/src/vespa/searchcore/proton/common/CMakeLists.txt
+++ b/searchcore/src/vespa/searchcore/proton/common/CMakeLists.txt
@@ -1,8 +1,8 @@
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
vespa_add_library(searchcore_pcommon STATIC
SOURCES
+ attribute_updater.cpp
attributefieldvaluenode.cpp
- attrupdate.cpp
cachedselect.cpp
commit_time_tracker.cpp
dbdocumentid.cpp
diff --git a/searchcore/src/vespa/searchcore/proton/common/attrupdate.cpp b/searchcore/src/vespa/searchcore/proton/common/attribute_updater.cpp
index d8dc8b9df42..3ad838c595b 100644
--- a/searchcore/src/vespa/searchcore/proton/common/attrupdate.cpp
+++ b/searchcore/src/vespa/searchcore/proton/common/attribute_updater.cpp
@@ -1,30 +1,32 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include "attrupdate.h"
+#include "attribute_updater.h"
+#include <vespa/eval/tensor/tensor.h>
+#include <vespa/document/base/forcelink.h>
#include <vespa/document/fieldvalue/arrayfieldvalue.h>
-#include <vespa/document/fieldvalue/predicatefieldvalue.h>
-#include <vespa/document/fieldvalue/weightedsetfieldvalue.h>
#include <vespa/document/fieldvalue/literalfieldvalue.h>
-#include <vespa/document/fieldvalue/tensorfieldvalue.h>
+#include <vespa/document/fieldvalue/predicatefieldvalue.h>
#include <vespa/document/fieldvalue/referencefieldvalue.h>
-#include <vespa/document/update/assignvalueupdate.h>
+#include <vespa/document/fieldvalue/tensorfieldvalue.h>
+#include <vespa/document/fieldvalue/weightedsetfieldvalue.h>
#include <vespa/document/update/addvalueupdate.h>
-#include <vespa/document/update/removevalueupdate.h>
-#include <vespa/document/update/mapvalueupdate.h>
#include <vespa/document/update/arithmeticvalueupdate.h>
+#include <vespa/document/update/assignvalueupdate.h>
#include <vespa/document/update/clearvalueupdate.h>
-#include <vespa/document/base/forcelink.h>
-#include <vespa/searchlib/common/base.h>
-#include <vespa/searchlib/tensor/tensor_attribute.h>
-#include <vespa/searchlib/attribute/reference_attribute.h>
-#include <vespa/searchlib/attribute/predicate_attribute.h>
+#include <vespa/document/update/mapvalueupdate.h>
+#include <vespa/document/update/removevalueupdate.h>
+#include <vespa/document/update/tensormodifyupdate.h>
#include <vespa/searchlib/attribute/attributevector.hpp>
#include <vespa/searchlib/attribute/changevector.hpp>
+#include <vespa/searchlib/attribute/predicate_attribute.h>
+#include <vespa/searchlib/attribute/reference_attribute.h>
+#include <vespa/searchlib/common/base.h>
+#include <vespa/searchlib/tensor/tensor_attribute.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <sstream>
#include <vespa/log/log.h>
-LOG_SETUP(".proton.common.attrupdate");
+LOG_SETUP(".proton.common.attribute_updater");
using namespace document;
using vespalib::make_string;
@@ -120,7 +122,7 @@ private:
template <typename V, typename Accessor>
void
-AttrUpdate::handleUpdateT(V & vec, Accessor, uint32_t lid, const ValueUpdate & upd)
+AttributeUpdater::handleUpdateT(V & vec, Accessor, uint32_t lid, const ValueUpdate & upd)
{
LOG(spam, "handleValueUpdate(%s, %u): %s", vec.getName().c_str(), lid, toString(upd).c_str());
ValueUpdate::ValueUpdateType op = upd.getType();
@@ -181,7 +183,9 @@ AttrUpdate::handleUpdateT(V & vec, Accessor, uint32_t lid, const ValueUpdate & u
}
template <>
-void AttrUpdate::handleUpdate(PredicateAttribute &vec, uint32_t lid, const ValueUpdate &upd) {
+void
+AttributeUpdater::handleUpdate(PredicateAttribute &vec, uint32_t lid, const ValueUpdate &upd)
+{
LOG(spam, "handleValueUpdate(%s, %u): %s", vec.getName().c_str(), lid, toString(upd).c_str());
ValueUpdate::ValueUpdateType op = upd.getType();
assert(!vec.hasMultiValue());
@@ -199,8 +203,26 @@ void AttrUpdate::handleUpdate(PredicateAttribute &vec, uint32_t lid, const Value
}
}
+namespace {
+
+void
+applyTensorModifyUpdate(TensorAttribute &vec, uint32_t lid, const TensorModifyUpdate &update)
+{
+ auto oldTensor = vec.getTensor(lid);
+ if (oldTensor) {
+ auto newTensor = update.applyTo(*oldTensor);
+ if (newTensor) {
+ vec.setTensor(lid, *newTensor);
+ }
+ }
+}
+
+}
+
template <>
-void AttrUpdate::handleUpdate(TensorAttribute &vec, uint32_t lid, const ValueUpdate &upd) {
+void
+AttributeUpdater::handleUpdate(TensorAttribute &vec, uint32_t lid, const ValueUpdate &upd)
+{
LOG(spam, "handleUpdate(%s, %u): %s", vec.getName().c_str(), lid, toString(upd).c_str());
ValueUpdate::ValueUpdateType op = upd.getType();
assert(!vec.hasMultiValue());
@@ -210,6 +232,8 @@ void AttrUpdate::handleUpdate(TensorAttribute &vec, uint32_t lid, const ValueUpd
vec.clearDoc(lid);
updateValue(vec, lid, assign.getValue());
}
+ } else if (op == ValueUpdate::TensorModifyUpdate) {
+ applyTensorModifyUpdate(vec, lid, static_cast<const TensorModifyUpdate &>(upd));
} else if (op == ValueUpdate::Clear) {
vec.clearDoc(lid);
} else {
@@ -219,7 +243,9 @@ void AttrUpdate::handleUpdate(TensorAttribute &vec, uint32_t lid, const ValueUpd
}
template <>
-void AttrUpdate::handleUpdate(ReferenceAttribute &vec, uint32_t lid, const ValueUpdate &upd) {
+void
+AttributeUpdater::handleUpdate(ReferenceAttribute &vec, uint32_t lid, const ValueUpdate &upd)
+{
LOG(spam, "handleUpdate(%s, %u): %s", vec.getName().c_str(), lid, toString(upd).c_str());
ValueUpdate::ValueUpdateType op = upd.getType();
assert(!vec.hasMultiValue());
@@ -237,7 +263,7 @@ void AttrUpdate::handleUpdate(ReferenceAttribute &vec, uint32_t lid, const Value
}
void
-AttrUpdate::handleUpdate(AttributeVector & vec, uint32_t lid, const FieldUpdate & fUpdate)
+AttributeUpdater::handleUpdate(AttributeVector & vec, uint32_t lid, const FieldUpdate & fUpdate)
{
LOG(spam, "handleFieldUpdate(%s, %u): %s", vec.getName().c_str(), lid, toString(fUpdate).c_str());
for(const auto & update : fUpdate.getUpdates()) {
@@ -276,7 +302,7 @@ AttrUpdate::handleUpdate(AttributeVector & vec, uint32_t lid, const FieldUpdate
}
void
-AttrUpdate::handleValue(AttributeVector & vec, uint32_t lid, const FieldValue & val)
+AttributeUpdater::handleValue(AttributeVector & vec, uint32_t lid, const FieldValue & val)
{
LOG(spam, "handleValue(%s, %u): %s", vec.getName().c_str(), lid, toString(val).c_str());
const vespalib::Identifiable::RuntimeClass & rc = vec.getClass();
@@ -303,7 +329,7 @@ AttrUpdate::handleValue(AttributeVector & vec, uint32_t lid, const FieldValue &
template <typename V, typename Accessor>
void
-AttrUpdate::handleValueT(V & vec, Accessor, uint32_t lid, const FieldValue & val)
+AttributeUpdater::handleValueT(V & vec, Accessor, uint32_t lid, const FieldValue & val)
{
if (vec.hasMultiValue()) {
vec.clearDoc(lid);
@@ -323,7 +349,7 @@ AttrUpdate::handleValueT(V & vec, Accessor, uint32_t lid, const FieldValue & val
}
void
-AttrUpdate::appendValue(IntegerAttribute & vec, uint32_t lid, const FieldValue & val, int weight)
+AttributeUpdater::appendValue(IntegerAttribute & vec, uint32_t lid, const FieldValue & val, int weight)
{
int64_t v = val.getAsLong();
if (!vec.append(lid, v, weight)) {
@@ -333,7 +359,7 @@ AttrUpdate::appendValue(IntegerAttribute & vec, uint32_t lid, const FieldValue &
}
void
-AttrUpdate::removeValue(IntegerAttribute & vec, uint32_t lid, const FieldValue & val)
+AttributeUpdater::removeValue(IntegerAttribute & vec, uint32_t lid, const FieldValue & val)
{
int64_t v = val.getAsLong();
if (!vec.remove(lid, v, 1)) {
@@ -343,7 +369,7 @@ AttrUpdate::removeValue(IntegerAttribute & vec, uint32_t lid, const FieldValue &
}
void
-AttrUpdate::updateValue(IntegerAttribute & vec, uint32_t lid, const FieldValue & val)
+AttributeUpdater::updateValue(IntegerAttribute & vec, uint32_t lid, const FieldValue & val)
{
int64_t v = val.getAsLong();
if (!vec.update(lid, v)) {
@@ -353,7 +379,7 @@ AttrUpdate::updateValue(IntegerAttribute & vec, uint32_t lid, const FieldValue &
}
void
-AttrUpdate::appendValue(FloatingPointAttribute & vec, uint32_t lid, const FieldValue & val, int weight)
+AttributeUpdater::appendValue(FloatingPointAttribute & vec, uint32_t lid, const FieldValue & val, int weight)
{
double v = val.getAsDouble();
if (!vec.append(lid, v, weight)) {
@@ -364,7 +390,7 @@ AttrUpdate::appendValue(FloatingPointAttribute & vec, uint32_t lid, const FieldV
template <typename V, typename Accessor>
void
-AttrUpdate::appendValue(V & vec, uint32_t lid, Accessor & ac)
+AttributeUpdater::appendValue(V & vec, uint32_t lid, Accessor & ac)
{
if (!vec.append(lid, ac)) {
throw UpdateException(make_string("attribute append failed: %s[%u]",
@@ -373,7 +399,7 @@ AttrUpdate::appendValue(V & vec, uint32_t lid, Accessor & ac)
}
void
-AttrUpdate::removeValue(FloatingPointAttribute & vec, uint32_t lid, const FieldValue & val)
+AttributeUpdater::removeValue(FloatingPointAttribute & vec, uint32_t lid, const FieldValue & val)
{
double v = val.getAsDouble();
if (!vec.remove(lid, v, 1)) {
@@ -383,7 +409,7 @@ AttrUpdate::removeValue(FloatingPointAttribute & vec, uint32_t lid, const FieldV
}
void
-AttrUpdate::updateValue(FloatingPointAttribute & vec, uint32_t lid, const FieldValue & val)
+AttributeUpdater::updateValue(FloatingPointAttribute & vec, uint32_t lid, const FieldValue & val)
{
double v = val.getAsDouble();
if (!vec.update(lid, v)) {
@@ -406,7 +432,7 @@ getString(const search::StringAttribute & attr, uint32_t lid, const FieldValue &
}
void
-AttrUpdate::appendValue(StringAttribute & vec, uint32_t lid, const FieldValue & val, int weight)
+AttributeUpdater::appendValue(StringAttribute & vec, uint32_t lid, const FieldValue & val, int weight)
{
const vespalib::string & s = getString(vec, lid, val);
if (!vec.append(lid, s, weight)) {
@@ -416,7 +442,7 @@ AttrUpdate::appendValue(StringAttribute & vec, uint32_t lid, const FieldValue &
}
void
-AttrUpdate::removeValue(StringAttribute & vec, uint32_t lid, const FieldValue & val)
+AttributeUpdater::removeValue(StringAttribute & vec, uint32_t lid, const FieldValue & val)
{
const vespalib::string & v = getString(vec, lid, val);
if (!vec.remove(lid, v, 1)) {
@@ -426,7 +452,7 @@ AttrUpdate::removeValue(StringAttribute & vec, uint32_t lid, const FieldValue &
}
void
-AttrUpdate::updateValue(StringAttribute & vec, uint32_t lid, const FieldValue & val)
+AttributeUpdater::updateValue(StringAttribute & vec, uint32_t lid, const FieldValue & val)
{
const vespalib::string & v = getString(vec, lid, val);
if (!vec.update(lid, v)) {
@@ -435,7 +461,8 @@ AttrUpdate::updateValue(StringAttribute & vec, uint32_t lid, const FieldValue &
}
}
-void AttrUpdate::updateValue(PredicateAttribute &vec, uint32_t lid, const FieldValue &val)
+void
+AttributeUpdater::updateValue(PredicateAttribute &vec, uint32_t lid, const FieldValue &val)
{
if (!val.inherits(PredicateFieldValue::classId)) {
throw UpdateException(
@@ -445,7 +472,8 @@ void AttrUpdate::updateValue(PredicateAttribute &vec, uint32_t lid, const FieldV
vec.updateValue(lid, static_cast<const PredicateFieldValue &>(val));
}
-void AttrUpdate::updateValue(TensorAttribute &vec, uint32_t lid, const FieldValue &val)
+void
+AttributeUpdater::updateValue(TensorAttribute &vec, uint32_t lid, const FieldValue &val)
{
if (!val.inherits(TensorFieldValue::classId)) {
throw UpdateException(
@@ -461,7 +489,8 @@ void AttrUpdate::updateValue(TensorAttribute &vec, uint32_t lid, const FieldValu
}
}
-void AttrUpdate::updateValue(ReferenceAttribute &vec, uint32_t lid, const FieldValue &val)
+void
+AttributeUpdater::updateValue(ReferenceAttribute &vec, uint32_t lid, const FieldValue &val)
{
if (!val.inherits(ReferenceFieldValue::classId)) {
vec.clearDoc(lid);
diff --git a/searchcore/src/vespa/searchcore/proton/common/attrupdate.h b/searchcore/src/vespa/searchcore/proton/common/attribute_updater.h
index cece6d2ceae..01be6299692 100644
--- a/searchcore/src/vespa/searchcore/proton/common/attrupdate.h
+++ b/searchcore/src/vespa/searchcore/proton/common/attribute_updater.h
@@ -15,7 +15,10 @@ namespace attribute {class ReferenceAttribute; }
VESPA_DEFINE_EXCEPTION(UpdateException, vespalib::Exception);
-class AttrUpdate {
+/**
+ * Class used to apply (document) field values and field updates to attribute vectors.
+ */
+class AttributeUpdater {
using Field = document::Field;
using FieldValue = document::FieldValue;
using FieldUpdate = document::FieldUpdate;