diff options
Diffstat (limited to 'storageapi/src')
4 files changed, 34 insertions, 39 deletions
diff --git a/storageapi/src/vespa/storageapi/buckets/bucketinfo.cpp b/storageapi/src/vespa/storageapi/buckets/bucketinfo.cpp index 7466d5c603e..9e4e48d67f4 100644 --- a/storageapi/src/vespa/storageapi/buckets/bucketinfo.cpp +++ b/storageapi/src/vespa/storageapi/buckets/bucketinfo.cpp @@ -2,9 +2,12 @@ #include "bucketinfo.h" #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/util/xmlstream.h> +#include <ostream> namespace storage::api { +static_assert(sizeof(BucketInfo) == 32, "BucketInfo should be 32 bytes"); + BucketInfo::BucketInfo() noexcept : _lastModified(0), _checksum(0), @@ -69,10 +72,6 @@ BucketInfo::BucketInfo(uint32_t checksum, uint32_t docCount, _active(active) {} -BucketInfo::BucketInfo(const BucketInfo &) noexcept = default; -BucketInfo & BucketInfo::operator = (const BucketInfo &) noexcept = default; -BucketInfo::~BucketInfo() = default; - bool BucketInfo::operator==(const BucketInfo& info) const { @@ -86,9 +85,10 @@ BucketInfo::operator==(const BucketInfo& info) const } // TODO: add ready/active to printing -void -BucketInfo::print(vespalib::asciistream& out, const PrintProperties&) const +vespalib::string +BucketInfo::toString() const { + vespalib::asciistream out; out << "BucketInfo("; if (valid()) { out << "crc 0x" << vespalib::hex << _checksum << vespalib::dec @@ -108,6 +108,7 @@ BucketInfo::print(vespalib::asciistream& out, const PrintProperties&) const out << "invalid"; } out << ")"; + return out.str(); } void @@ -124,4 +125,9 @@ BucketInfo::printXml(vespalib::XmlOutputStream& xos) const << XmlAttribute("lastmodified", _lastModified); } +std::ostream & +operator << (std::ostream & os, const BucketInfo & bucketInfo) { + return os << bucketInfo.toString(); +} + } diff --git a/storageapi/src/vespa/storageapi/buckets/bucketinfo.h b/storageapi/src/vespa/storageapi/buckets/bucketinfo.h index f15d99588ca..75d0f4f512d 100644 --- a/storageapi/src/vespa/storageapi/buckets/bucketinfo.h +++ b/storageapi/src/vespa/storageapi/buckets/bucketinfo.h @@ -19,7 +19,7 @@ namespace storage::api { -class BucketInfo : public vespalib::AsciiPrintable +class BucketInfo { Timestamp _lastModified; uint32_t _checksum; @@ -41,9 +41,6 @@ public: BucketInfo(uint32_t checksum, uint32_t docCount, uint32_t totDocSize, uint32_t metaCount, uint32_t usedFileSize, bool ready, bool active, Timestamp lastModified) noexcept; - BucketInfo(const BucketInfo &) noexcept; - BucketInfo & operator = (const BucketInfo &) noexcept; - ~BucketInfo(); Timestamp getLastModified() const { return _lastModified; } uint32_t getChecksum() const { return _checksum; } @@ -78,12 +75,10 @@ public: bool empty() const { return _metaCount == 0 && _usedFileSize == 0 && _checksum == 0; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override { - vespalib::AsciiPrintable::print(out, verbose, indent); - } - void print(vespalib::asciistream&, const PrintProperties&) const override; - + vespalib::string toString() const; void printXml(vespalib::XmlOutputStream&) const; }; +std::ostream & operator << (std::ostream & os, const BucketInfo & bucketInfo); + } diff --git a/storageapi/src/vespa/storageapi/message/bucket.cpp b/storageapi/src/vespa/storageapi/message/bucket.cpp index de47a52ca9d..c69e5c6a5bc 100644 --- a/storageapi/src/vespa/storageapi/message/bucket.cpp +++ b/storageapi/src/vespa/storageapi/message/bucket.cpp @@ -109,7 +109,7 @@ MergeBucketCommand::MergeBucketCommand( _chain(chain) {} -MergeBucketCommand::~MergeBucketCommand() {} +MergeBucketCommand::~MergeBucketCommand() = default; void MergeBucketCommand::print(std::ostream& out, bool verbose, const std::string& indent) const @@ -212,7 +212,7 @@ GetBucketDiffCommand::GetBucketDiffCommand( _maxTimestamp(maxTimestamp) {} -GetBucketDiffCommand::~GetBucketDiffCommand() {} +GetBucketDiffCommand::~GetBucketDiffCommand() = default; void GetBucketDiffCommand::print(std::ostream& out, bool verbose, @@ -250,7 +250,7 @@ GetBucketDiffReply::GetBucketDiffReply(const GetBucketDiffCommand& cmd) _diff(cmd.getDiff()) {} -GetBucketDiffReply::~GetBucketDiffReply() {} +GetBucketDiffReply::~GetBucketDiffReply() = default; void GetBucketDiffReply::print(std::ostream& out, bool verbose, @@ -297,7 +297,7 @@ ApplyBucketDiffCommand::Entry::Entry(const GetBucketDiffCommand::Entry& e) _repo() {} -ApplyBucketDiffCommand::Entry::~Entry() {} +ApplyBucketDiffCommand::Entry::~Entry() = default; ApplyBucketDiffCommand::Entry::Entry(const Entry &) = default; ApplyBucketDiffCommand::Entry & ApplyBucketDiffCommand::Entry::operator = (const Entry &) = default; @@ -349,7 +349,7 @@ ApplyBucketDiffCommand::ApplyBucketDiffCommand( _maxBufferSize(maxBufferSize) {} -ApplyBucketDiffCommand::~ApplyBucketDiffCommand() {} +ApplyBucketDiffCommand::~ApplyBucketDiffCommand() = default; void ApplyBucketDiffCommand::print(std::ostream& out, bool verbose, @@ -398,7 +398,7 @@ ApplyBucketDiffReply::ApplyBucketDiffReply(const ApplyBucketDiffCommand& cmd) _maxBufferSize(cmd.getMaxBufferSize()) {} -ApplyBucketDiffReply::~ApplyBucketDiffReply() {} +ApplyBucketDiffReply::~ApplyBucketDiffReply() = default; void ApplyBucketDiffReply::print(std::ostream& out, bool verbose, @@ -406,12 +406,10 @@ ApplyBucketDiffReply::print(std::ostream& out, bool verbose, { uint32_t totalSize = 0; uint32_t filled = 0; - for (std::vector<Entry>::const_iterator it = _diff.begin(); - it != _diff.end(); ++it) - { - totalSize += it->_headerBlob.size(); - totalSize += it->_bodyBlob.size(); - if (it->filled()) ++filled; + for (const Entry & entry : _diff) { + totalSize += entry._headerBlob.size(); + totalSize += entry._bodyBlob.size(); + if (entry.filled()) ++filled; } out << "ApplyBucketDiffReply(" << getBucketId() << ", nodes: "; for (uint32_t i=0; i<_nodes.size(); ++i) { @@ -487,14 +485,14 @@ RequestBucketInfoCommand::print(std::ostream& out, bool verbose, const std::string& indent) const { out << "RequestBucketInfoCommand("; - if (_buckets.size() != 0) { + if ( ! _buckets.empty()) { out << _buckets.size() << " buckets"; } if (hasSystemState()) { out << "distributor " << _distributor << " in "; _state->print(out, verbose, indent + " "); } - if (verbose && _buckets.size() > 0) { + if (verbose && !_buckets.empty()) { out << "\n" << indent << " Specified buckets:\n" << indent << " "; std::copy(_buckets.begin(), _buckets.end(), std::ostream_iterator<document::BucketId>( @@ -507,20 +505,18 @@ RequestBucketInfoCommand::print(std::ostream& out, bool verbose, } } -std::ostream& operator<<(std::ostream& out, - const RequestBucketInfoReply::Entry& e) +std::ostream& operator<<(std::ostream& out, const RequestBucketInfoReply::Entry& e) { return out << e._bucketId << " - " << e._info; } -RequestBucketInfoReply::RequestBucketInfoReply( - const RequestBucketInfoCommand& cmd) +RequestBucketInfoReply::RequestBucketInfoReply(const RequestBucketInfoCommand& cmd) : StorageReply(cmd), _buckets() { } -RequestBucketInfoReply::~RequestBucketInfoReply() { } +RequestBucketInfoReply::~RequestBucketInfoReply() = default; void RequestBucketInfoReply::print(std::ostream& out, bool verbose, @@ -552,7 +548,7 @@ NotifyBucketChangeCommand::print(std::ostream& out, bool verbose, const std::string& indent) const { out << "NotifyBucketChangeCommand(" << getBucketId() << ", "; - _info.print(out, verbose, indent); + out << _info.toString(); out << ")"; if (verbose) { out << " : "; diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.cpp b/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.cpp index 50efdd6c560..67e4d835e0c 100644 --- a/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.cpp +++ b/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.cpp @@ -3,8 +3,7 @@ #include "bucketinforeply.h" #include <ostream> -namespace storage { -namespace api { +namespace storage::api { BucketInfoReply::BucketInfoReply(const BucketInfoCommand& cmd, const ReturnCode& code) @@ -24,5 +23,4 @@ BucketInfoReply::print(std::ostream& out, bool verbose, } } -} // api -} // storage +} |