diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2017-07-26 20:52:42 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2017-07-31 17:04:20 +0200 |
commit | 1502958aa0d409a734dcc4a9618d743ac6d4808f (patch) | |
tree | ee15f0df196f479eab5398326d5dfd5ced9a2c45 /document | |
parent | 6e823240494e3c61ce5cf44676c1729abfbd3a48 (diff) |
Removed unused parameters.
Diffstat (limited to 'document')
9 files changed, 75 insertions, 105 deletions
diff --git a/document/src/tests/fieldpathupdatetestcase.cpp b/document/src/tests/fieldpathupdatetestcase.cpp index 782037067ae..fc94c5e63eb 100644 --- a/document/src/tests/fieldpathupdatetestcase.cpp +++ b/document/src/tests/fieldpathupdatetestcase.cpp @@ -284,7 +284,7 @@ struct TestFieldPathUpdate : FieldPathUpdate mutable std::string _str; ~TestFieldPathUpdate(); - TestFieldPathUpdate(const DataType *type, const std::string& fieldPath, const std::string& whereClause); + TestFieldPathUpdate(const std::string& fieldPath, const std::string& whereClause); TestFieldPathUpdate(const TestFieldPathUpdate& other); @@ -303,9 +303,8 @@ struct TestFieldPathUpdate : FieldPathUpdate }; TestFieldPathUpdate::~TestFieldPathUpdate() { } -TestFieldPathUpdate::TestFieldPathUpdate(const DataType *type, const std::string& fieldPath, - const std::string& whereClause) - : FieldPathUpdate(*type, fieldPath, whereClause) +TestFieldPathUpdate::TestFieldPathUpdate(const std::string& fieldPath, const std::string& whereClause) + : FieldPathUpdate(fieldPath, whereClause) { } @@ -348,7 +347,7 @@ FieldPathUpdateTestCase::testWhereClause() DocumentTypeRepo repo(getRepoConfig()); Document::UP doc(createTestDocument(repo)); std::string where = "test.l1s1.structmap.value.smap{$x} == \"dicaprio\""; - TestFieldPathUpdate update(doc->getDataType(), "l1s1.structmap.value.smap{$x}", where); + TestFieldPathUpdate update("l1s1.structmap.value.smap{$x}", where); update.applyTo(*doc); CPPUNIT_ASSERT_EQUAL(std::string("dicaprio"), update._str); } @@ -358,7 +357,7 @@ FieldPathUpdateTestCase::testNoIterateMapValues() { DocumentTypeRepo repo(getRepoConfig()); Document::UP doc(createTestDocument(repo)); - TestFieldPathUpdate update(doc->getDataType(), "l1s1.structwset.primitive1", "true"); + TestFieldPathUpdate update("l1s1.structwset.primitive1", "true"); update.applyTo(*doc); CPPUNIT_ASSERT_EQUAL(std::string("3;5"), update._str); } @@ -372,7 +371,7 @@ FieldPathUpdateTestCase::testRemoveField() CPPUNIT_ASSERT_EQUAL(vespalib::string("cocacola"), doc->getValue("strfoo")->getAsString()); //doc->print(std::cerr, true, ""); DocumentUpdate docUp(_foobar_type, DocumentId("doc:barbar:foofoo")); - docUp.addFieldPathUpdate(FieldPathUpdate::CP(new RemoveFieldPathUpdate(*doc->getDataType(), "strfoo"))); + docUp.addFieldPathUpdate(FieldPathUpdate::CP(new RemoveFieldPathUpdate("strfoo"))); docUp.applyTo(*doc); CPPUNIT_ASSERT(doc->hasValue("strfoo") == false); } @@ -394,8 +393,7 @@ FieldPathUpdateTestCase::testApplyRemoveMultiList() //doc->print(std::cerr, true, ""); DocumentUpdate docUp(_foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP( - new RemoveFieldPathUpdate(*doc->getDataType(), - "strarray[$x]", "foobar.strarray[$x] == \"remove val 1\""))); + new RemoveFieldPathUpdate("strarray[$x]", "foobar.strarray[$x] == \"remove val 1\""))); docUp.applyTo(*doc); { std::unique_ptr<ArrayFieldValue> strArray = doc->getAs<ArrayFieldValue>(doc->getField("strarray")); @@ -419,7 +417,7 @@ FieldPathUpdateTestCase::testApplyRemoveEntireListField() } //doc->print(std::cerr, true, ""); DocumentUpdate docUp(_foobar_type, DocumentId("doc:barbar:foofoo")); - docUp.addFieldPathUpdate(FieldPathUpdate::CP(new RemoveFieldPathUpdate(*doc->getDataType(), "strarray", ""))); + docUp.addFieldPathUpdate(FieldPathUpdate::CP(new RemoveFieldPathUpdate("strarray", ""))); docUp.applyTo(*doc); CPPUNIT_ASSERT(!doc->hasValue("strarray")); } @@ -438,8 +436,7 @@ FieldPathUpdateTestCase::testApplyRemoveMultiWset() CPPUNIT_ASSERT(doc->hasValue("strwset")); //doc->print(std::cerr, true, ""); DocumentUpdate docUp(_foobar_type, DocumentId("doc:barbar:foofoo")); - docUp.addFieldPathUpdate(FieldPathUpdate::CP(new RemoveFieldPathUpdate(*doc->getDataType(), - "strwset{remove val 1}"))); + docUp.addFieldPathUpdate(FieldPathUpdate::CP(new RemoveFieldPathUpdate("strwset{remove val 1}"))); docUp.applyTo(*doc); { std::unique_ptr<WeightedSetFieldValue> strWset = doc->getAs<WeightedSetFieldValue>(doc->getField("strwset")); @@ -475,8 +472,7 @@ FieldPathUpdateTestCase::testApplyAssignMath() doc->setValue("num", IntFieldValue(34)); DocumentUpdate docUp(_foobar_type, DocumentId("doc:barbar:foofoo")); - docUp.addFieldPathUpdate(FieldPathUpdate::CP( - new AssignFieldPathUpdate(*doc->getDataType(), "num", "", "($value * 2) / $value"))); + docUp.addFieldPathUpdate(FieldPathUpdate::CP(new AssignFieldPathUpdate("num", "", "($value * 2) / $value"))); docUp.applyTo(*doc); CPPUNIT_ASSERT_EQUAL(static_cast<const FieldValue&>(IntFieldValue(2)), *doc->getValue("num")); } @@ -488,7 +484,7 @@ FieldPathUpdateTestCase::testApplyAssignMathByteToZero() doc->setValue("byteval", ByteFieldValue(3)); DocumentUpdate docUp(_foobar_type, DocumentId("doc:barbar:foofoo")); - docUp.addFieldPathUpdate(FieldPathUpdate::CP(new AssignFieldPathUpdate(*doc->getDataType(), "byteval", "", "$value - 3"))); + docUp.addFieldPathUpdate(FieldPathUpdate::CP(new AssignFieldPathUpdate("byteval", "", "$value - 3"))); docUp.applyTo(*doc); CPPUNIT_ASSERT_EQUAL(static_cast<const FieldValue&>(ByteFieldValue(0)), *doc->getValue("byteval")); } @@ -501,8 +497,7 @@ FieldPathUpdateTestCase::testApplyAssignMathNotModifiedOnUnderflow() doc->setValue("byteval", ByteFieldValue(low_value)); DocumentUpdate docUp(_foobar_type, DocumentId("doc:barbar:foofoo")); - docUp.addFieldPathUpdate(FieldPathUpdate::CP( - new AssignFieldPathUpdate(*doc->getDataType(), "byteval", "", "$value - 4"))); + docUp.addFieldPathUpdate(FieldPathUpdate::CP(new AssignFieldPathUpdate("byteval", "", "$value - 4"))); docUp.applyTo(*doc); // Over/underflow will happen. You must have control of your data types. CPPUNIT_ASSERT_EQUAL(static_cast<const FieldValue&>(ByteFieldValue((char)(low_value - 4))), *doc->getValue("byteval")); @@ -515,8 +510,7 @@ FieldPathUpdateTestCase::testApplyAssignMathNotModifiedOnOverflow() doc->setValue("byteval", ByteFieldValue(127)); DocumentUpdate docUp(_foobar_type, DocumentId("doc:barbar:foofoo")); - docUp.addFieldPathUpdate(FieldPathUpdate::CP( - new AssignFieldPathUpdate(*doc->getDataType(), "byteval", "", "$value + 200"))); + docUp.addFieldPathUpdate(FieldPathUpdate::CP(new AssignFieldPathUpdate("byteval", "", "$value + 200"))); docUp.applyTo(*doc); // Over/underflow will happen. You must have control of your data types. CPPUNIT_ASSERT_EQUAL(static_cast<const FieldValue&>(ByteFieldValue(static_cast<char>(static_cast<int>(127+200)))), *doc->getValue("byteval")); @@ -530,8 +524,7 @@ FieldPathUpdateTestCase::testApplyAssignMathDivZero() doc->setValue("num", IntFieldValue(10)); DocumentUpdate docUp(_foobar_type, DocumentId("doc:barbar:foofoo")); - docUp.addFieldPathUpdate(FieldPathUpdate::CP( - new AssignFieldPathUpdate(*doc->getDataType(), "num", "", "$value / ($value - 10)"))); + docUp.addFieldPathUpdate(FieldPathUpdate::CP(new AssignFieldPathUpdate("num", "", "$value / ($value - 10)"))); docUp.applyTo(*doc); CPPUNIT_ASSERT_EQUAL(static_cast<const FieldValue&>(IntFieldValue(10)), *doc->getValue("num")); } @@ -545,8 +538,7 @@ FieldPathUpdateTestCase::testApplyAssignFieldNotExistingInExpression() doc->setValue("num", IntFieldValue(10)); DocumentUpdate docUp(_foobar_type, DocumentId("doc:barbar:foofoo")); - docUp.addFieldPathUpdate(FieldPathUpdate::CP( - new AssignFieldPathUpdate(*doc->getDataType(), "num", "", "foobar.num2 + $value"))); + docUp.addFieldPathUpdate(FieldPathUpdate::CP(new AssignFieldPathUpdate("num", "", "foobar.num2 + $value"))); docUp.applyTo(*doc); CPPUNIT_ASSERT_EQUAL(static_cast<const FieldValue&>(IntFieldValue(10)), *doc->getValue("num")); } @@ -555,11 +547,12 @@ void FieldPathUpdateTestCase::testApplyAssignFieldNotExistingInPath() { Document::UP doc(new Document(_foobar_type, DocumentId("doc:bat:man"))); + doc->setRepo(*_repo); DocumentUpdate docUp(_foobar_type, DocumentId("doc:barbar:foofoo")); try { - docUp.addFieldPathUpdate(FieldPathUpdate::CP( - new AssignFieldPathUpdate(*doc->getDataType(), "nosuchnum", "", "foobar.num + $value"))); + docUp.addFieldPathUpdate(FieldPathUpdate::CP(new AssignFieldPathUpdate("nosuchnum", "", "foobar.num + $value"))); + docUp.applyTo(*doc); CPPUNIT_ASSERT(false); } catch (const FieldNotFoundException&) { } @@ -572,8 +565,7 @@ FieldPathUpdateTestCase::testApplyAssignTargetNotExisting() CPPUNIT_ASSERT(doc->hasValue("num") == false); DocumentUpdate docUp(_foobar_type, DocumentId("doc:barbar:foofoo")); - docUp.addFieldPathUpdate(FieldPathUpdate::CP( - new AssignFieldPathUpdate(*doc->getDataType(), "num", "", "$value + 5"))); + docUp.addFieldPathUpdate(FieldPathUpdate::CP(new AssignFieldPathUpdate("num", "", "$value + 5"))); docUp.applyTo(*doc); CPPUNIT_ASSERT_EQUAL(static_cast<const FieldValue&>(IntFieldValue(5)), *doc->getValue("num")); } @@ -616,7 +608,7 @@ FieldPathUpdateTestCase::testApplyAssignMathRemoveIfZero() CPPUNIT_ASSERT(doc->hasValue("num") == true); DocumentUpdate docUp(_foobar_type, DocumentId("doc:barbar:foofoo")); - FieldPathUpdate::CP up1(new AssignFieldPathUpdate(*doc->getDataType(), "num", "", "($value * 2) / $value - 2")); + FieldPathUpdate::CP up1(new AssignFieldPathUpdate("num", "", "($value * 2) / $value - 2")); static_cast<AssignFieldPathUpdate&>(*up1).setRemoveIfZero(true); docUp.addFieldPathUpdate(up1); @@ -1115,7 +1107,7 @@ FieldPathUpdateTestCase::testSerializeRemove() DocumentUpdate docUp(_foobar_type, DocumentId("doc:barbar:foofoo")); CPPUNIT_ASSERT(!docUp.affectsDocumentBody()); - FieldPathUpdate::CP update1(new RemoveFieldPathUpdate(*doc->getDataType(), "structmap{ribbit}", std::string())); + FieldPathUpdate::CP update1(new RemoveFieldPathUpdate("structmap{ribbit}", std::string())); docUp.addFieldPathUpdate(update1); testSerialize(*_repo, docUp); @@ -1129,8 +1121,7 @@ FieldPathUpdateTestCase::testSerializeAssignMath() doc->setValue("num", IntFieldValue(34)); DocumentUpdate docUp(_foobar_type, DocumentId("doc:barbar:foofoo")); - docUp.addFieldPathUpdate(FieldPathUpdate::CP( - new AssignFieldPathUpdate(*doc->getDataType(), "num", "", "($value * 2) / $value"))); + docUp.addFieldPathUpdate(FieldPathUpdate::CP(new AssignFieldPathUpdate("num", "", "($value * 2) / $value"))); testSerialize(*_repo, docUp); } @@ -1140,7 +1131,7 @@ FieldPathUpdateTestCase::createDocumentUpdateForSerialization(const DocumentType const DocumentType *docType(repo.getDocumentType("serializetest")); DocumentUpdate::UP docUp(new DocumentUpdate(*docType, DocumentId("doc:serialization:xlanguage"))); - FieldPathUpdate::CP assign(new AssignFieldPathUpdate(*docType, "intfield", "", "3")); + FieldPathUpdate::CP assign(new AssignFieldPathUpdate("intfield", "", "3")); static_cast<AssignFieldPathUpdate&>(*assign).setRemoveIfZero(true); static_cast<AssignFieldPathUpdate&>(*assign).setCreateMissingPath(false); docUp->addFieldPathUpdate(assign); @@ -1150,7 +1141,7 @@ FieldPathUpdateTestCase::createDocumentUpdateForSerialization(const DocumentType fArray.add(FloatFieldValue(5.0)); docUp->addFieldPathUpdate(FieldPathUpdate::CP(new AddFieldPathUpdate(*docType, "arrayoffloatfield", "", fArray))); - docUp->addFieldPathUpdate(FieldPathUpdate::CP(new RemoveFieldPathUpdate(*docType, "intfield", "serializetest.intfield > 0"))); + docUp->addFieldPathUpdate(FieldPathUpdate::CP(new RemoveFieldPathUpdate("intfield", "serializetest.intfield > 0"))); return docUp; } @@ -1197,4 +1188,4 @@ FieldPathUpdateTestCase::testGenerateSerializedFile() close(fd); } -} // ns document +} diff --git a/document/src/vespa/document/update/addfieldpathupdate.cpp b/document/src/vespa/document/update/addfieldpathupdate.cpp index f2ec2c3064e..d0796b9b2a0 100644 --- a/document/src/vespa/document/update/addfieldpathupdate.cpp +++ b/document/src/vespa/document/update/addfieldpathupdate.cpp @@ -21,10 +21,10 @@ IMPLEMENT_IDENTIFIABLE(AddFieldPathUpdate, FieldPathUpdate); AddFieldPathUpdate::AddFieldPathUpdate(const DataType& type, stringref fieldPath, stringref whereClause, const ArrayFieldValue& values) - : FieldPathUpdate(type, fieldPath, whereClause), + : FieldPathUpdate(fieldPath, whereClause), _values(vespalib::CloneablePtr<ArrayFieldValue>(values.clone())) { - checkCompatibility(*_values); + checkCompatibility(*_values, type); } AddFieldPathUpdate::AddFieldPathUpdate() @@ -93,7 +93,9 @@ AddFieldPathUpdate::deserialize(const DocumentTypeRepo& repo, const DataType& ty { FieldPathUpdate::deserialize(repo, type, buffer, version); - const DataType& fieldType = getResultingDataType(); + FieldPath path; + type.buildFieldPath(path, getOriginalFieldPath()); + const DataType& fieldType = getResultingDataType(path); assert(fieldType.inherits(ArrayDataType::classId)); FieldValue::UP val = fieldType.createFieldValue(); _values.reset(static_cast<ArrayFieldValue*>(val.release())); diff --git a/document/src/vespa/document/update/assignfieldpathupdate.cpp b/document/src/vespa/document/update/assignfieldpathupdate.cpp index 276f9f2a3d6..1de38b982d0 100644 --- a/document/src/vespa/document/update/assignfieldpathupdate.cpp +++ b/document/src/vespa/document/update/assignfieldpathupdate.cpp @@ -36,21 +36,17 @@ AssignFieldPathUpdate::AssignFieldPathUpdate( stringref fieldPath, stringref whereClause, const FieldValue& newValue) - : FieldPathUpdate(type, fieldPath, whereClause), + : FieldPathUpdate(fieldPath, whereClause), _newValue(newValue.clone()), _expression(), _removeIfZero(false), _createMissingPath(true) { - checkCompatibility(*_newValue); + checkCompatibility(*_newValue, type); } -AssignFieldPathUpdate::AssignFieldPathUpdate( - const DataType& type, - stringref fieldPath, - stringref whereClause, - stringref expression) - : FieldPathUpdate(type, fieldPath, whereClause), +AssignFieldPathUpdate::AssignFieldPathUpdate(stringref fieldPath, stringref whereClause, stringref expression) + : FieldPathUpdate(fieldPath, whereClause), _newValue(), _expression(expression), _removeIfZero(false), @@ -222,8 +218,7 @@ AssignFieldPathUpdate::print(std::ostream& out, bool verbose, const std::string& } void -AssignFieldPathUpdate::deserialize(const DocumentTypeRepo& repo, - const DataType& type, +AssignFieldPathUpdate::deserialize(const DocumentTypeRepo& repo, const DataType& type, ByteBuffer& buffer, uint16_t version) { FieldPathUpdate::deserialize(repo, type, buffer, version); @@ -237,7 +232,9 @@ AssignFieldPathUpdate::deserialize(const DocumentTypeRepo& repo, if (flags & ARITHMETIC_EXPRESSION) { _expression = getString(buffer); } else { - _newValue.reset(getResultingDataType().createFieldValue().release()); + FieldPath path; + type.buildFieldPath(path, getOriginalFieldPath()); + _newValue.reset(getResultingDataType(path).createFieldValue().release()); nbostream stream(buffer.getBufferAtPos(), buffer.getRemaining()); VespaDocumentDeserializer deserializer(repo, stream, version); deserializer.read(*_newValue); diff --git a/document/src/vespa/document/update/assignfieldpathupdate.h b/document/src/vespa/document/update/assignfieldpathupdate.h index 645df623282..329ce5d8c93 100644 --- a/document/src/vespa/document/update/assignfieldpathupdate.h +++ b/document/src/vespa/document/update/assignfieldpathupdate.h @@ -19,15 +19,8 @@ public: /** For deserialization */ AssignFieldPathUpdate(); - AssignFieldPathUpdate(const DataType& type, - stringref fieldPath, - stringref whereClause, - const FieldValue& newValue); - - AssignFieldPathUpdate(const DataType& type, - stringref fieldPath, - stringref whereClause, - stringref expression); + AssignFieldPathUpdate(const DataType& type, stringref fieldPath, stringref whereClause, const FieldValue& newValue); + AssignFieldPathUpdate(stringref fieldPath, stringref whereClause, stringref expression); ~AssignFieldPathUpdate(); void setRemoveIfZero(bool removeIfZero) { @@ -51,8 +44,7 @@ public: private: uint8_t getSerializedType() const override { return AssignMagic; } - void deserialize(const DocumentTypeRepo& repo, const DataType& type, - ByteBuffer& buffer, uint16_t version) override; + void deserialize(const DocumentTypeRepo& repo, const DataType& type, ByteBuffer& buffer, uint16_t version) override; std::unique_ptr<fieldvalue::IteratorHandler> getIteratorHandler(Document& doc, const DocumentTypeRepo & repo) const override; diff --git a/document/src/vespa/document/update/documentupdate.cpp b/document/src/vespa/document/update/documentupdate.cpp index 9bf28b614e6..cedbd32107b 100644 --- a/document/src/vespa/document/update/documentupdate.cpp +++ b/document/src/vespa/document/update/documentupdate.cpp @@ -100,7 +100,7 @@ DocumentUpdate::affectsDocumentBody() const } } for (const auto & update : _fieldPathUpdates) { - if (update->affectsDocumentBody()) { + if (update->affectsDocumentBody(*_type)) { return true; } } @@ -165,7 +165,7 @@ DocumentUpdate::applyTo(Document& doc) const { const DocumentType& type = doc.getType(); if (_type->getName() != type.getName()) { - string err = make_string("Can not apply a \"%s\" document update to a \"%s\" document.", + string err = make_string("Can not apply a \"%s\" document update to a \"%s\" document.", _type->getName().c_str(), type.getName().c_str()); throw IllegalArgumentException(err, VESPA_STRLOC); } diff --git a/document/src/vespa/document/update/fieldpathupdate.cpp b/document/src/vespa/document/update/fieldpathupdate.cpp index 817dcce5af9..256439a039b 100644 --- a/document/src/vespa/document/update/fieldpathupdate.cpp +++ b/document/src/vespa/document/update/fieldpathupdate.cpp @@ -34,20 +34,16 @@ parseDocumentSelection(vespalib::stringref query, const DocumentTypeRepo& repo) FieldPathUpdate::FieldPathUpdate() : _originalFieldPath(), - _originalWhereClause(), - _fieldPath() + _originalWhereClause() { } FieldPathUpdate::FieldPathUpdate(const FieldPathUpdate &) = default; FieldPathUpdate & FieldPathUpdate::operator =(const FieldPathUpdate &) = default; -FieldPathUpdate::FieldPathUpdate(const DataType& type, stringref fieldPath, stringref whereClause) : +FieldPathUpdate::FieldPathUpdate(stringref fieldPath, stringref whereClause) : _originalFieldPath(fieldPath), - _originalWhereClause(whereClause), - _fieldPath() -{ - type.buildFieldPath(_fieldPath, _originalFieldPath); -} + _originalWhereClause(whereClause) +{ } FieldPathUpdate::~FieldPathUpdate() { } @@ -63,8 +59,10 @@ FieldPathUpdate::applyTo(Document& doc) const { std::unique_ptr<IteratorHandler> handler(getIteratorHandler(doc, *doc.getRepo())); + FieldPath path; + doc.getDataType()->buildFieldPath(path, _originalFieldPath); if (_originalWhereClause.empty()) { - doc.iterateNested(_fieldPath, *handler); + doc.iterateNested(path, *handler); } else { std::unique_ptr<select::Node> whereClause = parseDocumentSelection(_originalWhereClause, *doc.getRepo()); select::ResultList results = whereClause->contains(doc); @@ -72,17 +70,19 @@ FieldPathUpdate::applyTo(Document& doc) const LOG(spam, "vars = %s", handler->getVariables().toString().c_str()); if (*i->second == select::Result::True) { handler->setVariables(i->first); - doc.iterateNested(_fieldPath, *handler); + doc.iterateNested(path, *handler); } } } } bool -FieldPathUpdate::affectsDocumentBody() const +FieldPathUpdate::affectsDocumentBody(const DataType & type) const { - if (_fieldPath.empty() || !_fieldPath[0].hasField()) return false; - const Field& field = _fieldPath[0].getFieldRef(); + FieldPath path; + type.buildFieldPath(path, _originalFieldPath); + if (path.empty() || !path[0].hasField()) return false; + const Field& field = path[0].getFieldRef(); return !field.isHeaderField(); } @@ -94,24 +94,26 @@ FieldPathUpdate::print(std::ostream& out, bool, const std::string& indent) const } void -FieldPathUpdate::checkCompatibility(const FieldValue& fv) const +FieldPathUpdate::checkCompatibility(const FieldValue& fv, const DataType & type) const { - if ( !getResultingDataType().isValueType(fv)) { + FieldPath path; + type.buildFieldPath(path, _originalFieldPath); + if ( !getResultingDataType(path).isValueType(fv)) { throw IllegalArgumentException( make_string("Cannot update a '%s' field with a '%s' value", - getResultingDataType().toString().c_str(), + getResultingDataType(path).toString().c_str(), fv.getDataType()->toString().c_str()), VESPA_STRLOC); } } const DataType& -FieldPathUpdate::getResultingDataType() const +FieldPathUpdate::getResultingDataType(const FieldPath & path) const { - if (_fieldPath.empty()) { + if (path.empty()) { throw vespalib::IllegalStateException("Cannot get resulting data type from an empty field path", VESPA_STRLOC); } - return _fieldPath.rbegin()->getDataType(); + return path.rbegin()->getDataType(); } vespalib::string @@ -125,21 +127,15 @@ FieldPathUpdate::getString(ByteBuffer& buffer) } void -FieldPathUpdate::deserialize(const DocumentTypeRepo&, - const DataType& type, - ByteBuffer& buffer, uint16_t) +FieldPathUpdate::deserialize(const DocumentTypeRepo&, const DataType&, ByteBuffer& buffer, uint16_t) { _originalFieldPath = getString(buffer); _originalWhereClause = getString(buffer); - - type.buildFieldPath(_fieldPath, _originalFieldPath); - } std::unique_ptr<FieldPathUpdate> -FieldPathUpdate::createInstance(const DocumentTypeRepo& repo, - const DataType &type, ByteBuffer& buffer, - int serializationVersion) +FieldPathUpdate::createInstance(const DocumentTypeRepo& repo, const DataType &type, + ByteBuffer& buffer, int serializationVersion) { unsigned char updateType = 0; buffer.getByte(updateType); @@ -162,5 +158,4 @@ FieldPathUpdate::createInstance(const DocumentTypeRepo& repo, return update; } -} // ns document - +} diff --git a/document/src/vespa/document/update/fieldpathupdate.h b/document/src/vespa/document/update/fieldpathupdate.h index 01fa8ee6b79..c120c8d3979 100644 --- a/document/src/vespa/document/update/fieldpathupdate.h +++ b/document/src/vespa/document/update/fieldpathupdate.h @@ -62,10 +62,10 @@ public: * the field path. * @throws IllegalArgumentException upon datatype mismatch. */ - void checkCompatibility(const FieldValue& fv) const; + void checkCompatibility(const FieldValue& fv, const DataType & type) const; /** @return Whether or not the first field path element is a body field */ - bool affectsDocumentBody() const; + bool affectsDocumentBody(const DataType & type) const; void print(std::ostream& out, bool verbose, const std::string& indent) const override; @@ -83,7 +83,7 @@ public: int serializationVersion); protected: - FieldPathUpdate(const DataType& type, stringref fieldPath, stringref whereClause = stringref()); + FieldPathUpdate(stringref fieldPath, stringref whereClause = stringref()); /** * Deserializes the given byte buffer into an instance of a FieldPathUpdate @@ -97,7 +97,7 @@ protected: ByteBuffer& buffer, uint16_t version); /** @return the datatype of the last path element in the field path */ - const DataType& getResultingDataType() const; + const DataType& getResultingDataType(const FieldPath & path) const; enum SerializedMagic {AssignMagic=0, RemoveMagic=1, AddMagic=2}; private: // TODO: rename to createIteratorHandler? @@ -105,8 +105,6 @@ private: vespalib::string _originalFieldPath; vespalib::string _originalWhereClause; - - FieldPath _fieldPath; }; } diff --git a/document/src/vespa/document/update/removefieldpathupdate.cpp b/document/src/vespa/document/update/removefieldpathupdate.cpp index 4c938eefa7e..c0ae2f869e4 100644 --- a/document/src/vespa/document/update/removefieldpathupdate.cpp +++ b/document/src/vespa/document/update/removefieldpathupdate.cpp @@ -15,11 +15,8 @@ RemoveFieldPathUpdate::RemoveFieldPathUpdate() { } -RemoveFieldPathUpdate::RemoveFieldPathUpdate( - const DataType& type, - stringref fieldPath, - stringref whereClause) - : FieldPathUpdate(type, fieldPath, whereClause) +RemoveFieldPathUpdate::RemoveFieldPathUpdate(stringref fieldPath, stringref whereClause) + : FieldPathUpdate(fieldPath, whereClause) { } diff --git a/document/src/vespa/document/update/removefieldpathupdate.h b/document/src/vespa/document/update/removefieldpathupdate.h index 2dfc826e61f..db7e234bfc8 100644 --- a/document/src/vespa/document/update/removefieldpathupdate.h +++ b/document/src/vespa/document/update/removefieldpathupdate.h @@ -11,7 +11,7 @@ public: /** For deserialization */ RemoveFieldPathUpdate(); - RemoveFieldPathUpdate(const DataType& type, stringref fieldPath, stringref whereClause = stringref()); + RemoveFieldPathUpdate(stringref fieldPath, stringref whereClause = stringref()); FieldPathUpdate* clone() const override { return new RemoveFieldPathUpdate(*this); } @@ -29,6 +29,4 @@ private: std::unique_ptr<fieldvalue::IteratorHandler> getIteratorHandler(Document &, const DocumentTypeRepo &) const override; }; - } // ns document - |