diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-04 12:10:25 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-04 13:01:43 +0000 |
commit | 46f44aed6e46f5a81a5f7c01745f97ec31c33d9f (patch) | |
tree | 4d5fb00aa47ab4ee76caddb574f26291a87c2854 /document | |
parent | 19c86cb3ebac5b36630eb2a83281bb0d037a9070 (diff) |
Remove clone from DataType.
Diffstat (limited to 'document')
27 files changed, 61 insertions, 120 deletions
diff --git a/document/src/tests/datatype/datatype_test.cpp b/document/src/tests/datatype/datatype_test.cpp index b3da01dfec3..84c72127735 100644 --- a/document/src/tests/datatype/datatype_test.cpp +++ b/document/src/tests/datatype/datatype_test.cpp @@ -19,22 +19,6 @@ void assign(S &lhs, const S &rhs) { lhs = rhs; } -TEST("require that ArrayDataType can be assigned to.") { - ArrayDataType type1(*DataType::STRING); - ArrayDataType type2(*DataType::INT); - assign(type1, type1); - EXPECT_EQUAL(*DataType::STRING, type1.getNestedType()); - type1 = type2; - EXPECT_EQUAL(*DataType::INT, type1.getNestedType()); -} - -TEST("require that ArrayDataType can be cloned.") { - ArrayDataType type1(*DataType::STRING); - std::unique_ptr<ArrayDataType> type2(type1.clone()); - ASSERT_TRUE(type2.get()); - EXPECT_EQUAL(*DataType::STRING, type2->getNestedType()); -} - TEST("require that assignment operator works for LongFieldValue") { LongFieldValue val; val = "1"; diff --git a/document/src/tests/datatype/referencedatatype_test.cpp b/document/src/tests/datatype/referencedatatype_test.cpp index 9dba3541594..d558d5aff1a 100644 --- a/document/src/tests/datatype/referencedatatype_test.cpp +++ b/document/src/tests/datatype/referencedatatype_test.cpp @@ -43,12 +43,6 @@ TEST_F("operator== checks document type and type ID", Fixture) { EXPECT_NOT_EQUAL(f.refType, refWithSameTypeDifferentId); } -TEST_F("clone() creates new type instance equal to old instance", Fixture) { - std::unique_ptr<ReferenceDataType> cloned(f.refType.clone()); - ASSERT_TRUE(cloned.get() != nullptr); - EXPECT_EQUAL(f.refType, *cloned); -} - TEST_F("print() emits type name and id", Fixture) { std::ostringstream ss; f.refType.print(ss, true, ""); diff --git a/document/src/vespa/document/datatype/annotationreferencedatatype.cpp b/document/src/vespa/document/datatype/annotationreferencedatatype.cpp index b9060bd8c6c..6983676a42b 100644 --- a/document/src/vespa/document/datatype/annotationreferencedatatype.cpp +++ b/document/src/vespa/document/datatype/annotationreferencedatatype.cpp @@ -10,29 +10,25 @@ using std::ostream; namespace document { -AnnotationReferenceDataType::AnnotationReferenceDataType( - const AnnotationType &type, int id) +AnnotationReferenceDataType::AnnotationReferenceDataType(const AnnotationType &type, int id) : DataType("annotationreference<" + type.getName() + ">", id), _type(&type) { } -const AnnotationType &AnnotationReferenceDataType::getAnnotationType() const { +const AnnotationType & +AnnotationReferenceDataType::getAnnotationType() const { assert(_type); return *_type; } void AnnotationReferenceDataType::print(ostream &out, bool, const std::string &) const { - out << "AnnotationReferenceDataType(" - << getName() << ", " << getId() << ")"; + out << "AnnotationReferenceDataType("<< getName() << ", " << getId() << ")"; } -AnnotationReferenceDataType *AnnotationReferenceDataType::clone() const { - return new AnnotationReferenceDataType(*this); -} - -unique_ptr<FieldValue> AnnotationReferenceDataType::createFieldValue() const { - return FieldValue::UP(new AnnotationReferenceFieldValue(*this, 0)); +unique_ptr<FieldValue> +AnnotationReferenceDataType::createFieldValue() const { + return std::make_unique<AnnotationReferenceFieldValue>(*this, 0); } void AnnotationReferenceDataType::onBuildFieldPath(FieldPath &, vespalib::stringref) const { } diff --git a/document/src/vespa/document/datatype/annotationreferencedatatype.h b/document/src/vespa/document/datatype/annotationreferencedatatype.h index 271e22183d8..32017442ce3 100644 --- a/document/src/vespa/document/datatype/annotationreferencedatatype.h +++ b/document/src/vespa/document/datatype/annotationreferencedatatype.h @@ -14,10 +14,10 @@ public: typedef std::shared_ptr<AnnotationReferenceDataType> SP; AnnotationReferenceDataType(const AnnotationType &type, int id); - + AnnotationReferenceDataType(const AnnotationReferenceDataType &) = delete; + AnnotationReferenceDataType & operator=(const AnnotationReferenceDataType &) = delete; const AnnotationType &getAnnotationType() const; void print(std::ostream &out, bool verbose, const std::string &indent) const override; - AnnotationReferenceDataType *clone() const override; std::unique_ptr<FieldValue> createFieldValue() const override; void onBuildFieldPath(FieldPath & path, vespalib::stringref remainFieldName) const override; }; diff --git a/document/src/vespa/document/datatype/arraydatatype.h b/document/src/vespa/document/datatype/arraydatatype.h index 74004885aeb..a984fee0c0d 100644 --- a/document/src/vespa/document/datatype/arraydatatype.h +++ b/document/src/vespa/document/datatype/arraydatatype.h @@ -12,21 +12,16 @@ namespace document { class ArrayDataType final : public CollectionDataType { -protected: - // Protected to help you avoid calling the copy constructor when - // you think you're calling the regular constructor with a nested - // ArrayDataType. - ArrayDataType(const ArrayDataType &o) : CollectionDataType(o) {} - public: explicit ArrayDataType(const DataType &nestedType); + ArrayDataType(const ArrayDataType &o) = delete; + ArrayDataType &operator=(const ArrayDataType &rhs) = delete; + ArrayDataType(const DataType &nestedType, int32_t id); std::unique_ptr<FieldValue> createFieldValue() const override; void print(std::ostream&, bool verbose, const std::string& indent) const override; bool equals(const DataType& other) const noexcept override; - ArrayDataType* clone() const override { return new ArrayDataType(*this); } - ArrayDataType &operator=(const ArrayDataType &rhs) = default; void onBuildFieldPath(FieldPath & path, vespalib::stringref remainFieldName) const override; bool isArray() const noexcept override { return true; } diff --git a/document/src/vespa/document/datatype/collectiondatatype.cpp b/document/src/vespa/document/datatype/collectiondatatype.cpp index e7655b953be..c9fdddb14b3 100644 --- a/document/src/vespa/document/datatype/collectiondatatype.cpp +++ b/document/src/vespa/document/datatype/collectiondatatype.cpp @@ -4,21 +4,6 @@ namespace document { -CollectionDataType::CollectionDataType(const CollectionDataType& other) noexcept - : DataType(other), - _nestedType(other._nestedType) -{ } - -CollectionDataType& -CollectionDataType::operator=(const CollectionDataType& other) -{ - if (this != &other) { - DataType::operator=(other); - _nestedType = other._nestedType; - } - return *this; -} - CollectionDataType::CollectionDataType(vespalib::stringref name, const DataType& nestedType) noexcept : DataType(name), diff --git a/document/src/vespa/document/datatype/collectiondatatype.h b/document/src/vespa/document/datatype/collectiondatatype.h index aa07736bc56..a41a56bb51f 100644 --- a/document/src/vespa/document/datatype/collectiondatatype.h +++ b/document/src/vespa/document/datatype/collectiondatatype.h @@ -17,12 +17,12 @@ class CollectionDataType : public DataType { const DataType *_nestedType; protected: - CollectionDataType(const CollectionDataType&) noexcept; - CollectionDataType& operator=(const CollectionDataType&); CollectionDataType(vespalib::stringref name, const DataType &nestedType) noexcept; CollectionDataType(vespalib::stringref name, const DataType &nestedType, int32_t id) noexcept; public: + CollectionDataType(const CollectionDataType&) = delete; + CollectionDataType& operator=(const CollectionDataType&) = delete; ~CollectionDataType() override; bool equals(const DataType&) const noexcept override; diff --git a/document/src/vespa/document/datatype/datatype.h b/document/src/vespa/document/datatype/datatype.h index d1331ef0f7e..1cd3f898be1 100644 --- a/document/src/vespa/document/datatype/datatype.h +++ b/document/src/vespa/document/datatype/datatype.h @@ -109,7 +109,6 @@ public: * Create a field value using this datatype. */ virtual std::unique_ptr<FieldValue> createFieldValue() const = 0; - virtual DataType* clone() const = 0; virtual bool isWeightedSet() const noexcept { return false; } virtual bool isArray() const noexcept { return false; } @@ -121,6 +120,7 @@ public: virtual const CollectionDataType * cast_collection() const noexcept { return nullptr; } virtual const MapDataType * cast_map() const noexcept { return nullptr; } virtual const ReferenceDataType * cast_reference() const noexcept { return nullptr; } + bool isMap() const { return cast_map() != nullptr; } /** * Whether another datatype is a supertype of this one. Document types may diff --git a/document/src/vespa/document/datatype/documenttype.cpp b/document/src/vespa/document/datatype/documenttype.cpp index 18db872c029..21a4734af9b 100644 --- a/document/src/vespa/document/datatype/documenttype.cpp +++ b/document/src/vespa/document/datatype/documenttype.cpp @@ -86,6 +86,8 @@ DocumentType::DocumentType(stringref name, const StructDataType& fields) } } +DocumentType & DocumentType::operator=(const DocumentType &) = default; +DocumentType::DocumentType(const DocumentType &) = default; DocumentType::~DocumentType() = default; DocumentType & @@ -147,7 +149,7 @@ DocumentType::inherit(const DocumentType &docType) { Field::Set fs = docType._fields->getFieldSet(); for (const auto* field : fs) { if (!_ownedFields.get()) { - _ownedFields.reset(_fields->clone()); + _ownedFields = std::make_shared<StructDataType>(*_fields); _fields = _ownedFields.get(); } _ownedFields->addInheritedField(*field); @@ -237,17 +239,14 @@ DocumentType::getFieldSet() const return _fields->getFieldSet(); } -bool DocumentType::has_imported_field_name(const vespalib::string& name) const noexcept { +bool +DocumentType::has_imported_field_name(const vespalib::string& name) const noexcept { return (_imported_field_names.find(name) != _imported_field_names.end()); } -void DocumentType::add_imported_field_name(const vespalib::string& name) { +void +DocumentType::add_imported_field_name(const vespalib::string& name) { _imported_field_names.insert(name); } -DocumentType * -DocumentType::clone() const { - return new DocumentType(*this); -} - } // document diff --git a/document/src/vespa/document/datatype/documenttype.h b/document/src/vespa/document/datatype/documenttype.h index d63a01b6001..942cacf597b 100644 --- a/document/src/vespa/document/datatype/documenttype.h +++ b/document/src/vespa/document/datatype/documenttype.h @@ -62,6 +62,8 @@ public: explicit DocumentType(vespalib::stringref name); DocumentType(vespalib::stringref name, const StructDataType& fields); + DocumentType(const DocumentType &); // TODO remove usage + DocumentType & operator = (const DocumentType &); // TODO remove usage ~DocumentType() override; @@ -97,7 +99,6 @@ public: return _fields->hasField(fieldId); } Field::Set getFieldSet() const override; - DocumentType* clone() const override; DocumentType & addFieldSet(const vespalib::string & name, FieldSet::Fields fields); const FieldSet * getFieldSet(const vespalib::string & name) const; diff --git a/document/src/vespa/document/datatype/mapdatatype.cpp b/document/src/vespa/document/datatype/mapdatatype.cpp index 616bd91b625..086e05fe6dd 100644 --- a/document/src/vespa/document/datatype/mapdatatype.cpp +++ b/document/src/vespa/document/datatype/mapdatatype.cpp @@ -28,6 +28,8 @@ MapDataType::MapDataType(const DataType &key, const DataType &value, int id) noe _valueType(&value) { } +MapDataType::~MapDataType() = default; + FieldValue::UP MapDataType::createFieldValue() const { return std::make_unique<MapFieldValue>(*this); } diff --git a/document/src/vespa/document/datatype/mapdatatype.h b/document/src/vespa/document/datatype/mapdatatype.h index bd4b40fa569..f08033e60b2 100644 --- a/document/src/vespa/document/datatype/mapdatatype.h +++ b/document/src/vespa/document/datatype/mapdatatype.h @@ -18,6 +18,9 @@ class MapDataType final : public DataType { public: MapDataType(const DataType &keyType, const DataType &valueType) noexcept; MapDataType(const DataType &keyType, const DataType &valueType, int id) noexcept; + MapDataType(const MapDataType &) = delete; + MapDataType & operator=(const MapDataType &) = delete; + ~MapDataType() override; const DataType& getKeyType() const noexcept { return *_keyType; } const DataType& getValueType() const noexcept { return *_valueType; } @@ -25,7 +28,6 @@ public: std::unique_ptr<FieldValue> createFieldValue() const override; void print(std::ostream&, bool verbose, const std::string& indent) const override; bool equals(const DataType& other) const noexcept override; - MapDataType* clone() const override { return new MapDataType(*this); } const MapDataType * cast_map() const noexcept override { return this; } void onBuildFieldPath(FieldPath & path, vespalib::stringref remainFieldName) const override; diff --git a/document/src/vespa/document/datatype/numericdatatype.h b/document/src/vespa/document/datatype/numericdatatype.h index e8688398d5f..8a94eab78d8 100644 --- a/document/src/vespa/document/datatype/numericdatatype.h +++ b/document/src/vespa/document/datatype/numericdatatype.h @@ -19,7 +19,6 @@ class NumericDataType final : public PrimitiveDataType { public: NumericDataType(Type type); - NumericDataType* clone() const override { return new NumericDataType(*this); } void print(std::ostream&, bool verbose, const std::string& indent) const override; bool isNumeric() const noexcept override { return true; } }; diff --git a/document/src/vespa/document/datatype/primitivedatatype.h b/document/src/vespa/document/datatype/primitivedatatype.h index 2d87a48a585..bd9e9786365 100644 --- a/document/src/vespa/document/datatype/primitivedatatype.h +++ b/document/src/vespa/document/datatype/primitivedatatype.h @@ -25,7 +25,6 @@ public: PrimitiveDataType(Type _type); std::unique_ptr<FieldValue> createFieldValue() const override; - PrimitiveDataType* clone() const override { return new PrimitiveDataType(*this); } void print(std::ostream&, bool verbose, const std::string& indent) const override; bool isPrimitive() const noexcept override { return true; } diff --git a/document/src/vespa/document/datatype/referencedatatype.cpp b/document/src/vespa/document/datatype/referencedatatype.cpp index 062f07f0ad0..8e810226b72 100644 --- a/document/src/vespa/document/datatype/referencedatatype.cpp +++ b/document/src/vespa/document/datatype/referencedatatype.cpp @@ -18,21 +18,20 @@ ReferenceDataType::ReferenceDataType(const DocumentType& targetDocType, int id) ReferenceDataType::~ReferenceDataType() = default; -std::unique_ptr<FieldValue> ReferenceDataType::createFieldValue() const { +std::unique_ptr<FieldValue> +ReferenceDataType::createFieldValue() const { return std::make_unique<ReferenceFieldValue>(*this); } -void ReferenceDataType::print(std::ostream& os, bool verbose, const std::string& indent) const { +void +ReferenceDataType::print(std::ostream& os, bool verbose, const std::string& indent) const { (void) verbose; (void) indent; os << "ReferenceDataType(" << _targetDocType.getName() << ", id " << getId() << ')'; } -ReferenceDataType* ReferenceDataType::clone() const { - return new ReferenceDataType(_targetDocType, getId()); -} - -void ReferenceDataType::onBuildFieldPath(FieldPath &, vespalib::stringref remainingFieldName) const { +void +ReferenceDataType::onBuildFieldPath(FieldPath &, vespalib::stringref remainingFieldName) const { if ( ! remainingFieldName.empty() ) { throw IllegalArgumentException(make_string("Reference data type does not support further field recursion: '%s'", vespalib::string(remainingFieldName).c_str()), VESPA_STRLOC); @@ -40,7 +39,8 @@ void ReferenceDataType::onBuildFieldPath(FieldPath &, vespalib::stringref remain } -bool ReferenceDataType::equals(const DataType &rhs) const noexcept { +bool +ReferenceDataType::equals(const DataType &rhs) const noexcept { const ReferenceDataType *rt = rhs.cast_reference(); return rt && DataType::equals(rhs) && _targetDocType.equals(rt->_targetDocType); } diff --git a/document/src/vespa/document/datatype/referencedatatype.h b/document/src/vespa/document/datatype/referencedatatype.h index 966f1c7f827..32165ff3450 100644 --- a/document/src/vespa/document/datatype/referencedatatype.h +++ b/document/src/vespa/document/datatype/referencedatatype.h @@ -14,6 +14,8 @@ class ReferenceDataType final : public DataType { const DocumentType& _targetDocType; public: ReferenceDataType(const DocumentType& targetDocType, int id); + ReferenceDataType(const ReferenceDataType &) = delete; + ReferenceDataType & operator =(const ReferenceDataType &) = delete; ~ReferenceDataType() override; const DocumentType& getTargetType() const noexcept { @@ -22,7 +24,6 @@ public: std::unique_ptr<FieldValue> createFieldValue() const override; void print(std::ostream&, bool verbose, const std::string& indent) const override; - ReferenceDataType* clone() const override; void onBuildFieldPath(FieldPath & path, vespalib::stringref remainingFieldName) const override; const ReferenceDataType * cast_reference() const noexcept override { return this; } diff --git a/document/src/vespa/document/datatype/structdatatype.cpp b/document/src/vespa/document/datatype/structdatatype.cpp index 57167fb5d75..6f0eff3b7ad 100644 --- a/document/src/vespa/document/datatype/structdatatype.cpp +++ b/document/src/vespa/document/datatype/structdatatype.cpp @@ -28,13 +28,9 @@ StructDataType::StructDataType(vespalib::stringref name, int32_t dataTypeId) _idFieldMap() { } +StructDataType::StructDataType(const StructDataType & rhs) = default; StructDataType::~StructDataType() = default; -StructDataType* -StructDataType::clone() const { - return new StructDataType(*this); -} - void StructDataType::print(std::ostream& out, bool verbose, const std::string& indent) const diff --git a/document/src/vespa/document/datatype/structdatatype.h b/document/src/vespa/document/datatype/structdatatype.h index b6f4c842422..c4292e84b09 100644 --- a/document/src/vespa/document/datatype/structdatatype.h +++ b/document/src/vespa/document/datatype/structdatatype.h @@ -21,6 +21,8 @@ public: StructDataType(vespalib::stringref name); StructDataType(vespalib::stringref name, int32_t id); + StructDataType(const StructDataType & rhs); // TODO avoid using this + StructDataType & operator=(const StructDataType & rhs) = delete; ~StructDataType(); /** @@ -59,7 +61,6 @@ public: } Field::Set getFieldSet() const override; - StructDataType* clone() const override; private: using StringFieldMap = vespalib::hash_map<vespalib::string, Field::SP>; using IntFieldMap = vespalib::hash_map<int32_t, Field::SP>; diff --git a/document/src/vespa/document/datatype/structureddatatype.h b/document/src/vespa/document/datatype/structureddatatype.h index 7f98ed12b4a..211ace1791a 100644 --- a/document/src/vespa/document/datatype/structureddatatype.h +++ b/document/src/vespa/document/datatype/structureddatatype.h @@ -17,7 +17,6 @@ namespace document { class StructuredDataType : public DataType { void onBuildFieldPath(FieldPath & path, vespalib::stringref remainFieldName) const override; - protected: StructuredDataType(vespalib::stringref name); StructuredDataType(vespalib::stringref name, int32_t dataTypeId); @@ -32,8 +31,6 @@ public: virtual bool hasField(int32_t fieldId) const noexcept = 0; virtual Field::Set getFieldSet() const = 0; - - virtual StructuredDataType* clone() const override = 0; bool isStructured() const noexcept override { return true; } bool equals(const DataType& type) const noexcept override; diff --git a/document/src/vespa/document/datatype/tensor_data_type.cpp b/document/src/vespa/document/datatype/tensor_data_type.cpp index 9d5d2bb58b9..820a7cf3dcd 100644 --- a/document/src/vespa/document/datatype/tensor_data_type.cpp +++ b/document/src/vespa/document/datatype/tensor_data_type.cpp @@ -9,17 +9,13 @@ using vespalib::eval::ValueType; namespace document { -TensorDataType::TensorDataType() - : TensorDataType(ValueType::error_type()) -{ -} - TensorDataType::TensorDataType(ValueType tensorType) : PrimitiveDataType(DataType::T_TENSOR), _tensorType(std::move(tensorType)) { } +TensorDataType::TensorDataType(const TensorDataType &) = default; TensorDataType::~TensorDataType() = default; FieldValue::UP @@ -28,12 +24,6 @@ TensorDataType::createFieldValue() const return std::make_unique<TensorFieldValue>(*this); } -TensorDataType* -TensorDataType::clone() const -{ - return new TensorDataType(*this); -} - void TensorDataType::print(std::ostream& out, bool verbose, const std::string& indent) const { diff --git a/document/src/vespa/document/datatype/tensor_data_type.h b/document/src/vespa/document/datatype/tensor_data_type.h index aa52af32b54..b2f313f0778 100644 --- a/document/src/vespa/document/datatype/tensor_data_type.h +++ b/document/src/vespa/document/datatype/tensor_data_type.h @@ -12,13 +12,13 @@ namespace document { class TensorDataType final : public PrimitiveDataType { vespalib::eval::ValueType _tensorType; public: - TensorDataType(); TensorDataType(vespalib::eval::ValueType tensorType); + TensorDataType(const TensorDataType &); //TODO try to avoid + TensorDataType & operator=(const TensorDataType &) = delete; ~TensorDataType(); bool isTensor() const noexcept override { return true; } std::unique_ptr<FieldValue> createFieldValue() const override; - TensorDataType* clone() const override; void print(std::ostream&, bool verbose, const std::string& indent) const override; static std::unique_ptr<const TensorDataType> fromSpec(const vespalib::string &spec); const vespalib::eval::ValueType &getTensorType() const { return _tensorType; } diff --git a/document/src/vespa/document/datatype/weightedsetdatatype.cpp b/document/src/vespa/document/datatype/weightedsetdatatype.cpp index 67c32f861b7..13a66caee7f 100644 --- a/document/src/vespa/document/datatype/weightedsetdatatype.cpp +++ b/document/src/vespa/document/datatype/weightedsetdatatype.cpp @@ -36,14 +36,15 @@ WeightedSetDataType::WeightedSetDataType(const DataType& nested, bool createIfNo { } -WeightedSetDataType::WeightedSetDataType( - const DataType& nested, bool createIfNon, bool remove, int id) +WeightedSetDataType::WeightedSetDataType(const DataType& nested, bool createIfNon, bool remove, int id) : CollectionDataType(createName(nested, createIfNon, remove), nested, id), _createIfNonExistent(createIfNon), _removeIfZero(remove) { } +WeightedSetDataType::~WeightedSetDataType() = default; + FieldValue::UP WeightedSetDataType::createFieldValue() const { diff --git a/document/src/vespa/document/datatype/weightedsetdatatype.h b/document/src/vespa/document/datatype/weightedsetdatatype.h index 53aa526a6a8..1c60ca5f3fa 100644 --- a/document/src/vespa/document/datatype/weightedsetdatatype.h +++ b/document/src/vespa/document/datatype/weightedsetdatatype.h @@ -22,6 +22,9 @@ class WeightedSetDataType final : public CollectionDataType { public: WeightedSetDataType(const DataType& nestedType, bool createIfNonExistent, bool removeIfZero); WeightedSetDataType(const DataType& nestedType, bool createIfNonExistent, bool removeIfZero, int id); + WeightedSetDataType(const WeightedSetDataType &) = delete; + WeightedSetDataType & operator=(const WeightedSetDataType &) = delete; + ~WeightedSetDataType() override; /** * @return Whether values of this datatype will autogenerate entries if @@ -40,7 +43,6 @@ public: std::unique_ptr<FieldValue> createFieldValue() const override; void print(std::ostream&, bool verbose, const std::string& indent) const override; bool equals(const DataType& other) const noexcept override; - WeightedSetDataType* clone() const override { return new WeightedSetDataType(*this); } void onBuildFieldPath(FieldPath & path, vespalib::stringref remainFieldName) const override; }; diff --git a/document/src/vespa/document/fieldvalue/tensorfieldvalue.cpp b/document/src/vespa/document/fieldvalue/tensorfieldvalue.cpp index 6f208ed6a89..42f4080d6b6 100644 --- a/document/src/vespa/document/fieldvalue/tensorfieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/tensorfieldvalue.cpp @@ -9,7 +9,6 @@ #include <vespa/eval/eval/value_codec.h> #include <vespa/eval/eval/value.h> #include <ostream> -#include <cassert> using vespalib::eval::FastValueBuilderFactory; using vespalib::eval::TensorSpec; @@ -20,7 +19,7 @@ namespace document { namespace { -TensorDataType emptyTensorDataType; +TensorDataType emptyTensorDataType(ValueType::error_type()); vespalib::string makeWrongTensorTypeMsg(const ValueType &fieldTensorType, const ValueType &tensorType) { diff --git a/document/src/vespa/document/repo/documenttyperepo.cpp b/document/src/vespa/document/repo/documenttyperepo.cpp index 2a994d55ecb..8bcdba9244a 100644 --- a/document/src/vespa/document/repo/documenttyperepo.cpp +++ b/document/src/vespa/document/repo/documenttyperepo.cpp @@ -417,11 +417,12 @@ void inheritDocumentTypes(const vector<DocumenttypesConfig::Documenttype::Inheri } } -DataTypeRepo::UP makeDataTypeRepo(const DocumentType &doc_type, const DocumentTypeMap &type_map) { +DataTypeRepo::UP +makeDataTypeRepo(const DocumentType &doc_type, const DocumentTypeMap &type_map) { auto data_types = std::make_unique<DataTypeRepo>(); data_types->repo.inherit(lookupRepo(DataType::T_DOCUMENT, type_map).repo); data_types->annotations.inherit(lookupRepo(DataType::T_DOCUMENT, type_map).annotations); - data_types->doc_type = doc_type.clone(); + data_types->doc_type = new DocumentType(doc_type); return data_types; } diff --git a/document/src/vespa/document/update/tensor_modify_update.cpp b/document/src/vespa/document/update/tensor_modify_update.cpp index e0da2dc0cc7..91ac6f4c754 100644 --- a/document/src/vespa/document/update/tensor_modify_update.cpp +++ b/document/src/vespa/document/update/tensor_modify_update.cpp @@ -12,7 +12,6 @@ #include <vespa/eval/eval/operation.h> #include <vespa/eval/eval/value.h> #include <vespa/eval/eval/fast_value.h> -#include <vespa/vespalib/objects/nbostream.h> #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/util/xmlstream.h> @@ -94,7 +93,7 @@ TensorModifyUpdate::TensorModifyUpdate() TensorModifyUpdate::TensorModifyUpdate(const TensorModifyUpdate &rhs) : _operation(rhs._operation), - _tensorType(rhs._tensorType->clone()), + _tensorType(std::make_unique<TensorDataType>(*rhs._tensorType)), _tensor(Identifiable::cast<TensorFieldValue *>(_tensorType->createFieldValue().release())) { *_tensor = *rhs._tensor; @@ -102,7 +101,7 @@ TensorModifyUpdate::TensorModifyUpdate(const TensorModifyUpdate &rhs) TensorModifyUpdate::TensorModifyUpdate(Operation operation, std::unique_ptr<TensorFieldValue> tensor) : _operation(operation), - _tensorType(dynamic_cast<const TensorDataType &>(*tensor->getDataType()).clone()), + _tensorType(std::make_unique<TensorDataType>(dynamic_cast<const TensorDataType &>(*tensor->getDataType()))), _tensor(Identifiable::cast<TensorFieldValue *>(_tensorType->createFieldValue().release())) { *_tensor = *tensor; @@ -116,7 +115,7 @@ TensorModifyUpdate::operator=(const TensorModifyUpdate &rhs) if (&rhs != this) { _operation = rhs._operation; _tensor.reset(); - _tensorType.reset(rhs._tensorType->clone()); + _tensorType = std::make_unique<TensorDataType>(*rhs._tensorType); _tensor.reset(Identifiable::cast<TensorFieldValue *>(_tensorType->createFieldValue().release())); *_tensor = *rhs._tensor; } diff --git a/document/src/vespa/document/update/tensor_remove_update.cpp b/document/src/vespa/document/update/tensor_remove_update.cpp index a47c69d4f30..f4dc9490b62 100644 --- a/document/src/vespa/document/update/tensor_remove_update.cpp +++ b/document/src/vespa/document/update/tensor_remove_update.cpp @@ -9,10 +9,8 @@ #include <vespa/document/serialization/vespadocumentdeserializer.h> #include <vespa/eval/eval/fast_value.h> #include <vespa/eval/eval/value.h> -#include <vespa/vespalib/objects/nbostream.h> #include <vespa/vespalib/util/xmlstream.h> #include <ostream> -#include <cassert> using vespalib::IllegalArgumentException; using vespalib::IllegalStateException; @@ -49,13 +47,13 @@ TensorRemoveUpdate::TensorRemoveUpdate() } TensorRemoveUpdate::TensorRemoveUpdate(const TensorRemoveUpdate &rhs) - : _tensorType(rhs._tensorType->clone()), + : _tensorType(std::make_unique<TensorDataType>(*rhs._tensorType)), _tensor(rhs._tensor->clone()) { } TensorRemoveUpdate::TensorRemoveUpdate(std::unique_ptr<TensorFieldValue> tensor) - : _tensorType(dynamic_cast<const TensorDataType &>(*tensor->getDataType()).clone()), + : _tensorType(std::make_unique<TensorDataType>(dynamic_cast<const TensorDataType &>(*tensor->getDataType()))), _tensor(Identifiable::cast<TensorFieldValue *>(_tensorType->createFieldValue().release())) { *_tensor = *tensor; @@ -68,7 +66,7 @@ TensorRemoveUpdate::operator=(const TensorRemoveUpdate &rhs) { if (&rhs != this) { _tensor.reset(); - _tensorType.reset(rhs._tensorType->clone()); + _tensorType = std::make_unique<TensorDataType>(*rhs._tensorType); _tensor.reset(Identifiable::cast<TensorFieldValue *>(_tensorType->createFieldValue().release())); *_tensor = *rhs._tensor; } |