summaryrefslogtreecommitdiffstats
path: root/storageapi
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@oath.com>2018-06-07 16:47:01 +0200
committerHenning Baldersheim <balder@oath.com>2018-06-12 09:56:59 +0200
commit498bd3df67182d16e021fccd5514c578838ba2bf (patch)
treeb43692b3621746ff2617ff6ba871d8d459ef57e7 /storageapi
parent89521c8531b0eeb03bd28f899ecd59a9f8b334a6 (diff)
Reduce code visibility
Diffstat (limited to 'storageapi')
-rw-r--r--storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp1
-rw-r--r--storageapi/src/vespa/storageapi/message/persistence.cpp121
-rw-r--r--storageapi/src/vespa/storageapi/message/persistence.h47
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/bucketinfocommand.h6
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/bucketinforeply.h9
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/bucketreply.h14
6 files changed, 85 insertions, 113 deletions
diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp
index a1be0def20b..44050264484 100644
--- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp
+++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp
@@ -6,6 +6,7 @@
#include "storagereply.h"
#include <vespa/storageapi/message/bucketsplitting.h>
#include <vespa/storageapi/message/visitor.h>
+#include <vespa/document/update/documentupdate.h>
#include <vespa/document/bucket/fixed_bucket_spaces.h>
#include <sstream>
diff --git a/storageapi/src/vespa/storageapi/message/persistence.cpp b/storageapi/src/vespa/storageapi/message/persistence.cpp
index 10dbc9f1313..c1db27b4c1a 100644
--- a/storageapi/src/vespa/storageapi/message/persistence.cpp
+++ b/storageapi/src/vespa/storageapi/message/persistence.cpp
@@ -1,12 +1,13 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "persistence.h"
+#include <vespa/document/fieldvalue/document.h>
+#include <vespa/document/update/documentupdate.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <ostream>
-namespace storage {
-namespace api {
+namespace storage::api {
IMPLEMENT_COMMAND(PutCommand, PutReply)
IMPLEMENT_REPLY(PutReply)
@@ -22,22 +23,25 @@ IMPLEMENT_REPLY(RevertReply)
TestAndSetCommand::TestAndSetCommand(const MessageType & messageType, const document::Bucket &bucket)
: BucketInfoCommand(messageType, bucket)
{}
-TestAndSetCommand::~TestAndSetCommand() { }
+TestAndSetCommand::~TestAndSetCommand() = default;
-PutCommand::PutCommand(const document::Bucket &bucket,
- const document::Document::SP& doc, Timestamp time)
+PutCommand::PutCommand(const document::Bucket &bucket, const DocumentSP& doc, Timestamp time)
: TestAndSetCommand(MessageType::PUT, bucket),
_doc(doc),
_timestamp(time),
_updateTimestamp(0)
{
if (_doc.get() == 0) {
- throw vespalib::IllegalArgumentException(
- "Cannot put a null document", VESPA_STRLOC);
+ throw vespalib::IllegalArgumentException("Cannot put a null document", VESPA_STRLOC);
}
}
-PutCommand::~PutCommand() {}
+PutCommand::~PutCommand() = default;
+
+const document::DocumentId&
+PutCommand::getDocumentId() const {
+ return _doc->getId();
+}
vespalib::string
PutCommand::getSummary() const
@@ -52,8 +56,7 @@ PutCommand::getSummary() const
}
void
-PutCommand::print(std::ostream& out, bool verbose,
- const std::string& indent) const
+PutCommand::print(std::ostream& out, bool verbose, const std::string& indent) const
{
out << "Put(" << getBucketId() << ", " << _doc->getId()
<< ", timestamp " << _timestamp << ", size "
@@ -76,15 +79,13 @@ PutReply::PutReply(const PutCommand& cmd, bool wasFoundFlag)
{
}
-PutReply::~PutReply() {}
+PutReply::~PutReply() = default;
void
PutReply::print(std::ostream& out, bool verbose,
- const std::string& indent) const
+ const std::string& indent) const
{
- out << "PutReply("
- << _docId.toString() << ", " << getBucketId() << ", timestamp "
- << _timestamp;
+ out << "PutReply(" << _docId.toString() << ", " << getBucketId() << ", timestamp " << _timestamp;
if (hasBeenRemapped()) {
out << " (was remapped)";
@@ -97,28 +98,29 @@ PutReply::print(std::ostream& out, bool verbose,
}
}
-UpdateCommand::UpdateCommand(const document::Bucket &bucket,
- const document::DocumentUpdate::SP& update,
- Timestamp time)
+UpdateCommand::UpdateCommand(const document::Bucket &bucket, const document::DocumentUpdate::SP& update, Timestamp time)
: TestAndSetCommand(MessageType::UPDATE, bucket),
_update(update),
_timestamp(time),
_oldTimestamp(0)
{
if (_update.get() == 0) {
- throw vespalib::IllegalArgumentException(
- "Cannot update a null update", VESPA_STRLOC);
+ throw vespalib::IllegalArgumentException("Cannot update a null update", VESPA_STRLOC);
}
}
-UpdateCommand::~UpdateCommand() {}
+UpdateCommand::~UpdateCommand() = default;
+
+const document::DocumentId&
+UpdateCommand::getDocumentId() const {
+ return _update->getId();
+}
vespalib::string
UpdateCommand::getSummary() const {
vespalib::asciistream stream;
stream << "Update(BucketId(0x" << vespalib::hex << getBucketId().getId() << "), "
- << _update->getId().toString()
- << ", timestamp " << vespalib::dec << _timestamp;
+ << _update->getId().toString() << ", timestamp " << vespalib::dec << _timestamp;
if (_oldTimestamp != 0) {
stream << ", old timestamp " << _oldTimestamp;
}
@@ -128,11 +130,9 @@ UpdateCommand::getSummary() const {
}
void
-UpdateCommand::print(std::ostream& out, bool verbose,
- const std::string& indent) const
+UpdateCommand::print(std::ostream& out, bool verbose, const std::string& indent) const
{
- out << "Update(" << getBucketId() << ", " << _update->getId()
- << ", timestamp " << _timestamp;
+ out << "Update(" << getBucketId() << ", " << _update->getId() << ", timestamp " << _timestamp;
if (_oldTimestamp != 0) {
out << ", old timestamp " << _oldTimestamp;
}
@@ -154,11 +154,10 @@ UpdateReply::UpdateReply(const UpdateCommand& cmd, Timestamp oldTimestamp)
{
}
-UpdateReply::~UpdateReply() {}
+UpdateReply::~UpdateReply() = default;
void
-UpdateReply::print(std::ostream& out, bool verbose,
- const std::string& indent) const
+UpdateReply::print(std::ostream& out, bool verbose, const std::string& indent) const
{
out << "UpdateReply("
<< _docId.toString() << ", " << getBucketId() << ", timestamp "
@@ -176,8 +175,7 @@ UpdateReply::print(std::ostream& out, bool verbose,
}
}
-GetCommand::GetCommand(const document::Bucket &bucket,
- const document::DocumentId& docId,
+GetCommand::GetCommand(const document::Bucket &bucket, const document::DocumentId& docId,
const vespalib::stringref & fieldSet, Timestamp before)
: BucketInfoCommand(MessageType::GET, bucket),
_docId(docId),
@@ -186,24 +184,21 @@ GetCommand::GetCommand(const document::Bucket &bucket,
{
}
-GetCommand::~GetCommand() {}
+GetCommand::~GetCommand() = default;
vespalib::string
GetCommand::getSummary() const
{
vespalib::asciistream stream;
- stream << "Get(BucketId(" << vespalib::hex << getBucketId().getId() << "), "
- << _docId.toString()
- << ", beforetimestamp " << vespalib::dec << _beforeTimestamp
- << ')';
+ stream << "Get(BucketId(" << vespalib::hex << getBucketId().getId() << "), " << _docId.toString()
+ << ", beforetimestamp " << vespalib::dec << _beforeTimestamp << ')';
return stream.str();
}
void
-GetCommand::print(std::ostream& out, bool verbose,
- const std::string& indent) const
+GetCommand::print(std::ostream& out, bool verbose, const std::string& indent) const
{
out << "Get(" << getBucketId() << ", " << _docId << ")";
if (verbose) {
@@ -212,9 +207,7 @@ GetCommand::print(std::ostream& out, bool verbose,
}
}
-GetReply::GetReply(const GetCommand& cmd,
- const document::Document::SP& doc,
- Timestamp lastModified)
+GetReply::GetReply(const GetCommand& cmd, const DocumentSP& doc, Timestamp lastModified)
: BucketInfoReply(cmd),
_docId(cmd.getDocumentId()),
_fieldSet(cmd.getFieldSet()),
@@ -224,30 +217,26 @@ GetReply::GetReply(const GetCommand& cmd,
{
}
-GetReply::~GetReply() {}
+GetReply::~GetReply() = default;
void
-GetReply::print(std::ostream& out, bool verbose,
- const std::string& indent) const
+GetReply::print(std::ostream& out, bool verbose, const std::string& indent) const
{
- out << "GetReply(" << getBucketId() << ", " << _docId
- << ", timestamp " << _lastModifiedTime << ")";
+ out << "GetReply(" << getBucketId() << ", " << _docId << ", timestamp " << _lastModifiedTime << ")";
if (verbose) {
out << " : ";
BucketReply::print(out, verbose, indent);
}
}
-RemoveCommand::RemoveCommand(const document::Bucket &bucket,
- const document::DocumentId& docId,
- Timestamp timestamp)
+RemoveCommand::RemoveCommand(const document::Bucket &bucket, const document::DocumentId& docId, Timestamp timestamp)
: TestAndSetCommand(MessageType::REMOVE, bucket),
_docId(docId),
_timestamp(timestamp)
{
}
-RemoveCommand::~RemoveCommand() {}
+RemoveCommand::~RemoveCommand() = default;
vespalib::string
RemoveCommand::getSummary() const {
@@ -258,11 +247,9 @@ RemoveCommand::getSummary() const {
return stream.str();
}
void
-RemoveCommand::print(std::ostream& out, bool verbose,
- const std::string& indent) const
+RemoveCommand::print(std::ostream& out, bool verbose, const std::string& indent) const
{
- out << "Remove(" << getBucketId() << ", " << _docId
- << ", timestamp " << _timestamp << ")";
+ out << "Remove(" << getBucketId() << ", " << _docId << ", timestamp " << _timestamp << ")";
if (verbose) {
out << " : ";
BucketInfoCommand::print(out, verbose, indent);
@@ -277,14 +264,12 @@ RemoveReply::RemoveReply(const RemoveCommand& cmd, Timestamp oldTimestamp)
{
}
-RemoveReply::~RemoveReply() {}
+RemoveReply::~RemoveReply() = default;
void
-RemoveReply::print(std::ostream& out, bool verbose,
- const std::string& indent) const
+RemoveReply::print(std::ostream& out, bool verbose, const std::string& indent) const
{
- out << "RemoveReply(" << getBucketId() << ", " << _docId
- << ", timestamp " << _timestamp;
+ out << "RemoveReply(" << getBucketId() << ", " << _docId << ", timestamp " << _timestamp;
if (_oldTimestamp != 0) {
out << ", removed doc from " << _oldTimestamp;
} else {
@@ -297,18 +282,16 @@ RemoveReply::print(std::ostream& out, bool verbose,
}
}
-RevertCommand::RevertCommand(const document::Bucket &bucket,
- const std::vector<Timestamp>& revertTokens)
+RevertCommand::RevertCommand(const document::Bucket &bucket, const std::vector<Timestamp>& revertTokens)
: BucketInfoCommand(MessageType::REVERT, bucket),
_tokens(revertTokens)
{
}
-RevertCommand::~RevertCommand() {}
+RevertCommand::~RevertCommand() = default;
void
-RevertCommand::print(std::ostream& out, bool verbose,
- const std::string& indent) const
+RevertCommand::print(std::ostream& out, bool verbose, const std::string& indent) const
{
out << "Revert(" << getBucketId();
if (verbose) {
@@ -330,11 +313,10 @@ RevertReply::RevertReply(const RevertCommand& cmd)
{
}
-RevertReply::~RevertReply() {}
+RevertReply::~RevertReply() = default;
void
-RevertReply::print(std::ostream& out, bool verbose,
- const std::string& indent) const
+RevertReply::print(std::ostream& out, bool verbose, const std::string& indent) const
{
out << "RevertReply(" << getBucketId() << ")";
if (verbose) {
@@ -343,5 +325,4 @@ RevertReply::print(std::ostream& out, bool verbose,
}
}
-} // api
-} // storage
+}
diff --git a/storageapi/src/vespa/storageapi/message/persistence.h b/storageapi/src/vespa/storageapi/message/persistence.h
index 60d10c40648..bda1bd0f038 100644
--- a/storageapi/src/vespa/storageapi/message/persistence.h
+++ b/storageapi/src/vespa/storageapi/message/persistence.h
@@ -6,21 +6,22 @@
*/
#pragma once
-#include <vespa/document/base/documentid.h>
-#include <vespa/document/fieldvalue/document.h>
-#include <vespa/document/update/documentupdate.h>
#include <vespa/storageapi/messageapi/bucketinforeply.h>
#include <vespa/storageapi/defs.h>
+#include <vespa/document/base/documentid.h>
#include <vespa/documentapi/messagebus/messages/testandsetcondition.h>
-namespace storage {
-namespace api {
+namespace document {
+ class DocumentUpdate;
+ class Document;
+}
+namespace storage::api {
using documentapi::TestAndSetCondition;
+using DocumentSP = std::shared_ptr<document::Document>;
class TestAndSetCommand : public BucketInfoCommand {
TestAndSetCondition _condition;
-
public:
TestAndSetCommand(const MessageType & messageType, const document::Bucket &bucket);
~TestAndSetCommand();
@@ -42,12 +43,12 @@ public:
* @brief Command for adding a document to the storage system.
*/
class PutCommand : public TestAndSetCommand {
- document::Document::SP _doc;
- Timestamp _timestamp;
- Timestamp _updateTimestamp;
+ DocumentSP _doc;
+ Timestamp _timestamp;
+ Timestamp _updateTimestamp;
public:
- PutCommand(const document::Bucket &bucket, const document::Document::SP&, Timestamp);
+ PutCommand(const document::Bucket &bucket, const DocumentSP&, Timestamp);
~PutCommand();
void setTimestamp(Timestamp ts) { _timestamp = ts; }
@@ -60,8 +61,8 @@ public:
void setUpdateTimestamp(Timestamp ts) { _updateTimestamp = ts; }
Timestamp getUpdateTimestamp() const { return _updateTimestamp; }
- const document::Document::SP& getDocument() const { return _doc; }
- const document::DocumentId& getDocumentId() const override { return _doc->getId(); }
+ const DocumentSP& getDocument() const { return _doc; }
+ const document::DocumentId& getDocumentId() const override;
Timestamp getTimestamp() const { return _timestamp; }
vespalib::string getSummary() const override;
@@ -78,7 +79,7 @@ public:
*/
class PutReply : public BucketInfoReply {
document::DocumentId _docId;
- document::Document::SP _document; // Not serialized
+ DocumentSP _document; // Not serialized
Timestamp _timestamp;
Timestamp _updateTimestamp;
bool _wasFound;
@@ -89,7 +90,7 @@ public:
const document::DocumentId& getDocumentId() const { return _docId; }
bool hasDocument() const { return _document.get(); }
- const document::Document::SP& getDocument() const { return _document; }
+ const DocumentSP& getDocument() const { return _document; }
Timestamp getTimestamp() const { return _timestamp; };
Timestamp getUpdateTimestamp() const { return _updateTimestamp; }
@@ -108,21 +109,20 @@ public:
* @brief Command for updating a document to the storage system.
*/
class UpdateCommand : public TestAndSetCommand {
- document::DocumentUpdate::SP _update;
+ std::shared_ptr<document::DocumentUpdate> _update;
Timestamp _timestamp;
Timestamp _oldTimestamp;
public:
UpdateCommand(const document::Bucket &bucket,
- const document::DocumentUpdate::SP&, Timestamp);
+ const std::shared_ptr<document::DocumentUpdate>&, Timestamp);
~UpdateCommand();
void setTimestamp(Timestamp ts) { _timestamp = ts; }
void setOldTimestamp(Timestamp ts) { _oldTimestamp = ts; }
- const document::DocumentUpdate::SP& getUpdate() const { return _update; }
- const document::DocumentId& getDocumentId() const override
- { return _update->getId(); }
+ const std::shared_ptr<document::DocumentUpdate>& getUpdate() const { return _update; }
+ const document::DocumentId& getDocumentId() const override;
Timestamp getTimestamp() const { return _timestamp; }
Timestamp getOldTimestamp() const { return _oldTimestamp; }
@@ -211,17 +211,17 @@ public:
class GetReply : public BucketInfoReply {
document::DocumentId _docId; // In case of not found, we want id still
vespalib::string _fieldSet;
- document::Document::SP _doc; // Null pointer if not found
+ DocumentSP _doc; // Null pointer if not found
Timestamp _beforeTimestamp;
Timestamp _lastModifiedTime;
public:
GetReply(const GetCommand& cmd,
- const document::Document::SP& doc = document::Document::SP(),
+ const DocumentSP& doc = DocumentSP(),
Timestamp lastModified = 0);
~GetReply();
- const document::Document::SP& getDocument() const { return _doc; }
+ const DocumentSP& getDocument() const { return _doc; }
const document::DocumentId& getDocumentId() const { return _docId; }
const vespalib::string& getFieldSet() const { return _fieldSet; }
@@ -311,5 +311,4 @@ public:
DECLARE_STORAGEREPLY(RevertReply, onRevertReply)
};
-} // api
-} // storage
+}
diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketinfocommand.h b/storageapi/src/vespa/storageapi/messageapi/bucketinfocommand.h
index 25fa01758ca..814ae33bfe3 100644
--- a/storageapi/src/vespa/storageapi/messageapi/bucketinfocommand.h
+++ b/storageapi/src/vespa/storageapi/messageapi/bucketinfocommand.h
@@ -14,8 +14,7 @@
#include "bucketcommand.h"
-namespace storage {
-namespace api {
+namespace storage::api {
class BucketInfoCommand : public BucketCommand {
protected:
@@ -27,6 +26,5 @@ public:
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
};
-} // api
-} // storage
+}
diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.h b/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.h
index d4308f2d4e4..5b784267da2 100644
--- a/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.h
+++ b/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.h
@@ -16,15 +16,13 @@
#include "bucketinfocommand.h"
#include <vespa/storageapi/buckets/bucketinfo.h>
-namespace storage {
-namespace api {
+namespace storage::api {
class BucketInfoReply : public BucketReply {
BucketInfo _result;
protected:
- BucketInfoReply(const BucketInfoCommand& cmd,
- const ReturnCode& code = ReturnCode(ReturnCode::OK));
+ BucketInfoReply(const BucketInfoCommand& cmd, const ReturnCode& code = ReturnCode(ReturnCode::OK));
public:
DECLARE_POINTER_TYPEDEFS(BucketInfoReply);
@@ -34,5 +32,4 @@ public:
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
};
-} // api
-} // storage
+}
diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketreply.h b/storageapi/src/vespa/storageapi/messageapi/bucketreply.h
index b0f98d91152..5b4e6963fd9 100644
--- a/storageapi/src/vespa/storageapi/messageapi/bucketreply.h
+++ b/storageapi/src/vespa/storageapi/messageapi/bucketreply.h
@@ -10,8 +10,7 @@
#include "storagereply.h"
-namespace storage {
-namespace api {
+namespace storage::api {
class BucketCommand;
@@ -20,23 +19,20 @@ class BucketReply : public StorageReply {
document::BucketId _originalBucket;
protected:
- BucketReply(const BucketCommand& cmd,
- const ReturnCode& code = ReturnCode(ReturnCode::OK));
+ BucketReply(const BucketCommand& cmd, const ReturnCode& code = ReturnCode(ReturnCode::OK));
public:
DECLARE_POINTER_TYPEDEFS(BucketReply);
document::Bucket getBucket() const override { return _bucket; }
- virtual bool hasSingleBucketId() const override { return true; }
+ bool hasSingleBucketId() const override { return true; }
bool hasBeenRemapped() const { return (_originalBucket.getRawId() != 0); }
- const document::BucketId& getOriginalBucketId() const
- { return _originalBucket; }
+ const document::BucketId& getOriginalBucketId() const { return _originalBucket; }
/** The deserialization code need access to set the remapping. */
void remapBucketId(const document::BucketId& bucket);
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
};
-} // api
-} // storage
+}