diff options
author | Haavard <havardpe@yahoo-inc.com> | 2017-03-20 13:04:33 +0000 |
---|---|---|
committer | Haavard <havardpe@yahoo-inc.com> | 2017-03-27 09:53:26 +0000 |
commit | 23abed1a0bc4f4c5ea47b43fc7ea0645e63a26e6 (patch) | |
tree | 6d943bbe31738f7e9b84979e4fd63dfd76eef580 /storage | |
parent | 8844ccb7297e8a5120dd903c85e923f2f93aa693 (diff) |
remove most usage of LinkedPtr from vespa
Diffstat (limited to 'storage')
45 files changed, 88 insertions, 97 deletions
diff --git a/storage/src/tests/distributor/mergelimitertest.cpp b/storage/src/tests/distributor/mergelimitertest.cpp index fd86e071579..57b3690dc24 100644 --- a/storage/src/tests/distributor/mergelimitertest.cpp +++ b/storage/src/tests/distributor/mergelimitertest.cpp @@ -1,6 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/vespalib/util/linkedptr.h> #include <vespa/storage/distributor/operations/idealstate/mergelimiter.h> #include <vespa/vdstestlib/cppunit/macros.h> @@ -29,7 +28,7 @@ struct MergeLimiterTest : public CppUnit::TestFixture CPPUNIT_TEST_SUITE_REGISTRATION(MergeLimiterTest); namespace { - typedef vespalib::LinkedPtr<BucketCopy> BucketCopyPtr; + using BucketCopyPtr = std::unique_ptr<BucketCopy>; std::vector<BucketCopyPtr> _bucketDatabase; struct NodeFactory { diff --git a/storage/src/tests/persistence/persistencetestutils.cpp b/storage/src/tests/persistence/persistencetestutils.cpp index e6a401548aa..faaaaac178d 100644 --- a/storage/src/tests/persistence/persistencetestutils.cpp +++ b/storage/src/tests/persistence/persistencetestutils.cpp @@ -55,7 +55,7 @@ PersistenceTestEnvironment::PersistenceTestEnvironment(DiskCount numDisks, const _node.getComponentRegister(), 255, 0)); for (uint32_t i = 0; i < numDisks; i++) { _diskEnvs.push_back( - vespalib::LinkedPtr<PersistenceUtil>( + std::unique_ptr<PersistenceUtil>( new PersistenceUtil( _config.getConfigId(), _node.getComponentRegister(), diff --git a/storage/src/tests/persistence/persistencetestutils.h b/storage/src/tests/persistence/persistencetestutils.h index 4f6c6ba3bbb..4a51faafe05 100644 --- a/storage/src/tests/persistence/persistencetestutils.h +++ b/storage/src/tests/persistence/persistencetestutils.h @@ -32,7 +32,7 @@ struct PersistenceTestEnvironment { StorageComponent _component; FileStorMetrics _metrics; std::unique_ptr<FileStorHandler> _handler; - std::vector<vespalib::LinkedPtr<PersistenceUtil> > _diskEnvs; + std::vector<std::unique_ptr<PersistenceUtil> > _diskEnvs; }; class PersistenceTestUtils : public CppUnit::TestFixture { diff --git a/storage/src/tests/persistence/splitbitdetectortest.cpp b/storage/src/tests/persistence/splitbitdetectortest.cpp index cdec8e3e3f6..65ea629ad81 100644 --- a/storage/src/tests/persistence/splitbitdetectortest.cpp +++ b/storage/src/tests/persistence/splitbitdetectortest.cpp @@ -28,14 +28,14 @@ struct SplitBitDetectorTest : public CppUnit::TestFixture { void testZeroDocLimitFallbacksToOneBitIncreaseOnGidCollision(); void findBucketCollisionIds(); - spi::DocEntry::LP + spi::DocEntry::UP generateDocEntry(uint32_t userId, uint32_t docNum, spi::Timestamp timestamp) { std::ostringstream ost; ost << "id:storage_test:testdoctype1:n=" << userId << ":" << docNum; - return spi::DocEntry::LP(new spi::DocEntry( + return spi::DocEntry::UP(new spi::DocEntry( timestamp, 0, document::DocumentId(ost.str()))); }; @@ -68,7 +68,7 @@ SplitBitDetectorTest::testTwoUsers() provider.createBucket(bucket, context); - std::vector<spi::DocEntry::LP> entries; + std::vector<spi::DocEntry::UP> entries; for (uint32_t i = 0; i < 5; ++i) { document::Document::SP doc( testDocMan.createRandomDocumentAtLocation(1, i, 1, 1)); @@ -102,7 +102,7 @@ SplitBitDetectorTest::testSingleUser() provider.createBucket(bucket, context); - std::vector<spi::DocEntry::LP> entries; + std::vector<spi::DocEntry::UP> entries; for (uint32_t i = 0; i < 10; ++i) { document::Document::SP doc( testDocMan.createRandomDocumentAtLocation(1, i, 1, 1)); @@ -131,7 +131,7 @@ SplitBitDetectorTest::testMaxBits() provider.createBucket(bucket, context); - std::vector<spi::DocEntry::LP> entries; + std::vector<spi::DocEntry::UP> entries; for (uint32_t seed = 0; seed < 10; ++seed) { int location = 1; document::Document::SP doc(testDocMan.createRandomDocumentAtLocation( @@ -160,7 +160,7 @@ SplitBitDetectorTest::testMaxBitsOneBelowMax() provider.createBucket(bucket, context); - std::vector<spi::DocEntry::LP> entries; + std::vector<spi::DocEntry::UP> entries; for (uint32_t seed = 0; seed < 10; ++seed) { int location = 1 | (seed % 2 == 0 ? 0x8000 : 0); document::Document::SP doc(testDocMan.createRandomDocumentAtLocation( @@ -198,7 +198,7 @@ SplitBitDetectorTest::testUnsplittable() provider.createBucket(bucket, context); - std::vector<spi::DocEntry::LP> entries; + std::vector<spi::DocEntry::UP> entries; for (uint32_t i = 0; i < 10; ++i) { document::Document::SP doc( @@ -227,7 +227,7 @@ SplitBitDetectorTest::testUnsplittableMinCount() provider.createBucket(bucket, context); - std::vector<spi::DocEntry::LP> entries; + std::vector<spi::DocEntry::UP> entries; for (uint32_t i = 0; i < 10; ++i) { document::Document::SP doc( diff --git a/storage/src/tests/storageserver/testvisitormessagesession.cpp b/storage/src/tests/storageserver/testvisitormessagesession.cpp index 6c8f491162b..aca7c23996d 100644 --- a/storage/src/tests/storageserver/testvisitormessagesession.cpp +++ b/storage/src/tests/storageserver/testvisitormessagesession.cpp @@ -50,7 +50,7 @@ TestVisitorMessageSession::send( } else { pendingCount++; sentMessages.push_back( - vespalib::LinkedPtr<documentapi::DocumentMessage>( + std::unique_ptr<documentapi::DocumentMessage>( message.release())); guard.broadcast(); return mbus::Result(); diff --git a/storage/src/tests/storageserver/testvisitormessagesession.h b/storage/src/tests/storageserver/testvisitormessagesession.h index 3ae6ccafb84..9b2f645905d 100644 --- a/storage/src/tests/storageserver/testvisitormessagesession.h +++ b/storage/src/tests/storageserver/testvisitormessagesession.h @@ -26,7 +26,7 @@ public: ~TestVisitorMessageSession(); - std::deque<vespalib::LinkedPtr<documentapi::DocumentMessage> > sentMessages; + std::deque<std::unique_ptr<documentapi::DocumentMessage> > sentMessages; TestVisitorMessageSession(VisitorThread& t, Visitor& v, diff --git a/storage/src/tests/visiting/visitortest.cpp b/storage/src/tests/visiting/visitortest.cpp index cddd044ca4c..1e2eda75cc8 100644 --- a/storage/src/tests/visiting/visitortest.cpp +++ b/storage/src/tests/visiting/visitortest.cpp @@ -342,8 +342,9 @@ VisitorTest::getMessagesAndReply( { vespalib::MonitorGuard guard(session.getMonitor()); CPPUNIT_ASSERT(!session.sentMessages.empty()); - vespalib::LinkedPtr<documentapi::DocumentMessage> msg( - session.sentMessages.front()); + std::unique_ptr<documentapi::DocumentMessage> msg( + std::move(session.sentMessages.front())); + session.sentMessages.pop_front(); CPPUNIT_ASSERT(msg->getPriority() < 16); switch (msg->getType()) { @@ -369,7 +370,6 @@ VisitorTest::getMessagesAndReply( reply = msg->createReply(); reply->swapState(*msg); - session.sentMessages.pop_front(); // Release linked ptr ref. reply->setMessage(mbus::Message::UP(msg.release())); if (result != api::ReturnCode::OK) { @@ -443,7 +443,7 @@ VisitorTest::sendGetIterReply(GetIterCommand& cmd, size_t documentCount = maxDocuments != 0 ? maxDocuments : _documents.size(); for (size_t i = 0; i < documentCount; ++i) { reply->getEntries().push_back( - spi::DocEntry::LP( + spi::DocEntry::UP( new spi::DocEntry( spi::Timestamp(1000 + i), spi::NONE, diff --git a/storage/src/vespa/storage/bucketdb/lockablemap.h b/storage/src/vespa/storage/bucketdb/lockablemap.h index 6301014d26b..40e45b72c48 100644 --- a/storage/src/vespa/storage/bucketdb/lockablemap.h +++ b/storage/src/vespa/storage/bucketdb/lockablemap.h @@ -17,7 +17,6 @@ #include <map> #include <vespa/vespalib/util/printable.h> #include <vespa/vespalib/util/sync.h> -#include <vespa/vespalib/util/linkedptr.h> #include <vespa/vespalib/stllike/hash_map.h> #include <vespa/vespalib/stllike/hash_set.h> #include <vespa/document/bucket/bucketid.h> @@ -86,7 +85,7 @@ public: bool _exists; bool _preExisted; - vespalib::LinkedPtr<LockKeeper> _lockKeeper; + std::unique_ptr<LockKeeper> _lockKeeper; mapped_type _value; const char* _clientId; friend class LockableMap<Map>; diff --git a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp index 79dde3f839a..178731469ba 100644 --- a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp +++ b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp @@ -21,7 +21,7 @@ namespace storage { using BucketSet = vespalib::hash_set<document::BucketId, document::BucketId::hash>; struct BucketReadState { - typedef vespalib::LinkedPtr<BucketReadState> LP; + using UP = std::unique_ptr<BucketReadState>; BucketSet _pending; document::BucketId _databaseIterator; @@ -132,7 +132,7 @@ StorageBucketDBInitializer::StorageBucketDBInitializer( // Initialize read state for disks being available for (uint32_t i=0; i<_system._partitions.size(); ++i) { if (!_system._partitions[i].isUp()) continue; - _readState[i] = BucketReadState::LP(new BucketReadState); + _readState[i] = BucketReadState::UP(new BucketReadState); _state._dirsToList += 1; } _system._component.registerStatusPage(*this); diff --git a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h index 5190be426a5..94afc5b2e1a 100644 --- a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h +++ b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h @@ -129,7 +129,7 @@ class StorageBucketDBInitializer : public StorageLink, System _system; Metrics _metrics; GlobalState _state; - std::vector<vespalib::LinkedPtr<BucketReadState>> _readState; + std::vector<std::unique_ptr<BucketReadState>> _readState; public: StorageBucketDBInitializer(const config::ConfigUri&, diff --git a/storage/src/vespa/storage/bucketmover/run.h b/storage/src/vespa/storage/bucketmover/run.h index 575a9c60183..292b18f63a5 100644 --- a/storage/src/vespa/storage/bucketmover/run.h +++ b/storage/src/vespa/storage/bucketmover/run.h @@ -19,7 +19,6 @@ #include <map> #include <vespa/storage/bucketmover/move.h> #include <vespa/storage/bucketmover/runstatistics.h> -#include <vespa/vespalib/util/linkedptr.h> #include <vespa/vdslib/distribution/distribution.h> #include <vespa/vdslib/state/nodestate.h> diff --git a/storage/src/vespa/storage/bucketmover/runstatistics.cpp b/storage/src/vespa/storage/bucketmover/runstatistics.cpp index 7383e0ca5ef..6ba0dfd463a 100644 --- a/storage/src/vespa/storage/bucketmover/runstatistics.cpp +++ b/storage/src/vespa/storage/bucketmover/runstatistics.cpp @@ -6,7 +6,6 @@ #include <iomanip> #include <vespa/log/log.h> #include <vespa/storage/bucketmover/htmltable.h> -#include <vespa/vespalib/util/linkedptr.h> LOG_SETUP(".bucketmover.run.statistics"); diff --git a/storage/src/vespa/storage/bucketmover/runstatistics.h b/storage/src/vespa/storage/bucketmover/runstatistics.h index 1483c241eb9..625d7f5fac4 100644 --- a/storage/src/vespa/storage/bucketmover/runstatistics.h +++ b/storage/src/vespa/storage/bucketmover/runstatistics.h @@ -19,8 +19,8 @@ if (anyset) { \ out << "<h4>" << desc << "</h4>\n"; \ HtmlTable matrixTable("Source \\ Target"); \ - typedef vespalib::LinkedPtr<LongColumn> LCLP; \ - std::vector<LCLP> matrixData((rs)._diskData.size()); \ + using LCUP = std::unique_ptr<LongColumn>; \ + std::vector<LCUP> matrixData((rs)._diskData.size()); \ for (uint32_t i=0; i<(rs)._diskData.size(); ++i) { \ std::ostringstream index; \ index << "Disk " << i; \ diff --git a/storage/src/vespa/storage/common/hostreporter/cpureporter.cpp b/storage/src/vespa/storage/common/hostreporter/cpureporter.cpp index d7f59e07d4e..59c0f1c36f3 100644 --- a/storage/src/vespa/storage/common/hostreporter/cpureporter.cpp +++ b/storage/src/vespa/storage/common/hostreporter/cpureporter.cpp @@ -3,7 +3,6 @@ #include "cpureporter.h" #include <vespa/log/log.h> -#include <vespa/vespalib/util/linkedptr.h> #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/text/stringtokenizer.h> diff --git a/storage/src/vespa/storage/common/hostreporter/hostinfo.h b/storage/src/vespa/storage/common/hostreporter/hostinfo.h index 340ffdc73c7..3563cbb4af6 100644 --- a/storage/src/vespa/storage/common/hostreporter/hostinfo.h +++ b/storage/src/vespa/storage/common/hostreporter/hostinfo.h @@ -2,7 +2,6 @@ #ifndef STORAGE_SRC_CPP_STORAGE_COMMON_HOSTREPORTER_HOSTINFO_H_ #define STORAGE_SRC_CPP_STORAGE_COMMON_HOSTREPORTER_HOSTINFO_H_ -#include <vespa/vespalib/util/linkedptr.h> #include <vespa/vespalib/util/jsonstream.h> #include "cpureporter.h" diff --git a/storage/src/vespa/storage/distributor/maintenance/bucketprioritydatabase.h b/storage/src/vespa/storage/distributor/maintenance/bucketprioritydatabase.h index 30ccf0040ba..3088e6f5322 100644 --- a/storage/src/vespa/storage/distributor/maintenance/bucketprioritydatabase.h +++ b/storage/src/vespa/storage/distributor/maintenance/bucketprioritydatabase.h @@ -4,7 +4,6 @@ #include <vespa/storage/bucketdb/bucketdatabase.h> #include <vespa/storage/distributor/maintenance/prioritizedbucket.h> #include <boost/iterator/iterator_facade.hpp> -#include <vespa/vespalib/util/linkedptr.h> namespace storage { namespace distributor { @@ -23,7 +22,7 @@ protected: virtual PrioritizedBucket dereference() const = 0; }; - typedef vespalib::LinkedPtr<ConstIteratorImpl> ConstIteratorImplPtr; + using ConstIteratorImplPtr = std::unique_ptr<ConstIteratorImpl>; public: class ConstIterator : public boost::iterator_facade< @@ -35,9 +34,11 @@ public: { ConstIteratorImplPtr _impl; public: - ConstIterator(const ConstIteratorImplPtr& impl) - : _impl(impl) + ConstIterator(ConstIteratorImplPtr impl) + : _impl(std::move(impl)) {} + ConstIterator(const ConstIterator &) = delete; + ConstIterator(ConstIterator &&) = default; virtual ~ConstIterator() {} private: diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/idealstateoperation.h b/storage/src/vespa/storage/distributor/operations/idealstate/idealstateoperation.h index 3491eacf066..cf820dd3381 100644 --- a/storage/src/vespa/storage/distributor/operations/idealstate/idealstateoperation.h +++ b/storage/src/vespa/storage/distributor/operations/idealstate/idealstateoperation.h @@ -108,7 +108,6 @@ public: static const uint32_t MAINTENANCE_MESSAGE_TYPES[]; typedef std::shared_ptr<IdealStateOperation> SP; - typedef vespalib::LinkedPtr<IdealStateOperation> LP; typedef std::unique_ptr<IdealStateOperation> UP; typedef std::vector<SP> Vector; typedef std::map<document::BucketId, SP> Map; diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp index f222738cd9a..76fdaded452 100644 --- a/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp +++ b/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp @@ -158,13 +158,13 @@ MergeOperation::onStart(DistributorMessageSender& sender) } const lib::ClusterState& clusterState(_manager->getDistributorComponent().getClusterState()); - std::vector<vespalib::LinkedPtr<BucketCopy> > newCopies; + std::vector<std::unique_ptr<BucketCopy> > newCopies; std::vector<MergeMetaData> nodes; for (uint32_t i = 0; i < getNodes().size(); ++i) { const BucketCopy* copy = entry->getNode(getNodes()[i]); if (copy == 0) { // New copies? - newCopies.push_back(vespalib::LinkedPtr<BucketCopy>( + newCopies.push_back(std::unique_ptr<BucketCopy>( new BucketCopy(0, getNodes()[i], api::BucketInfo()))); copy = newCopies.back().get(); } diff --git a/storage/src/vespa/storage/distributor/persistence_operation_metric_set.cpp b/storage/src/vespa/storage/distributor/persistence_operation_metric_set.cpp index b7766713b01..8be0450659f 100644 --- a/storage/src/vespa/storage/distributor/persistence_operation_metric_set.cpp +++ b/storage/src/vespa/storage/distributor/persistence_operation_metric_set.cpp @@ -41,7 +41,7 @@ PersistenceFailuresMetricSet::PersistenceFailuresMetricSet(MetricSet* owner) PersistenceFailuresMetricSet::~PersistenceFailuresMetricSet() { } MetricSet * -PersistenceFailuresMetricSet::clone(std::vector<Metric::LP>& ownerList, CopyType copyType, +PersistenceFailuresMetricSet::clone(std::vector<Metric::UP>& ownerList, CopyType copyType, MetricSet* owner, bool includeUnused) const { if (copyType == INACTIVE) { @@ -61,7 +61,7 @@ PersistenceOperationMetricSet::PersistenceOperationMetricSet(const std::string& PersistenceOperationMetricSet::~PersistenceOperationMetricSet() { } MetricSet * -PersistenceOperationMetricSet::clone(std::vector<Metric::LP>& ownerList, CopyType copyType, +PersistenceOperationMetricSet::clone(std::vector<Metric::UP>& ownerList, CopyType copyType, MetricSet* owner, bool includeUnused) const { if (copyType == INACTIVE) { diff --git a/storage/src/vespa/storage/distributor/persistence_operation_metric_set.h b/storage/src/vespa/storage/distributor/persistence_operation_metric_set.h index 221662a2ba6..b50ca0cb798 100644 --- a/storage/src/vespa/storage/distributor/persistence_operation_metric_set.h +++ b/storage/src/vespa/storage/distributor/persistence_operation_metric_set.h @@ -28,7 +28,7 @@ public: metrics::LongCountMetric inconsistent_bucket; metrics::LongCountMetric notfound; - MetricSet * clone(std::vector<Metric::LP>& ownerList, CopyType copyType, + MetricSet * clone(std::vector<Metric::UP>& ownerList, CopyType copyType, metrics::MetricSet* owner, bool includeUnused) const; }; @@ -42,7 +42,7 @@ public: PersistenceOperationMetricSet(const std::string& name, metrics::MetricSet* owner = nullptr); ~PersistenceOperationMetricSet(); - MetricSet * clone(std::vector<Metric::LP>& ownerList, CopyType copyType, + MetricSet * clone(std::vector<Metric::UP>& ownerList, CopyType copyType, metrics::MetricSet* owner, bool includeUnused) const override; /** diff --git a/storage/src/vespa/storage/distributor/statechecker.cpp b/storage/src/vespa/storage/distributor/statechecker.cpp index 972397922c2..64a80117fe3 100644 --- a/storage/src/vespa/storage/distributor/statechecker.cpp +++ b/storage/src/vespa/storage/distributor/statechecker.cpp @@ -52,7 +52,7 @@ public: StateChecker::Result StateChecker::Result::noMaintenanceNeeded() { - return Result(vespalib::LinkedPtr<ResultImpl>()); + return Result(std::unique_ptr<ResultImpl>()); } StateChecker::Result @@ -60,7 +60,7 @@ StateChecker::Result::createStoredResult( IdealStateOperation::UP operation, MaintenancePriority::Priority priority) { - return Result(vespalib::LinkedPtr<ResultImpl>(new StoredResultImpl(std::move(operation), MaintenancePriority(priority)))); + return Result(std::unique_ptr<ResultImpl>(new StoredResultImpl(std::move(operation), MaintenancePriority(priority)))); } StateChecker::Context::Context(const DistributorComponent& c, diff --git a/storage/src/vespa/storage/distributor/statechecker.h b/storage/src/vespa/storage/distributor/statechecker.h index 48f43cbd00f..9a40b6bbdcd 100644 --- a/storage/src/vespa/storage/distributor/statechecker.h +++ b/storage/src/vespa/storage/distributor/statechecker.h @@ -8,7 +8,6 @@ #include <vespa/storage/distributor/bucketgctimecalculator.h> #include <vespa/storage/distributor/maintenancebucket.h> #include <vespa/storage/bucketdb/bucketdatabase.h> -#include <vespa/vespalib/util/linkedptr.h> #include <unordered_set> #include <map> @@ -97,7 +96,7 @@ public: class Result { - vespalib::LinkedPtr<ResultImpl> _impl; + std::unique_ptr<ResultImpl> _impl; public: IdealStateOperation::UP createOperation() { return (_impl.get() @@ -123,8 +122,8 @@ public: IdealStateOperation::UP operation, MaintenancePriority::Priority priority); private: - Result(const vespalib::LinkedPtr<ResultImpl> impl) - : _impl(impl) + Result(std::unique_ptr<ResultImpl> impl) + : _impl(std::move(impl)) {} }; diff --git a/storage/src/vespa/storage/distributor/visitormetricsset.cpp b/storage/src/vespa/storage/distributor/visitormetricsset.cpp index fb2bab51d1a..5c81d732c11 100644 --- a/storage/src/vespa/storage/distributor/visitormetricsset.cpp +++ b/storage/src/vespa/storage/distributor/visitormetricsset.cpp @@ -25,7 +25,7 @@ VisitorMetricSet::VisitorMetricSet(MetricSet* owner) VisitorMetricSet::~VisitorMetricSet() { } MetricSet * -VisitorMetricSet::clone(std::vector<Metric::LP>& ownerList, CopyType copyType, +VisitorMetricSet::clone(std::vector<Metric::UP>& ownerList, CopyType copyType, MetricSet* owner, bool includeUnused) const { if (copyType == INACTIVE) { diff --git a/storage/src/vespa/storage/distributor/visitormetricsset.h b/storage/src/vespa/storage/distributor/visitormetricsset.h index 34d65b9ec07..04568cfb587 100644 --- a/storage/src/vespa/storage/distributor/visitormetricsset.h +++ b/storage/src/vespa/storage/distributor/visitormetricsset.h @@ -15,7 +15,7 @@ struct VisitorMetricSet : public PersistenceOperationMetricSet { VisitorMetricSet(MetricSet* owner = nullptr); ~VisitorMetricSet(); - MetricSet * clone(std::vector<Metric::LP>& ownerList, CopyType copyType, + MetricSet * clone(std::vector<Metric::UP>& ownerList, CopyType copyType, MetricSet* owner, bool includeUnused) const override; }; diff --git a/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp b/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp index d77b62c3c6e..a3c8fc3d671 100644 --- a/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp +++ b/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp @@ -228,7 +228,7 @@ FileStorManager::mapOperationToBucketAndDisk(api::BucketCommand& cmd, cmd.getBucketId().toString().c_str(), results.begin()->first.toString().c_str()); cmd.remapBucketId(results.begin()->first); - return results.begin()->second; + return std::move(results.begin()->second); } std::ostringstream error; error << "Dropping " << cmd.getType() << " to bucket " diff --git a/storage/src/vespa/storage/persistence/filestorage/filestormetrics.cpp b/storage/src/vespa/storage/persistence/filestorage/filestormetrics.cpp index 342240f0be7..519385032d8 100644 --- a/storage/src/vespa/storage/persistence/filestorage/filestormetrics.cpp +++ b/storage/src/vespa/storage/persistence/filestorage/filestormetrics.cpp @@ -20,7 +20,7 @@ FileStorThreadMetrics::Op::Op(const std::string& id, const std::string name, Met FileStorThreadMetrics::Op::~Op() { } MetricSet * -FileStorThreadMetrics::Op::clone(std::vector<Metric::LP>& ownerList, +FileStorThreadMetrics::Op::clone(std::vector<Metric::UP>& ownerList, CopyType copyType, MetricSet* owner, bool includeUnused) const @@ -40,7 +40,7 @@ FileStorThreadMetrics::OpWithNotFound::OpWithNotFound(const std::string& id, con FileStorThreadMetrics::OpWithNotFound::~OpWithNotFound() { } MetricSet * -FileStorThreadMetrics::OpWithNotFound::clone(std::vector<Metric::LP>& ownerList, +FileStorThreadMetrics::OpWithNotFound::clone(std::vector<Metric::UP>& ownerList, CopyType copyType, MetricSet* owner, bool includeUnused) const @@ -61,7 +61,7 @@ FileStorThreadMetrics::Update::Update(MetricSet* owner) FileStorThreadMetrics::Update::~Update() { } MetricSet * -FileStorThreadMetrics::Update::clone(std::vector<Metric::LP>& ownerList, +FileStorThreadMetrics::Update::clone(std::vector<Metric::UP>& ownerList, CopyType copyType, MetricSet* owner, bool includeUnused) const @@ -80,7 +80,7 @@ FileStorThreadMetrics::Visitor::Visitor(MetricSet* owner) FileStorThreadMetrics::Visitor::~Visitor() { } MetricSet * -FileStorThreadMetrics::Visitor::clone(std::vector<Metric::LP>& ownerList, +FileStorThreadMetrics::Visitor::clone(std::vector<Metric::UP>& ownerList, CopyType copyType, MetricSet* owner, bool includeUnused) const diff --git a/storage/src/vespa/storage/persistence/filestorage/filestormetrics.h b/storage/src/vespa/storage/persistence/filestorage/filestormetrics.h index 8d4aa670cc6..43310c7a1e8 100644 --- a/storage/src/vespa/storage/persistence/filestorage/filestormetrics.h +++ b/storage/src/vespa/storage/persistence/filestorage/filestormetrics.h @@ -28,7 +28,7 @@ struct FileStorThreadMetrics : public metrics::MetricSet Op(const std::string& id, const std::string name, MetricSet* owner = 0); ~Op(); - MetricSet * clone(std::vector<Metric::LP>& ownerList, CopyType copyType, + MetricSet * clone(std::vector<Metric::UP>& ownerList, CopyType copyType, MetricSet* owner, bool includeUnused) const override; Op* operator&() { return this; } }; @@ -37,7 +37,7 @@ struct FileStorThreadMetrics : public metrics::MetricSet OpWithNotFound(const std::string& id, const std::string name, metrics::MetricSet* owner = 0); ~OpWithNotFound(); - MetricSet* clone(std::vector<Metric::LP>& ownerList, CopyType copyType, + MetricSet* clone(std::vector<Metric::UP>& ownerList, CopyType copyType, MetricSet* owner, bool includeUnused) const override; OpWithNotFound* operator&() { return this; } }; @@ -48,7 +48,7 @@ struct FileStorThreadMetrics : public metrics::MetricSet Update(MetricSet* owner = 0); ~Update(); - MetricSet* clone(std::vector<Metric::LP>& ownerList, CopyType copyType, + MetricSet* clone(std::vector<Metric::UP>& ownerList, CopyType copyType, MetricSet* owner, bool includeUnused) const override; Update* operator&() { return this; } }; @@ -59,7 +59,7 @@ struct FileStorThreadMetrics : public metrics::MetricSet Visitor(MetricSet* owner = 0); ~Visitor(); - MetricSet * clone(std::vector<Metric::LP>& ownerList, CopyType copyType, + MetricSet * clone(std::vector<Metric::UP>& ownerList, CopyType copyType, MetricSet* owner, bool includeUnused) const override; Visitor* operator&() { return this; } }; diff --git a/storage/src/vespa/storage/persistence/mergehandler.cpp b/storage/src/vespa/storage/persistence/mergehandler.cpp index b0e40789f86..9775e53fac7 100644 --- a/storage/src/vespa/storage/persistence/mergehandler.cpp +++ b/storage/src/vespa/storage/persistence/mergehandler.cpp @@ -126,13 +126,13 @@ public: struct IndirectDocEntryTimestampPredicate { - bool operator()(const spi::DocEntry::LP& e1, - const spi::DocEntry::LP& e2) const + bool operator()(const spi::DocEntry::UP& e1, + const spi::DocEntry::UP& e2) const { return e1->getTimestamp() < e2->getTimestamp(); } - bool operator()(const spi::DocEntry::LP& e, + bool operator()(const spi::DocEntry::UP& e, const spi::Timestamp timestamp) const { return e->getTimestamp() < timestamp; @@ -154,7 +154,7 @@ void MergeHandler::populateMetaData( const spi::Bucket& bucket, Timestamp maxTimestamp, - std::vector<spi::DocEntry::LP>& entries, + std::vector<spi::DocEntry::UP>& entries, spi::Context& context) { spi::DocumentSelection docSel(""); @@ -190,9 +190,8 @@ MergeHandler::populateMetaData( << result.getErrorMessage(); throw std::runtime_error(ss.str()); } - for (size_t i = 0; i < result.getEntries().size(); ++i) { - entries.push_back(result.getEntries()[i]); - } + auto list = result.steal_entries(); + std::move(list.begin(), list.end(), std::back_inserter(entries)); if (result.isCompleted()) { break; } @@ -266,7 +265,7 @@ MergeHandler::buildBucketInfoList( } } - std::vector<spi::DocEntry::LP> entries; + std::vector<spi::DocEntry::UP> entries; populateMetaData(bucket, maxTimestamp, entries, context); for (size_t i = 0; i < entries.size(); ++i) { @@ -444,7 +443,7 @@ MergeHandler::fetchLocalData( IteratorGuard iteratorGuard(_spi, iteratorId, context); // Fetch all entries - std::vector<spi::DocEntry::LP> entries; + std::vector<spi::DocEntry::UP> entries; entries.reserve(slots.size()); bool fetchedAllLocalData = false; bool chunkLimitReached = false; @@ -459,19 +458,20 @@ MergeHandler::fetchLocalData( << result.getErrorMessage(); throw std::runtime_error(ss.str()); } - for (size_t i = 0; i < result.getEntries().size(); ++i) { - if (result.getEntries()[i]->getSize() <= remainingSize + auto list = result.steal_entries(); + for (size_t i = 0; i < list.size(); ++i) { + if (list[i]->getSize() <= remainingSize || (entries.empty() && alreadyFilled == 0)) { - entries.push_back(result.getEntries()[i]); - remainingSize -= result.getEntries()[i]->getSize(); + remainingSize -= list[i]->getSize(); LOG(spam, "Added %s, remainingSize is %u", entries.back()->toString().c_str(), remainingSize); + entries.push_back(std::move(list[i])); } else { LOG(spam, "Adding %s would exceed chunk size limit of %u; " "not filling up any more diffs for current round", - result.getEntries()[i]->toString().c_str(), _maxChunkSize); + list[i]->toString().c_str(), _maxChunkSize); chunkLimitReached = true; break; } @@ -610,7 +610,7 @@ MergeHandler::applyDiffLocally( uint32_t addedCount = 0; uint32_t notNeededByteCount = 0; - std::vector<spi::DocEntry::LP> entries; + std::vector<spi::DocEntry::UP> entries; populateMetaData(bucket, MAX_TIMESTAMP, entries, context); FlushGuard flushGuard(_spi, bucket, context); diff --git a/storage/src/vespa/storage/persistence/mergehandler.h b/storage/src/vespa/storage/persistence/mergehandler.h index f23dbe0c9b7..812f9d83907 100644 --- a/storage/src/vespa/storage/persistence/mergehandler.h +++ b/storage/src/vespa/storage/persistence/mergehandler.h @@ -91,7 +91,7 @@ private: */ void populateMetaData(const spi::Bucket&, Timestamp maxTimestamp, - std::vector<spi::DocEntry::LP>& entries, + std::vector<spi::DocEntry::UP>& entries, spi::Context& context); Document::UP deserializeDiffDocument( diff --git a/storage/src/vespa/storage/persistence/messages.h b/storage/src/vespa/storage/persistence/messages.h index 75655198fca..aad2d1bedce 100644 --- a/storage/src/vespa/storage/persistence/messages.h +++ b/storage/src/vespa/storage/persistence/messages.h @@ -53,7 +53,7 @@ class GetIterReply : public api::InternalReply { private: framework::MemoryToken::UP _token; document::BucketId _bucketId; - std::vector<spi::DocEntry::LP> _entries; + std::vector<spi::DocEntry::UP> _entries; bool _completed; public: @@ -69,11 +69,11 @@ public: return _bucketId; } - const std::vector<spi::DocEntry::LP>& getEntries() const { + const std::vector<spi::DocEntry::UP>& getEntries() const { return _entries; } - std::vector<spi::DocEntry::LP>& getEntries() { + std::vector<spi::DocEntry::UP>& getEntries() { return _entries; } diff --git a/storage/src/vespa/storage/persistence/persistencethread.cpp b/storage/src/vespa/storage/persistence/persistencethread.cpp index f0ff2bafdb2..b2848ed3712 100644 --- a/storage/src/vespa/storage/persistence/persistencethread.cpp +++ b/storage/src/vespa/storage/persistence/persistencethread.cpp @@ -443,7 +443,7 @@ PersistenceThread::handleGetIter(GetIterCommand& cmd) cmd.getMaxByteSize(), _context)); if (checkForError(result, *tracker)) { GetIterReply::SP reply(new GetIterReply(cmd)); - reply->getEntries() = result.getEntries(); + reply->getEntries() = result.steal_entries(); _env._metrics.visit[cmd.getLoadType()]. documentsPerIterate.addValue(reply->getEntries().size()); if (result.isCompleted()) { @@ -1120,7 +1120,7 @@ bool hasBucketInfo(const api::StorageMessage& msg) void PersistenceThread::flushAllReplies( const document::BucketId& bucketId, - std::vector<vespalib::LinkedPtr<MessageTracker> >& replies) + std::vector<std::unique_ptr<MessageTracker> >& replies) { if (replies.empty()) { return; @@ -1184,7 +1184,7 @@ PersistenceThread::flushAllReplies( void PersistenceThread::processMessages(FileStorHandler::LockedMessage & lock) { - std::vector<MessageTracker::LP> trackers; + std::vector<MessageTracker::UP> trackers; document::BucketId bucketId = lock.first->getBucketId(); while (lock.second.get() != 0) { @@ -1215,7 +1215,7 @@ void PersistenceThread::processMessages(FileStorHandler::LockedMessage & lock) tracker->getReply()->toString().c_str(), bucketId.toString().c_str()); - trackers.push_back(MessageTracker::LP(tracker.release())); + trackers.push_back(MessageTracker::UP(tracker.release())); if (trackers.back()->getReply()->getResult().success()) { _env._fileStorHandler.getNextMessage( diff --git a/storage/src/vespa/storage/persistence/persistencethread.h b/storage/src/vespa/storage/persistence/persistencethread.h index 032bc586342..89658b5041e 100644 --- a/storage/src/vespa/storage/persistence/persistencethread.h +++ b/storage/src/vespa/storage/persistence/persistencethread.h @@ -106,7 +106,7 @@ private: spi::Bucket getBucket(const DocumentId& id, const BucketId& bucket) const; void flushAllReplies(const document::BucketId& bucketId, - std::vector<MessageTracker::LP>& trackers); + std::vector<MessageTracker::UP>& trackers); friend class TestAndSetHelper; bool tasConditionExists(const api::TestAndSetCommand & cmd); diff --git a/storage/src/vespa/storage/persistence/persistenceutil.h b/storage/src/vespa/storage/persistence/persistenceutil.h index ed4812b3505..c917d4d0149 100644 --- a/storage/src/vespa/storage/persistence/persistenceutil.h +++ b/storage/src/vespa/storage/persistence/persistenceutil.h @@ -17,7 +17,6 @@ namespace storage { class MessageTracker : protected Types { public: - typedef vespalib::LinkedPtr<MessageTracker> LP; typedef std::unique_ptr<MessageTracker> UP; MessageTracker(FileStorThreadMetrics::Op& metric, diff --git a/storage/src/vespa/storage/persistence/types.h b/storage/src/vespa/storage/persistence/types.h index 747b9fbd074..de31145f27b 100644 --- a/storage/src/vespa/storage/persistence/types.h +++ b/storage/src/vespa/storage/persistence/types.h @@ -17,7 +17,6 @@ namespace storage { struct Types { typedef document::BucketId BucketId; typedef document::Document Document; - typedef vespalib::LinkedPtr<Document> DocLP; typedef document::DocumentId DocumentId; typedef document::GlobalId GlobalId; typedef framework::MicroSecTime Timestamp; diff --git a/storage/src/vespa/storage/visiting/countvisitor.cpp b/storage/src/vespa/storage/visiting/countvisitor.cpp index 4c1a082893c..c3dd7cc4995 100644 --- a/storage/src/vespa/storage/visiting/countvisitor.cpp +++ b/storage/src/vespa/storage/visiting/countvisitor.cpp @@ -23,7 +23,7 @@ CountVisitor::CountVisitor(StorageComponent& component, void CountVisitor::handleDocuments(const document::BucketId& /*bucketId*/, - std::vector<spi::DocEntry::LP>& entries, + std::vector<spi::DocEntry::UP>& entries, HitCounter& hitCounter) { for (size_t i = 0; i < entries.size(); ++i) { diff --git a/storage/src/vespa/storage/visiting/countvisitor.h b/storage/src/vespa/storage/visiting/countvisitor.h index c2b85c35419..75e0e866553 100644 --- a/storage/src/vespa/storage/visiting/countvisitor.h +++ b/storage/src/vespa/storage/visiting/countvisitor.h @@ -22,7 +22,7 @@ public: private: void handleDocuments(const document::BucketId& bucketId, - std::vector<spi::DocEntry::LP>& entries, + std::vector<spi::DocEntry::UP>& entries, HitCounter& hitCounter); bool _doScheme; diff --git a/storage/src/vespa/storage/visiting/dumpvisitor.cpp b/storage/src/vespa/storage/visiting/dumpvisitor.cpp index 271217fb7e7..388f9dc5e19 100644 --- a/storage/src/vespa/storage/visiting/dumpvisitor.cpp +++ b/storage/src/vespa/storage/visiting/dumpvisitor.cpp @@ -69,7 +69,7 @@ DumpVisitor::createMultiOperation(const document::BucketId& bucketId, } void DumpVisitor::handleDocuments(const document::BucketId& bucketId, - std::vector<spi::DocEntry::LP>& entries, + std::vector<spi::DocEntry::UP>& entries, HitCounter& hitCounter) { LOG(debug, "Visitor %s handling block of %zu documents.", diff --git a/storage/src/vespa/storage/visiting/dumpvisitor.h b/storage/src/vespa/storage/visiting/dumpvisitor.h index c4572766a3e..0aa690ce3c0 100644 --- a/storage/src/vespa/storage/visiting/dumpvisitor.h +++ b/storage/src/vespa/storage/visiting/dumpvisitor.h @@ -26,7 +26,7 @@ private: const std::vector<const document::Document*>& docs); void handleDocuments(const document::BucketId& bucketId, - std::vector<spi::DocEntry::LP>& entries, + std::vector<spi::DocEntry::UP>& entries, HitCounter& hitCounter); std::unique_ptr<std::set<std::string> > _requestedFields; diff --git a/storage/src/vespa/storage/visiting/dumpvisitorsingle.cpp b/storage/src/vespa/storage/visiting/dumpvisitorsingle.cpp index a7712ee189f..a36ace1d427 100644 --- a/storage/src/vespa/storage/visiting/dumpvisitorsingle.cpp +++ b/storage/src/vespa/storage/visiting/dumpvisitorsingle.cpp @@ -20,7 +20,7 @@ DumpVisitorSingle::DumpVisitorSingle(StorageComponent& component, } void DumpVisitorSingle::handleDocuments(const document::BucketId& /*bucketId*/, - std::vector<spi::DocEntry::LP>& entries, + std::vector<spi::DocEntry::UP>& entries, HitCounter& hitCounter) { LOG(debug, "Visitor %s handling block of %zu documents.", diff --git a/storage/src/vespa/storage/visiting/dumpvisitorsingle.h b/storage/src/vespa/storage/visiting/dumpvisitorsingle.h index f7b3fe66b88..eab10ad2653 100644 --- a/storage/src/vespa/storage/visiting/dumpvisitorsingle.h +++ b/storage/src/vespa/storage/visiting/dumpvisitorsingle.h @@ -20,7 +20,7 @@ public: private: void handleDocuments(const document::BucketId&, - std::vector<spi::DocEntry::LP>&, + std::vector<spi::DocEntry::UP>&, HitCounter&); }; diff --git a/storage/src/vespa/storage/visiting/recoveryvisitor.cpp b/storage/src/vespa/storage/visiting/recoveryvisitor.cpp index b6fcc0a97c8..9ae18d7b05d 100644 --- a/storage/src/vespa/storage/visiting/recoveryvisitor.cpp +++ b/storage/src/vespa/storage/visiting/recoveryvisitor.cpp @@ -30,7 +30,7 @@ RecoveryVisitor::RecoveryVisitor(StorageComponent& component, void RecoveryVisitor::handleDocuments(const document::BucketId& bid, - std::vector<spi::DocEntry::LP>& entries, + std::vector<spi::DocEntry::UP>& entries, HitCounter& hitCounter) { vespalib::LockGuard guard(_mutex); @@ -46,7 +46,7 @@ RecoveryVisitor::handleDocuments(const document::BucketId& bid, if (iter == _activeCommands.end()) { CommandPtr ptr(new documentapi::DocumentListMessage(bid)); cmd = ptr.get(); - _activeCommands[bid] = ptr; + _activeCommands[bid] = std::move(ptr); } else { cmd = iter->second.get(); } diff --git a/storage/src/vespa/storage/visiting/recoveryvisitor.h b/storage/src/vespa/storage/visiting/recoveryvisitor.h index b2771c2c64c..b8c64e7d0fd 100644 --- a/storage/src/vespa/storage/visiting/recoveryvisitor.h +++ b/storage/src/vespa/storage/visiting/recoveryvisitor.h @@ -25,15 +25,15 @@ public: private: void handleDocuments(const document::BucketId& bucketId, - std::vector<spi::DocEntry::LP>& entries, + std::vector<spi::DocEntry::UP>& entries, HitCounter& hitCounter); void completedBucket(const document::BucketId&, HitCounter&); std::set<std::string> _requestedFields; - typedef vespalib::LinkedPtr<documentapi::DocumentListMessage> CommandPtr; - typedef std::map<document::BucketId, CommandPtr> CommandMap; + using CommandPtr = std::unique_ptr<documentapi::DocumentListMessage>; + using CommandMap = std::map<document::BucketId, CommandPtr>; CommandMap _activeCommands; vespalib::Lock _mutex; diff --git a/storage/src/vespa/storage/visiting/testvisitor.cpp b/storage/src/vespa/storage/visiting/testvisitor.cpp index 5b02ac1271a..07b97b505c1 100644 --- a/storage/src/vespa/storage/visiting/testvisitor.cpp +++ b/storage/src/vespa/storage/visiting/testvisitor.cpp @@ -44,7 +44,7 @@ TestVisitor::startingVisitor(const std::vector<document::BucketId>& buckets) void TestVisitor::handleDocuments(const document::BucketId& /*bucketId*/, - std::vector<spi::DocEntry::LP>& entries, + std::vector<spi::DocEntry::UP>& entries, HitCounter& /*hitCounter*/) { std::ostringstream ost; diff --git a/storage/src/vespa/storage/visiting/testvisitor.h b/storage/src/vespa/storage/visiting/testvisitor.h index 5b32ec62906..9d4bb498ae0 100644 --- a/storage/src/vespa/storage/visiting/testvisitor.h +++ b/storage/src/vespa/storage/visiting/testvisitor.h @@ -20,7 +20,7 @@ private: void startingVisitor(const std::vector<document::BucketId>& buckets); void handleDocuments(const document::BucketId& bucketId, - std::vector<spi::DocEntry::LP>& entries, + std::vector<spi::DocEntry::UP>& entries, HitCounter& hitCounter); void completedBucket(const document::BucketId& bucket, HitCounter& hitCounter); diff --git a/storage/src/vespa/storage/visiting/visitor.h b/storage/src/vespa/storage/visiting/visitor.h index 87b894a6d2c..a392374ed5d 100644 --- a/storage/src/vespa/storage/visiting/visitor.h +++ b/storage/src/vespa/storage/visiting/visitor.h @@ -404,7 +404,7 @@ public: * vector of documents arrive from the persistence layer. */ virtual void handleDocuments(const document::BucketId&, - std::vector<spi::DocEntry::LP>& entries, + std::vector<spi::DocEntry::UP>& entries, HitCounter& hitCounter) = 0; /** |