diff options
23 files changed, 119 insertions, 120 deletions
diff --git a/document/src/tests/documentselectparsertest.cpp b/document/src/tests/documentselectparsertest.cpp index 3d2e4e983d7..d2fa969daa9 100644 --- a/document/src/tests/documentselectparsertest.cpp +++ b/document/src/tests/documentselectparsertest.cpp @@ -153,18 +153,18 @@ DocumentSelectParserTest::createDocs() // Add some arrays and structs to doc 1 { StructFieldValue sval(_doc.back()->getField("mystruct").getDataType()); - sval.setValue("key", std::make_unique<IntFieldValue>(14)); - sval.setValue("value", std::make_unique<StringFieldValue>("structval")); + sval.setValue("key", IntFieldValue::make(14)); + sval.setValue("value", StringFieldValue::make("structval")); _doc.back()->setValue("mystruct", sval); ArrayFieldValue aval(_doc.back()->getField("structarray").getDataType()); { StructFieldValue sval1(aval.getNestedType()); - sval1.setValue("key", std::make_unique<IntFieldValue>(15)); - sval1.setValue("value", std::make_unique<StringFieldValue>("structval1")); + sval1.setValue("key", IntFieldValue::make(15)); + sval1.setValue("value", StringFieldValue::make("structval1")); StructFieldValue sval2(aval.getNestedType()); - sval2.setValue("key", std::make_unique<IntFieldValue>(16)); - sval2.setValue("value", std::make_unique<StringFieldValue>("structval2")); + sval2.setValue("key", IntFieldValue::make(16)); + sval2.setValue("value", StringFieldValue::make("structval2")); aval.add(sval1); aval.add(sval2); } @@ -182,11 +182,11 @@ DocumentSelectParserTest::createDocs() ArrayFieldValue abval(_doc.back()->getField("structarray").getDataType()); { StructFieldValue sval1(aval.getNestedType()); - sval1.setValue("key", std::make_unique<IntFieldValue>(17)); - sval1.setValue("value", std::make_unique<StringFieldValue>("structval3")); + sval1.setValue("key", IntFieldValue::make(17)); + sval1.setValue("value", StringFieldValue::make("structval3")); StructFieldValue sval2(aval.getNestedType()); - sval2.setValue("key", std::make_unique<IntFieldValue>(18)); - sval2.setValue("value", std::make_unique<StringFieldValue>("structval4")); + sval2.setValue("key", IntFieldValue::make(18)); + sval2.setValue("value", StringFieldValue::make("structval4")); abval.add(sval1); abval.add(sval2); } diff --git a/document/src/tests/documenttestcase.cpp b/document/src/tests/documenttestcase.cpp index 73d94452b28..c852e219faa 100644 --- a/document/src/tests/documenttestcase.cpp +++ b/document/src/tests/documenttestcase.cpp @@ -707,15 +707,15 @@ TEST(DocumentTest,testReadSerializedAllVersions) // Create a memory instance of document { Document doc(*docType, DocumentId("id:ns:serializetest::http://test.doc.id/")); - doc.setValue("intfield", std::make_unique<IntFieldValue>(5)); - doc.setValue("floatfield", std::make_unique<FloatFieldValue>(-9.23)); - doc.setValue("stringfield", std::make_unique<StringFieldValue>("This is a string.")); - doc.setValue("longfield", std::make_unique<LongFieldValue>(static_cast<int64_t>(398420092938472983LL))); - doc.setValue("doublefield", std::make_unique<DoubleFieldValue>(98374532.398820)); - doc.setValue("bytefield", std::make_unique<ByteFieldValue>(-2)); + doc.setValue("intfield", IntFieldValue::make(5)); + doc.setValue("floatfield", FloatFieldValue::make(-9.23)); + doc.setValue("stringfield", StringFieldValue::make("This is a string.")); + doc.setValue("longfield", LongFieldValue::make(static_cast<int64_t>(398420092938472983LL))); + doc.setValue("doublefield", DoubleFieldValue::make(98374532.398820)); + doc.setValue("bytefield", ByteFieldValue::make(-2)); doc.setValue("rawfield", std::make_unique<RawFieldValue>("RAW DATA", 8)); Document docInDoc(*docInDocType, DocumentId("id:ns:docindoc::http://doc.in.doc/")); - docInDoc.setValue("stringindocfield", std::make_unique<StringFieldValue>("Elvis is dead")); + docInDoc.setValue("stringindocfield", StringFieldValue::make("Elvis is dead")); doc.setValue("docfield", docInDoc); ArrayFieldValue floatArray(*arrayOfFloatDataType); CollectionHelper(floatArray).add(1.0); @@ -830,13 +830,13 @@ TEST(DocumentTest, testGenerateSerializedFile) DocumentTypeRepo repo(readDocumenttypesConfig(file_name)); Document doc(*repo.getDocumentType("serializetest"), DocumentId("id:ns:serializetest::http://test.doc.id/")); - doc.setValue("intfield", std::make_unique<IntFieldValue>(5)); - doc.setValue("floatfield", std::make_unique<FloatFieldValue>(-9.23)); - doc.setValue("stringfield", std::make_unique<StringFieldValue>("This is a string.")); - doc.setValue("longfield", std::make_unique<LongFieldValue>((int64_t) 398420092938472983ll)); - doc.setValue("doublefield", std::make_unique<DoubleFieldValue>(98374532.398820)); - doc.setValue("urifield", std::make_unique<StringFieldValue>("http://this.is.a.test/")); - doc.setValue("bytefield", std::make_unique<ByteFieldValue>(-2)); + doc.setValue("intfield", IntFieldValue::make(5)); + doc.setValue("floatfield", FloatFieldValue::make(-9.23)); + doc.setValue("stringfield", StringFieldValue::make("This is a string.")); + doc.setValue("longfield", LongFieldValue::make((int64_t) 398420092938472983ll)); + doc.setValue("doublefield", DoubleFieldValue::make(98374532.398820)); + doc.setValue("urifield", StringFieldValue::make("http://this.is.a.test/")); + doc.setValue("bytefield", ByteFieldValue::make(-2)); doc.setValue("rawfield", std::make_unique<RawFieldValue>("RAW DATA")); const DocumentType *docindoc_type = repo.getDocumentType("docindoc"); @@ -951,7 +951,7 @@ TEST(DocumentTest, testHasChanged) Document doc2(test_repo.getTypeRepo(), buf); EXPECT_TRUE(!doc2.hasChanged()); - doc2.setValue("headerval", std::make_unique<IntFieldValue>(13)); + doc2.setValue("headerval", IntFieldValue::make(13)); EXPECT_TRUE(doc2.hasChanged()); } // Overwriting a value in doc tags us changed. @@ -959,7 +959,7 @@ TEST(DocumentTest, testHasChanged) buf.rp(0); Document doc2(test_repo.getTypeRepo(), buf); - doc2.setValue("hstringval", std::make_unique<StringFieldValue>("bla bla bla bla bla")); + doc2.setValue("hstringval", StringFieldValue::make("bla bla bla bla bla")); EXPECT_TRUE(doc2.hasChanged()); } // Clearing value tags us changed. diff --git a/document/src/tests/documentupdatetestcase.cpp b/document/src/tests/documentupdatetestcase.cpp index 28d254e8982..26819699db4 100644 --- a/document/src/tests/documentupdatetestcase.cpp +++ b/document/src/tests/documentupdatetestcase.cpp @@ -139,8 +139,8 @@ TEST(DocumentUpdateTest, testSimpleUsage) // Create a test document Document doc(*docType, DocumentId("id:ns:test::1")); - doc.setValue("bytef", std::make_unique<ByteFieldValue>(0)); - doc.setValue("intf", std::make_unique<IntFieldValue>(5)); + doc.setValue("bytef", ByteFieldValue::make(0)); + doc.setValue("intf", IntFieldValue::make(5)); ArrayFieldValue array(*arrayType); array.add(IntFieldValue(3)); array.add(IntFieldValue(7)); diff --git a/document/src/vespa/document/datatype/primitivedatatype.cpp b/document/src/vespa/document/datatype/primitivedatatype.cpp index 08e873c7de2..d5af0ca6885 100644 --- a/document/src/vespa/document/datatype/primitivedatatype.cpp +++ b/document/src/vespa/document/datatype/primitivedatatype.cpp @@ -56,16 +56,16 @@ FieldValue::UP PrimitiveDataType::createFieldValue() const { switch (getId()) { - case T_INT: return std::make_unique<IntFieldValue>(); - case T_SHORT: return std::make_unique<ShortFieldValue>(); - case T_FLOAT: return std::make_unique<FloatFieldValue>(); - case T_URI: return std::make_unique<StringFieldValue>(); - case T_STRING: return std::make_unique<StringFieldValue>(); + case T_INT: return IntFieldValue::make(); + case T_SHORT: return ShortFieldValue::make(); + case T_FLOAT: return FloatFieldValue::make(); + case T_URI: return StringFieldValue::make(); + case T_STRING: return StringFieldValue::make(); case T_RAW: return std::make_unique<RawFieldValue>(); - case T_LONG: return std::make_unique<LongFieldValue>(); - case T_DOUBLE: return std::make_unique<DoubleFieldValue>(); - case T_BOOL: return std::make_unique<BoolFieldValue>(); - case T_BYTE: return std::make_unique<ByteFieldValue>(); + case T_LONG: return LongFieldValue::make(); + case T_DOUBLE: return DoubleFieldValue::make(); + case T_BOOL: return BoolFieldValue::make(); + case T_BYTE: return ByteFieldValue::make(); case T_PREDICATE: return std::make_unique<PredicateFieldValue>(); } LOG_ABORT("getId() returned value out of range"); diff --git a/document/src/vespa/document/fieldvalue/boolfieldvalue.h b/document/src/vespa/document/fieldvalue/boolfieldvalue.h index c24428beaf4..01cfcf2cd48 100644 --- a/document/src/vespa/document/fieldvalue/boolfieldvalue.h +++ b/document/src/vespa/document/fieldvalue/boolfieldvalue.h @@ -42,8 +42,8 @@ public: vespalib::string getAsString() const override; BoolFieldValue& operator=(vespalib::stringref) override; - DECLARE_IDENTIFIABLE(BoolFieldValue); + static std::unique_ptr<BoolFieldValue> make(bool value=false) { return std::make_unique<BoolFieldValue>(value); } }; } diff --git a/document/src/vespa/document/fieldvalue/bytefieldvalue.h b/document/src/vespa/document/fieldvalue/bytefieldvalue.h index b817c4e16ec..2cccf483c84 100644 --- a/document/src/vespa/document/fieldvalue/bytefieldvalue.h +++ b/document/src/vespa/document/fieldvalue/bytefieldvalue.h @@ -23,10 +23,10 @@ public: void accept(ConstFieldValueVisitor &visitor) const override { visitor.visit(*this); } const DataType *getDataType() const override { return DataType::BYTE; } ByteFieldValue* clone() const override { return new ByteFieldValue(*this); } - using NumericFieldValue<Number>::operator=; + using NumericFieldValue<Number>::operator=; DECLARE_IDENTIFIABLE(ByteFieldValue); - + static std::unique_ptr<ByteFieldValue> make(Number value=0) { return std::make_unique<ByteFieldValue>(value); } }; } // document diff --git a/document/src/vespa/document/fieldvalue/doublefieldvalue.h b/document/src/vespa/document/fieldvalue/doublefieldvalue.h index c0c6d0781f0..b9b20bbd24a 100644 --- a/document/src/vespa/document/fieldvalue/doublefieldvalue.h +++ b/document/src/vespa/document/fieldvalue/doublefieldvalue.h @@ -25,9 +25,8 @@ public: DoubleFieldValue* clone() const override { return new DoubleFieldValue(*this); } using NumericFieldValue<Number>::operator=; - DECLARE_IDENTIFIABLE(DoubleFieldValue); - + static std::unique_ptr<DoubleFieldValue> make(Number value=0) { return std::make_unique<DoubleFieldValue>(value); } }; } // document diff --git a/document/src/vespa/document/fieldvalue/floatfieldvalue.h b/document/src/vespa/document/fieldvalue/floatfieldvalue.h index 07a645c13cb..f662c400633 100644 --- a/document/src/vespa/document/fieldvalue/floatfieldvalue.h +++ b/document/src/vespa/document/fieldvalue/floatfieldvalue.h @@ -25,9 +25,8 @@ public: FloatFieldValue* clone() const override { return new FloatFieldValue(*this); } using NumericFieldValue<Number>::operator=; - DECLARE_IDENTIFIABLE(FloatFieldValue); - + static std::unique_ptr<FloatFieldValue> make(Number value = 0) { return std::make_unique<FloatFieldValue>(value); } }; } // document diff --git a/document/src/vespa/document/fieldvalue/intfieldvalue.h b/document/src/vespa/document/fieldvalue/intfieldvalue.h index 5eb511aa09c..d365e34779e 100644 --- a/document/src/vespa/document/fieldvalue/intfieldvalue.h +++ b/document/src/vespa/document/fieldvalue/intfieldvalue.h @@ -26,7 +26,7 @@ public: using NumericFieldValue<Number>::operator=; DECLARE_IDENTIFIABLE(IntFieldValue); - + static std::unique_ptr<IntFieldValue> make(Number value=0) { return std::make_unique<IntFieldValue>(value); } }; } // document diff --git a/document/src/vespa/document/fieldvalue/literalfieldvalue.cpp b/document/src/vespa/document/fieldvalue/literalfieldvalue.cpp index f362de974a8..7ba537d9cc2 100644 --- a/document/src/vespa/document/fieldvalue/literalfieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/literalfieldvalue.cpp @@ -30,7 +30,7 @@ LiteralFieldValueB::LiteralFieldValueB(const LiteralFieldValueB& other) _value = _backing; } -LiteralFieldValueB::LiteralFieldValueB(const string& value) +LiteralFieldValueB::LiteralFieldValueB(const stringref & value) : FieldValue(), _value(), _backing(value), diff --git a/document/src/vespa/document/fieldvalue/literalfieldvalue.h b/document/src/vespa/document/fieldvalue/literalfieldvalue.h index d6bf083d0ce..6e3f0223b20 100644 --- a/document/src/vespa/document/fieldvalue/literalfieldvalue.h +++ b/document/src/vespa/document/fieldvalue/literalfieldvalue.h @@ -32,7 +32,7 @@ public: ~LiteralFieldValueB(); LiteralFieldValueB(const LiteralFieldValueB &); - LiteralFieldValueB(const string& value); + LiteralFieldValueB(const stringref & value); const value_type & getValue() const { sync(); return _backing; } /** @@ -91,7 +91,7 @@ public: typedef std::unique_ptr<SubClass> UP; LiteralFieldValue() : LiteralFieldValueB() { } - LiteralFieldValue(const string& value) : LiteralFieldValueB(value) { } + LiteralFieldValue(const stringref& value) : LiteralFieldValueB(value) { } const DataType *getDataType() const override; }; diff --git a/document/src/vespa/document/fieldvalue/longfieldvalue.h b/document/src/vespa/document/fieldvalue/longfieldvalue.h index b978bda7213..64ab4332cef 100644 --- a/document/src/vespa/document/fieldvalue/longfieldvalue.h +++ b/document/src/vespa/document/fieldvalue/longfieldvalue.h @@ -25,8 +25,8 @@ public: LongFieldValue* clone() const override { return new LongFieldValue(*this); } using NumericFieldValue<Number>::operator=; - DECLARE_IDENTIFIABLE(LongFieldValue); + static std::unique_ptr<LongFieldValue> make(Number value=0) { return std::make_unique<LongFieldValue>(value); } }; diff --git a/document/src/vespa/document/fieldvalue/shortfieldvalue.h b/document/src/vespa/document/fieldvalue/shortfieldvalue.h index f2047d1a521..dff7644159e 100644 --- a/document/src/vespa/document/fieldvalue/shortfieldvalue.h +++ b/document/src/vespa/document/fieldvalue/shortfieldvalue.h @@ -27,9 +27,8 @@ public: ShortFieldValue* clone() const override { return new ShortFieldValue(*this); } using NumericFieldValue<Number>::operator=; - DECLARE_IDENTIFIABLE(ShortFieldValue); - + static std::unique_ptr<ShortFieldValue> make(int32_t value = 0) { return std::make_unique<ShortFieldValue>(value); } }; } // document diff --git a/document/src/vespa/document/fieldvalue/stringfieldvalue.h b/document/src/vespa/document/fieldvalue/stringfieldvalue.h index 15aeeccd0de..17a0302f6f9 100644 --- a/document/src/vespa/document/fieldvalue/stringfieldvalue.h +++ b/document/src/vespa/document/fieldvalue/stringfieldvalue.h @@ -24,7 +24,7 @@ public: typedef std::vector<SpanTree::UP> SpanTrees; StringFieldValue() : Parent(), _annotationData() { } - StringFieldValue(const string &value) + StringFieldValue(const vespalib::stringref &value) : Parent(value), _annotationData() { } StringFieldValue(const StringFieldValue &rhs); @@ -57,6 +57,8 @@ public: using LiteralFieldValueB::operator=; DECLARE_IDENTIFIABLE(StringFieldValue); + static std::unique_ptr<StringFieldValue> make(vespalib::stringref value) { return std::make_unique<StringFieldValue>(value); } + static std::unique_ptr<StringFieldValue> make() { return StringFieldValue::make(""); } private: void doClearSpanTrees(); diff --git a/document/src/vespa/document/fieldvalue/weightedsetfieldvalue.cpp b/document/src/vespa/document/fieldvalue/weightedsetfieldvalue.cpp index 6b80ceb1f6e..2a3726095df 100644 --- a/document/src/vespa/document/fieldvalue/weightedsetfieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/weightedsetfieldvalue.cpp @@ -59,7 +59,7 @@ WeightedSetFieldValue::add(const FieldValue& key, int weight) _map.erase(key); return false; } - return _map.insert(FieldValue::UP(key.clone()), std::make_unique<IntFieldValue>(weight)); + return _map.insert(FieldValue::UP(key.clone()), IntFieldValue::make(weight)); } bool @@ -67,14 +67,14 @@ WeightedSetFieldValue::addIgnoreZeroWeight(const FieldValue& key, int32_t weight { verifyKey(key); _altered = true; - return _map.insert(FieldValue::UP(key.clone()), std::make_unique<IntFieldValue>(weight)); + return _map.insert(FieldValue::UP(key.clone()), IntFieldValue::make(weight)); } void WeightedSetFieldValue::push_back(FieldValue::UP key, int weight) { _altered = true; - _map.push_back(std::move(key), std::make_unique<IntFieldValue>(weight)); + _map.push_back(std::move(key), IntFieldValue::make(weight)); } void diff --git a/searchcore/src/tests/proton/attribute/document_field_extractor/document_field_extractor_test.cpp b/searchcore/src/tests/proton/attribute/document_field_extractor/document_field_extractor_test.cpp index 65d17d207ec..903b4d89696 100644 --- a/searchcore/src/tests/proton/attribute/document_field_extractor/document_field_extractor_test.cpp +++ b/searchcore/src/tests/proton/attribute/document_field_extractor/document_field_extractor_test.cpp @@ -50,7 +50,7 @@ makeIntArray(const std::vector<int32_t> &array) { auto result = std::make_unique<ArrayFieldValue>(arrayTypeInt); for (const auto &elem : array) { - result->append(std::make_unique<IntFieldValue>(elem)); + result->append(IntFieldValue::make(elem)); } return result; } @@ -60,7 +60,7 @@ makeStringArray(const std::vector<vespalib::string> &array) { auto result = std::make_unique<ArrayFieldValue>(arrayTypeString); for (const auto &elem : array) { - result->append(std::make_unique<StringFieldValue>(elem)); + result->append(StringFieldValue::make(elem)); } return result; } @@ -160,8 +160,8 @@ TEST_F("require that simple fields give simple values", SimpleFixture) auto doc = f.makeDoc(); doc->setValue(f.weightField, IntFieldValue(200)); doc->setValue(f.nameField, StringFieldValue("name200b")); - TEST_DO(f.assertExtracted("weight", std::make_unique<IntFieldValue>(200))); - TEST_DO(f.assertExtracted("name", std::make_unique<StringFieldValue>("name200b"))); + TEST_DO(f.assertExtracted("weight", IntFieldValue::make(200))); + TEST_DO(f.assertExtracted("name", StringFieldValue::make("name200b"))); } struct ArrayFixture : public FixtureBase 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 cafdff1020f..a460c65fbb2 100644 --- a/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp +++ b/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp @@ -338,8 +338,8 @@ const DocumentType &getAttrDocType() { IDocumentRetriever::SP doc_with_fields(const std::string &id, Timestamp t, Bucket b) { auto d = std::make_unique<Document>(getDocType(), DocumentId(id)); - d->setValue("header", std::make_unique<StringFieldValue>("foo")); - d->setValue("body", std::make_unique<StringFieldValue>("bar")); + d->setValue("header", StringFieldValue::make("foo")); + d->setValue("body", StringFieldValue::make("bar")); return std::make_shared<UnitDR>(getDocType(), std::move(d), t, b, false); } @@ -355,12 +355,12 @@ IDocumentRetriever::SP doc_with_attr_fields(const vespalib::string &id, const vespalib::string &attr_ss) { auto d = std::make_unique<Document>(getAttrDocType(), DocumentId(id)); - d->setValue("header", std::make_unique<StringFieldValue>("foo")); - d->setValue("body", std::make_unique<StringFieldValue>("bar")); - d->setValue("aa", std::make_unique<IntFieldValue>(aa)); - d->setValue("ab", std::make_unique<IntFieldValue>(ab)); - d->setValue("dd", std::make_unique<DoubleFieldValue>(dd)); - d->setValue("ss", std::make_unique<StringFieldValue>(ss)); + d->setValue("header", StringFieldValue::make("foo")); + d->setValue("body", StringFieldValue::make("bar")); + d->setValue("aa", IntFieldValue::make(aa)); + d->setValue("ab", IntFieldValue::make(ab)); + d->setValue("dd", DoubleFieldValue::make(dd)); + d->setValue("ss", StringFieldValue::make(ss)); return std::make_shared<AttrUnitDR>(std::move(d), t, b, false, attr_aa, attr_dd, attr_ss); } @@ -782,7 +782,7 @@ TEST("require that fieldset limits fields returned") { EXPECT_TRUE(res.isCompleted()); EXPECT_EQUAL(1u, res.getEntries().size()); Document expected(getDocType(), DocumentId("id:ns:foo::xxx1")); - expected.setValue("header", std::make_unique<StringFieldValue>("foo")); + expected.setValue("header", StringFieldValue::make("foo")); TEST_DO(checkEntry(res, 0, expected, Timestamp(1))); } @@ -838,19 +838,19 @@ TEST("require that attributes are used") EXPECT_TRUE(res.isCompleted()); EXPECT_EQUAL(2u, res.getEntries().size()); Document expected1(getAttrDocType(), DocumentId("id:ns:foo::xx2")); - expected1.setValue("header", std::make_unique<StringFieldValue>("foo")); - expected1.setValue("body", std::make_unique<StringFieldValue>("bar")); - expected1.setValue("aa", std::make_unique<IntFieldValue>(27)); - expected1.setValue("ab", std::make_unique<IntFieldValue>(28)); - expected1.setValue("dd", std::make_unique<DoubleFieldValue>(2.7)); - expected1.setValue("ss", std::make_unique<StringFieldValue>("x27")); + expected1.setValue("header", StringFieldValue::make("foo")); + expected1.setValue("body", StringFieldValue::make("bar")); + expected1.setValue("aa", IntFieldValue::make(27)); + expected1.setValue("ab", IntFieldValue::make(28)); + expected1.setValue("dd", DoubleFieldValue::make(2.7)); + expected1.setValue("ss", StringFieldValue::make("x27")); Document expected2(getAttrDocType(), DocumentId("id:ns:foo::xx4")); - expected2.setValue("header", std::make_unique<StringFieldValue>("foo")); - expected2.setValue("body", std::make_unique<StringFieldValue>("bar")); - expected2.setValue("aa", std::make_unique<IntFieldValue>(45)); - expected2.setValue("ab", std::make_unique<IntFieldValue>(46)); - expected2.setValue("dd", std::make_unique<DoubleFieldValue>(4.5)); - expected2.setValue("ss", std::make_unique<StringFieldValue>("x45")); + expected2.setValue("header", StringFieldValue::make("foo")); + expected2.setValue("body", StringFieldValue::make("bar")); + expected2.setValue("aa", IntFieldValue::make(45)); + expected2.setValue("ab", IntFieldValue::make(46)); + expected2.setValue("dd", DoubleFieldValue::make(4.5)); + expected2.setValue("ss", StringFieldValue::make("x45")); TEST_DO(checkEntry(res, 0, expected1, Timestamp(2))); TEST_DO(checkEntry(res, 1, expected2, Timestamp(4))); @@ -868,19 +868,19 @@ TEST("require that attributes are used") EXPECT_TRUE(res2.isCompleted()); EXPECT_EQUAL(2u, res2.getEntries().size()); Document expected3(getAttrDocType(), DocumentId("id:ns:foo::xx6")); - expected3.setValue("header", std::make_unique<StringFieldValue>("foo")); - expected3.setValue("body", std::make_unique<StringFieldValue>("bar")); - expected3.setValue("aa", std::make_unique<IntFieldValue>(27)); - expected3.setValue("ab", std::make_unique<IntFieldValue>(28)); - expected3.setValue("dd", std::make_unique<DoubleFieldValue>(2.7)); - expected3.setValue("ss", std::make_unique<StringFieldValue>("x27")); + expected3.setValue("header", StringFieldValue::make("foo")); + expected3.setValue("body", StringFieldValue::make("bar")); + expected3.setValue("aa", IntFieldValue::make(27)); + expected3.setValue("ab", IntFieldValue::make(28)); + expected3.setValue("dd", DoubleFieldValue::make(2.7)); + expected3.setValue("ss", StringFieldValue::make("x27")); Document expected4(getAttrDocType(), DocumentId("id:ns:foo::xx8")); - expected4.setValue("header", std::make_unique<StringFieldValue>("foo")); - expected4.setValue("body", std::make_unique<StringFieldValue>("bar")); - expected4.setValue("aa", std::make_unique<IntFieldValue>(45)); - expected4.setValue("ab", std::make_unique<IntFieldValue>(46)); - expected4.setValue("dd", std::make_unique<DoubleFieldValue>(4.5)); - expected4.setValue("ss", std::make_unique<StringFieldValue>("x45")); + expected4.setValue("header", StringFieldValue::make("foo")); + expected4.setValue("body", StringFieldValue::make("bar")); + expected4.setValue("aa", IntFieldValue::make(45)); + expected4.setValue("ab", IntFieldValue::make(46)); + expected4.setValue("dd", DoubleFieldValue::make(4.5)); + expected4.setValue("ss", StringFieldValue::make("x45")); TEST_DO(checkEntry(res2, 0, expected3, Timestamp(6))); TEST_DO(checkEntry(res2, 1, expected4, Timestamp(8))); @@ -898,19 +898,19 @@ TEST("require that attributes are used") EXPECT_TRUE(res3.isCompleted()); EXPECT_EQUAL(2u, res3.getEntries().size()); Document expected5(getAttrDocType(), DocumentId("id:ns:foo::xx10")); - expected5.setValue("header", std::make_unique<StringFieldValue>("foo")); - expected5.setValue("body", std::make_unique<StringFieldValue>("bar")); - expected5.setValue("aa", std::make_unique<IntFieldValue>(27)); - expected5.setValue("ab", std::make_unique<IntFieldValue>(28)); - expected5.setValue("dd", std::make_unique<DoubleFieldValue>(2.7)); - expected5.setValue("ss", std::make_unique<StringFieldValue>("x27")); + expected5.setValue("header", StringFieldValue::make("foo")); + expected5.setValue("body", StringFieldValue::make("bar")); + expected5.setValue("aa", IntFieldValue::make(27)); + expected5.setValue("ab", IntFieldValue::make(28)); + expected5.setValue("dd", DoubleFieldValue::make(2.7)); + expected5.setValue("ss", StringFieldValue::make("x27")); Document expected6(getAttrDocType(), DocumentId("id:ns:foo::xx12")); - expected6.setValue("header", std::make_unique<StringFieldValue>("foo")); - expected6.setValue("body", std::make_unique<StringFieldValue>("bar")); - expected6.setValue("aa", std::make_unique<IntFieldValue>(45)); - expected6.setValue("ab", std::make_unique<IntFieldValue>(46)); - expected6.setValue("dd", std::make_unique<DoubleFieldValue>(4.5)); - expected6.setValue("ss", std::make_unique<StringFieldValue>("x45")); + expected6.setValue("header", StringFieldValue::make("foo")); + expected6.setValue("body", StringFieldValue::make("bar")); + expected6.setValue("aa", IntFieldValue::make(45)); + expected6.setValue("ab", IntFieldValue::make(46)); + expected6.setValue("dd", DoubleFieldValue::make(4.5)); + expected6.setValue("ss", StringFieldValue::make("x45")); TEST_DO(checkEntry(res3, 0, expected5, Timestamp(10))); TEST_DO(checkEntry(res3, 1, expected6, Timestamp(12))); } diff --git a/searchcore/src/tests/proton/server/documentretriever_test.cpp b/searchcore/src/tests/proton/server/documentretriever_test.cpp index afda9bcf73a..b4236ba4e3e 100644 --- a/searchcore/src/tests/proton/server/documentretriever_test.cpp +++ b/searchcore/src/tests/proton/server/documentretriever_test.cpp @@ -162,12 +162,12 @@ struct MyDocumentStore : proton::test::DummyDocumentStore { const DocumentType *doc_type = r.getDocumentType(doc_type_name); auto doc = std::make_unique<Document>(*doc_type, doc_id); ASSERT_TRUE(doc); - doc->setValue(static_field, std::make_unique<IntFieldValue>(static_value)); - doc->setValue(dyn_field_i, std::make_unique<IntFieldValue>(static_value)); - doc->setValue(dyn_field_s, std::make_unique<StringFieldValue>(static_value_s)); - doc->setValue(dyn_field_nai, std::make_unique<IntFieldValue>(static_value)); - doc->setValue(dyn_field_nas, std::make_unique<StringFieldValue>(static_value_s)); - doc->setValue(zcurve_field, std::make_unique<LongFieldValue>(static_zcurve_value)); + doc->setValue(static_field, IntFieldValue::make(static_value)); + doc->setValue(dyn_field_i, IntFieldValue::make(static_value)); + doc->setValue(dyn_field_s, StringFieldValue::make(static_value_s)); + doc->setValue(dyn_field_nai, IntFieldValue::make(static_value)); + doc->setValue(dyn_field_nas, StringFieldValue::make(static_value_s)); + doc->setValue(zcurve_field, LongFieldValue::make(static_zcurve_value)); doc->setValue(dyn_field_p, static_value_p); TensorFieldValue tensorFieldValue(tensorDataType); tensorFieldValue = SimpleValue::from_value(*static_tensor); @@ -175,8 +175,8 @@ struct MyDocumentStore : proton::test::DummyDocumentStore { if (_set_position_struct_field) { FieldValue::UP fv = PositionDataType::getInstance().createFieldValue(); auto &pos = dynamic_cast<StructFieldValue &>(*fv); - pos.setValue(PositionDataType::FIELD_X, std::make_unique<IntFieldValue>(42)); - pos.setValue(PositionDataType::FIELD_Y, std::make_unique<IntFieldValue>(21)); + pos.setValue(PositionDataType::FIELD_X, IntFieldValue::make(42)); + pos.setValue(PositionDataType::FIELD_Y, IntFieldValue::make(21)); doc->setValue(doc->getField(position_field), *fv); } diff --git a/searchcore/src/vespa/searchcore/bmcluster/bm_feed.cpp b/searchcore/src/vespa/searchcore/bmcluster/bm_feed.cpp index 49d1bb1c0a8..56cea8db741 100644 --- a/searchcore/src/vespa/searchcore/bmcluster/bm_feed.cpp +++ b/searchcore/src/vespa/searchcore/bmcluster/bm_feed.cpp @@ -65,7 +65,7 @@ BmFeed::make_document(uint32_t n, uint32_t i) const auto id = make_document_id(n, i); auto document = std::make_unique<Document>(*_document_type, id); document->setRepo(*_repo); - document->setFieldValue(_field, std::make_unique<IntFieldValue>(i)); + document->setFieldValue(_field, IntFieldValue::make(i)); return document; } diff --git a/searchlib/src/apps/tests/memoryindexstress_test.cpp b/searchlib/src/apps/tests/memoryindexstress_test.cpp index fcac0be8f85..07747a66892 100644 --- a/searchlib/src/apps/tests/memoryindexstress_test.cpp +++ b/searchlib/src/apps/tests/memoryindexstress_test.cpp @@ -137,7 +137,7 @@ setFieldValue(Document &doc, const vespalib::string &fieldName, const vespalib::string &fieldString) { std::unique_ptr<StringFieldValue> fieldValue = - std::make_unique<StringFieldValue>(fieldString); + StringFieldValue::make(fieldString); document::FixedTypeRepo repo(*doc.getRepo(), doc.getType()); tokenizeStringFieldValue(repo, *fieldValue); doc.setFieldValue(doc.getField(fieldName), std::move(fieldValue)); diff --git a/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp b/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp index dd23304fe50..c08aa7ce9fc 100644 --- a/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp +++ b/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp @@ -68,9 +68,9 @@ makeDoc(const DocumentTypeRepo &repo, uint32_t i, bool before) mainstr << (j + i * 1000) << " "; } mainstr << " and end field"; - doc->setValue("main", std::make_unique<StringFieldValue>(mainstr.str())); + doc->setValue("main", StringFieldValue::make(mainstr.str())); if (!before) { - doc->setValue("extra", std::make_unique<StringFieldValue>("foo")); + doc->setValue("extra", StringFieldValue::make("foo")); } return doc; @@ -162,7 +162,7 @@ MyRewriteVisitor::visit(uint32_t lid, const std::shared_ptr<Document> &doc) Document::UP expDoc(makeDoc(_repo, lid, _before)); EXPECT_TRUE(*expDoc == *doc); _valid->setBitAndMaintainCount(lid); - doc->setValue("extra", std::make_unique<StringFieldValue>("foo")); + doc->setValue("extra", StringFieldValue::make("foo")); } diff --git a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp index e3d2490954c..bb2d0177dd9 100644 --- a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp +++ b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp @@ -431,9 +431,9 @@ makeDoc(const DocumentTypeRepo &repo, uint32_t i, bool extra_field, size_t numRe mainstr << (j + i * 1000) << " "; } mainstr << " and end field"; - doc->setValue("main", std::make_unique<StringFieldValue>(mainstr.str())); + doc->setValue("main", StringFieldValue::make(mainstr.str())); if (extra_field) { - doc->setValue("extra", std::make_unique<StringFieldValue>("foo")); + doc->setValue("extra", StringFieldValue::make("foo")); } return doc; } diff --git a/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp b/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp index 597cfe8eb40..487fb9e329f 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp @@ -322,7 +322,7 @@ public: if (_field_value.get()) { return std::move(_field_value); } - return std::make_unique<StringFieldValue>(_str.str()); + return StringFieldValue::make(_str.str()); } }; |