diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-07 13:12:50 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-07 13:34:23 +0000 |
commit | 4d47dde39b5d741561dc11832427a2c73eeb941e (patch) | |
tree | 56681f3d5a1326462a03cf13993fee098ec7d739 /searchcore | |
parent | c84242e30dd34656fe79e5a6c539d3e5fcc3fd38 (diff) |
Use XXFieldValue::make over std::make_unique
Diffstat (limited to 'searchcore')
4 files changed, 58 insertions, 58 deletions
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; } |