diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-09 12:13:43 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-09 21:35:47 +0000 |
commit | 9e6251c1e2246da4f490ae1013fc3972504c42ab (patch) | |
tree | 201d9a0fc85e8ec1fbba9833fea58a8f81b041b7 /persistence | |
parent | 1fa852eadd7b09b98ce6dd8bdd7b0446d07a37d6 (diff) |
Move BucketIdListResult
Diffstat (limited to 'persistence')
4 files changed, 25 insertions, 20 deletions
diff --git a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp index d947ca51f49..33770004aba 100644 --- a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp +++ b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp @@ -318,14 +318,14 @@ DummyPersistence::listBuckets(BucketSpace bucketSpace) const list.push_back(entry.first); } } - return BucketIdListResult(list); + return BucketIdListResult(std::move(list)); } void -DummyPersistence::setModifiedBuckets(const BucketIdListResult::List& buckets) +DummyPersistence::setModifiedBuckets(BucketIdListResult::List buckets) { std::lock_guard lock(_monitor); - _modifiedBuckets = buckets; + _modifiedBuckets = std::move(buckets); } void DummyPersistence::set_fake_bucket_set(const std::vector<std::pair<Bucket, BucketInfo>>& fake_info) { @@ -348,10 +348,10 @@ DummyPersistence::getModifiedBuckets(BucketSpace bucketSpace) const { std::lock_guard lock(_monitor); if (bucketSpace == FixedBucketSpaces::default_space()) { - return BucketIdListResult(_modifiedBuckets); + return BucketIdListResult(std::move(_modifiedBuckets)); } else { BucketIdListResult::List emptyList; - return BucketIdListResult(emptyList); + return BucketIdListResult(BucketIdListResult::List()); } } diff --git a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h index 3b6fc9f1449..683a738255f 100644 --- a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h +++ b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h @@ -138,12 +138,12 @@ class DummyPersistence : public AbstractPersistenceProvider { public: DummyPersistence(const std::shared_ptr<const document::DocumentTypeRepo>& repo); - ~DummyPersistence(); + ~DummyPersistence() override; Result initialize() override; BucketIdListResult listBuckets(BucketSpace bucketSpace) const override; - void setModifiedBuckets(const BucketIdListResult::List& result); + void setModifiedBuckets(BucketIdListResult::List result); // Important: any subsequent mutations to the bucket set in fake_info will reset // the bucket info due to implicit recalculation of bucket info. diff --git a/persistence/src/vespa/persistence/spi/abstractpersistenceprovider.cpp b/persistence/src/vespa/persistence/spi/abstractpersistenceprovider.cpp index 35654240ec7..6ee99e49798 100644 --- a/persistence/src/vespa/persistence/spi/abstractpersistenceprovider.cpp +++ b/persistence/src/vespa/persistence/spi/abstractpersistenceprovider.cpp @@ -18,8 +18,7 @@ AbstractPersistenceProvider::removeIfFoundAsync(const Bucket& b, Timestamp times BucketIdListResult AbstractPersistenceProvider::getModifiedBuckets(BucketSpace) const { - BucketIdListResult::List list; - return BucketIdListResult(list); + return BucketIdListResult(BucketIdListResult::List()); } } diff --git a/persistence/src/vespa/persistence/spi/result.h b/persistence/src/vespa/persistence/spi/result.h index 10c589307ba..5046a380c86 100644 --- a/persistence/src/vespa/persistence/spi/result.h +++ b/persistence/src/vespa/persistence/spi/result.h @@ -71,7 +71,7 @@ std::ostream & operator << (std::ostream & os, const Result & r); std::ostream & operator << (std::ostream & os, const Result::ErrorType &errorCode); -class BucketInfoResult : public Result { +class BucketInfoResult final : public Result { public: /** * Constructor to use for a result where an error has been detected. @@ -95,7 +95,7 @@ private: BucketInfo _info; }; -class UpdateResult : public Result +class UpdateResult final : public Result { public: /** @@ -151,7 +151,7 @@ private: uint32_t _numRemoved; }; -class GetResult : public Result { +class GetResult final : public Result { public: /** * Constructor to use when there was an error retrieving the document. @@ -173,6 +173,8 @@ public: _is_tombstone(false) { } + GetResult(GetResult &&) noexcept = default; + GetResult & operator=(GetResult &&) noexcept = default; /** * Constructor to use when we found the document asked for. @@ -225,7 +227,7 @@ private: bool _is_tombstone; }; -class BucketIdListResult : public Result { +class BucketIdListResult final : public Result { public: using List = document::bucket::BucketIdList; @@ -241,12 +243,16 @@ public: * @param list The list of bucket ids this partition has. Is swapped with * the list internal to this object. */ - BucketIdListResult(List& list) - : Result() - { - _info.swap(list); - } - + BucketIdListResult(List list) + : Result(), + _info(std::move(list)) + { } + BucketIdListResult() + : Result(), + _info() + { } + BucketIdListResult(BucketIdListResult &&) noexcept = default; + BucketIdListResult & operator =(BucketIdListResult &&) noexcept = default; ~BucketIdListResult(); const List& getList() const { return _info; } @@ -278,7 +284,7 @@ private: IteratorId _iterator; }; -class IterateResult : public Result { +class IterateResult final : public Result { public: using List = std::vector<std::unique_ptr<DocEntry>>; |