summaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorGeir Storli <geirst@yahooinc.com>2023-03-13 16:56:36 +0100
committerGitHub <noreply@github.com>2023-03-13 16:56:36 +0100
commite516c905090b34d10e6f13b72a8b836ab33f6331 (patch)
tree21f5a109fdc03a07ef1dd0cbe99fe8fb9b845ec4 /storage
parent087f462b06d3f6bf4073ac34fa383310e5a15d21 (diff)
parent0c657642eff7d85c000464e9edba16ded4845e7d (diff)
Merge pull request #26423 from vespa-engine/geirst/less-document-without-type-repo
Reduce creation of Document instances without DocumentTypeRepo.
Diffstat (limited to 'storage')
-rw-r--r--storage/src/tests/bucketdb/bucketmanagertest.cpp2
-rw-r--r--storage/src/tests/distributor/getoperationtest.cpp2
-rw-r--r--storage/src/tests/distributor/putoperationtest.cpp10
-rw-r--r--storage/src/tests/distributor/twophaseupdateoperationtest.cpp2
-rw-r--r--storage/src/tests/persistence/filestorage/filestormanagertest.cpp12
-rw-r--r--storage/src/tests/storageserver/documentapiconvertertest.cpp4
-rw-r--r--storage/src/tests/storageserver/rpc/storage_api_rpc_service_test.cpp2
-rw-r--r--storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp3
8 files changed, 20 insertions, 17 deletions
diff --git a/storage/src/tests/bucketdb/bucketmanagertest.cpp b/storage/src/tests/bucketdb/bucketmanagertest.cpp
index dc33bfd04e2..ea3a782d432 100644
--- a/storage/src/tests/bucketdb/bucketmanagertest.cpp
+++ b/storage/src/tests/bucketdb/bucketmanagertest.cpp
@@ -171,7 +171,7 @@ void BucketManagerTest::setupTestEnvironment(bool fakePersistenceLayer,
}
// Generate a doc to use for testing..
const DocumentType &type(*_node->getTypeRepo()->getDocumentType("text/html"));
- _document = std::make_shared<document::Document>(type, document::DocumentId("id:ns:text/html::ntnu"));
+ _document = std::make_shared<document::Document>(*_node->getTypeRepo(), type, document::DocumentId("id:ns:text/html::ntnu"));
}
void BucketManagerTest::addBucketsToDB(uint32_t count)
diff --git a/storage/src/tests/distributor/getoperationtest.cpp b/storage/src/tests/distributor/getoperationtest.cpp
index 8d188f6c005..36a1495579f 100644
--- a/storage/src/tests/distributor/getoperationtest.cpp
+++ b/storage/src/tests/distributor/getoperationtest.cpp
@@ -85,7 +85,7 @@ struct GetOperationTest : Test, DistributorStripeTestUtil {
if (!authorVal.empty()) {
const document::DocumentType* type(_repo->getDocumentType("text/html"));
- doc = std::make_unique<document::Document>(*type, docId);
+ doc = std::make_unique<document::Document>(*_repo, *type, docId);
doc->setValue(doc->getField("author"),
document::StringFieldValue(authorVal));
diff --git a/storage/src/tests/distributor/putoperationtest.cpp b/storage/src/tests/distributor/putoperationtest.cpp
index 735666e5c89..2a3f06b1e8c 100644
--- a/storage/src/tests/distributor/putoperationtest.cpp
+++ b/storage/src/tests/distributor/putoperationtest.cpp
@@ -83,8 +83,12 @@ public:
return *_testDocMan.getTypeRepo().getDocumentType("testdoctype1");
}
+ const document::DocumentTypeRepo& type_repo() const {
+ return _testDocMan.getTypeRepo();
+ }
+
Document::SP createDummyDocument(const char* ns, const char* id) const {
- return std::make_shared<Document>(doc_type(), DocumentId(vespalib::make_string("id:%s:testdoctype1::%s", ns, id)));
+ return std::make_shared<Document>(type_repo(), doc_type(), DocumentId(vespalib::make_string("id:%s:testdoctype1::%s", ns, id)));
}
static std::shared_ptr<api::PutCommand> createPut(Document::SP doc) {
@@ -98,7 +102,7 @@ PutOperationTest::~PutOperationTest() = default;
document::BucketId
PutOperationTest::createAndSendSampleDocument(vespalib::duration timeout) {
- auto doc = std::make_shared<Document>(doc_type(), DocumentId("id:test:testdoctype1::"));
+ auto doc = std::make_shared<Document>(type_repo(), doc_type(), DocumentId("id:test:testdoctype1::"));
document::BucketId id = operation_context().make_split_bit_constrained_bucket_id(doc->getId());
addIdealNodes(id);
@@ -453,7 +457,7 @@ TEST_F(PutOperationTest, no_storage_nodes) {
TEST_F(PutOperationTest, update_correct_bucket_on_remapped_put) {
setup_stripe(2, 2, "storage:2 distributor:1");
- auto doc = std::make_shared<Document>(doc_type(), DocumentId("id:test:testdoctype1:n=13:uri"));
+ auto doc = std::make_shared<Document>(type_repo(), doc_type(), DocumentId("id:test:testdoctype1:n=13:uri"));
addNodesToBucketDB(document::BucketId(16,13), "0=0,1=0");
sendPut(createPut(doc));
diff --git a/storage/src/tests/distributor/twophaseupdateoperationtest.cpp b/storage/src/tests/distributor/twophaseupdateoperationtest.cpp
index 579fd156962..da32225cde3 100644
--- a/storage/src/tests/distributor/twophaseupdateoperationtest.cpp
+++ b/storage/src/tests/distributor/twophaseupdateoperationtest.cpp
@@ -237,7 +237,7 @@ TwoPhaseUpdateOperationTest::replyToGet(
std::shared_ptr<api::StorageReply> reply;
if (haveDocument) {
- auto doc(std::make_shared<Document>(*_doc_type, DocumentId("id:ns:" + _doc_type->getName() + "::1")));
+ auto doc(std::make_shared<Document>(*_repo, *_doc_type, DocumentId("id:ns:" + _doc_type->getName() + "::1")));
doc->setValue("headerval", IntFieldValue(oldTimestamp));
reply = std::make_shared<api::GetReply>(get, doc, oldTimestamp);
diff --git a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp
index 7f3fe06fc29..4227f3dbe13 100644
--- a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp
+++ b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp
@@ -485,7 +485,7 @@ TEST_F(FileStorManagerTest, flush) {
// Creating a document to test with
document::DocumentId docId("id:ns:testdoctype1::crawler:http://www.ntnu.no/");
- auto doc = std::make_shared<Document>(*_testdoctype1, docId);
+ auto doc = std::make_shared<Document>(*_node->getTypeRepo(), *_testdoctype1, docId);
document::BucketId bid(4000);
static const uint32_t msgCount = 10;
@@ -1032,7 +1032,7 @@ FileStorTestBase::putDoc(DummyStorageLink& top,
document::BucketId bucket(16, factory.getBucketId(docId).getRawId());
//std::cerr << "doc bucket is " << bucket << " vs source " << source << "\n";
_node->getPersistenceProvider().createBucket(makeSpiBucket(target));
- Document::SP doc(new Document(*_testdoctype1, docId));
+ auto doc = std::make_shared<Document>(*_node->getTypeRepo(), *_testdoctype1, docId);
auto cmd = std::make_shared<api::PutCommand>(makeDocumentBucket(target), doc, docNum+1);
cmd->setAddress(_Storage3);
cmd->setPriority(120);
@@ -1073,7 +1073,7 @@ TEST_F(FileStorManagerTest, split_empty_target_with_remapped_ops) {
document::DocumentId docId(
vespalib::make_string("id:ns:testdoctype1:n=%d:1234", 0x100001));
- auto doc = std::make_shared<Document>(*_testdoctype1, docId);
+ auto doc = std::make_shared<Document>(*_node->getTypeRepo(), *_testdoctype1, docId);
auto putCmd = std::make_shared<api::PutCommand>(makeDocumentBucket(source), doc, 1001);
putCmd->setAddress(_Storage3);
putCmd->setPriority(120);
@@ -1399,7 +1399,7 @@ TEST_F(FileStorManagerTest, delete_bucket) {
auto& top = c.top;
// Creating a document to test with
document::DocumentId docId("id:crawler:testdoctype1:n=4000:http://www.ntnu.no/");
- auto doc = std::make_shared<Document>(*_testdoctype1, docId);
+ auto doc = std::make_shared<Document>(*_node->getTypeRepo(), *_testdoctype1, docId);
document::BucketId bid(16, 4000);
createBucket(bid);
@@ -1440,7 +1440,7 @@ TEST_F(FileStorManagerTest, delete_bucket_rejects_outdated_bucket_info) {
auto& top = c.top;
// Creating a document to test with
document::DocumentId docId("id:crawler:testdoctype1:n=4000:http://www.ntnu.no/");
- Document::SP doc(new Document(*_testdoctype1, docId));
+ auto doc = std::make_shared<Document>(*_node->getTypeRepo(), *_testdoctype1, docId);
document::BucketId bid(16, 4000);
createBucket(bid);
@@ -1487,7 +1487,7 @@ TEST_F(FileStorManagerTest, delete_bucket_with_invalid_bucket_info){
auto& top = c.top;
// Creating a document to test with
document::DocumentId docId("id:crawler:testdoctype1:n=4000:http://www.ntnu.no/");
- auto doc = std::make_shared<Document>(*_testdoctype1, docId);
+ auto doc = std::make_shared<Document>(*_node->getTypeRepo(), *_testdoctype1, docId);
document::BucketId bid(16, 4000);
createBucket(bid);
diff --git a/storage/src/tests/storageserver/documentapiconvertertest.cpp b/storage/src/tests/storageserver/documentapiconvertertest.cpp
index c375443b265..42944c81f13 100644
--- a/storage/src/tests/storageserver/documentapiconvertertest.cpp
+++ b/storage/src/tests/storageserver/documentapiconvertertest.cpp
@@ -106,7 +106,7 @@ struct DocumentApiConverterTest : Test {
};
TEST_F(DocumentApiConverterTest, put) {
- auto doc = std::make_shared<Document>(_html_type, defaultDocId);
+ auto doc = std::make_shared<Document>(*_repo, _html_type, defaultDocId);
documentapi::PutDocumentMessage putmsg(doc);
putmsg.setTimestamp(1234);
@@ -126,7 +126,7 @@ TEST_F(DocumentApiConverterTest, put) {
}
TEST_F(DocumentApiConverterTest, forwarded_put) {
- auto doc = std::make_shared<Document>(_html_type, DocumentId("id:ns:" + _html_type.getName() + "::test"));
+ auto doc = std::make_shared<Document>(*_repo, _html_type, DocumentId("id:ns:" + _html_type.getName() + "::test"));
auto putmsg = std::make_unique<documentapi::PutDocumentMessage>(doc);
auto* putmsg_raw = putmsg.get();
diff --git a/storage/src/tests/storageserver/rpc/storage_api_rpc_service_test.cpp b/storage/src/tests/storageserver/rpc/storage_api_rpc_service_test.cpp
index bfc22b9f1ea..26c5b8df5a5 100644
--- a/storage/src/tests/storageserver/rpc/storage_api_rpc_service_test.cpp
+++ b/storage/src/tests/storageserver/rpc/storage_api_rpc_service_test.cpp
@@ -161,7 +161,7 @@ public:
std::shared_ptr<api::PutCommand> create_dummy_put_command() const {
auto doc_type = _doc_type_repo->getDocumentType("testdoctype1");
- auto doc = std::make_shared<document::Document>(*doc_type, document::DocumentId("id:foo:testdoctype1::bar"));
+ auto doc = std::make_shared<document::Document>(*_doc_type_repo, *doc_type, document::DocumentId("id:foo:testdoctype1::bar"));
doc->setFieldValue(doc->getField("hstringval"), std::make_unique<document::StringFieldValue>("hello world"));
return std::make_shared<api::PutCommand>(makeDocumentBucket(document::BucketId(0)), std::move(doc), 100);
}
diff --git a/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp b/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp
index bdf4fa2ba72..515b72520ec 100644
--- a/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp
@@ -672,8 +672,7 @@ std::shared_ptr<document::Document>
TwoPhaseUpdateOperation::createBlankDocument() const
{
const document::DocumentUpdate& up(*_updateCmd->getUpdate());
- auto doc = std::make_shared<document::Document>(up.getType(), up.getId());
- doc->setRepo(*up.getRepoPtr());
+ auto doc = std::make_shared<document::Document>(*up.getRepoPtr(), up.getType(), up.getId());
return doc;
}