From 23abed1a0bc4f4c5ea47b43fc7ea0645e63a26e6 Mon Sep 17 00:00:00 2001 From: Haavard Date: Mon, 20 Mar 2017 13:04:33 +0000 Subject: remove most usage of LinkedPtr from vespa --- config/src/vespa/config/common/configrequest.h | 6 -- configd/src/apps/sentinel/config-handler.cpp | 59 ++++++++----------- configd/src/apps/sentinel/config-handler.h | 7 +-- configd/src/apps/sentinel/service.h | 3 +- .../src/vespa/document/update/fieldpathupdate.h | 2 - .../src/vespa/documentapi/loadtypes/loadtype.h | 3 +- .../src/tests/device/devicemanagertest.cpp | 4 +- .../src/tests/device/devicestest.cpp | 10 ++-- .../src/tests/device/mountpointlisttest.cpp | 11 ++-- .../src/tests/init/filescannertest.cpp | 2 +- .../src/tests/spi/iteratorhandlertest.cpp | 38 +++++-------- .../src/tests/spi/simplememfileiobuffertest.cpp | 4 +- .../src/tests/tools/vdsdisktooltest.cpp | 5 +- .../memfilepersistence/common/environment.cpp | 4 +- .../src/vespa/memfilepersistence/common/types.h | 1 - .../memfilepersistence/device/devicemanager.cpp | 36 ++++++------ .../memfilepersistence/device/devicemanager.h | 20 +++---- .../vespa/memfilepersistence/device/directory.h | 4 +- .../src/vespa/memfilepersistence/device/disk.h | 3 +- .../memfilepersistence/device/mountpointlist.cpp | 22 ++++---- .../memfilepersistence/device/mountpointlist.h | 7 +-- .../vespa/memfilepersistence/device/partition.h | 6 +- .../memfilepersistence/device/partitionmonitor.h | 3 +- .../vespa/memfilepersistence/init/filescanner.cpp | 2 +- .../src/vespa/memfilepersistence/mapper/buffer.h | 3 +- .../mapper/memfile_v1_serializer.h | 2 +- .../memfilepersistence/mapper/memfilemapper.cpp | 16 +++--- .../memfilepersistence/mapper/memfilemapper.h | 4 +- .../mapper/simplememfileiobuffer.cpp | 20 +++---- .../mapper/simplememfileiobuffer.h | 20 +++---- .../memfilepersistence/mapper/versionserializer.h | 3 +- .../memfilepersistence/memfile/memfilecache.cpp | 6 +- .../memfilepersistence/memfile/memfilecache.h | 8 +-- .../vespa/memfilepersistence/memfile/memfileptr.h | 8 +-- .../src/vespa/memfilepersistence/memfile/memslot.h | 2 +- .../memfilepersistence/spi/iteratorhandler.cpp | 22 ++++---- .../vespa/memfilepersistence/spi/iteratorhandler.h | 14 ++--- .../memfilepersistence/tools/dumpslotfile.cpp | 2 +- .../vespa/memfilepersistence/tools/vdsdisktool.cpp | 4 +- .../src/vespa/messagebus/network/rpcservice.h | 3 +- .../vespa/messagebus/network/rpcservicepool.cpp | 7 ++- .../src/vespa/messagebus/network/rpcservicepool.h | 2 +- metrics/src/tests/loadmetrictest.cpp | 6 +- metrics/src/tests/metricsettest.cpp | 2 +- metrics/src/tests/snapshottest.cpp | 8 +-- metrics/src/tests/stresstest.cpp | 10 ++-- metrics/src/tests/valuemetrictest.cpp | 2 +- metrics/src/vespa/metrics/countmetric.h | 4 +- metrics/src/vespa/metrics/countmetric.hpp | 2 +- metrics/src/vespa/metrics/loadmetric.h | 8 +-- metrics/src/vespa/metrics/loadmetric.hpp | 18 +++--- metrics/src/vespa/metrics/metric.cpp | 2 +- metrics/src/vespa/metrics/metric.h | 16 +----- metrics/src/vespa/metrics/metricset.cpp | 12 ++-- metrics/src/vespa/metrics/metricset.h | 9 +-- metrics/src/vespa/metrics/metricsnapshot.cpp | 6 +- metrics/src/vespa/metrics/metricsnapshot.h | 2 +- metrics/src/vespa/metrics/printutils.cpp | 2 +- metrics/src/vespa/metrics/summetric.h | 12 ++-- metrics/src/vespa/metrics/summetric.hpp | 30 +++++----- metrics/src/vespa/metrics/updatehook.h | 3 +- metrics/src/vespa/metrics/valuemetric.h | 4 +- metrics/src/vespa/metrics/valuemetric.hpp | 2 +- .../spi/conformance/ConformanceTest.java | 4 +- .../src/tests/dummyimpl/dummypersistence_test.cpp | 6 +- persistence/src/tests/proxy/mockprovider.h | 4 +- .../conformancetest/conformancetest.cpp | 51 ++++++++--------- .../persistence/dummyimpl/dummypersistence.cpp | 66 +++++++++++----------- .../vespa/persistence/dummyimpl/dummypersistence.h | 22 ++++---- .../src/vespa/persistence/proxy/providerproxy.cpp | 6 +- .../src/vespa/persistence/proxy/providerstub.cpp | 2 +- persistence/src/vespa/persistence/spi/docentry.h | 5 +- persistence/src/vespa/persistence/spi/result.h | 10 +++- .../src/vespa/searchcommon/common/iblobconverter.h | 2 - .../documentdb/feedhandler/feedhandler_test.cpp | 2 +- .../storeonlyfeedview/storeonlyfeedview_test.cpp | 2 +- .../metrics/metrics_engine/metrics_engine_test.cpp | 12 ++-- .../proton_config_fetcher_test.cpp | 2 - .../server/legacy_attribute_metrics_test.cpp | 36 ++++++------ .../vespa/searchcore/grouping/groupingsession.h | 1 - .../proton/feedoperation/lidvectorcontext.h | 3 +- .../pruneremoveddocumentsoperation.cpp | 4 +- .../feedoperation/pruneremoveddocumentsoperation.h | 4 +- .../feedoperation/removedocumentsoperation.cpp | 2 +- .../feedoperation/removedocumentsoperation.h | 8 +-- .../searchcore/proton/matching/match_master.cpp | 2 +- .../searchcore/proton/matching/match_thread.h | 1 + .../searchcore/proton/matching/partial_result.h | 5 +- .../proton/matching/result_processor.cpp | 16 ++---- .../searchcore/proton/matching/result_processor.h | 9 ++- .../searchcore/proton/matching/sessionmanager.cpp | 18 +++--- .../proton/metrics/legacy_attribute_metrics.cpp | 35 ++++++------ .../proton/metrics/legacy_attribute_metrics.h | 13 ++--- .../proton/metrics/legacy_documentdb_metrics.cpp | 2 +- .../proton/metrics/legacy_documentdb_metrics.h | 9 ++- .../searchcore/proton/metrics/metrics_engine.cpp | 11 ++-- .../proton/persistenceengine/document_iterator.cpp | 7 +-- .../searchcore/proton/server/docstorevalidator.cpp | 4 +- .../searchcore/proton/server/docstorevalidator.h | 2 +- .../vespa/searchcore/proton/server/documentdb.cpp | 4 +- .../vespa/searchcore/proton/server/feedhandler.cpp | 2 +- .../proton/server/pruneremoveddocumentsjob.cpp | 2 +- .../searchcore/proton/server/storeonlyfeedview.cpp | 4 +- searchlib/src/vespa/searchlib/fef/simpletermdata.h | 1 + .../src/vespa/searchlib/uca/ucafunctionnode.h | 2 +- .../src/vespa/vespalib/stllike/lrucache_map.h | 7 +++ .../src/vespa/vespalib/stllike/lrucache_map.hpp | 10 ++++ storage/src/tests/distributor/mergelimitertest.cpp | 3 +- .../src/tests/persistence/persistencetestutils.cpp | 2 +- .../src/tests/persistence/persistencetestutils.h | 2 +- .../src/tests/persistence/splitbitdetectortest.cpp | 16 +++--- .../storageserver/testvisitormessagesession.cpp | 2 +- .../storageserver/testvisitormessagesession.h | 2 +- storage/src/tests/visiting/visitortest.cpp | 8 +-- storage/src/vespa/storage/bucketdb/lockablemap.h | 3 +- .../bucketdb/storagebucketdbinitializer.cpp | 4 +- .../storage/bucketdb/storagebucketdbinitializer.h | 2 +- storage/src/vespa/storage/bucketmover/run.h | 1 - .../vespa/storage/bucketmover/runstatistics.cpp | 1 - .../src/vespa/storage/bucketmover/runstatistics.h | 4 +- .../storage/common/hostreporter/cpureporter.cpp | 1 - .../vespa/storage/common/hostreporter/hostinfo.h | 1 - .../maintenance/bucketprioritydatabase.h | 9 +-- .../operations/idealstate/idealstateoperation.h | 1 - .../operations/idealstate/mergeoperation.cpp | 4 +- .../persistence_operation_metric_set.cpp | 4 +- .../distributor/persistence_operation_metric_set.h | 4 +- .../src/vespa/storage/distributor/statechecker.cpp | 4 +- .../src/vespa/storage/distributor/statechecker.h | 7 +-- .../storage/distributor/visitormetricsset.cpp | 2 +- .../vespa/storage/distributor/visitormetricsset.h | 2 +- .../persistence/filestorage/filestormanager.cpp | 2 +- .../persistence/filestorage/filestormetrics.cpp | 8 +-- .../persistence/filestorage/filestormetrics.h | 8 +-- .../src/vespa/storage/persistence/mergehandler.cpp | 30 +++++----- .../src/vespa/storage/persistence/mergehandler.h | 2 +- storage/src/vespa/storage/persistence/messages.h | 6 +- .../storage/persistence/persistencethread.cpp | 8 +-- .../vespa/storage/persistence/persistencethread.h | 2 +- .../vespa/storage/persistence/persistenceutil.h | 1 - storage/src/vespa/storage/persistence/types.h | 1 - .../src/vespa/storage/visiting/countvisitor.cpp | 2 +- storage/src/vespa/storage/visiting/countvisitor.h | 2 +- storage/src/vespa/storage/visiting/dumpvisitor.cpp | 2 +- storage/src/vespa/storage/visiting/dumpvisitor.h | 2 +- .../vespa/storage/visiting/dumpvisitorsingle.cpp | 2 +- .../src/vespa/storage/visiting/dumpvisitorsingle.h | 2 +- .../src/vespa/storage/visiting/recoveryvisitor.cpp | 4 +- .../src/vespa/storage/visiting/recoveryvisitor.h | 6 +- storage/src/vespa/storage/visiting/testvisitor.cpp | 2 +- storage/src/vespa/storage/visiting/testvisitor.h | 2 +- storage/src/vespa/storage/visiting/visitor.h | 2 +- storageapi/src/vespa/storageapi/message/batch.cpp | 6 +- storageapi/src/vespa/storageapi/message/batch.h | 2 +- .../src/tests/memory/memorymanagertest.cpp | 6 +- .../component/componentregisterimpl.cpp | 4 +- .../component/componentregisterimpl.h | 2 +- .../defaultimplementation/memory/memorymanager.cpp | 6 +- .../defaultimplementation/memory/memorymanager.h | 2 +- .../memory/nomemorymanager.cpp | 6 +- .../defaultimplementation/memory/nomemorymanager.h | 2 +- .../generic/memory/memoryallocationtype.h | 4 +- .../generic/thread/tickingthread.cpp | 4 +- .../generic/thread/tickingthread.h | 5 +- storageserver/src/tests/storageservertest.cpp | 11 ++-- .../src/tests/searchvisitor/searchvisitor.cpp | 10 ++-- .../src/vespa/searchvisitor/searchenvironment.cpp | 2 +- .../src/vespa/searchvisitor/searchenvironment.h | 4 +- .../src/vespa/searchvisitor/searchvisitor.cpp | 2 +- .../src/vespa/searchvisitor/searchvisitor.h | 2 +- 170 files changed, 590 insertions(+), 663 deletions(-) diff --git a/config/src/vespa/config/common/configrequest.h b/config/src/vespa/config/common/configrequest.h index 94d9aa352a2..0eac663de87 100644 --- a/config/src/vespa/config/common/configrequest.h +++ b/config/src/vespa/config/common/configrequest.h @@ -3,11 +3,6 @@ #include -namespace vespalib { - template - class LinkedPtr; -} - namespace config { class ConfigKey; @@ -25,7 +20,6 @@ private: ConfigRequest& operator=(const ConfigRequest&); public: - typedef vespalib::LinkedPtr LP; typedef std::unique_ptr UP; ConfigRequest() { } diff --git a/configd/src/apps/sentinel/config-handler.cpp b/configd/src/apps/sentinel/config-handler.cpp index dedcfc5595a..9ce4926357f 100644 --- a/configd/src/apps/sentinel/config-handler.cpp +++ b/configd/src/apps/sentinel/config-handler.cpp @@ -96,7 +96,7 @@ void ConfigHandler::terminateServices(bool catchable, bool printDebug) { for (ServiceMap::iterator it(_services.begin()), mt(_services.end()); it != mt; it++) { - Service::LP service = it->second; + Service *service = it->second.get(); if (printDebug && service->isRunning()) { LOG(info, "%s: killing", service->name().c_str()); } @@ -177,32 +177,17 @@ ConfigHandler::doConfigure() const vespalib::string name(serviceConfig.name); ServiceMap::iterator found(_services.find(name)); if (found == _services.end()) { - services[name] = Service::LP(new Service(serviceConfig, config.application, _outputConnections, _startMetrics)); + services[name] = Service::UP(new Service(serviceConfig, config.application, _outputConnections, _startMetrics)); } else { - services[name] = found->second; found->second->reconfigure(serviceConfig); + services[name] = std::move(found->second); } } - stopOldServicesNotInMap(services); _services.swap(services); vespalib::ComponentConfigProducer::Config current("sentinel", _subscriber.getGeneration(), "ok"); _stateApi.myComponents.addConfig(current); } -void -ConfigHandler::stopOldServicesNotInMap(const ServiceMap & newServices) -{ - for (ServiceMap::iterator it(_services.begin()), mt(_services.end()); it != mt; it++) { - const vespalib::string & key(it->first); - if (newServices.find(key) == newServices.end()) { - Service::LP service = it->second; - if (service->isRunning()) { - service->terminate(true); - } - } - } -} - int ConfigHandler::doWork() @@ -237,8 +222,8 @@ ConfigHandler::handleChildDeaths() pid_t pid; while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { // A child process has exited. find it. - Service::LP service = serviceByPid(pid); - if (service.get() != NULL) { + Service *service = serviceByPid(pid); + if (service != NULL) { LOG(debug, "pid %d finished, Service:%s", (int)pid, service->name().c_str()); service->youExited(status); @@ -348,26 +333,26 @@ ConfigHandler::handleCommands() _connections.erase(dst, _connections.end()); } -Service::LP +Service * ConfigHandler::serviceByPid(pid_t pid) { for (ServiceMap::iterator it(_services.begin()), mt(_services.end()); it != mt; it++) { - Service::LP service = it->second; + Service *service = it->second.get(); if (service->pid() == pid) { return service; } } - return Service::LP(NULL); + return NULL; } -Service::LP +Service * ConfigHandler::serviceByName(const vespalib::string & name) { ServiceMap::iterator found(_services.find(name)); if (found != _services.end()) { - return found->second; + return found->second.get(); } - return Service::LP(NULL); + return NULL; } @@ -475,7 +460,7 @@ void ConfigHandler::doLs(CommandConnection *c, char *args) { for (ServiceMap::iterator it(_services.begin()), mt(_services.end()); it != mt; it++) { - Service::LP service = it->second; + Service *service = it->second.get(); if (*args && strcmp(args, service->name().c_str()) != 0) { continue; } @@ -502,8 +487,8 @@ ConfigHandler::doQuit(CommandConnection *c, char *) void ConfigHandler::doStart(CommandConnection *c, char *args) { - Service::LP service = serviceByName(args); - if (service.get() == NULL) { + Service *service = serviceByName(args); + if (service == NULL) { c->printf("Cannot find any service named '%s'\n", args); return; } @@ -528,8 +513,8 @@ ConfigHandler::doRestart(CommandConnection *c, char *args) void ConfigHandler::doRestart(CommandConnection *c, char *args, bool force) { - Service::LP service = serviceByName(args); - if (service.get() == NULL) { + Service *service = serviceByName(args); + if (service == NULL) { c->printf("Cannot find any service named '%s'\n", args); return; } @@ -565,8 +550,8 @@ ConfigHandler::doStop(CommandConnection *c, char *args) void ConfigHandler::doStop(CommandConnection *c, char *args, bool force) { - Service::LP service = serviceByName(args); - if (service.get() == NULL) { + Service *service = serviceByName(args); + if (service == NULL) { c->printf("Cannot find any service named '%s'\n", args); return; } @@ -589,8 +574,8 @@ ConfigHandler::doStop(CommandConnection *c, char *args, bool force) void ConfigHandler::doAuto(CommandConnection *c, char *args) { - Service::LP service = serviceByName(args); - if (service.get() == NULL) { + Service *service = serviceByName(args); + if (service == NULL) { c->printf("Cannot find any service named '%s'\n", args); return; } @@ -615,8 +600,8 @@ ConfigHandler::doAuto(CommandConnection *c, char *args) void ConfigHandler::doManual(CommandConnection *c, char *args) { - Service::LP service = serviceByName(args); - if (service.get() == NULL) { + Service *service = serviceByName(args); + if (service == NULL) { c->printf("Cannot find any service named '%s'\n", args); return; } diff --git a/configd/src/apps/sentinel/config-handler.h b/configd/src/apps/sentinel/config-handler.h index ffd5af7ef4c..2656a8df571 100644 --- a/configd/src/apps/sentinel/config-handler.h +++ b/configd/src/apps/sentinel/config-handler.h @@ -26,7 +26,7 @@ class OutputConnection; class ConfigHandler { private: - typedef std::map ServiceMap; + typedef std::map ServiceMap; ConfigSubscriber _subscriber; ConfigHandle::UP _sentinelHandle; @@ -41,8 +41,8 @@ private: ConfigHandler(const ConfigHandler&); ConfigHandler& operator =(const ConfigHandler&); - Service::LP serviceByPid(pid_t pid); - Service::LP serviceByName(const vespalib::string & name); + Service *serviceByPid(pid_t pid); + Service *serviceByName(const vespalib::string & name); void handleCommands(); void handleCommand(CommandConnection *c); void handleOutputs(); @@ -65,7 +65,6 @@ private: void doQuit(CommandConnection *c, char *args); void terminateServices(bool catchable, bool printDebug = false); - void stopOldServicesNotInMap(const ServiceMap & newServices); void doConfigure(); diff --git a/configd/src/apps/sentinel/service.h b/configd/src/apps/sentinel/service.h index 0021221b17e..ad391d3680f 100644 --- a/configd/src/apps/sentinel/service.h +++ b/configd/src/apps/sentinel/service.h @@ -1,7 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include #include #include #include @@ -46,7 +45,7 @@ private: StartMetrics &_metrics; public: - typedef vespalib::LinkedPtr LP; + using UP = std::unique_ptr; ~Service(); Service(const SentinelConfig::Service& config, const SentinelConfig::Application& application, diff --git a/document/src/vespa/document/update/fieldpathupdate.h b/document/src/vespa/document/update/fieldpathupdate.h index 9424ed9c54f..c083e17197e 100644 --- a/document/src/vespa/document/update/fieldpathupdate.h +++ b/document/src/vespa/document/update/fieldpathupdate.h @@ -111,8 +111,6 @@ private: vespalib::string _originalFieldPath; vespalib::string _originalWhereClause; - // TODO: replace these with LinkedPtr? Need to verify updates cannot - // be shared between threads first vespalib::CloneablePtr _fieldPath; std::shared_ptr _whereClause; }; diff --git a/documentapi/src/vespa/documentapi/loadtypes/loadtype.h b/documentapi/src/vespa/documentapi/loadtypes/loadtype.h index 15d9c6f528b..6916c62416b 100644 --- a/documentapi/src/vespa/documentapi/loadtypes/loadtype.h +++ b/documentapi/src/vespa/documentapi/loadtypes/loadtype.h @@ -14,7 +14,6 @@ #pragma once #include -#include #include namespace vespalib { @@ -28,7 +27,7 @@ class LoadType : public metrics::LoadType { Priority::Value _priority; public: - typedef vespalib::LinkedPtr LP; + using UP = std::unique_ptr; LoadType(uint32_t id, const string& name, Priority::Value priority) : metrics::LoadType(id, name), _priority(priority) {} diff --git a/memfilepersistence/src/tests/device/devicemanagertest.cpp b/memfilepersistence/src/tests/device/devicemanagertest.cpp index eeb5007f452..7e26543349b 100644 --- a/memfilepersistence/src/tests/device/devicemanagertest.cpp +++ b/memfilepersistence/src/tests/device/devicemanagertest.cpp @@ -94,7 +94,7 @@ void DeviceManagerTest::testEventSending() DeviceManager manager(DeviceMapper::UP(new SimpleDeviceMapper), _clock); Listener l; manager.addIOEventListener(l); - Directory::LP dir(manager.getDirectory("/home/foo/var", 0)); + Directory::SP dir(manager.getDirectory("/home/foo/var", 0)); // IO failures are disk events. Will mark all partitions and // directories on that disk bad dir->addEvent(IOEvent::createEventFromErrno(1, EIO, "/home/foo/var/foo")); @@ -117,7 +117,7 @@ void DeviceManagerTest::testEventSending() void DeviceManagerTest::testXml() { DeviceManager manager(DeviceMapper::UP(new SimpleDeviceMapper), _clock); - Directory::LP dir(manager.getDirectory("/home/", 0)); + Directory::SP dir(manager.getDirectory("/home/", 0)); dir->getPartition().initializeMonitor(); std::string xml = manager.toXml(" "); CPPUNIT_ASSERT_MSG(xml, diff --git a/memfilepersistence/src/tests/device/devicestest.cpp b/memfilepersistence/src/tests/device/devicestest.cpp index bd6898cb7ac..8bcc93e5fc9 100644 --- a/memfilepersistence/src/tests/device/devicestest.cpp +++ b/memfilepersistence/src/tests/device/devicestest.cpp @@ -31,11 +31,11 @@ CPPUNIT_TEST_SUITE_REGISTRATION(DevicesTest); void DevicesTest::testDisk() { DeviceManager manager(DeviceMapper::UP(new SimpleDeviceMapper), _clock); - Disk::LP disk1(manager.getDisk("/something/on/disk")); - Disk::LP disk2(manager.getDisk("/something/on/disk")); + Disk::SP disk1(manager.getDisk("/something/on/disk")); + Disk::SP disk2(manager.getDisk("/something/on/disk")); CPPUNIT_ASSERT_EQUAL(disk1->getId(), disk2->getId()); CPPUNIT_ASSERT_EQUAL(disk1.get(), disk2.get()); - Disk::LP disk3(manager.getDisk("/something/on/disk2")); + Disk::SP disk3(manager.getDisk("/something/on/disk2")); CPPUNIT_ASSERT(disk2->getId() != disk3->getId()); disk3->toString(); // Add code coverage } @@ -43,7 +43,7 @@ void DevicesTest::testDisk() void DevicesTest::testPartition() { DeviceManager manager(DeviceMapper::UP(new SimpleDeviceMapper), _clock); - Partition::LP part(manager.getPartition("/etc")); + Partition::SP part(manager.getPartition("/etc")); CPPUNIT_ASSERT_EQUAL(std::string("/etc"), part->getMountPoint()); part->toString(); // Add code coverage } @@ -51,7 +51,7 @@ void DevicesTest::testPartition() void DevicesTest::testDirectory() { DeviceManager manager(DeviceMapper::UP(new SimpleDeviceMapper), _clock); - Directory::LP dir1(manager.getDirectory("/on/disk", 0)); + Directory::SP dir1(manager.getDirectory("/on/disk", 0)); CPPUNIT_ASSERT_EQUAL(std::string("/on/disk"), dir1->getPath()); CPPUNIT_ASSERT(dir1->getLastEvent() == 0); CPPUNIT_ASSERT_EQUAL(Device::OK, dir1->getState()); diff --git a/memfilepersistence/src/tests/device/mountpointlisttest.cpp b/memfilepersistence/src/tests/device/mountpointlisttest.cpp index 4cb5822ceb7..aaeff981af8 100644 --- a/memfilepersistence/src/tests/device/mountpointlisttest.cpp +++ b/memfilepersistence/src/tests/device/mountpointlisttest.cpp @@ -7,7 +7,6 @@ #include #include -using vespalib::LinkedPtr; using vespalib::fileExists; using vespalib::isDirectory; using vespalib::isSymLink; @@ -37,8 +36,8 @@ public: framework::defaultimplementation::FakeClock _clock; private: - LinkedPtr newDeviceManager() { - return LinkedPtr( + DeviceManager::UP newDeviceManager() { + return DeviceManager::UP( new DeviceManager( DeviceMapper::UP(new SimpleDeviceMapper), _clock)); @@ -88,7 +87,7 @@ void MountPointList_Test::testScanning() init(); MountPointList list(_prefix, std::vector(), - vespalib::LinkedPtr( + DeviceManager::UP( new DeviceManager( DeviceMapper::UP(new SimpleDeviceMapper), _clock))); @@ -133,7 +132,7 @@ void MountPointList_Test::testStatusFile() { MountPointList list(_prefix, std::vector(), - vespalib::LinkedPtr( + DeviceManager::UP( new DeviceManager( DeviceMapper::UP(new SimpleDeviceMapper), _clock))); @@ -195,7 +194,7 @@ void MountPointList_Test::testStatusFile() { MountPointList list(_prefix, std::vector(), - vespalib::LinkedPtr( + DeviceManager::UP( new DeviceManager( DeviceMapper::UP(new SimpleDeviceMapper), _clock))); diff --git a/memfilepersistence/src/tests/init/filescannertest.cpp b/memfilepersistence/src/tests/init/filescannertest.cpp index 8b49a21dad0..2a69804a295 100644 --- a/memfilepersistence/src/tests/init/filescannertest.cpp +++ b/memfilepersistence/src/tests/init/filescannertest.cpp @@ -375,7 +375,7 @@ FileScannerTest::runTest(const TestParameters& params) MountPointList mountPoints("./vdsroot", std::vector(), - vespalib::LinkedPtr( + DeviceManager::UP( new DeviceManager( DeviceMapper::UP(new SimpleDeviceMapper), clock))); diff --git a/memfilepersistence/src/tests/spi/iteratorhandlertest.cpp b/memfilepersistence/src/tests/spi/iteratorhandlertest.cpp index 5b622987e73..6fb2a8393be 100644 --- a/memfilepersistence/src/tests/spi/iteratorhandlertest.cpp +++ b/memfilepersistence/src/tests/spi/iteratorhandlertest.cpp @@ -63,7 +63,7 @@ public: struct Chunk { - std::vector _entries; + std::vector _entries; }; private: @@ -144,18 +144,12 @@ IteratorHandlerTest::doIterate(spi::IteratorId id, std::vector chunks; while (true) { - std::vector entries; - spi::IterateResult result(getPersistenceProvider().iterate( id, maxByteSize, context)); CPPUNIT_ASSERT_EQUAL(spi::Result::NONE, result.getErrorCode()); CPPUNIT_ASSERT(result.getEntries().size() > 0 || allowEmptyResult); - for (size_t i = 0; i < result.getEntries().size(); ++i) { - entries.push_back(result.getEntries()[i]); - } - chunks.push_back(Chunk()); - chunks.back()._entries.swap(entries); + chunks.push_back(Chunk{std::move(result.steal_entries())}); if (result.isCompleted() || (maxChunks != 0 && chunks.size() >= maxChunks)) { @@ -178,7 +172,7 @@ getDocCount(const std::vector& chunks) } size_t -getRemoveEntryCount(const std::vector& entries) +getRemoveEntryCount(const std::vector& entries) { size_t ret = 0; for (size_t i = 0; i < entries.size(); ++i) { @@ -191,20 +185,20 @@ getRemoveEntryCount(const std::vector& entries) struct DocEntryIndirectTimestampComparator { - 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(); } }; -std::vector +std::vector getEntriesFromChunks(const std::vector& chunks) { - std::vector ret; + std::vector ret; for (size_t chunk = 0; chunk < chunks.size(); ++chunk) { for (size_t i = 0; i < chunks[chunk]._entries.size(); ++i) { - ret.push_back(chunks[chunk]._entries[i]); + ret.push_back(spi::DocEntry::UP(chunks[chunk]._entries[i]->clone())); } } std::sort(ret.begin(), @@ -233,7 +227,7 @@ IteratorHandlerTest::verifyDocs(const std::vector& wanted, const std::vector& chunks, const std::set& removes) const { - std::vector retrieved( + std::vector retrieved( getEntriesFromChunks(chunks)); size_t removeCount = getRemoveEntryCount(retrieved); // Ensure that we've got the correct number of puts and removes @@ -321,9 +315,7 @@ IteratorHandlerTest::testSomeSlotsRemovedBetweenInvocations() std::vector chunks2 = doIterate(iter.getIteratorId(), 10000); CPPUNIT_ASSERT_EQUAL(size_t(24), chunks2.size()); - std::copy(chunks2.begin(), - chunks2.end(), - std::back_insert_iterator >(chunks)); + std::move(chunks2.begin(), chunks2.end(), std::back_inserter(chunks)); verifyDocs(docs, chunks); @@ -393,7 +385,7 @@ IteratorHandlerTest::testIterateMetadataOnly() create(b, sel, spi::NEWEST_DOCUMENT_OR_REMOVE, document::NoFields())); std::vector chunks = doIterate(iter.getIteratorId(), 4096); - std::vector entries = getEntriesFromChunks(chunks); + std::vector entries = getEntriesFromChunks(chunks); CPPUNIT_ASSERT_EQUAL(docs.size(), entries.size()); std::vector::const_iterator docIter( docs.begin()); @@ -495,9 +487,7 @@ IteratorHandlerTest::testDocumentsRemovedBetweenInvocations() std::vector chunks2 = doIterate(iter.getIteratorId(), 1); CPPUNIT_ASSERT_EQUAL(size_t(75), chunks2.size()); - std::copy(chunks2.begin(), - chunks2.end(), - std::back_insert_iterator >(chunks)); + std::move(chunks2.begin(), chunks2.end(), std::back_inserter(chunks)); verifyDocs(docs, chunks); @@ -539,7 +529,7 @@ IteratorHandlerTest::doTestUnrevertableRemoveBetweenInvocations(bool includeRemo flush(b.getBucketId()); std::vector chunks2 = doIterate(iter.getIteratorId(), 1); - std::vector entries = getEntriesFromChunks(chunks2); + std::vector entries = getEntriesFromChunks(chunks2); if (!includeRemoves) { CPPUNIT_ASSERT_EQUAL(nonRemovedDocs.size(), chunks2.size()); verifyDocs(nonRemovedDocs, chunks2); @@ -764,7 +754,7 @@ IteratorHandlerTest::testFieldSetFiltering() spi::CreateIteratorResult iter( create(b, sel, spi::NEWEST_DOCUMENT_ONLY, *repo.parse(*getTypeRepo(), "testdoctype1:hstringval,content"))); - std::vector entries( + std::vector entries( getEntriesFromChunks(doIterate(iter.getIteratorId(), 4096))); CPPUNIT_ASSERT_EQUAL(size_t(1), entries.size()); CPPUNIT_ASSERT_EQUAL(std::string("content: fancy content\n" diff --git a/memfilepersistence/src/tests/spi/simplememfileiobuffertest.cpp b/memfilepersistence/src/tests/spi/simplememfileiobuffertest.cpp index d7dc3354316..3eac7b57e81 100644 --- a/memfilepersistence/src/tests/spi/simplememfileiobuffertest.cpp +++ b/memfilepersistence/src/tests/spi/simplememfileiobuffertest.cpp @@ -31,13 +31,13 @@ class SimpleMemFileIOBufferTest : public SingleDiskMemFileTestUtils CPPUNIT_TEST_SUITE_END(); using BufferType = SimpleMemFileIOBuffer::BufferType; - using BufferLP = BufferType::LP; + using BufferSP = BufferType::SP; using BufferAllocation = SimpleMemFileIOBuffer::BufferAllocation; using HeaderChunkEncoder = SimpleMemFileIOBuffer::HeaderChunkEncoder; using SimpleMemFileIOBufferUP = std::unique_ptr; BufferAllocation allocateBuffer(size_t sz) { - return BufferAllocation(BufferLP(new BufferType(sz)), 0, sz); + return BufferAllocation(BufferSP(new BufferType(sz)), 0, sz); } /** diff --git a/memfilepersistence/src/tests/tools/vdsdisktooltest.cpp b/memfilepersistence/src/tests/tools/vdsdisktooltest.cpp index 29e780bc900..08bfa3bcab3 100644 --- a/memfilepersistence/src/tests/tools/vdsdisktooltest.cpp +++ b/memfilepersistence/src/tests/tools/vdsdisktooltest.cpp @@ -14,7 +14,6 @@ namespace memfile { struct VdsDiskToolTest : public SingleDiskMemFileTestUtils { framework::defaultimplementation::FakeClock _clock; - DeviceManager::LP _deviceManager; void setUp(); void setupRoot(); @@ -55,8 +54,6 @@ void VdsDiskToolTest::setUp() { system("rm -rf vdsroot"); - _deviceManager.reset(new DeviceManager( - DeviceMapper::UP(new SimpleDeviceMapper), _clock)); } void @@ -94,7 +91,7 @@ VdsDiskToolTest::testSimple() createDisk(1); MountPointList mountPoints("vdsroot/mycluster/storage/3", std::vector(), - _deviceManager); + std::make_unique(std::make_unique(), _clock)); mountPoints.scanForDisks(); CPPUNIT_ASSERT_EQUAL(2u, mountPoints.getSize()); mountPoints[1].addEvent(Device::IO_FAILURE, "Bad", "Found in test"); diff --git a/memfilepersistence/src/vespa/memfilepersistence/common/environment.cpp b/memfilepersistence/src/vespa/memfilepersistence/common/environment.cpp index ff4c91026f2..11577542573 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/common/environment.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/common/environment.cpp @@ -50,7 +50,7 @@ Environment::Environment(const config::ConfigUri & configUri, _devicesConfig(resolveConfig(configUri)), _options(std::make_shared(*_config, *_persistenceConfig)) { - DeviceManager::LP manager( + DeviceManager::UP manager( new DeviceManager(DeviceMapper::UP(new SimpleDeviceMapper()), _clock)); @@ -58,7 +58,7 @@ Environment::Environment(const config::ConfigUri & configUri, _devicesConfig->statfsPolicy, _devicesConfig->statfsPeriod); _mountPoints.reset(new MountPointList(_devicesConfig->rootFolder, _devicesConfig->diskPath, - manager)); + std::move(manager))); if (!ignoreDisks) { _mountPoints->init(0); diff --git a/memfilepersistence/src/vespa/memfilepersistence/common/types.h b/memfilepersistence/src/vespa/memfilepersistence/common/types.h index 283eb1153f4..58643275503 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/common/types.h +++ b/memfilepersistence/src/vespa/memfilepersistence/common/types.h @@ -76,7 +76,6 @@ std::ostream& operator<<(std::ostream&, const DataLocation&); struct Types { typedef document::BucketId BucketId; typedef document::Document Document; - typedef vespalib::LinkedPtr DocLP; typedef document::DocumentId DocumentId; typedef document::GlobalId GlobalId; typedef framework::MicroSecTime Timestamp; diff --git a/memfilepersistence/src/vespa/memfilepersistence/device/devicemanager.cpp b/memfilepersistence/src/vespa/memfilepersistence/device/devicemanager.cpp index d088f1dab46..9d77b84d4c6 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/device/devicemanager.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/device/devicemanager.cpp @@ -28,7 +28,7 @@ DeviceManager::setPartitionMonitorPolicy( { _statPolicy = policy; _statPeriod = period; - for (std::map::iterator it + for (std::map::iterator it = _partitions.begin(); it != _partitions.end(); ++it) { Partition& p(*it->second); @@ -80,26 +80,26 @@ DeviceManager::removeIOEventListener(IOEventListener& listener) _eventListeners.erase(&listener); } -Directory::LP +Directory::SP DeviceManager::getDirectory(const std::string& dir, uint16_t index) { - std::map::iterator it = + std::map::iterator it = _directories.find(dir); if (it != _directories.end()) { return it->second; } - Directory::LP d(new Directory(*this, index, dir)); + Directory::SP d(new Directory(*this, index, dir)); _directories[dir] = d; return d; } -Directory::LP +Directory::SP DeviceManager::deserializeDirectory(const std::string& serialized) { // Deserialize object - Directory::LP d(new Directory(serialized, *this)); + Directory::SP d(new Directory(serialized, *this)); // If not existing, just add it. - std::map::iterator it = + std::map::iterator it = _directories.find(d->getPath()); if (it == _directories.end()) { _directories[d->getPath()] = d; @@ -110,18 +110,18 @@ DeviceManager::deserializeDirectory(const std::string& serialized) return it->second; } -Partition::LP +Partition::SP DeviceManager::getPartition(const std::string& path) { try{ std::string mountPoint(_deviceMapper->getMountPoint(path)); uint64_t id = _deviceMapper->getPartitionId(mountPoint); - std::map::iterator it( + std::map::iterator it( _partitions.find(mountPoint)); if (it != _partitions.end()) { return it->second; } - Partition::LP part(new Partition(*this, id, mountPoint)); + Partition::SP part(new Partition(*this, id, mountPoint)); if (part->getMonitor() != 0) { part->getMonitor()->setPolicy(_statPolicy, _statPeriod); } @@ -131,7 +131,7 @@ DeviceManager::getPartition(const std::string& path) // If we fail to create partition, due to having IO troubles getting // partition id or mount point, create a partition that doesn't // correspond to a physical device containing the error found. - Partition::LP part(new Partition(*this, -1, path)); + Partition::SP part(new Partition(*this, -1, path)); part->addEvent(IOEvent::createEventFromIoException( e, _clock.getTimeInSeconds().getTime())); @@ -140,16 +140,16 @@ DeviceManager::getPartition(const std::string& path) } } -Disk::LP +Disk::SP DeviceManager::getDisk(const std::string& path) { try{ int devnr = _deviceMapper->getDeviceId(path); - std::map::iterator it = _disks.find(devnr); + std::map::iterator it = _disks.find(devnr); if (it != _disks.end()) { return it->second; } - Disk::LP disk(new Disk(*this, devnr)); + Disk::SP disk(new Disk(*this, devnr)); _disks[devnr] = disk; return disk; } catch (vespalib::IoException& e) { @@ -160,7 +160,7 @@ DeviceManager::getDisk(const std::string& path) // If we fail to create partition, due to having IO troubles getting // partition id or mount point, create a partition that doesn't // correspond to a physical device containing the error found. - Disk::LP disk(new Disk(*this, devnr)); + Disk::SP disk(new Disk(*this, devnr)); disk->addEvent(IOEvent::createEventFromIoException( e, _clock.getTimeInSeconds().getTime())); @@ -177,11 +177,11 @@ DeviceManager::printXml(vespalib::XmlOutputStream& xos) const xos << XmlTag("mapper") << XmlAttribute("type", _deviceMapper->getName()) << XmlEndTag(); xos << XmlTag("devices"); - for (std::map::const_iterator diskIt = _disks.begin(); + for (std::map::const_iterator diskIt = _disks.begin(); diskIt != _disks.end(); ++diskIt) { xos << XmlTag("disk") << XmlAttribute("deviceId", diskIt->first); - for (std::map::const_iterator partIt + for (std::map::const_iterator partIt = _partitions.begin(); partIt != _partitions.end(); ++partIt) { if (partIt->second->getDisk() != *diskIt->second) continue; @@ -191,7 +191,7 @@ DeviceManager::printXml(vespalib::XmlOutputStream& xos) const if (partIt->second->getMonitor() != 0) { xos << *partIt->second->getMonitor(); } - for (std::map::const_iterator dirIt + for (std::map::const_iterator dirIt = _directories.begin(); dirIt != _directories.end(); ++dirIt) { diff --git a/memfilepersistence/src/vespa/memfilepersistence/device/devicemanager.h b/memfilepersistence/src/vespa/memfilepersistence/device/devicemanager.h index dc1c6fdd68d..d4528ad10b6 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/device/devicemanager.h +++ b/memfilepersistence/src/vespa/memfilepersistence/device/devicemanager.h @@ -25,9 +25,9 @@ namespace memfile { class DeviceManager : public vespalib::XmlSerializable { DeviceMapper::UP _deviceMapper; - std::map _disks; - std::map _partitions; - std::map _directories; + std::map _disks; + std::map _partitions; + std::map _directories; std::set _eventListeners; vespa::config::storage::StorDevicesConfig::StatfsPolicy _statPolicy; uint32_t _statPeriod; @@ -39,7 +39,7 @@ class DeviceManager : public vespalib::XmlSerializable { void setFindDeviceFunction(); public: - typedef vespalib::LinkedPtr LP; + using UP = std::unique_ptr; DeviceManager(DeviceMapper::UP mapper, const framework::Clock& clock); @@ -54,13 +54,13 @@ public: void addIOEventListener(IOEventListener& listener); void removeIOEventListener(IOEventListener& listener); - Directory::LP getDirectory(const std::string& dir, uint16_t index); - Directory::LP deserializeDirectory(const std::string& serialized); - Partition::LP getPartition(const std::string& path); - Disk::LP getDisk(const std::string& path); + Directory::SP getDirectory(const std::string& dir, uint16_t index); + Directory::SP deserializeDirectory(const std::string& serialized); + Partition::SP getPartition(const std::string& path); + Disk::SP getDisk(const std::string& path); - std::vector getDirectories(const Disk& disk) const; - std::vector getDirectories(const Partition& part) const; + std::vector getDirectories(const Disk& disk) const; + std::vector getDirectories(const Partition& part) const; vespa::config::storage::StorDevicesConfig::StatfsPolicy getStatPolicy() const { return _statPolicy; } diff --git a/memfilepersistence/src/vespa/memfilepersistence/device/directory.h b/memfilepersistence/src/vespa/memfilepersistence/device/directory.h index 7bd2f7dcd53..b02d12a4552 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/device/directory.h +++ b/memfilepersistence/src/vespa/memfilepersistence/device/directory.h @@ -19,7 +19,7 @@ namespace memfile { class Directory : public Device { uint16_t _index; std::string _path; - Partition::LP _partition; + Partition::SP _partition; // Only DeviceManager can create these objects, so we only need // to cope with these constructors being so similar there. @@ -31,7 +31,7 @@ class Directory : public Device { friend class DeviceManager; public: - typedef vespalib::LinkedPtr LP; + using SP = std::shared_ptr; void setIndex(uint16_t index) { _index = index; } // Used when deserializing uint16_t getIndex() const { return _index; } diff --git a/memfilepersistence/src/vespa/memfilepersistence/device/disk.h b/memfilepersistence/src/vespa/memfilepersistence/device/disk.h index 77549a12470..9e63b7b7c68 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/device/disk.h +++ b/memfilepersistence/src/vespa/memfilepersistence/device/disk.h @@ -15,7 +15,6 @@ #pragma once #include -#include namespace storage { @@ -29,7 +28,7 @@ class Disk : public Device { friend class DeviceManager; public: - typedef vespalib::LinkedPtr LP; + using SP = std::shared_ptr; uint64_t getId() const { return _id; } diff --git a/memfilepersistence/src/vespa/memfilepersistence/device/mountpointlist.cpp b/memfilepersistence/src/vespa/memfilepersistence/device/mountpointlist.cpp index 0f5dbb288f1..63d3251fead 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/device/mountpointlist.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/device/mountpointlist.cpp @@ -28,9 +28,9 @@ using vespalib::DirPointer; MountPointList::MountPointList(const std::string& vdsRoot, const std::vector& diskPath, - DeviceManager::LP manager) + DeviceManager::UP manager) : framework::XmlStatusReporter("mountpointlist", "Disk directories"), - _deviceManager(manager), + _deviceManager(std::move(manager)), _vdsRoot(vdsRoot), _diskPath(diskPath), _mountPoints(0) @@ -120,7 +120,7 @@ void MountPointList::scanForDisks() { _mountPoints.clear(); - std::vector entries; + std::vector entries; DirPointer dir(opendir((_vdsRoot + "/disks").c_str())); struct dirent* entry; if (dir) while ((entry = readdir(dir))) { @@ -245,7 +245,7 @@ namespace { void MountPointList::readFromFile() { - std::vector entries; + std::vector entries; // Read entries from disk std::ifstream is; // Throw exception if failing to read file @@ -254,7 +254,7 @@ MountPointList::readFromFile() std::string line("EOF"); while (std::getline(is, line)) { if (line == "EOF") { break; } - Directory::LP dir = _deviceManager->deserializeDirectory(line); + Directory::SP dir = _deviceManager->deserializeDirectory(line); int diskNr = getDiskNr(dir->getPath()); if (diskNr == -1) { LOG(warning, "Found illegal disk entry '%s' in vds disk file %s.", @@ -297,7 +297,7 @@ MountPointList::writeToFile() const "disks.status file.", filename.c_str()); return; } - for (std::vector::const_iterator it + for (std::vector::const_iterator it = _mountPoints.begin(); it != _mountPoints.end(); ++it) { if (it->get() && @@ -453,10 +453,10 @@ MountPointList::verifyHealthyDisks(int mountPointCount) { WriteStatusFileIfFailing statusWriter(*this); int usable = 0, empty = 0; - std::map lackingChunkDef; + std::map lackingChunkDef; // Test disks and get chunkinfo for (uint32_t i=0, n=_mountPoints.size(); i::const_iterator it + for (std::map::const_iterator it = lackingChunkDef.begin(); it != lackingChunkDef.end(); ++it) { - const Directory::LP& dir = it->second; + const Directory::SP &dir = it->second; Chunk c; c.nr = it->first; c.total = mountPointCount; @@ -610,7 +610,7 @@ MountPointList::verifyHealthyDisks(int mountPointCount) for (int i = _mountPoints.size(); i < mountPointCount; ++i) { std::ostringstream ost; ost << _vdsRoot + "/disks/d" << i; - Directory::LP dir(_deviceManager->getDirectory(ost.str(), i)); + Directory::SP dir(_deviceManager->getDirectory(ost.str(), i)); dir->addEvent(Device::NOT_FOUND, "Disk not found during scanning of disks directory", VESPA_STRLOC); diff --git a/memfilepersistence/src/vespa/memfilepersistence/device/mountpointlist.h b/memfilepersistence/src/vespa/memfilepersistence/device/mountpointlist.h index 33a9574682a..0bd035097f1 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/device/mountpointlist.h +++ b/memfilepersistence/src/vespa/memfilepersistence/device/mountpointlist.h @@ -21,7 +21,6 @@ #include #include #include -#include #include namespace storage { @@ -37,7 +36,7 @@ struct MountPointList : public framework::XmlStatusReporter { /** Create a mount point list. */ MountPointList(const std::string& vdsRoot, const std::vector& diskPath, - vespalib::LinkedPtr); + std::unique_ptr); DeviceManager& getDeviceManager() { return *_deviceManager; } @@ -122,10 +121,10 @@ struct MountPointList : public framework::XmlStatusReporter { spi::PartitionStateList getPartitionStates() const; private: - vespalib::LinkedPtr _deviceManager; + std::unique_ptr _deviceManager; std::string _vdsRoot; std::vector _diskPath; - std::vector _mountPoints; + std::vector _mountPoints; /** Get the name used for the disk status file. */ std::string getDiskStatusFileName() const; diff --git a/memfilepersistence/src/vespa/memfilepersistence/device/partition.h b/memfilepersistence/src/vespa/memfilepersistence/device/partition.h index eeedafb7a49..1dc9fdacd41 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/device/partition.h +++ b/memfilepersistence/src/vespa/memfilepersistence/device/partition.h @@ -21,8 +21,8 @@ namespace memfile { class Partition : public Device { uint64_t _id; std::string _mountPoint; - Disk::LP _disk; - PartitionMonitor::LP _monitor; + Disk::SP _disk; + PartitionMonitor::UP _monitor; Partition(DeviceManager& manager, uint64_t id, const std::string& mountPoint); @@ -30,7 +30,7 @@ class Partition : public Device { friend class DeviceManager; public: - typedef vespalib::LinkedPtr LP; + using SP = std::shared_ptr; void initializeMonitor(); diff --git a/memfilepersistence/src/vespa/memfilepersistence/device/partitionmonitor.h b/memfilepersistence/src/vespa/memfilepersistence/device/partitionmonitor.h index 401a070389e..8e513b0f42f 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/device/partitionmonitor.h +++ b/memfilepersistence/src/vespa/memfilepersistence/device/partitionmonitor.h @@ -14,7 +14,6 @@ #include #include #include -#include #include #include @@ -28,7 +27,7 @@ class PartitionMonitor : public vespalib::Printable, public vespalib::XmlSerializable { public: - typedef vespalib::LinkedPtr LP; + using UP = std::unique_ptr; /** * Use an object to stat through, such that unit tests can fake stat diff --git a/memfilepersistence/src/vespa/memfilepersistence/init/filescanner.cpp b/memfilepersistence/src/vespa/memfilepersistence/init/filescanner.cpp index e921101aa17..8084d529d79 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/init/filescanner.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/init/filescanner.cpp @@ -71,7 +71,7 @@ FileScanner::buildBucketList(document::BucketId::List & list, } // Grab lock and update metrics vespalib::LockGuard lock(_globalLock); - std::vector newMetrics; + std::vector newMetrics; context._metrics.addToSnapshot(_globalMetrics, newMetrics); assert(newMetrics.empty()); } diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/buffer.h b/memfilepersistence/src/vespa/memfilepersistence/mapper/buffer.h index 26f4a644d0c..c3409b47656 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/mapper/buffer.h +++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/buffer.h @@ -12,7 +12,6 @@ #pragma once #include -#include namespace storage { namespace memfile { @@ -24,7 +23,7 @@ class Buffer size_t _size; public: - typedef vespalib::LinkedPtr LP; + using UP = std::unique_ptr; Buffer(const Buffer &) = delete; Buffer & operator = (const Buffer &) = delete; diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.h b/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.h index bc1bdd902b9..04d62074f05 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.h +++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.h @@ -18,7 +18,7 @@ class MemFileV1Serializer : public VersionSerializer return _metricProvider.getMetrics(); } public: - typedef vespalib::LinkedPtr LP; + using UP = std::unique_ptr; MemFileV1Serializer(ThreadMetricProvider&); diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/memfilemapper.cpp b/memfilepersistence/src/vespa/memfilepersistence/mapper/memfilemapper.cpp index 686ff05cf0e..90b261ceccc 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/mapper/memfilemapper.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/memfilemapper.cpp @@ -69,7 +69,7 @@ MemFileMapper::sendNotifyBucketCommand(const MemFile&, } void -MemFileMapper::addVersionSerializer(VersionSerializer::LP serializer) +MemFileMapper::addVersionSerializer(VersionSerializer::UP serializer) { FileVersion version = serializer->getFileVersion(); if (_serializers.find(version) != _serializers.end()) { @@ -78,13 +78,13 @@ MemFileMapper::addVersionSerializer(VersionSerializer::LP serializer) << " is already registered."; throw vespalib::IllegalStateException(error.str(), VESPA_STRLOC); } - _serializers[version] = serializer; + _serializers[version] = std::move(serializer); } VersionSerializer& MemFileMapper::getVersionSerializer(const MemFile& file) { - std::map::iterator it( + std::map::iterator it( _serializers.find(file.getCurrentVersion())); if (it == _serializers.end()) { std::ostringstream ost; @@ -99,7 +99,7 @@ MemFileMapper::getVersionSerializer(const MemFile& file) MemFileMapper::MemFileMapper(ThreadMetricProvider& metricProvider) : _metricProvider(metricProvider) { - addVersionSerializer(VersionSerializer::LP(new MemFileV1Serializer(metricProvider))); + addVersionSerializer(VersionSerializer::UP(new MemFileV1Serializer(metricProvider))); } void @@ -107,7 +107,7 @@ MemFileMapper::setDefaultMemFileIO(MemFile& file, vespalib::LazyFile::UP lf, const Environment& env) { - std::map::iterator serializer( + std::map::iterator serializer( _serializers.find(file.getFile().getWantedFileVersion())); assert(serializer != _serializers.end()); @@ -162,7 +162,7 @@ MemFileMapper::loadFileImpl(MemFile& file, Environment& env) FileVersion version = static_cast( *reinterpret_cast(buffer.getBuffer())); - std::map::iterator serializer( + std::map::iterator serializer( _serializers.find(version)); file.setCurrentVersion(version); if (serializer == _serializers.end()) { @@ -237,7 +237,7 @@ MemFileMapper::flush(MemFile& f, Environment& env, bool autoRepair) } // If we get here we failed to write updates only and will rewrite - std::map::iterator serializer( + std::map::iterator serializer( _serializers.find(f.getFile().getWantedFileVersion())); assert(serializer != _serializers.end()); @@ -250,7 +250,7 @@ MemFileMapper::verify(MemFile& file, Environment& env, uint16_t fileVerifyFlags) { if (file.fileExists()) { - std::map::iterator serializer( + std::map::iterator serializer( _serializers.find(file.getCurrentVersion())); if (serializer != _serializers.end()) { bool wasOk = serializer->second->verify( diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/memfilemapper.h b/memfilepersistence/src/vespa/memfilepersistence/mapper/memfilemapper.h index 30f483fc582..b82bc59b732 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/mapper/memfilemapper.h +++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/memfilemapper.h @@ -25,7 +25,7 @@ namespace memfile { class MemFileMapper : private Types { private: - std::map _serializers; + std::map _serializers; ThreadMetricProvider& _metricProvider; void setDefaultMemFileIO(MemFile& file, vespalib::LazyFile::UP lf, @@ -84,7 +84,7 @@ public: void removeAllSlotsExcept(MemFile& file, std::vector& keep); private: - void addVersionSerializer(VersionSerializer::LP); + void addVersionSerializer(VersionSerializer::UP); VersionSerializer& getVersionSerializer(const MemFile& file); void loadFileImpl(MemFile&, Environment&); diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.cpp b/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.cpp index 3c10efdf0c9..da3b180201e 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.cpp @@ -292,24 +292,24 @@ SimpleMemFileIOBuffer::allocateBuffer(DocumentPart part, // If the requested size is greater than or equal to our working buffer // size, simply allocate a separate buffer for it. if (sz >= WORKING_BUFFER_SIZE) { - return BufferAllocation(SharedBuffer::LP(new SharedBuffer(sz)), 0, sz); + return BufferAllocation(SharedBuffer::SP(new SharedBuffer(sz)), 0, sz); } - SharedBuffer::LP& bufLP(_workingBuffers[part]); + SharedBuffer::SP &bufSP(_workingBuffers[part]); bool requireNewBlock = false; - if (!bufLP.get()) { + if (!bufSP.get()) { requireNewBlock = true; - } else if (!bufLP->hasRoomFor(sz, align)) { + } else if (!bufSP->hasRoomFor(sz, align)) { requireNewBlock = true; } if (!requireNewBlock) { - return BufferAllocation(bufLP, - static_cast(bufLP->allocate(sz, align)), + return BufferAllocation(bufSP, + static_cast(bufSP->allocate(sz, align)), sz); } else { - SharedBuffer::LP newBuf(new SharedBuffer(WORKING_BUFFER_SIZE)); - bufLP = newBuf; + SharedBuffer::SP newBuf(new SharedBuffer(WORKING_BUFFER_SIZE)); + bufSP = newBuf; return BufferAllocation(newBuf, static_cast(newBuf->allocate(sz, align)), sz); @@ -384,7 +384,7 @@ SimpleMemFileIOBuffer::copyCache(const MemFileIOInterface& source, void SimpleMemFileIOBuffer::cacheLocation(DocumentPart part, DataLocation loc, - BufferType::LP& buf, + BufferType::SP buf, uint32_t bufferPos) { LOG(spam, @@ -396,7 +396,7 @@ SimpleMemFileIOBuffer::cacheLocation(DocumentPart part, loc._size, buf.get(), bufferPos); - _data[part][loc] = Data(buf, bufferPos, true); + _data[part][loc] = Data(std::move(buf), bufferPos, true); } bool diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h b/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h index 3e91916ff0b..40c5ffb4865 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h +++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h @@ -74,7 +74,7 @@ public: ALIGN_512_BYTES }; - typedef vespalib::LinkedPtr LP; + using SP = std::shared_ptr; explicit SharedBuffer(size_t totalSize) : _buf(vespalib::alloc::Alloc::allocMMap(totalSize)), _totalSize(totalSize), @@ -123,8 +123,8 @@ public: { BufferAllocation() : pos(0), size(0) {} - BufferAllocation(const SharedBuffer::LP& b, uint32_t p, uint32_t sz) - : buf(b), pos(p), size(sz) { } + BufferAllocation(SharedBuffer::SP b, uint32_t p, uint32_t sz) + : buf(std::move(b)), pos(p), size(sz) { } /** * Get buffer area available to this specific allocation @@ -136,11 +136,11 @@ public: * Get buffer that is (potentially) shared between many individual * allocations. */ - SharedBuffer::LP& getSharedBuffer() { return buf; } + SharedBuffer::SP getSharedBuffer() { return buf; } uint32_t getBufferPosition() const { return pos; } uint32_t getSize() const { return size; } - SharedBuffer::LP buf; + SharedBuffer::SP buf; uint32_t pos; uint32_t size; }; @@ -250,7 +250,7 @@ public: */ void cacheLocation(DocumentPart part, DataLocation loc, - BufferType::LP& buf, + BufferType::SP buf, uint32_t bufferPos); /** @@ -319,10 +319,10 @@ private: struct Data { Data() : pos(0), persisted(false) {} - Data(const BufferType::LP& b, uint32_t p, bool isPersisted) - : buf(b), pos(p), persisted(isPersisted) {} + Data(BufferType::SP b, uint32_t p, bool isPersisted) + : buf(std::move(b)), pos(p), persisted(isPersisted) {} - BufferType::LP buf; + BufferType::SP buf; uint32_t pos; bool persisted; }; @@ -331,7 +331,7 @@ private: VersionSerializer& _reader; std::vector _data; - std::vector _workingBuffers; + std::vector _workingBuffers; vespalib::LazyFile::UP _file; FileInfo::UP _fileInfo; FileSpecification _fileSpec; diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/versionserializer.h b/memfilepersistence/src/vespa/memfilepersistence/mapper/versionserializer.h index b57734c2b24..7cc45451126 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/mapper/versionserializer.h +++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/versionserializer.h @@ -15,7 +15,6 @@ #include #include #include -#include #include namespace storage { @@ -26,7 +25,7 @@ class MemFileEnvironment; class Options; struct VersionSerializer : protected Types { - typedef vespalib::LinkedPtr LP; + using UP = std::unique_ptr; virtual ~VersionSerializer() {} diff --git a/memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecache.cpp b/memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecache.cpp index 722fef80103..409789eadcc 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecache.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecache.cpp @@ -203,7 +203,7 @@ MemFileCache::get(const BucketId& id, Environment& env, Directory& dir, // in the common case that there's a bucket file on the disk. The // content layer shall guarantee that no concurrent operations happen // for a single bucket, so this should be fully thread safe. - Entry::LP entry(new Entry(file, env, createIfNotExisting)); + Entry::SP entry(new Entry(file, env, createIfNotExisting)); vespalib::LockGuard reLock(_cacheLock); std::pair inserted( @@ -211,7 +211,7 @@ MemFileCache::get(const BucketId& id, Environment& env, Directory& dir, assert(inserted.second); _metrics.misses.inc(); - return MemFilePtr(MemFilePtr::EntryGuard::LP( + return MemFilePtr(MemFilePtr::EntryGuard::SP( new CacheEntryGuard(*this, env, *entry))); } else { if (it->_ptr->isInUse()) { @@ -234,7 +234,7 @@ MemFileCache::get(const BucketId& id, Environment& env, Directory& dir, it->_ptr->_cacheSize.toString().c_str(), _memoryUsage.toString().c_str()); - return MemFilePtr(MemFilePtr::EntryGuard::LP( + return MemFilePtr(MemFilePtr::EntryGuard::SP( new CacheEntryGuard(*this, env, *it->_ptr))); } diff --git a/memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecache.h b/memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecache.h index e4417fb6e0f..112c5e6c399 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecache.h +++ b/memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecache.h @@ -53,7 +53,7 @@ public: private: class Entry { public: - typedef vespalib::LinkedPtr LP; + using SP = std::shared_ptr; MemFile _file; MemoryUsage _cacheSize; @@ -78,10 +78,10 @@ private: struct EntryWrapper { EntryWrapper( - Entry::LP ptr, + Entry::SP ptr, uint64_t lastUsed, const document::BucketId& bid) - : _ptr(ptr), _lastUsed(lastUsed), _bid(bid) {} + : _ptr(std::move(ptr)), _lastUsed(lastUsed), _bid(bid) {} const Entry* operator->() const { return _ptr.get(); @@ -91,7 +91,7 @@ private: return _ptr.get(); }; - Entry::LP _ptr; + Entry::SP _ptr; uint64_t _lastUsed; document::BucketId _bid; }; diff --git a/memfilepersistence/src/vespa/memfilepersistence/memfile/memfileptr.h b/memfilepersistence/src/vespa/memfilepersistence/memfile/memfileptr.h index 545686e5f2f..32d86bd415c 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/memfile/memfileptr.h +++ b/memfilepersistence/src/vespa/memfilepersistence/memfile/memfileptr.h @@ -18,8 +18,6 @@ #pragma once -#include - namespace storage { namespace memfile { @@ -33,7 +31,7 @@ public: * doing it, to prevent cyclic dependency with cache. */ struct EntryGuard { - typedef vespalib::LinkedPtr LP; + using SP = std::shared_ptr; MemFile* _file; @@ -46,11 +44,11 @@ public: }; private: - EntryGuard::LP _entry; + EntryGuard::SP _entry; public: MemFilePtr() {}; - MemFilePtr(EntryGuard::LP entry) : _entry(entry) {} + MemFilePtr(EntryGuard::SP entry) : _entry(std::move(entry)) {} // Behave like pointer to MemFile for ease of use. MemFile* operator->() { return _entry->_file; } diff --git a/memfilepersistence/src/vespa/memfilepersistence/memfile/memslot.h b/memfilepersistence/src/vespa/memfilepersistence/memfile/memslot.h index 32f7f0ebe39..31a0b7b2ea6 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/memfile/memslot.h +++ b/memfilepersistence/src/vespa/memfilepersistence/memfile/memslot.h @@ -81,7 +81,7 @@ public: std::string toString() const; }; - typedef vespalib::LinkedPtr LP; + using UP = std::unique_ptr; MemSlot(const MemSlot&); /** Constructor used by mappers reading from file. */ diff --git a/memfilepersistence/src/vespa/memfilepersistence/spi/iteratorhandler.cpp b/memfilepersistence/src/vespa/memfilepersistence/spi/iteratorhandler.cpp index 3985459a5be..7a733e8cc1b 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/spi/iteratorhandler.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/spi/iteratorhandler.cpp @@ -60,7 +60,7 @@ IteratorHandler::createIterator(const spi::Bucket& bucket, // By default, no explicit prefetching is required. CachePrefetchRequirements prefetcher; - vespalib::LinkedPtr docSelection; + std::unique_ptr docSelection; if (!sel.getDocumentSelection().getDocumentSelection().empty()) { docSelection.reset( parseDocumentSelection( @@ -96,7 +96,7 @@ IteratorHandler::createIterator(const spi::Bucket& bucket, sel, document::FieldSet::UP(fields.clone()), versions, - docSelection, + std::move(docSelection), prefetcher)))); assert(inserted.second); // Should never have duplicates @@ -250,11 +250,11 @@ IteratorHandler::addMetaDataEntry(spi::IterateResult::List& result, totalSize += entrySize; int metaFlags = (slot.deleted() || slot.deletedInPlace()) ? spi::REMOVE_ENTRY : 0; - spi::DocEntry::LP docEntry( + spi::DocEntry::UP docEntry( new spi::DocEntry( spi::Timestamp(slot.getTimestamp().getTime()), metaFlags)); - result.push_back(docEntry); + result.push_back(std::move(docEntry)); return true; } @@ -274,12 +274,12 @@ IteratorHandler::addRemoveEntry(spi::IterateResult::List& results, } totalSize += entrySize; - spi::DocEntry::LP docEntry( + spi::DocEntry::UP docEntry( new spi::DocEntry( spi::Timestamp(slot.getTimestamp().getTime()), spi::REMOVE_ENTRY, did)); - results.push_back(docEntry); + results.push_back(std::move(docEntry)); return true; } @@ -307,12 +307,12 @@ IteratorHandler::addPutEntry(spi::IterateResult::List& results, { document::FieldSet::stripFields(*doc, fieldsToKeep); } - spi::DocEntry::LP docEntry( + spi::DocEntry::UP docEntry( new spi::DocEntry(spi::Timestamp(slot.getTimestamp().getTime()), 0, std::move(doc), docSize)); - results.push_back(docEntry); + results.push_back(std::move(docEntry)); return true; } @@ -338,7 +338,7 @@ IteratorHandler::iterate(spi::IteratorId id, uint64_t maxByteSize) assert(!iter->second.isActive()); state = &iter->second; if (state->isCompleted()) { - return spi::IterateResult(results, true); + return spi::IterateResult(std::move(results), true); } state->setActive(true); } @@ -422,10 +422,10 @@ IteratorHandler::iterate(spi::IteratorId id, uint64_t maxByteSize) if (remaining.empty()) { state->setCompleted(); - return spi::IterateResult(results, true); + return spi::IterateResult(std::move(results), true); } - return spi::IterateResult(results, false); + return spi::IterateResult(std::move(results), false); } } diff --git a/memfilepersistence/src/vespa/memfilepersistence/spi/iteratorhandler.h b/memfilepersistence/src/vespa/memfilepersistence/spi/iteratorhandler.h index 7b3ee9627e5..4e15ef5d137 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/spi/iteratorhandler.h +++ b/memfilepersistence/src/vespa/memfilepersistence/spi/iteratorhandler.h @@ -11,14 +11,12 @@ #include #include #include +#include namespace document { class FieldSet; -namespace select { -class Node; -} } namespace storage { @@ -75,8 +73,8 @@ class IteratorState { spi::Bucket _bucket; spi::Selection _selection; - vespalib::LinkedPtr _fieldSet; - vespalib::LinkedPtr _documentSelection; + std::unique_ptr _fieldSet; + std::unique_ptr _documentSelection; std::vector _remaining; spi::IncludedVersions _versions; CachePrefetchRequirements _prefetchRequirements; @@ -89,12 +87,12 @@ public: const spi::Selection& sel, document::FieldSet::UP fieldSet, spi::IncludedVersions versions, - vespalib::LinkedPtr docSel, + std::unique_ptr docSel, const CachePrefetchRequirements& prefetchRequirements) : _bucket(bucket), _selection(sel), - _fieldSet(vespalib::LinkedPtr(fieldSet.release())), - _documentSelection(docSel), + _fieldSet(std::move(fieldSet)), + _documentSelection(std::move(docSel)), _remaining(), _versions(versions), _prefetchRequirements(prefetchRequirements), diff --git a/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp b/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp index f3eb1429207..030bac0752e 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp @@ -257,7 +257,7 @@ int SlotFileDumper::dump(int argc, const char * const * argv, EnvironmentImpl env(config, o.toXml ? o.documentManConfigId.c_str() : ""); document::BucketId bucket(extractBucketId(o.filename)); - Directory::LP dir(env._deviceManager.getDirectory(o.filename, 0)); + Directory::SP dir(env._deviceManager.getDirectory(o.filename, 0)); FileSpecification fileSpec(bucket, *dir, o.filename); MemFile::LoadOptions opts; diff --git a/memfilepersistence/src/vespa/memfilepersistence/tools/vdsdisktool.cpp b/memfilepersistence/src/vespa/memfilepersistence/tools/vdsdisktool.cpp index ad9b08f4994..04d300e83b0 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/tools/vdsdisktool.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/tools/vdsdisktool.cpp @@ -379,12 +379,12 @@ VdsDiskTool::run(int argc, const char * const * argv, } framework::defaultimplementation::RealClock clock; // Read the disk status file. - DeviceManager::LP devMan(new DeviceManager( + DeviceManager::UP devMan(new DeviceManager( DeviceMapper::UP(new SimpleDeviceMapper), clock)); MountPointList mountPointList(options.getNodePath(nodeIndex), vector(), - devMan); + std::move(devMan)); mountPointList.scanForDisks(); if (options._mode == "enable" || options._mode == "disable") { if (mountPointList.getSize() <= options._diskIndex diff --git a/messagebus/src/vespa/messagebus/network/rpcservice.h b/messagebus/src/vespa/messagebus/network/rpcservice.h index 2566ad0f262..5b5afb1c704 100644 --- a/messagebus/src/vespa/messagebus/network/rpcservice.h +++ b/messagebus/src/vespa/messagebus/network/rpcservice.h @@ -2,7 +2,6 @@ #pragma once #include -#include #include "rpcserviceaddress.h" namespace mbus { @@ -26,7 +25,7 @@ private: AddressList _addressList; public: - typedef vespalib::LinkedPtr LP; + using UP = std::unique_ptr; RPCService(const RPCService &) = delete; RPCService & operator = (const RPCService &) = delete; /** diff --git a/messagebus/src/vespa/messagebus/network/rpcservicepool.cpp b/messagebus/src/vespa/messagebus/network/rpcservicepool.cpp index 3b0e0072d38..83f0716948d 100644 --- a/messagebus/src/vespa/messagebus/network/rpcservicepool.cpp +++ b/messagebus/src/vespa/messagebus/network/rpcservicepool.cpp @@ -24,9 +24,10 @@ RPCServicePool::resolve(const string &pattern) if (_lru.hasKey(pattern)) { return _lru[pattern]->resolve(); } else { - RPCService::LP service(new RPCService(_net.getMirror(), pattern)); - _lru[pattern] = service; - return service->resolve(); + RPCService::UP service(new RPCService(_net.getMirror(), pattern)); + auto result = service->resolve(); + _lru[pattern] = std::move(service); + return result; } } diff --git a/messagebus/src/vespa/messagebus/network/rpcservicepool.h b/messagebus/src/vespa/messagebus/network/rpcservicepool.h index 55fac7da577..891a84fa4ef 100644 --- a/messagebus/src/vespa/messagebus/network/rpcservicepool.h +++ b/messagebus/src/vespa/messagebus/network/rpcservicepool.h @@ -14,7 +14,7 @@ class RPCNetwork; */ class RPCServicePool { private: - typedef vespalib::lrucache_map< vespalib::LruParam > ServiceCache; + typedef vespalib::lrucache_map< vespalib::LruParam > ServiceCache; RPCNetwork &_net; ServiceCache _lru; diff --git a/metrics/src/tests/loadmetrictest.cpp b/metrics/src/tests/loadmetrictest.cpp index 8ea3e9aee6d..97af77169de 100644 --- a/metrics/src/tests/loadmetrictest.cpp +++ b/metrics/src/tests/loadmetrictest.cpp @@ -61,7 +61,7 @@ namespace { metric("tack", "", "", this) { } - MetricSet* clone(std::vector& ownerList, CopyType copyType, + MetricSet* clone(std::vector &ownerList, CopyType copyType, MetricSet* owner, bool includeUnused = false) const override { if (copyType != CLONE) { @@ -86,7 +86,7 @@ LoadMetricTest::testClone(Metric::CopyType copyType) LoadMetric metric(loadTypes, myset, &top); metric[loadTypes["foo"]].metric.addValue(5); - std::vector ownerList; + std::vector ownerList; MetricSet::UP copy(dynamic_cast(top.clone(ownerList, copyType, 0, true))); CPPUNIT_ASSERT(copy.get()); @@ -116,7 +116,7 @@ LoadMetricTest::testAdding() LoadMetric metric(loadTypes, myset, &top); metric[loadTypes["foo"]].metric.addValue(5); - std::vector ownerList; + std::vector ownerList; MetricSet::UP copy(dynamic_cast( top.clone(ownerList, Metric::INACTIVE, 0, false))); CPPUNIT_ASSERT(copy.get()); diff --git a/metrics/src/tests/metricsettest.cpp b/metrics/src/tests/metricsettest.cpp index 9ce141feaf3..309794cad1e 100644 --- a/metrics/src/tests/metricsettest.cpp +++ b/metrics/src/tests/metricsettest.cpp @@ -147,7 +147,7 @@ MetricSetTest::uniqueTargetMetricsAreAddedToMetricSet() // 'doge' metric in set2 must be preserved even though it does not exist // in set1. - std::vector ownerList; + std::vector ownerList; set1.addToSnapshot(set2, ownerList); CPPUNIT_ASSERT(set2.getMetric("wow") != nullptr); diff --git a/metrics/src/tests/snapshottest.cpp b/metrics/src/tests/snapshottest.cpp index 2527a048df6..977f6e4ad68 100644 --- a/metrics/src/tests/snapshottest.cpp +++ b/metrics/src/tests/snapshottest.cpp @@ -40,7 +40,7 @@ struct SubSubMetricSet : public MetricSet { SubSubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner = 0); ~SubSubMetricSet(); - virtual MetricSet* clone(std::vector& ownerList, CopyType copyType, + virtual MetricSet* clone(std::vector &ownerList, CopyType copyType, metrics::MetricSet* owner, bool includeUnused) const; void incValues(); }; @@ -72,7 +72,7 @@ SubSubMetricSet::SubSubMetricSet(vespalib::stringref name, const LoadTypeSet& lo SubSubMetricSet::~SubSubMetricSet() { } MetricSet* -SubSubMetricSet::clone(std::vector& ownerList, +SubSubMetricSet::clone(std::vector &ownerList, CopyType copyType, metrics::MetricSet* owner, bool includeUnused) const { @@ -114,7 +114,7 @@ struct SubMetricSet : public MetricSet { SubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner = 0); ~SubMetricSet(); - MetricSet* clone(std::vector& ownerList, CopyType copyType, + MetricSet* clone(std::vector &ownerList, CopyType copyType, metrics::MetricSet* owner, bool includeUnused) const override; void incValues(); @@ -134,7 +134,7 @@ SubMetricSet::SubMetricSet(vespalib::stringref name, const LoadTypeSet& loadType SubMetricSet::~SubMetricSet() { } MetricSet* -SubMetricSet::clone(std::vector& ownerList, CopyType copyType, +SubMetricSet::clone(std::vector &ownerList, CopyType copyType, metrics::MetricSet* owner, bool includeUnused) const { if (copyType == INACTIVE) { diff --git a/metrics/src/tests/stresstest.cpp b/metrics/src/tests/stresstest.cpp index 9eb13e00a79..905a79252d1 100644 --- a/metrics/src/tests/stresstest.cpp +++ b/metrics/src/tests/stresstest.cpp @@ -33,7 +33,7 @@ struct InnerMetricSet : public MetricSet { InnerMetricSet(const char* name, const LoadTypeSet& lt, MetricSet* owner = 0); ~InnerMetricSet(); - MetricSet* clone(std::vector& ownerList, CopyType copyType, + MetricSet* clone(std::vector &ownerList, CopyType copyType, MetricSet* owner, bool includeUnused) const override; }; @@ -52,7 +52,7 @@ InnerMetricSet::InnerMetricSet(const char* name, const LoadTypeSet& lt, MetricSe InnerMetricSet::~InnerMetricSet() { } MetricSet* - InnerMetricSet::clone(std::vector& ownerList, CopyType copyType, + InnerMetricSet::clone(std::vector &ownerList, CopyType copyType, MetricSet* owner, bool includeUnused) const { if (copyType != CLONE) { @@ -89,7 +89,7 @@ OuterMetricSet::OuterMetricSet(const LoadTypeSet& lt, MetricSet* owner) OuterMetricSet::~OuterMetricSet() { } struct Hammer : public document::Runnable { - typedef vespalib::LinkedPtr LP; + using UP = std::unique_ptr; OuterMetricSet& _metrics; const LoadTypeSet& _loadTypes; @@ -141,9 +141,9 @@ StressTest::testStress() LOG(info, "Starting load givers"); FastOS_ThreadPool threadPool(256 * 1024); - std::vector hammers; + std::vector hammers; for (uint32_t i=0; i<10; ++i) { - hammers.push_back(Hammer::LP( + hammers.push_back(Hammer::UP( new Hammer(metrics, loadTypes, threadPool))); } LOG(info, "Waiting to let loadgivers hammer a while"); diff --git a/metrics/src/tests/valuemetrictest.cpp b/metrics/src/tests/valuemetrictest.cpp index 556592d518b..b06b6806a8b 100644 --- a/metrics/src/tests/valuemetrictest.cpp +++ b/metrics/src/tests/valuemetrictest.cpp @@ -178,7 +178,7 @@ void ValueMetricTest::testSmallAverage() m.addValue(0.0001); m.addValue(0.0002); m.addValue(0.0003); - std::vector ownerList; + std::vector ownerList; Metric::UP c(m.clone(ownerList, Metric::INACTIVE, 0, false)); std::string expect("test average=0.0002 last=0.0003 min=0.0001 max=0.0003 count=3 total=0.0006"); CPPUNIT_ASSERT_EQUAL(expect, m.toString()); diff --git a/metrics/src/vespa/metrics/countmetric.h b/metrics/src/vespa/metrics/countmetric.h index 55f3b8a78b3..76eb166ef9a 100644 --- a/metrics/src/vespa/metrics/countmetric.h +++ b/metrics/src/vespa/metrics/countmetric.h @@ -93,7 +93,7 @@ public: } virtual CountMetric * clone( - std::vector&, CopyType type, MetricSet* owner, + std::vector &, CopyType type, MetricSet* owner, bool /*includeUnused*/) const { return new CountMetric(*this, type, owner); } @@ -125,7 +125,7 @@ public: virtual void printDebug(std::ostream&, const std::string& indent) const; virtual void addToPart(Metric&) const; - virtual void addToSnapshot(Metric&, std::vector&) const; + virtual void addToSnapshot(Metric&, std::vector &) const; }; typedef CountMetric LongCountMetric; diff --git a/metrics/src/vespa/metrics/countmetric.hpp b/metrics/src/vespa/metrics/countmetric.hpp index 187048ce596..836c50dc2b3 100644 --- a/metrics/src/vespa/metrics/countmetric.hpp +++ b/metrics/src/vespa/metrics/countmetric.hpp @@ -136,7 +136,7 @@ CountMetric::dec(T value) template void CountMetric::addToSnapshot( - Metric& other, std::vector&) const + Metric& other, std::vector &) const { CountMetric& o( reinterpret_cast&>(other)); diff --git a/metrics/src/vespa/metrics/loadmetric.h b/metrics/src/vespa/metrics/loadmetric.h index d31ef5efca4..2aec4cb7383 100644 --- a/metrics/src/vespa/metrics/loadmetric.h +++ b/metrics/src/vespa/metrics/loadmetric.h @@ -27,9 +27,9 @@ namespace metrics { template class LoadMetric : public MetricSet { - std::vector _ownerList; - typedef vespalib::LinkedPtr MetricTypeLP; - using MetricMap = vespalib::hash_map; + std::vector _ownerList; + using MetricTypeUP = std::unique_ptr; + using MetricMap = vespalib::hash_map; MetricMap _metrics; SumMetric _sum; @@ -49,7 +49,7 @@ public: */ LoadMetric(const LoadMetric& other, MetricSet* owner); ~LoadMetric(); - MetricSet* clone(std::vector& ownerList, + MetricSet* clone(std::vector &ownerList, CopyType copyType, MetricSet* owner, bool includeUnused = false) const override; diff --git a/metrics/src/vespa/metrics/loadmetric.hpp b/metrics/src/vespa/metrics/loadmetric.hpp index 54171341b67..3741783180e 100644 --- a/metrics/src/vespa/metrics/loadmetric.hpp +++ b/metrics/src/vespa/metrics/loadmetric.hpp @@ -21,15 +21,15 @@ LoadMetric::LoadMetric(const LoadTypeSet& loadTypes, const MetricTyp setTags(metric.getTags()); Tags noTags; for (uint32_t i=0; i(metric.clone(_ownerList, CLONE, 0, false))); + MetricTypeUP copy(dynamic_cast(metric.clone(_ownerList, CLONE, 0, false))); assert(copy.get()); copy->setName(loadTypes[i].getName()); copy->setTags(noTags); - _metrics[loadTypes[i].getId()] = copy; registerMetric(*copy); _sum.addMetricToSum(*copy); + _metrics[loadTypes[i].getId()] = std::move(copy); } - trim(_ownerList); + _ownerList.shrink_to_fit(); } template @@ -42,15 +42,15 @@ LoadMetric::LoadMetric(const LoadMetric& other, MetricSe setTags(other.getTags()); Tags noTags; for (const auto & metric : other._metrics) { - MetricTypeLP copy(dynamic_cast(metric.second->clone(_ownerList, CLONE, 0, false))); + MetricTypeUP copy(dynamic_cast(metric.second->clone(_ownerList, CLONE, 0, false))); assert(copy.get()); copy->setName(metric.second->getName()); copy->setTags(noTags); - _metrics[metric.first] = copy; registerMetric(*copy); _sum.addMetricToSum(*copy); + _metrics[metric.first] = std::move(copy); } - trim(_ownerList); + _ownerList.shrink_to_fit(); } template @@ -58,7 +58,7 @@ LoadMetric::~LoadMetric() { } template MetricSet* -LoadMetric::clone(std::vector& ownerList, +LoadMetric::clone(std::vector &ownerList, CopyType copyType, MetricSet* owner, bool includeUnused) const { @@ -73,7 +73,7 @@ MetricType& LoadMetric::getMetric(const LoadType& type) { MetricType* metric; - typename vespalib::hash_map::iterator it( + typename vespalib::hash_map::iterator it( _metrics.find(type.getId())); if (it == _metrics.end()) { it = _metrics.find(0); @@ -89,7 +89,7 @@ template void LoadMetric::addMemoryUsage(MemoryConsumption& mc) const { ++mc._loadMetricCount; - mc._loadMetricMeta += (sizeof(Metric::LP) * _ownerList.capacity()) + mc._loadMetricMeta += (sizeof(Metric::UP) * _ownerList.capacity()) + (sizeof(typename MetricMap::value_type) * _metrics.capacity()); _sum.addMemoryUsage(mc); mc._loadMetricMeta += sizeof(LoadMetric) diff --git a/metrics/src/vespa/metrics/metric.cpp b/metrics/src/vespa/metrics/metric.cpp index 4560dfce1df..2259808a8be 100644 --- a/metrics/src/vespa/metrics/metric.cpp +++ b/metrics/src/vespa/metrics/metric.cpp @@ -236,7 +236,7 @@ Metric::printDebug(std::ostream& out, const std::string& indent) const Metric* Metric::assignValues(const Metric& m) { - std::vector ownerList; + std::vector ownerList; const_cast(m).addToSnapshot(*this, ownerList); // As this should only be called among active metrics, all metrics // should exist and owner list should thus always end up empty. diff --git a/metrics/src/vespa/metrics/metric.h b/metrics/src/vespa/metrics/metric.h index 959c9bd2411..c45920cfda4 100644 --- a/metrics/src/vespa/metrics/metric.h +++ b/metrics/src/vespa/metrics/metric.h @@ -3,8 +3,8 @@ #include #include -#include #include +#include namespace metrics { @@ -17,15 +17,6 @@ class XmlWriterMetricVisitor; class MemoryConsumption; class NameHash; -template -void trim(std::vector& v) { - if (v.size() < v.capacity()) { - std::vector copy(v); - copy.swap(v); - } - assert(v.size() == v.capacity()); -} - /** Implement class to visit metrics. */ struct MetricVisitor { virtual ~MetricVisitor() {} @@ -107,7 +98,6 @@ public: using String = std::string; using stringref = vespalib::stringref; using UP = std::unique_ptr; - using LP = vespalib::LinkedPtr; using SP = std::shared_ptr; using Tags = std::vector; @@ -151,7 +141,7 @@ public: * unused metrics, but while generating sum metric sum in active * metrics we want to. This has no affect if type is CLONE. */ - virtual Metric* clone(std::vector& ownerList, + virtual Metric* clone(std::vector &ownerList, CopyType type, MetricSet* owner, bool includeUnused = false) const = 0; @@ -200,7 +190,7 @@ public: * @param ownerList In case snapshot doesn't contain given metric, it can * create them and add them to ownerlist. */ - virtual void addToSnapshot(Metric& m, std::vector& ownerList) const = 0; + virtual void addToSnapshot(Metric& m, std::vector &ownerList) const = 0; /** * For sum metrics to work with metric sets, metric sets need operator+=. diff --git a/metrics/src/vespa/metrics/metricset.cpp b/metrics/src/vespa/metrics/metricset.cpp index 397eaa85538..201b7c296e2 100644 --- a/metrics/src/vespa/metrics/metricset.cpp +++ b/metrics/src/vespa/metrics/metricset.cpp @@ -32,7 +32,7 @@ MetricSet::MetricSet(const String& name, Tags dimensions, } MetricSet::MetricSet(const MetricSet& other, - std::vector& ownerList, + std::vector &ownerList, CopyType copyType, MetricSet* owner, bool includeUnused) @@ -48,7 +48,7 @@ MetricSet::MetricSet(const MetricSet& other, for (const Metric* metric : other._metricOrder) { if (copyType != INACTIVE || includeUnused || metric->used()) { Metric* m = metric->clone(ownerList, copyType, this, includeUnused); - ownerList.push_back(Metric::LP(m)); + ownerList.push_back(Metric::UP(m)); } } } @@ -56,7 +56,7 @@ MetricSet::MetricSet(const MetricSet& other, MetricSet::~MetricSet() { } MetricSet* -MetricSet::clone(std::vector& ownerList, CopyType type, +MetricSet::clone(std::vector &ownerList, CopyType type, MetricSet* owner, bool includeUnused) const { return new MetricSet(*this, ownerList, type, owner, includeUnused); @@ -224,7 +224,7 @@ namespace { } void -MetricSet::addTo(Metric& other, std::vector* ownerList) const +MetricSet::addTo(Metric& other, std::vector *ownerList) const { bool mustAdd = (ownerList == 0); MetricSet& o(static_cast(other)); @@ -239,9 +239,9 @@ MetricSet::addTo(Metric& other, std::vector* ownerList) const if (target == map2.end() || source->first < target->first) { // Source missing in snapshot to add to. Lets create and add. if (!mustAdd && source->second->used()) { - Metric::LP copy(source->second->clone(*ownerList, INACTIVE, &o)); - ownerList->push_back(copy); + Metric::UP copy(source->second->clone(*ownerList, INACTIVE, &o)); newMetrics[source->first] = copy.get(); + ownerList->push_back(std::move(copy)); } ++source; } else if (source->first == target->first) { diff --git a/metrics/src/vespa/metrics/metricset.h b/metrics/src/vespa/metrics/metricset.h index b0ab0f4845c..b7c012af277 100644 --- a/metrics/src/vespa/metrics/metricset.h +++ b/metrics/src/vespa/metrics/metricset.h @@ -12,6 +12,7 @@ #include #include +#include namespace metrics { @@ -33,7 +34,7 @@ public: MetricSet(const String& name, Tags dimensions, const String& description, MetricSet* owner = 0); - MetricSet(const MetricSet&, std::vector& ownerList, + MetricSet(const MetricSet&, std::vector &ownerList, CopyType, MetricSet* owner = 0, bool includeUnused = false); ~MetricSet(); @@ -52,7 +53,7 @@ public: void registerMetric(Metric& m); void unregisterMetric(Metric& m); - MetricSet* clone(std::vector& ownerList, CopyType type, + MetricSet* clone(std::vector &ownerList, CopyType type, MetricSet* owner, bool includeUnused = false) const override; void reset(); @@ -75,7 +76,7 @@ public: const_cast(this)->getMetric(name)); } - virtual void addToSnapshot(Metric& m, std::vector& o) const + virtual void addToSnapshot(Metric& m, std::vector &o) const { addTo(m, &o); } const std::vector& getRegisteredMetrics() const @@ -109,7 +110,7 @@ private: void tagRegistrationAltered(); const Metric* getMetricInternal(const String& name) const; - virtual void addTo(Metric&, std::vector* ownerList) const; + virtual void addTo(Metric&, std::vector *ownerList) const; }; } // metrics diff --git a/metrics/src/vespa/metrics/metricsnapshot.cpp b/metrics/src/vespa/metrics/metricsnapshot.cpp index e8a50419751..1625de3b106 100644 --- a/metrics/src/vespa/metrics/metricsnapshot.cpp +++ b/metrics/src/vespa/metrics/metricsnapshot.cpp @@ -30,7 +30,7 @@ MetricSnapshot::MetricSnapshot( Metric* m = source.clone(_metrics, Metric::INACTIVE, 0, copyUnset); assert(m->isMetricSet()); _snapshot.reset(static_cast(m)); - trim(_metrics); + _metrics.shrink_to_fit(); } MetricSnapshot::~MetricSnapshot() { } @@ -46,7 +46,7 @@ MetricSnapshot::reset(time_t currentTime) void MetricSnapshot::recreateSnapshot(const MetricSet& metrics, bool copyUnset) { - std::vector newMetrics; + std::vector newMetrics; Metric* m = metrics.clone(newMetrics, Metric::INACTIVE, 0, copyUnset); assert(m->isMetricSet()); std::unique_ptr newSnapshot(static_cast(m)); @@ -54,7 +54,7 @@ MetricSnapshot::recreateSnapshot(const MetricSet& metrics, bool copyUnset) _snapshot->addToSnapshot(*newSnapshot, newMetrics); _snapshot = std::move(newSnapshot); _metrics.swap(newMetrics); - trim(_metrics); + _metrics.shrink_to_fit(); } void diff --git a/metrics/src/vespa/metrics/metricsnapshot.h b/metrics/src/vespa/metrics/metricsnapshot.h index b6770d8d7e9..121099ccf3e 100644 --- a/metrics/src/vespa/metrics/metricsnapshot.h +++ b/metrics/src/vespa/metrics/metricsnapshot.h @@ -28,7 +28,7 @@ class MetricSnapshot // Keeps the metrics set view of the snapshot std::unique_ptr _snapshot; // Snapshots must own their own metrics - mutable std::vector _metrics; + mutable std::vector _metrics; public: typedef std::unique_ptr UP; diff --git a/metrics/src/vespa/metrics/printutils.cpp b/metrics/src/vespa/metrics/printutils.cpp index 74db31de1ad..2373d2391ff 100644 --- a/metrics/src/vespa/metrics/printutils.cpp +++ b/metrics/src/vespa/metrics/printutils.cpp @@ -102,7 +102,7 @@ MetricSource::SourceMetricVisitor::visitMetric(const Metric& metric, bool) { + metric.toString(), VESPA_STRLOC); } - std::vector ownerList; + std::vector ownerList; _resultMetric.reset(metric.clone(ownerList, Metric::INACTIVE, 0)); if (!ownerList.empty()) { throw vespalib::IllegalArgumentException( diff --git a/metrics/src/vespa/metrics/summetric.h b/metrics/src/vespa/metrics/summetric.h index 61a1d31e4f6..32444b3a75d 100644 --- a/metrics/src/vespa/metrics/summetric.h +++ b/metrics/src/vespa/metrics/summetric.h @@ -26,7 +26,7 @@ public: class StartValue { private: - std::vector _startValueChildren; + std::vector _startValueChildren; Metric::UP _startValue; public: @@ -43,10 +43,10 @@ private: public: SumMetric(const String& name, const String& tags, const String& description, MetricSet* owner = 0); - SumMetric(const SumMetric& other, std::vector& ownerList, MetricSet* owner = 0); + SumMetric(const SumMetric& other, std::vector & ownerList, MetricSet* owner = 0); ~SumMetric(); - Metric* clone( std::vector&, CopyType, MetricSet* owner, bool includeUnused = false) const override; + Metric* clone( std::vector &, CopyType, MetricSet* owner, bool includeUnused = false) const override; /** * If you want to support sums of collections of metrics that may @@ -77,13 +77,13 @@ public: virtual void printDebug(std::ostream&, const std::string& indent="") const; virtual void addToPart(Metric&) const; - virtual void addToSnapshot(Metric&, std::vector&) const; + virtual void addToSnapshot(Metric&, std::vector &) const; private: friend class MetricManagerTest; - std::pair, Metric::LP> generateSum() const; + std::pair, Metric::UP> generateSum() const; - virtual void addTo(Metric&, std::vector* ownerList) const; + virtual void addTo(Metric&, std::vector *ownerList) const; bool isAddendType(const Metric* m) const; }; diff --git a/metrics/src/vespa/metrics/summetric.hpp b/metrics/src/vespa/metrics/summetric.hpp index e2421f322d3..1a54067b01f 100644 --- a/metrics/src/vespa/metrics/summetric.hpp +++ b/metrics/src/vespa/metrics/summetric.hpp @@ -16,7 +16,7 @@ SumMetric::visit(MetricVisitor& visitor, { (void) tagAsAutoGenerated; if (_metricsToSum.empty()) return true; - std::pair, Metric::LP> sum(generateSum()); + std::pair, Metric::UP> sum(generateSum()); return sum.second->visit(visitor, true); } @@ -31,7 +31,7 @@ SumMetric::SumMetric(const String& name, const String& tags, template SumMetric::SumMetric(const SumMetric& other, - std::vector& ownerList, + std::vector &ownerList, MetricSet* owner) : Metric(other, owner), _startValue(other._startValue), @@ -94,7 +94,7 @@ SumMetric::~SumMetric() { } template Metric* -SumMetric::clone(std::vector& ownerList, +SumMetric::clone(std::vector &ownerList, CopyType copyType, MetricSet* owner, bool includeUnused) const { @@ -139,19 +139,19 @@ template void SumMetric::addToPart(Metric& m) const { - std::pair, Metric::LP> sum(generateSum()); + std::pair, Metric::UP> sum(generateSum()); sum.second->addToPart(m); } template void SumMetric::addToSnapshot( - Metric& m, std::vector& ownerList) const + Metric& m, std::vector &ownerList) const { if (isAddendType(&m)) { // If the type to add to is an addend metric, it is part of an inactive // copy we need to add data to. - std::pair, Metric::LP> sum(generateSum()); + std::pair, Metric::UP> sum(generateSum()); sum.second->addToSnapshot(m, ownerList); } } @@ -159,16 +159,16 @@ SumMetric::addToSnapshot( template void SumMetric::addTo(Metric& m, - std::vector* ownerList) const + std::vector *ownerList) const { if (ownerList == 0) { - std::pair, Metric::LP> sum(generateSum()); + std::pair, Metric::UP> sum(generateSum()); sum.second->addToPart(m); } else { if (isAddendType(&m)) { // If the type to add to is an addend metric, it is part of an // inactive copy we need to add data to. - std::pair, Metric::LP> sum(generateSum()); + std::pair, Metric::UP> sum(generateSum()); sum.second->addToSnapshot(m, *ownerList); } } @@ -220,10 +220,10 @@ SumMetric::removeMetricFromSum(const AddendMetric &metric) } template -std::pair, Metric::LP> +std::pair, Metric::UP> SumMetric::generateSum() const { - std::pair, Metric::LP> retVal; + std::pair, Metric::UP> retVal; Metric* m = clone(retVal.first, INACTIVE, 0, true); m->setRegistered(_owner); retVal.second.reset(m); @@ -234,7 +234,7 @@ template int64_t SumMetric::getLongValue(const stringref & id) const { - std::pair, Metric::LP> sum(generateSum()); + std::pair, Metric::UP> sum(generateSum()); if (sum.second.get() == 0) return 0; return sum.second->getLongValue(id); } @@ -243,7 +243,7 @@ template double SumMetric::getDoubleValue(const stringref & id) const { - std::pair, Metric::LP> sum(generateSum()); + std::pair, Metric::UP> sum(generateSum()); if (sum.second.get() == 0) return 0.0; return sum.second->getDoubleValue(id); } @@ -252,7 +252,7 @@ template bool SumMetric::logEvent(const String & fullName) const { - std::pair, Metric::LP> sum(generateSum()); + std::pair, Metric::UP> sum(generateSum()); if (sum.second.get() == 0) return false; return sum.second->logEvent(fullName); } @@ -263,7 +263,7 @@ SumMetric::print(std::ostream& out, bool verbose, const std::string& indent, uint64_t secondsPassed) const { - std::pair, Metric::LP> sum(generateSum()); + std::pair, Metric::UP> sum(generateSum()); if (sum.second.get() == 0) return; sum.second->print(out, verbose, indent, secondsPassed); } diff --git a/metrics/src/vespa/metrics/updatehook.h b/metrics/src/vespa/metrics/updatehook.h index 2b2f4466b54..20d7c502a45 100644 --- a/metrics/src/vespa/metrics/updatehook.h +++ b/metrics/src/vespa/metrics/updatehook.h @@ -2,7 +2,6 @@ #pragma once #include -#include namespace metrics { @@ -15,7 +14,7 @@ class UpdateHook { friend class MetricManager; public: - typedef vespalib::LinkedPtr LP; + using UP = std::unique_ptr; using MetricLockGuard = vespalib::MonitorGuard; UpdateHook(const char* name) : _name(name), _nextCall(0), _period(0) {} diff --git a/metrics/src/vespa/metrics/valuemetric.h b/metrics/src/vespa/metrics/valuemetric.h index ce132e3ffdd..8c02857bcd7 100644 --- a/metrics/src/vespa/metrics/valuemetric.h +++ b/metrics/src/vespa/metrics/valuemetric.h @@ -97,7 +97,7 @@ public: void logOnlyIfSet() { _values.removeFlag(LOG_IF_UNSET); } virtual ValueMetric * clone( - std::vector&, CopyType type, MetricSet* owner, + std::vector &, CopyType type, MetricSet* owner, bool /*includeUnused*/) const { return new ValueMetric(*this, type, owner); } @@ -150,7 +150,7 @@ public: virtual void printDebug(std::ostream&, const std::string& indent) const; virtual void addToPart(Metric&) const; - virtual void addToSnapshot(Metric&, std::vector&) const; + virtual void addToSnapshot(Metric&, std::vector &) const; }; typedef ValueMetric DoubleValueMetric; diff --git a/metrics/src/vespa/metrics/valuemetric.hpp b/metrics/src/vespa/metrics/valuemetric.hpp index 08c639e8069..65a0c2bb5b2 100644 --- a/metrics/src/vespa/metrics/valuemetric.hpp +++ b/metrics/src/vespa/metrics/valuemetric.hpp @@ -79,7 +79,7 @@ void ValueMetric::dec(AvgVal decVal) template void ValueMetric::addToSnapshot( - Metric& other, std::vector&) const + Metric& other, std::vector &) const { ValueMetric& o( reinterpret_cast&>(other)); diff --git a/persistence/src/main/java/com/yahoo/persistence/spi/conformance/ConformanceTest.java b/persistence/src/main/java/com/yahoo/persistence/spi/conformance/ConformanceTest.java index 80aedc3263d..58a494a7e4d 100644 --- a/persistence/src/main/java/com/yahoo/persistence/spi/conformance/ConformanceTest.java +++ b/persistence/src/main/java/com/yahoo/persistence/spi/conformance/ConformanceTest.java @@ -1497,7 +1497,7 @@ public abstract class ConformanceTest extends TestCase { // } // // size_t -// getRemoveEntryCount(const std::vector& entries) +// getRemoveEntryCount(const std::vector& entries) // { // size_t ret = 0; // for (size_t i = 0; i < entries.size(); ++i) { @@ -1511,7 +1511,7 @@ public abstract class ConformanceTest extends TestCase { // List // getEntriesFromChunks(const std::vector& chunks) // { -// std::vector ret; +// std::vector ret; // for (size_t chunk = 0; chunk < chunks.size(); ++chunk) { // for (size_t i = 0; i < chunks[chunk]._entries.size(); ++i) { // ret.push_back(chunks[chunk]._entries[i]); diff --git a/persistence/src/tests/dummyimpl/dummypersistence_test.cpp b/persistence/src/tests/dummyimpl/dummypersistence_test.cpp index 1a7c43db600..a408eec739f 100644 --- a/persistence/src/tests/dummyimpl/dummypersistence_test.cpp +++ b/persistence/src/tests/dummyimpl/dummypersistence_test.cpp @@ -19,7 +19,7 @@ struct Fixture { BucketContent content; void insert(DocumentId id, Timestamp timestamp, int meta_flags) { - content.insert(DocEntry::LP(new DocEntry(timestamp, meta_flags, id))); + content.insert(DocEntry::UP(new DocEntry(timestamp, meta_flags, id))); } Fixture() { @@ -37,14 +37,14 @@ TEST("require that empty BucketContent behaves") { } TEST_F("require that BucketContent can retrieve by timestamp", Fixture) { - DocEntry::LP entry = f.content.getEntry(Timestamp(1)); + DocEntry::SP entry = f.content.getEntry(Timestamp(1)); ASSERT_TRUE(entry.get()); ASSERT_TRUE(entry->getDocumentId()); ASSERT_EQUAL("doc:test:1", entry->getDocumentId()->toString()); } TEST_F("require that BucketContent can retrieve by doc id", Fixture) { - DocEntry::LP entry = f.content.getEntry(DocumentId("doc:test:2")); + DocEntry::SP entry = f.content.getEntry(DocumentId("doc:test:2")); ASSERT_TRUE(entry.get()); ASSERT_TRUE(entry->getDocumentId()); ASSERT_EQUAL("doc:test:2", entry->getDocumentId()->toString()); diff --git a/persistence/src/tests/proxy/mockprovider.h b/persistence/src/tests/proxy/mockprovider.h index 42d21d393b8..fa15334625d 100644 --- a/persistence/src/tests/proxy/mockprovider.h +++ b/persistence/src/tests/proxy/mockprovider.h @@ -111,8 +111,8 @@ struct MockProvider : PersistenceProvider { virtual IterateResult iterate(IteratorId, uint64_t, Context&) const { last_called = ITERATE; IterateResult::List result; - result.push_back(DocEntry::LP(new DocEntry(Timestamp(1), 0))); - return IterateResult(result, true); + result.push_back(DocEntry::UP(new DocEntry(Timestamp(1), 0))); + return IterateResult(std::move(result), true); } virtual Result destroyIterator(IteratorId, Context&) { diff --git a/persistence/src/vespa/persistence/conformancetest/conformancetest.cpp b/persistence/src/vespa/persistence/conformancetest/conformancetest.cpp index 861b0afc100..7af0ea68da1 100644 --- a/persistence/src/vespa/persistence/conformancetest/conformancetest.cpp +++ b/persistence/src/vespa/persistence/conformancetest/conformancetest.cpp @@ -118,13 +118,13 @@ struct DocAndTimestamp */ struct Chunk { - std::vector _entries; + std::vector _entries; }; struct DocEntryIndirectTimestampComparator { - bool operator()(const DocEntry::LP& e1, - const DocEntry::LP& e2) const + bool operator()(const DocEntry::UP& e1, + const DocEntry::UP& e2) const { return e1->getTimestamp() < e2->getTimestamp(); } @@ -145,18 +145,12 @@ doIterate(PersistenceProvider& spi, std::vector chunks; while (true) { - std::vector entries; - Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); IterateResult result(spi.iterate(id, maxByteSize, context)); CPPUNIT_ASSERT_EQUAL(Result::NONE, result.getErrorCode()); - for (size_t i = 0; i < result.getEntries().size(); ++i) { - entries.push_back(result.getEntries()[i]); - } - chunks.push_back(Chunk()); - chunks.back()._entries.swap(entries); + chunks.push_back(Chunk{std::move(result.steal_entries())}); if (result.isCompleted() || (maxChunks != 0 && chunks.size() >= maxChunks)) { @@ -167,7 +161,7 @@ doIterate(PersistenceProvider& spi, } size_t -getRemoveEntryCount(const std::vector& entries) +getRemoveEntryCount(const std::vector& entries) { size_t ret = 0; for (size_t i = 0; i < entries.size(); ++i) { @@ -178,13 +172,13 @@ getRemoveEntryCount(const std::vector& entries) return ret; } -std::vector +std::vector getEntriesFromChunks(const std::vector& chunks) { - std::vector ret; + std::vector ret; for (size_t chunk = 0; chunk < chunks.size(); ++chunk) { for (size_t i = 0; i < chunks[chunk]._entries.size(); ++i) { - ret.push_back(chunks[chunk]._entries[i]); + ret.push_back(DocEntry::UP(chunks[chunk]._entries[i]->clone())); } } std::sort(ret.begin(), @@ -194,12 +188,12 @@ getEntriesFromChunks(const std::vector& chunks) } -std::vector +std::vector iterateBucket(PersistenceProvider& spi, const Bucket& bucket, IncludedVersions versions) { - std::vector ret; + std::vector ret; DocumentSelection docSel(""); Selection sel(docSel); @@ -218,11 +212,10 @@ iterateBucket(PersistenceProvider& spi, spi.iterate(iter.getIteratorId(), std::numeric_limits().max(), context); if (result.getErrorCode() != Result::NONE) { - return std::vector(); - } - for (size_t i = 0; i < result.getEntries().size(); ++i) { - ret.push_back(result.getEntries()[i]); + return std::vector(); } + auto list = result.steal_entries(); + std::move(list.begin(), list.end(), std::back_inserter(ret)); if (result.isCompleted()) { break; } @@ -240,7 +233,7 @@ verifyDocs(const std::vector& wanted, const std::vector& chunks, const std::set& removes = std::set()) { - std::vector retrieved( + std::vector retrieved( getEntriesFromChunks(chunks)); size_t removeCount = getRemoveEntryCount(retrieved); // Ensure that we've got the correct number of puts and removes @@ -686,7 +679,7 @@ void ConformanceTest::testPutDuplicate() { CPPUNIT_ASSERT_EQUAL(1, (int)info.getDocumentCount()); CPPUNIT_ASSERT_EQUAL(checksum, info.getChecksum()); } - std::vector entries( + std::vector entries( iterateBucket(*spi, bucket, ALL_VERSIONS)); CPPUNIT_ASSERT_EQUAL(size_t(1), entries.size()); } @@ -711,7 +704,7 @@ void ConformanceTest::testRemove() { CPPUNIT_ASSERT_EQUAL(1, (int)info.getDocumentCount()); CPPUNIT_ASSERT(info.getChecksum() != 0); - std::vector entries( + std::vector entries( iterateBucket(*spi, bucket, NEWEST_DOCUMENT_ONLY)); CPPUNIT_ASSERT_EQUAL(size_t(1), entries.size()); } @@ -731,13 +724,13 @@ void ConformanceTest::testRemove() { CPPUNIT_ASSERT_EQUAL(true, result2.wasFound()); } { - std::vector entries(iterateBucket(*spi, + std::vector entries(iterateBucket(*spi, bucket, NEWEST_DOCUMENT_ONLY)); CPPUNIT_ASSERT_EQUAL(size_t(0), entries.size()); } { - std::vector entries(iterateBucket(*spi, + std::vector entries(iterateBucket(*spi, bucket, NEWEST_DOCUMENT_OR_REMOVE)); @@ -820,7 +813,7 @@ void ConformanceTest::testRemoveMerge() { // Remove entry should exist afterwards { - std::vector entries(iterateBucket( + std::vector entries(iterateBucket( *spi, bucket, ALL_VERSIONS)); CPPUNIT_ASSERT_EQUAL(size_t(2), entries.size()); // Timestamp-sorted by iterateBucket @@ -848,7 +841,7 @@ void ConformanceTest::testRemoveMerge() { } // Must have new remove. We don't check for the presence of the old remove. { - std::vector entries(iterateBucket(*spi, bucket, ALL_VERSIONS)); + std::vector entries(iterateBucket(*spi, bucket, ALL_VERSIONS)); CPPUNIT_ASSERT(entries.size() >= 2); CPPUNIT_ASSERT_EQUAL(removeId, *entries.back()->getDocumentId()); CPPUNIT_ASSERT_EQUAL(Timestamp(11), entries.back()->getTimestamp()); @@ -875,7 +868,7 @@ void ConformanceTest::testRemoveMerge() { } // Must have newest remove. We don't check for the presence of the old remove. { - std::vector entries(iterateBucket(*spi, bucket, ALL_VERSIONS)); + std::vector entries(iterateBucket(*spi, bucket, ALL_VERSIONS)); CPPUNIT_ASSERT(entries.size() >= 2); CPPUNIT_ASSERT_EQUAL(removeId, *entries.back()->getDocumentId()); CPPUNIT_ASSERT_EQUAL(Timestamp(11), entries.back()->getTimestamp()); @@ -1302,7 +1295,7 @@ ConformanceTest::testIterateRemoves() createIterator(*spi, b, sel, NEWEST_DOCUMENT_OR_REMOVE)); std::vector chunks = doIterate(*spi, iter.getIteratorId(), 4096); - std::vector entries = getEntriesFromChunks(chunks); + std::vector entries = getEntriesFromChunks(chunks); CPPUNIT_ASSERT_EQUAL(docs.size(), entries.size()); verifyDocs(nonRemovedDocs, chunks, removedDocs); diff --git a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp index 75c83283c2c..f6a74fea83d 100644 --- a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp +++ b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp @@ -111,8 +111,8 @@ namespace { struct HasDocId { const DocumentId &_did; HasDocId(const DocumentId &did) : _did(did) {} - bool operator()(const DocEntry::LP &entry) - { return *entry->getDocumentId() == _did; } + bool operator()(const DocEntry &entry) + { return *entry.getDocumentId() == _did; } }; struct TimestampLess { @@ -159,7 +159,7 @@ BucketContent::hasTimestamp(Timestamp t) const */ void -BucketContent::insert(DocEntry::LP e) +BucketContent::insert(DocEntry::SP e) { LOG(spam, "insert(%s)", e->toString().c_str()); const DocumentId* docId(e->getDocumentId()); @@ -247,24 +247,24 @@ BucketContent::insert(DocEntry::LP e) assert(_outdatedInfo || _info.getEntryCount() == _entries.size()); } -DocEntry::LP +DocEntry::SP BucketContent::getEntry(const DocumentId& did) const { GidMapType::const_iterator it(_gidMap.find(did.getGlobalId())); if (it != _gidMap.end()) { return it->second; } - return DocEntry::LP(); + return DocEntry::SP(); } -DocEntry::LP +DocEntry::SP BucketContent::getEntry(Timestamp t) const { std::vector::const_iterator iter = lower_bound(_entries.begin(), _entries.end(), t, TimestampLess()); if (iter == _entries.end() || iter->entry->getTimestamp() != t) { - return DocEntry::LP(); + return DocEntry::SP(); } else { return iter->entry; } @@ -435,7 +435,7 @@ DummyPersistence::put(const Bucket& b, Timestamp t, const Document::SP& doc, return BucketInfoResult(Result::TRANSIENT_ERROR, "Bucket not found"); } - DocEntry::LP existing = (*bc)->getEntry(t); + DocEntry::SP existing = (*bc)->getEntry(t); if (existing.get()) { if (doc->getId() == *existing->getDocumentId()) { return Result(); @@ -447,8 +447,8 @@ DummyPersistence::put(const Bucket& b, Timestamp t, const Document::SP& doc, LOG(spam, "Inserting document %s", doc->toString(true).c_str()); - DocEntry::LP entry(new DocEntry(t, NONE, Document::UP(doc->clone()))); - (*bc)->insert(entry); + DocEntry::UP entry(new DocEntry(t, NONE, Document::UP(doc->clone()))); + (*bc)->insert(std::move(entry)); return Result(); } @@ -490,14 +490,14 @@ DummyPersistence::remove(const Bucket& b, return RemoveResult(Result::TRANSIENT_ERROR, "Bucket not found"); } - DocEntry::LP entry((*bc)->getEntry(did)); + DocEntry::SP entry((*bc)->getEntry(did)); bool foundPut(entry.get() && !entry->isRemove()); - DocEntry::LP remEntry(new DocEntry(t, REMOVE_ENTRY, did)); + DocEntry::UP remEntry(new DocEntry(t, REMOVE_ENTRY, did)); if ((*bc)->hasTimestamp(t)) { (*bc)->eraseEntry(t); } - (*bc)->insert(remEntry); + (*bc)->insert(std::move(remEntry)); return RemoveResult(foundPut); } @@ -514,7 +514,7 @@ DummyPersistence::get(const Bucket& b, BucketContentGuard::UP bc(acquireBucketWithLock(b)); if (!bc.get()) { } else { - DocEntry::LP entry((*bc)->getEntry(did)); + DocEntry::SP entry((*bc)->getEntry(did)); if (entry.get() == 0 || entry->isRemove()) { } else { Document::UP doc(entry->getDocument()->clone()); @@ -538,7 +538,7 @@ DummyPersistence::createIterator( { DUMMYPERSISTENCE_VERIFY_INITIALIZED; LOG(debug, "createIterator(%s)", b.toString().c_str()); - vespalib::LinkedPtr docSelection; + std::unique_ptr docSelection; if (!s.getDocumentSelection().getDocumentSelection().empty()) { docSelection.reset( parseDocumentSelection( @@ -563,13 +563,13 @@ DummyPersistence::createIterator( ++_nextIterator; assert(_iterators.find(id) == _iterators.end()); it = new Iterator; - _iterators[id] = Iterator::LP(it); + _iterators[id] = Iterator::UP(it); assert(it->_bucket.getBucketId().getRawId() == 0); // Wrap detection it->_bucket = b; } // Memory pointed to by 'it' should now be valid from here on out - it->_fieldSet = vespalib::LinkedPtr(fs.clone()); + it->_fieldSet = std::unique_ptr(fs.clone()); const BucketContent::GidMapType& gidMap((*bc)->_gidMap); if (s.getTimestampSubset().empty()) { @@ -630,7 +630,7 @@ DummyPersistence::iterate(IteratorId id, uint64_t maxByteSize, Context& ctx) con Iterator* it; { vespalib::MonitorGuard lock(_monitor); - std::map::iterator iter(_iterators.find(id)); + std::map::iterator iter(_iterators.find(id)); if (iter == _iterators.end()) { return IterateResult(Result::PERMANENT_ERROR, "Bug! Used iterate without sending createIterator first"); @@ -645,12 +645,12 @@ DummyPersistence::iterate(IteratorId id, uint64_t maxByteSize, Context& ctx) con } LOG(debug, "Iterator %zu acquired bucket lock", uint64_t(id)); - std::vector entries; + std::vector entries; uint32_t currentSize = 0; uint32_t fastPath = 0; while (!it->_leftToIterate.empty()) { Timestamp next(it->_leftToIterate.back()); - DocEntry::LP entry((*bc)->getEntry(next)); + DocEntry::SP entry((*bc)->getEntry(next)); if (entry.get() != 0) { uint32_t size = entry->getSize(); if (currentSize != 0 && currentSize + size > maxByteSize) break; @@ -664,14 +664,14 @@ DummyPersistence::iterate(IteratorId id, uint64_t maxByteSize, Context& ctx) con document::FieldSet::createDocumentSubsetCopy( *entry->getDocument(), *it->_fieldSet)); - DocEntry::LP ret(new DocEntry(entry->getTimestamp(), + DocEntry::UP ret(new DocEntry(entry->getTimestamp(), entry->getFlags(), std::move(filtered), entry->getPersistedDocumentSize())); - entries.push_back(ret); + entries.push_back(std::move(ret)); } else { // Use entry as-is. - entries.push_back(DocEntry::LP(entry->clone())); + entries.push_back(DocEntry::UP(entry->clone())); ++fastPath; } } @@ -691,10 +691,10 @@ DummyPersistence::iterate(IteratorId id, uint64_t maxByteSize, Context& ctx) con currentSize, fastPath); if (it->_leftToIterate.empty()) { - return IterateResult(entries, true); + return IterateResult(std::move(entries), true); } - return IterateResult(entries, false); + return IterateResult(std::move(entries), false); } Result @@ -716,7 +716,7 @@ DummyPersistence::createBucket(const Bucket& b, Context&) LOG(debug, "createBucket(%s)", b.toString().c_str()); vespalib::MonitorGuard lock(_monitor); if (_content[b.getPartition()].find(b) == _content[b.getPartition()].end()) { - _content[b.getPartition()][b] = BucketContent::LP(new BucketContent); + _content[b.getPartition()][b] = BucketContent::SP(new BucketContent); } else { assert(!_content[b.getPartition()][b]->_inUse); LOG(debug, "%s already existed", b.toString().c_str()); @@ -770,16 +770,16 @@ DummyPersistence::split(const Bucket& source, // Add entries for (uint32_t i=0; igetDocumentId()).getRawId()); if (bId == target1.getBucketId()) { - targ1.insert(entry); + targ1.insert(std::move(entry)); } else { - targ2.insert(entry); + targ2.insert(std::move(entry)); } } targ1.setActive(sour.isActive()); @@ -817,8 +817,8 @@ DummyPersistence::join(const Bucket& source1, const Bucket& source2, active |= sour.isActive(); for (uint32_t i=0; iinsert(entry); + DocEntry::SP entry(sour._entries[i].entry); + (*targetGuard)->insert(std::move(entry)); } sourceGuard.reset(0); deleteBucket(source, context); @@ -842,7 +842,7 @@ DummyPersistence::revert(const Bucket& b, Timestamp t, Context&) } BucketContent& content(**bc); - DocEntry::LP docEntry(content.getEntry(t)); + DocEntry::SP docEntry(content.getEntry(t)); if (!docEntry.get()) { return Result(); } @@ -953,4 +953,4 @@ DummyPersistence::releaseBucketNoLock(const BucketContent& bc) const } // spi } // storage -VESPALIB_HASH_MAP_INSTANTIATE_H(storage::spi::Bucket, vespalib::LinkedPtr, document::BucketId::hash) \ No newline at end of file +VESPALIB_HASH_MAP_INSTANTIATE_H(storage::spi::Bucket, std::shared_ptr, document::BucketId::hash) diff --git a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h index c1af86d5a77..940e72d1668 100644 --- a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h +++ b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h @@ -28,10 +28,10 @@ namespace dummy { struct BucketEntry { - DocEntry::LP entry; + DocEntry::SP entry; GlobalId gid; - BucketEntry(const DocEntry::LP& e, const GlobalId& g) + BucketEntry(DocEntry::SP e, const GlobalId& g) : entry(e), gid(g) { } @@ -40,11 +40,11 @@ struct BucketEntry struct BucketContent { typedef vespalib::hash_map< document::GlobalId, - DocEntry::LP, + DocEntry::SP, document::GlobalId::hash > GidMapType; - typedef vespalib::LinkedPtr LP; + using SP = std::shared_ptr; std::vector _entries; GidMapType _gidMap; @@ -67,9 +67,9 @@ struct BucketContent { const BucketInfo& getBucketInfo() const; BucketInfo& getMutableBucketInfo() { return _info; } bool hasTimestamp(Timestamp) const; - void insert(DocEntry::LP); - DocEntry::LP getEntry(const DocumentId&) const; - DocEntry::LP getEntry(Timestamp) const; + void insert(DocEntry::SP); + DocEntry::SP getEntry(const DocumentId&) const; + DocEntry::SP getEntry(Timestamp) const; void eraseEntry(Timestamp t); void setActive(bool active = true) { _active = active; @@ -87,10 +87,10 @@ struct BucketContent { }; struct Iterator { - typedef vespalib::LinkedPtr LP; + using UP = std::unique_ptr; Bucket _bucket; std::vector _leftToIterate; - vespalib::LinkedPtr _fieldSet; + std::unique_ptr _fieldSet; }; class DummyPersistence; @@ -220,12 +220,12 @@ private: mutable bool _initialized; document::DocumentTypeRepo::SP _repo; PartitionStateList _partitions; - typedef vespalib::hash_map + typedef vespalib::hash_map PartitionContent; std::vector _content; IteratorId _nextIterator; - mutable std::map _iterators; + mutable std::map _iterators; vespalib::Monitor _monitor; std::unique_ptr _clusterState; diff --git a/persistence/src/vespa/persistence/proxy/providerproxy.cpp b/persistence/src/vespa/persistence/proxy/providerproxy.cpp index 72936bbda6c..1f6d0b19be6 100644 --- a/persistence/src/vespa/persistence/proxy/providerproxy.cpp +++ b/persistence/src/vespa/persistence/proxy/providerproxy.cpp @@ -198,7 +198,7 @@ IterateResult ProviderProxy::readNoError(const FRT_Values &values) const { string doc_id(getString(values[4]._string_array._pt[i])); nbostream stream(values[5]._data_array._pt[i]._buf, values[5]._data_array._pt[i]._len); - DocEntry::LP entry; + DocEntry::UP entry; if (!stream.empty()) { Document::UP doc = readDocument(stream, *_repo); entry.reset(new DocEntry(timestamp, meta_flags, std::move(doc))); @@ -208,10 +208,10 @@ IterateResult ProviderProxy::readNoError(const FRT_Values &values) const { } else { entry.reset(new DocEntry(timestamp, meta_flags)); } - result.push_back(entry); + result.push_back(std::move(entry)); } - return IterateResult(result, values[6]._intval8); + return IterateResult(std::move(result), values[6]._intval8); } namespace { diff --git a/persistence/src/vespa/persistence/proxy/providerstub.cpp b/persistence/src/vespa/persistence/proxy/providerstub.cpp index 94d4811c0d6..e0f0a22f0dd 100644 --- a/persistence/src/vespa/persistence/proxy/providerstub.cpp +++ b/persistence/src/vespa/persistence/proxy/providerstub.cpp @@ -97,7 +97,7 @@ void addIterateResult(FRT_Values &ret, const IterateResult &result) { addResult(ret, result); - const vector &entries = result.getEntries(); + const vector &entries = result.getEntries(); uint64_t *timestamps = ret.AddInt64Array(entries.size()); uint32_t *flags = ret.AddInt32Array(entries.size()); assert(sizeof(DocEntry::SizeType) == sizeof(uint32_t)); diff --git a/persistence/src/vespa/persistence/spi/docentry.h b/persistence/src/vespa/persistence/spi/docentry.h index 69c65465d8e..08db894a89a 100644 --- a/persistence/src/vespa/persistence/spi/docentry.h +++ b/persistence/src/vespa/persistence/spi/docentry.h @@ -14,7 +14,6 @@ #pragma once #include -#include namespace storage { namespace spi { @@ -35,8 +34,8 @@ private: DocumentIdUP _documentId; DocumentUP _document; public: - typedef vespalib::LinkedPtr LP; - typedef std::unique_ptr UP; + using UP = std::unique_ptr; + using SP = std::shared_ptr; DocEntry(Timestamp t, int metaFlags, DocumentUP doc); diff --git a/persistence/src/vespa/persistence/spi/result.h b/persistence/src/vespa/persistence/spi/result.h index df2a2a55454..ce250f8aabe 100644 --- a/persistence/src/vespa/persistence/spi/result.h +++ b/persistence/src/vespa/persistence/spi/result.h @@ -248,7 +248,7 @@ private: class IterateResult : public Result { public: - typedef std::vector List; + typedef std::vector List; /** * Constructor used when there was an error creating the iterator. @@ -270,15 +270,19 @@ public: _entries(std::move(entries)) { } + IterateResult(const IterateResult &) = delete; + IterateResult(IterateResult &&rhs) = default; + IterateResult &operator=(IterateResult &&rhs) = default; + ~IterateResult(); const List& getEntries() const { return _entries; } - + List steal_entries() { return std::move(_entries); } bool isCompleted() const { return _completed; } private: bool _completed; - std::vector _entries; + std::vector _entries; }; class PartitionStateListResult : public Result diff --git a/searchcommon/src/vespa/searchcommon/common/iblobconverter.h b/searchcommon/src/vespa/searchcommon/common/iblobconverter.h index 820109c0504..789d91ba8d8 100644 --- a/searchcommon/src/vespa/searchcommon/common/iblobconverter.h +++ b/searchcommon/src/vespa/searchcommon/common/iblobconverter.h @@ -3,7 +3,6 @@ #pragma once #include -#include namespace search { namespace common { @@ -12,7 +11,6 @@ class BlobConverter { public: using SP = std::shared_ptr; - using LP = vespalib::LinkedPtr; using UP = std::unique_ptr; using ConstBufferRef = vespalib::ConstBufferRef; virtual ~BlobConverter() { } diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp index 7df80778cb7..a33a5f147f2 100644 --- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp @@ -569,7 +569,7 @@ TEST_F("require that outdated put is ignored", FeedHandlerFixture) void addLidToRemove(RemoveDocumentsOperation &op) { - LidVectorContext::LP lids(new LidVectorContext(42)); + LidVectorContext::SP lids(new LidVectorContext(42)); lids->addLid(4); op.setLidsToRemove(0, lids); } diff --git a/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp b/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp index 2c54188af3a..7a28dd02bca 100644 --- a/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp @@ -249,7 +249,7 @@ TEST_F("require that prune removed documents removes documents", { f.addDocsToMetaStore(3); - LidVectorContext::LP lids(new LidVectorContext(4)); + LidVectorContext::SP lids(new LidVectorContext(4)); lids->addLid(1); lids->addLid(3); PruneRemovedDocumentsOperation op(lids->getDocIdLimit(), subdb_id); diff --git a/searchcore/src/tests/proton/metrics/metrics_engine/metrics_engine_test.cpp b/searchcore/src/tests/proton/metrics/metrics_engine/metrics_engine_test.cpp index 36cdd7ff89f..78b53910023 100644 --- a/searchcore/src/tests/proton/metrics/metrics_engine/metrics_engine_test.cpp +++ b/searchcore/src/tests/proton/metrics/metrics_engine/metrics_engine_test.cpp @@ -44,14 +44,14 @@ struct AttributeMetricsFixture { EXPECT_EQUAL(expNumMetrics, totalLegacyMetrics.list.getRegisteredMetrics().size()); } void assertMetricsExists(const vespalib::string &attrName) { - EXPECT_TRUE(metrics.get(attrName).get() != nullptr); - EXPECT_TRUE(legacyMetrics.list.get(attrName).get() != nullptr); - EXPECT_TRUE(totalLegacyMetrics.list.get(attrName).get() != nullptr); + EXPECT_TRUE(metrics.get(attrName) != nullptr); + EXPECT_TRUE(legacyMetrics.list.get(attrName) != nullptr); + EXPECT_TRUE(totalLegacyMetrics.list.get(attrName) != nullptr); } void assertMetricsNotExists(const vespalib::string &attrName) { - EXPECT_TRUE(metrics.get(attrName).get() == nullptr); - EXPECT_TRUE(legacyMetrics.list.get(attrName).get() == nullptr); - EXPECT_TRUE(totalLegacyMetrics.list.get(attrName).get() == nullptr); + EXPECT_TRUE(metrics.get(attrName) == nullptr); + EXPECT_TRUE(legacyMetrics.list.get(attrName) == nullptr); + EXPECT_TRUE(totalLegacyMetrics.list.get(attrName) == nullptr); } }; diff --git a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp index 89159a6b92f..0afbfaedb73 100644 --- a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp +++ b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include @@ -33,7 +32,6 @@ using document::DocumenttypesConfig; using document::DocumenttypesConfigBuilder; using search::TuneFileDocumentDB; using std::map; -using vespalib::LinkedPtr; using vespalib::VarHolder; struct DoctypeFixture { diff --git a/searchcore/src/tests/proton/server/legacy_attribute_metrics_test.cpp b/searchcore/src/tests/proton/server/legacy_attribute_metrics_test.cpp index cd129d79693..513ad5a03dd 100644 --- a/searchcore/src/tests/proton/server/legacy_attribute_metrics_test.cpp +++ b/searchcore/src/tests/proton/server/legacy_attribute_metrics_test.cpp @@ -22,31 +22,31 @@ Test::Main() LegacyAttributeMetrics attrMetrics(0); EXPECT_EQUAL(0u, attrMetrics.list.release().size()); { - LegacyAttributeMetrics::List::Entry::LP e1 = attrMetrics.list.add("foo"); - LegacyAttributeMetrics::List::Entry::LP e2 = attrMetrics.list.add("bar"); - LegacyAttributeMetrics::List::Entry::LP e3 = attrMetrics.list.add("foo"); - EXPECT_TRUE(e1.get() != 0); - EXPECT_TRUE(e2.get() != 0); - EXPECT_TRUE(e3.get() == 0); + LegacyAttributeMetrics::List::Entry *e1 = attrMetrics.list.add("foo"); + LegacyAttributeMetrics::List::Entry *e2 = attrMetrics.list.add("bar"); + LegacyAttributeMetrics::List::Entry *e3 = attrMetrics.list.add("foo"); + EXPECT_TRUE(e1 != nullptr); + EXPECT_TRUE(e2 != nullptr); + EXPECT_TRUE(e3 == nullptr); } { const LegacyAttributeMetrics &constMetrics = attrMetrics; - LegacyAttributeMetrics::List::Entry::LP e1 = constMetrics.list.get("foo"); - LegacyAttributeMetrics::List::Entry::LP e2 = constMetrics.list.get("bar"); - LegacyAttributeMetrics::List::Entry::LP e3 = constMetrics.list.get("baz"); - EXPECT_TRUE(e1.get() != 0); - EXPECT_TRUE(e2.get() != 0); - EXPECT_TRUE(e3.get() == 0); + LegacyAttributeMetrics::List::Entry *e1 = constMetrics.list.get("foo"); + LegacyAttributeMetrics::List::Entry *e2 = constMetrics.list.get("bar"); + LegacyAttributeMetrics::List::Entry *e3 = constMetrics.list.get("baz"); + EXPECT_TRUE(e1 != nullptr); + EXPECT_TRUE(e2 != nullptr); + EXPECT_TRUE(e3 == nullptr); } EXPECT_EQUAL(2u, attrMetrics.list.release().size()); { const LegacyAttributeMetrics &constMetrics = attrMetrics; - LegacyAttributeMetrics::List::Entry::LP e1 = constMetrics.list.get("foo"); - LegacyAttributeMetrics::List::Entry::LP e2 = constMetrics.list.get("bar"); - LegacyAttributeMetrics::List::Entry::LP e3 = constMetrics.list.get("baz"); - EXPECT_TRUE(e1.get() == 0); - EXPECT_TRUE(e2.get() == 0); - EXPECT_TRUE(e3.get() == 0); + LegacyAttributeMetrics::List::Entry *e1 = constMetrics.list.get("foo"); + LegacyAttributeMetrics::List::Entry *e2 = constMetrics.list.get("bar"); + LegacyAttributeMetrics::List::Entry *e3 = constMetrics.list.get("baz"); + EXPECT_TRUE(e1 == nullptr); + EXPECT_TRUE(e2 == nullptr); + EXPECT_TRUE(e3 == nullptr); } EXPECT_EQUAL(0u, attrMetrics.list.release().size()); } diff --git a/searchcore/src/vespa/searchcore/grouping/groupingsession.h b/searchcore/src/vespa/searchcore/grouping/groupingsession.h index f355f5de418..110e0a51f93 100644 --- a/searchcore/src/vespa/searchcore/grouping/groupingsession.h +++ b/searchcore/src/vespa/searchcore/grouping/groupingsession.h @@ -34,7 +34,6 @@ private: fastos::TimeStamp _timeOfDoom; public: - typedef vespalib::LinkedPtr LP; typedef std::unique_ptr UP; /** diff --git a/searchcore/src/vespa/searchcore/proton/feedoperation/lidvectorcontext.h b/searchcore/src/vespa/searchcore/proton/feedoperation/lidvectorcontext.h index 6e2f9256b84..b4ae56306f0 100644 --- a/searchcore/src/vespa/searchcore/proton/feedoperation/lidvectorcontext.h +++ b/searchcore/src/vespa/searchcore/proton/feedoperation/lidvectorcontext.h @@ -3,7 +3,6 @@ #include #include -#include #include namespace proton { @@ -17,7 +16,7 @@ private: size_t _docIdLimit; enum { ARRAY = 0, BITVECTOR = 1 }; public: - typedef vespalib::LinkedPtr LP; + using SP = std::shared_ptr; LidVectorContext(); LidVectorContext(size_t docIdLimit); LidVectorContext(size_t docIdLimit, const LidVector &lids); diff --git a/searchcore/src/vespa/searchcore/proton/feedoperation/pruneremoveddocumentsoperation.cpp b/searchcore/src/vespa/searchcore/proton/feedoperation/pruneremoveddocumentsoperation.cpp index 9da621b5c84..b257fb14d57 100644 --- a/searchcore/src/vespa/searchcore/proton/feedoperation/pruneremoveddocumentsoperation.cpp +++ b/searchcore/src/vespa/searchcore/proton/feedoperation/pruneremoveddocumentsoperation.cpp @@ -26,7 +26,7 @@ PruneRemovedDocumentsOperation(DocumentIdT docIdLimit, : RemoveDocumentsOperation(FeedOperation::PRUNE_REMOVED_DOCUMENTS), _subDbId(subDbId) { - LidVectorContext::LP lidsToRemove(new LidVectorContext(docIdLimit)); + LidVectorContext::SP lidsToRemove(new LidVectorContext(docIdLimit)); setLidsToRemove(lidsToRemove); } @@ -51,7 +51,7 @@ PruneRemovedDocumentsOperation::deserialize(vespalib::nbostream &is, } vespalib::string PruneRemovedDocumentsOperation::toString() const { - LidVectorContext::LP lids = getLidsToRemove(); + LidVectorContext::SP lids = getLidsToRemove(); return make_string("PruneRemovedDocuments(limitLid=%zu, subDbId=%d, " "serialNum=%" PRIu64 ")", lids.get() ? lids->getDocIdLimit() : 0, diff --git a/searchcore/src/vespa/searchcore/proton/feedoperation/pruneremoveddocumentsoperation.h b/searchcore/src/vespa/searchcore/proton/feedoperation/pruneremoveddocumentsoperation.h index 35c413b2491..3f30c40f881 100644 --- a/searchcore/src/vespa/searchcore/proton/feedoperation/pruneremoveddocumentsoperation.h +++ b/searchcore/src/vespa/searchcore/proton/feedoperation/pruneremoveddocumentsoperation.h @@ -26,12 +26,12 @@ public: uint32_t getSubDbId() const { return _subDbId; } - void setLidsToRemove(const LidVectorContext::LP &lidsToRemove) + void setLidsToRemove(const LidVectorContext::SP &lidsToRemove) { RemoveDocumentsOperation::setLidsToRemove(_subDbId, lidsToRemove); } - const LidVectorContext::LP + const LidVectorContext::SP getLidsToRemove() const { return RemoveDocumentsOperation::getLidsToRemove(_subDbId); diff --git a/searchcore/src/vespa/searchcore/proton/feedoperation/removedocumentsoperation.cpp b/searchcore/src/vespa/searchcore/proton/feedoperation/removedocumentsoperation.cpp index a61819d861a..247a8dfc803 100644 --- a/searchcore/src/vespa/searchcore/proton/feedoperation/removedocumentsoperation.cpp +++ b/searchcore/src/vespa/searchcore/proton/feedoperation/removedocumentsoperation.cpp @@ -37,7 +37,7 @@ RemoveDocumentsOperation::deserializeLidsToRemove(vespalib::nbostream &is) for (i = 0; i < mapSize; ++i) { uint32_t subDbId; is >> subDbId; - LidVectorContext::LP lidsToRemove(new LidVectorContext()); + LidVectorContext::SP lidsToRemove(new LidVectorContext()); lidsToRemove->deserialize(is); setLidsToRemove(subDbId, lidsToRemove); } diff --git a/searchcore/src/vespa/searchcore/proton/feedoperation/removedocumentsoperation.h b/searchcore/src/vespa/searchcore/proton/feedoperation/removedocumentsoperation.h index 49a0f44a175..8ce182591f5 100644 --- a/searchcore/src/vespa/searchcore/proton/feedoperation/removedocumentsoperation.h +++ b/searchcore/src/vespa/searchcore/proton/feedoperation/removedocumentsoperation.h @@ -10,7 +10,7 @@ namespace proton { class RemoveDocumentsOperation : public FeedOperation { protected: - typedef std::map LidsToRemoveMap; + typedef std::map LidsToRemoveMap; LidsToRemoveMap _lidsToRemoveMap; RemoveDocumentsOperation(Type type); @@ -20,17 +20,17 @@ protected: public: virtual ~RemoveDocumentsOperation() { } - void setLidsToRemove(uint32_t subDbId, const LidVectorContext::LP &lidsToRemove) { + void setLidsToRemove(uint32_t subDbId, const LidVectorContext::SP &lidsToRemove) { _lidsToRemoveMap[subDbId] = lidsToRemove; } - const LidVectorContext::LP + const LidVectorContext::SP getLidsToRemove(uint32_t subDbId) const { LidsToRemoveMap::const_iterator found(_lidsToRemoveMap.find(subDbId)); if (found != _lidsToRemoveMap.end()) return found->second; else - return LidVectorContext::LP(); + return LidVectorContext::SP(); } }; diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp index 5398d5d6a3a..f971e2633de 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp @@ -81,7 +81,7 @@ MatchMaster::match(const MatchParams ¶ms, } resultProcessor.prepareThreadContextCreation(threadBundle.size()); threadBundle.run(targets); - ResultProcessor::Result::UP reply = resultProcessor.makeReply(); + ResultProcessor::Result::UP reply = resultProcessor.makeReply(threadState[0]->extract_result()); query_latency_time.stop(); double query_time_s = query_latency_time.elapsed().sec(); double rerank_time_s = timedCommunicator.rerank_time.elapsed().sec(); diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_thread.h b/searchcore/src/vespa/searchcore/proton/matching/match_thread.h index d38c2121034..d20e71e370a 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_thread.h +++ b/searchcore/src/vespa/searchcore/proton/matching/match_thread.h @@ -108,6 +108,7 @@ public: virtual void run(); const MatchingStats::Partition &get_thread_stats() const { return thread_stats; } double get_match_time() const { return match_time_s; } + PartialResult::UP extract_result() { return std::move(resultContext->result); } }; } // namespace proton::matching diff --git a/searchcore/src/vespa/searchcore/proton/matching/partial_result.h b/searchcore/src/vespa/searchcore/proton/matching/partial_result.h index f998a8aa92e..e39b0ed92f1 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/partial_result.h +++ b/searchcore/src/vespa/searchcore/proton/matching/partial_result.h @@ -2,7 +2,6 @@ #pragma once -#include #include #include #include @@ -17,8 +16,8 @@ namespace matching { class PartialResult : public vespalib::DualMergeDirector::Source { public: - typedef vespalib::LinkedPtr LP; - typedef std::pair SortRef; + using UP = std::unique_ptr; + using SortRef = std::pair; private: std::vector _hits; diff --git a/searchcore/src/vespa/searchcore/proton/matching/result_processor.cpp b/searchcore/src/vespa/searchcore/proton/matching/result_processor.cpp index a6bf98b2ccf..09929774550 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/result_processor.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/result_processor.cpp @@ -36,9 +36,9 @@ ResultProcessor::Sort::Sort(uint32_t partitionId, const vespalib::Doom & doom, I } } -ResultProcessor::Context::Context(Sort::UP s, PartialResult::LP r, GroupingContext::UP g) +ResultProcessor::Context::Context(Sort::UP s, PartialResult::UP r, GroupingContext::UP g) : sort(std::move(s)), - result(r), + result(std::move(r)), grouping(std::move(g)), groupingSource(grouping.get()) { } @@ -70,7 +70,6 @@ ResultProcessor::ResultProcessor(IAttributeContext &attrContext, _sortSpec(sortSpec), _offset(offset), _hits(hits), - _result(), _wasMerged(false) { if (!_groupingContext.empty()) { @@ -95,24 +94,21 @@ ResultProcessor::Context::UP ResultProcessor::createThreadContext(const vespalib::Doom & hardDoom, size_t thread_id, uint32_t distributionKey) { Sort::UP sort(new Sort(distributionKey, hardDoom, _attrContext, _sortSpec)); - PartialResult::LP result(new PartialResult((_offset + _hits), sort->hasSortData())); - if (thread_id == 0) { - _result = result; - } + PartialResult::UP result(new PartialResult((_offset + _hits), sort->hasSortData())); search::grouping::GroupingContext::UP groupingContext; if (_groupingSession.get() != 0) { groupingContext = _groupingSession->createThreadContext(thread_id, _attrContext); } - return Context::UP(new Context(std::move(sort), result, std::move(groupingContext))); + return Context::UP(new Context(std::move(sort), std::move(result), std::move(groupingContext))); } ResultProcessor::Result::UP -ResultProcessor::makeReply() +ResultProcessor::makeReply(PartialResultUP full_result) { search::engine::SearchReply::UP reply(new search::engine::SearchReply()); const search::IDocumentMetaStore &metaStore = _metaStore; search::engine::SearchReply &r = *reply; - PartialResult &result = *_result; + PartialResult &result = *full_result; size_t numFs4Hits(0); if (_groupingSession) { if (_wasMerged) { diff --git a/searchcore/src/vespa/searchcore/proton/matching/result_processor.h b/searchcore/src/vespa/searchcore/proton/matching/result_processor.h index 0ce87ceb7c6..8abc8bbc1a5 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/result_processor.h +++ b/searchcore/src/vespa/searchcore/proton/matching/result_processor.h @@ -27,7 +27,7 @@ class ResultProcessor using GroupingContext = search::grouping::GroupingContext; using GroupingSession = search::grouping::GroupingSession; using IAttributeContext = search::attribute::IAttributeContext; - using PartialResultLP = vespalib::LinkedPtr; + using PartialResultUP = std::unique_ptr; public: /** * Sorter selection and owner of additional data needed for @@ -63,11 +63,11 @@ public: using GroupingContextUP = std::unique_ptr; Sort::UP sort; - PartialResultLP result; + PartialResultUP result; GroupingContextUP grouping; GroupingSource groupingSource; - Context(Sort::UP s, PartialResultLP r, GroupingContextUP g); + Context(Sort::UP s, PartialResultUP r, GroupingContextUP g); ~Context(); }; @@ -89,7 +89,6 @@ private: const vespalib::string &_sortSpec; size_t _offset; size_t _hits; - PartialResultLP _result; bool _wasMerged; public: @@ -105,7 +104,7 @@ public: size_t countFS4Hits(); void prepareThreadContextCreation(size_t num_threads); Context::UP createThreadContext(const vespalib::Doom & hardDoom, size_t thread_id, uint32_t distributionKey); - std::unique_ptr makeReply(); + std::unique_ptr makeReply(PartialResultUP full_result); }; } // namespace proton::matching diff --git a/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp b/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp index db4d12de677..772ee7bd6e4 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp @@ -26,9 +26,8 @@ namespace matching { template struct SessionCache : SessionCacheBase { - typedef typename T::LP EntryLP; typedef typename T::UP EntryUP; - vespalib::lrucache_map > _cache; + vespalib::lrucache_map > _cache; SessionCache(uint32_t max_size) : _cache(max_size) {} @@ -38,7 +37,7 @@ namespace matching { if (_cache.size() >= _cache.capacity()) { entryDropped(id); } - _cache.insert(id, EntryLP(session.release())); + _cache.insert(id, std::move(session)); _stats.numInsert++; } EntryUP pick(const SessionId & id) { @@ -46,24 +45,23 @@ namespace matching { EntryUP ret; if (_cache.hasKey(id)) { _stats.numPick++; - EntryLP session(_cache.get(id)); + ret = std::move(_cache[id]); _cache.erase(id); - ret.reset(session.release()); } return ret; } void pruneTimedOutSessions(fastos::TimeStamp currentTime) { - std::vector toDestruct = stealTimedOutSessions(currentTime); + std::vector toDestruct = stealTimedOutSessions(currentTime); toDestruct.clear(); } - std::vector stealTimedOutSessions(fastos::TimeStamp currentTime) { - std::vector toDestruct; + std::vector stealTimedOutSessions(fastos::TimeStamp currentTime) { + std::vector toDestruct; vespalib::LockGuard guard(_lock); toDestruct.reserve(_cache.size()); for (auto it(_cache.begin()), mt(_cache.end()); it != mt;) { - EntryLP session = *it; + auto &session = *it; if (session->getTimeOfDoom() < currentTime) { - toDestruct.push_back(session); + toDestruct.push_back(std::move(session)); it = _cache.erase(it); _stats.numTimedout++; } else { diff --git a/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.cpp index c56cc3f3223..10083daa769 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.cpp @@ -12,46 +12,45 @@ LegacyAttributeMetrics::List::Entry::Entry(const std::string &name) { } -LegacyAttributeMetrics::List::Entry::LP +LegacyAttributeMetrics::List::Entry * LegacyAttributeMetrics::List::add(const std::string &name) { if (metrics.find(name) != metrics.end()) { - return Entry::LP(0); + return nullptr; } - Entry::LP entry(new Entry(name)); - metrics[name] = entry; - return entry; + auto &pos = metrics[name]; + pos = std::make_unique(name); + return pos.get(); } -LegacyAttributeMetrics::List::Entry::LP +LegacyAttributeMetrics::List::Entry * LegacyAttributeMetrics::List::get(const std::string &name) const { - std::map::const_iterator pos = metrics.find(name); + const auto pos = metrics.find(name); if (pos == metrics.end()) { - return Entry::LP(0); + return nullptr; } - return pos->second; + return pos->second.get(); } -LegacyAttributeMetrics::List::Entry::LP +LegacyAttributeMetrics::List::Entry::UP LegacyAttributeMetrics::List::remove(const std::string &name) { - std::map::const_iterator pos = metrics.find(name); + auto pos = metrics.find(name); if (pos == metrics.end()) { - return Entry::LP(0); + return Entry::UP(); } - Entry::LP retval = pos->second; + Entry::UP retval = std::move(pos->second); metrics.erase(name); return retval; } -std::vector +std::vector LegacyAttributeMetrics::List::release() { - std::vector entries; - std::map::const_iterator pos = metrics.begin(); - for (; pos != metrics.end(); ++pos) { - entries.push_back(pos->second); + std::vector entries; + for (auto &pos: metrics) { + entries.push_back(std::move(pos.second)); } metrics.clear(); return entries; diff --git a/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.h b/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.h index 116d0c2b2ea..128bb75662d 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.h @@ -3,7 +3,6 @@ #pragma once #include -#include namespace proton { @@ -16,22 +15,22 @@ struct LegacyAttributeMetrics : metrics::MetricSet { struct List : metrics::MetricSet { struct Entry : metrics::MetricSet { - typedef vespalib::LinkedPtr LP; + using UP = std::unique_ptr; metrics::LongValueMetric memoryUsage; metrics::LongValueMetric bitVectors; Entry(const std::string &name); }; - Entry::LP add(const std::string &name); - Entry::LP get(const std::string &name) const; - Entry::LP remove(const std::string &name); - std::vector release(); + Entry *add(const std::string &name); + Entry *get(const std::string &name) const; + Entry::UP remove(const std::string &name); + std::vector release(); // per attribute metrics will be wired in here (by the metrics engine) List(metrics::MetricSet *parent); ~List(); private: - std::map metrics; + std::map metrics; }; List list; diff --git a/searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.cpp index f1a65b18084..8d15559b4a6 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.cpp @@ -69,7 +69,7 @@ LegacyDocumentDBMetrics::MatchingMetrics::RankProfileMetrics::RankProfileMetrics { for (size_t i=0; i < numDocIdPartitions; i++) { vespalib::string s(make_string("docid_part%02ld", i)); - partitions.push_back(DocIdPartition::LP(new DocIdPartition(s, this))); + partitions.push_back(DocIdPartition::UP(new DocIdPartition(s, this))); } } diff --git a/searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.h b/searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.h index dd246443ae4..b7b22d256f1 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.h @@ -59,14 +59,13 @@ struct LegacyDocumentDBMetrics : metrics::MetricSet metrics::DoubleAverageMetric active_time; metrics::DoubleAverageMetric wait_time; - typedef vespalib::LinkedPtr LP; + using UP = std::unique_ptr; DocIdPartition(const std::string &name, metrics::MetricSet *parent); ~DocIdPartition(); void update(const matching::MatchingStats::Partition &stats); }; - typedef std::vector DocIdPartitions; - - typedef vespalib::LinkedPtr LP; + using DocIdPartitions = std::vector; + using UP = std::unique_ptr; metrics::LongCountMetric queries; metrics::LongCountMetric limited_queries; @@ -82,7 +81,7 @@ struct LegacyDocumentDBMetrics : metrics::MetricSet void update(const matching::MatchingStats &stats); }; - typedef std::map RankProfileMap; + using RankProfileMap = std::map; RankProfileMap rank_profiles; void update(const matching::MatchingStats &stats); diff --git a/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.cpp b/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.cpp index 23daf44d98a..125ffde7530 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.cpp @@ -132,8 +132,8 @@ void doAddAttribute(LegacyAttributeMetrics &attributes, const std::string &name) { - LegacyAttributeMetrics::List::Entry::LP entry = attributes.list.add(name); - if (entry.get() != 0) { + LegacyAttributeMetrics::List::Entry *entry = attributes.list.add(name); + if (entry != nullptr) { LOG(debug, "doAddAttribute(): name='%s', attributes=%p", name.c_str(), (void*)&attributes); attributes.list.registerMetric(*entry); @@ -146,7 +146,7 @@ void doRemoveAttribute(LegacyAttributeMetrics &attributes, const std::string &name) { - LegacyAttributeMetrics::List::Entry::LP entry = attributes.list.remove(name); + LegacyAttributeMetrics::List::Entry::UP entry = attributes.list.remove(name); if (entry.get() != 0) { LOG(debug, "doRemoveAttribute(): name='%s', attributes=%p", name.c_str(), (void*)&attributes); @@ -159,7 +159,7 @@ doRemoveAttribute(LegacyAttributeMetrics &attributes, void doCleanAttributes(LegacyAttributeMetrics &attributes) { - std::vector entries = attributes.list.release(); + std::vector entries = attributes.list.release(); for (size_t i = 0; i < entries.size(); ++i) { attributes.list.unregisterMetric(*entries[i]); } @@ -240,8 +240,7 @@ void MetricsEngine::addRankProfile(LegacyDocumentDBMetrics &owner, const std::string &name, size_t numDocIdPartitions) { metrics::MetricLockGuard guard(_manager->getMetricLock()); - LegacyDocumentDBMetrics::MatchingMetrics::RankProfileMetrics::LP &entry = - owner.matching.rank_profiles[name]; + auto &entry = owner.matching.rank_profiles[name]; if (entry.get()) { LOG(warning, "Two rank profiles have the same name: %s", name.c_str()); } else { diff --git a/searchcore/src/vespa/searchcore/proton/persistenceengine/document_iterator.cpp b/searchcore/src/vespa/searchcore/proton/persistenceengine/document_iterator.cpp index 18effa74af0..818bb13c21a 100644 --- a/searchcore/src/vespa/searchcore/proton/persistenceengine/document_iterator.cpp +++ b/searchcore/src/vespa/searchcore/proton/persistenceengine/document_iterator.cpp @@ -110,12 +110,11 @@ DocumentIterator::iterate(size_t maxBytes) } else { IterateResult::List results; for (size_t sz(0); (_nextItem < _list.size()) && ((sz < maxBytes) || results.empty()); _nextItem++) { - DocEntry::LP & item = _list[_nextItem]; + DocEntry::UP item = std::move(_list[_nextItem]); sz += item->getSize(); - results.push_back(item); - item.reset(); + results.push_back(std::move(item)); } - return IterateResult(results, _nextItem >= _list.size()); + return IterateResult(std::move(results), _nextItem >= _list.size()); } } diff --git a/searchcore/src/vespa/searchcore/proton/server/docstorevalidator.cpp b/searchcore/src/vespa/searchcore/proton/server/docstorevalidator.cpp index 14e29a2650c..fc6b7b9eeee 100644 --- a/searchcore/src/vespa/searchcore/proton/server/docstorevalidator.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/docstorevalidator.cpp @@ -92,10 +92,10 @@ DocStoreValidator::killOrphans(search::IDocumentStore &store, } -LidVectorContext::LP +LidVectorContext::SP DocStoreValidator::getInvalidLids(void) const { - LidVectorContext::LP res(new LidVectorContext(_docIdLimit)); + LidVectorContext::SP res(new LidVectorContext(_docIdLimit)); assert(_invalid->size() == _docIdLimit); for (search::DocumentIdT lid(_invalid->getFirstTrueBit(1)); lid < _docIdLimit; diff --git a/searchcore/src/vespa/searchcore/proton/server/docstorevalidator.h b/searchcore/src/vespa/searchcore/proton/server/docstorevalidator.h index fcca1fd9178..6057a801460 100644 --- a/searchcore/src/vespa/searchcore/proton/server/docstorevalidator.h +++ b/searchcore/src/vespa/searchcore/proton/server/docstorevalidator.h @@ -30,7 +30,7 @@ public: uint32_t getOrphanCount() const; uint32_t getVisitCount() const { return _visitCount; } uint32_t getVisitEmptyCount() const { return _visitEmptyCount; } - LidVectorContext::LP getInvalidLids() const; + LidVectorContext::SP getInvalidLids() const; }; diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp index 98ca479e8c8..d64a57f78e3 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp @@ -1392,8 +1392,8 @@ updateLegacyAttributeMetrics(LegacyAttributeMetrics &metrics, const TempAttributeMetrics &tmpMetrics) { for (const auto &attr : tmpMetrics._attrs) { - LegacyAttributeMetrics::List::Entry::LP entry = metrics.list.get(attr.first); - if (entry.get()) { + LegacyAttributeMetrics::List::Entry *entry = metrics.list.get(attr.first); + if (entry) { entry->memoryUsage.set(attr.second._memoryUsage.allocatedBytes()); entry->bitVectors.set(attr.second._bitVectors); } else { diff --git a/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp b/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp index 4a96c25d948..6cdf87eaaaf 100644 --- a/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp @@ -823,7 +823,7 @@ void FeedHandler:: performPruneRemovedDocuments(PruneRemovedDocumentsOperation &pruneOp) { - const LidVectorContext::LP lids_to_remove = pruneOp.getLidsToRemove(); + const LidVectorContext::SP lids_to_remove = pruneOp.getLidsToRemove(); if (lids_to_remove.get() && lids_to_remove->getNumLids() != 0) { storeOperation(pruneOp); _activeFeedView->handlePruneRemovedDocuments(pruneOp); diff --git a/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp b/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp index 5510a7a67bc..f7f0a5ae272 100644 --- a/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp @@ -44,7 +44,7 @@ PruneRemovedDocumentsJob::flush(DocId lowLid, DocId nextLowLid, return; DocId docIdLimit = _metaStore.getCommittedDocIdLimit(); PruneRemovedDocumentsOperation pruneOp(docIdLimit, _subDbId); - LidVectorContext::LP lvCtx(pruneOp.getLidsToRemove()); + LidVectorContext::SP lvCtx(pruneOp.getLidsToRemove()); for (std::vector::const_iterator it = _pruneLids.begin(), ite = _pruneLids.end(); it != ite; ++it) { diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp index c0bfcaf0024..2541900b036 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp @@ -695,7 +695,7 @@ StoreOnlyFeedView::removeDocuments(const RemoveDocumentsOperation &op, bool immediateCommit) { const SerialNum serialNum = op.getSerialNum(); - const LidVectorContext::LP &ctx = op.getLidsToRemove(_params._subDbId); + const LidVectorContext::SP &ctx = op.getLidsToRemove(_params._subDbId); if (!ctx.get()) { if (useDocumentMetaStore(serialNum)) { _metaStore.commit(serialNum, serialNum); @@ -748,7 +748,7 @@ StoreOnlyFeedView::prepareDeleteBucket(DeleteBucketOperation &delOp) bucket.toString().c_str(), lidsToRemove.size()); if (!lidsToRemove.empty()) { - LidVectorContext::LP ctx + LidVectorContext::SP ctx (new LidVectorContext(_metaStore.getCommittedDocIdLimit(), lidsToRemove)); delOp.setLidsToRemove(_params._subDbId, ctx); diff --git a/searchlib/src/vespa/searchlib/fef/simpletermdata.h b/searchlib/src/vespa/searchlib/fef/simpletermdata.h index 68d6dcd1160..266a2ec05b8 100644 --- a/searchlib/src/vespa/searchlib/fef/simpletermdata.h +++ b/searchlib/src/vespa/searchlib/fef/simpletermdata.h @@ -7,6 +7,7 @@ #include "simpletermfielddata.h" #include #include +#include namespace search { namespace fef { diff --git a/searchlib/src/vespa/searchlib/uca/ucafunctionnode.h b/searchlib/src/vespa/searchlib/uca/ucafunctionnode.h index 78242d9cbd1..38fc6471efa 100644 --- a/searchlib/src/vespa/searchlib/uca/ucafunctionnode.h +++ b/searchlib/src/vespa/searchlib/uca/ucafunctionnode.h @@ -51,7 +51,7 @@ private: }; vespalib::string _locale; vespalib::string _strength; - common::BlobConverter::LP _collator; + common::BlobConverter::SP _collator; std::unique_ptr _handler; }; diff --git a/staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.h b/staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.h index be16b1de5e2..3ca5f0ea2e8 100644 --- a/staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.h +++ b/staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.h @@ -20,6 +20,7 @@ struct LinkedValue : public LinkedValueBase { LinkedValue() {} LinkedValue(const V & v) : LinkedValueBase(), _value(v) { } + LinkedValue(V && v) : LinkedValueBase(), _value(std::move(v)) { } V _value; }; @@ -124,6 +125,12 @@ public: */ insert_result insert(const K & key, const V & value); + /** + * Object is inserted in cache with given key. + * Object is then put at head of LRU list. + */ + insert_result insert(const K & key, V && value); + /** * Return the object with the given key. If it does not exist an empty one will be created. * This can be used as an insert. diff --git a/staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.hpp b/staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.hpp index 3301abca3ba..f32f1027fb6 100644 --- a/staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.hpp +++ b/staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.hpp @@ -16,6 +16,16 @@ lrucache_map

::insert(const K & key, const V & value) { return res; } +template< typename P > +typename lrucache_map

::insert_result +lrucache_map

::insert(const K & key, V && value) { + insert_result res = insert(value_type(key, LV(std::move(value)))); + if (res.second) { + onInsert(key); + } + return res; +} + template< typename P > bool lrucache_map

::removeOldest(const value_type & v) { 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 #include #include @@ -29,7 +28,7 @@ struct MergeLimiterTest : public CppUnit::TestFixture CPPUNIT_TEST_SUITE_REGISTRATION(MergeLimiterTest); namespace { - typedef vespalib::LinkedPtr BucketCopyPtr; + using BucketCopyPtr = std::unique_ptr; std::vector _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( + std::unique_ptr( 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 _handler; - std::vector > _diskEnvs; + std::vector > _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 entries; + std::vector 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 entries; + std::vector 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 entries; + std::vector 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 entries; + std::vector 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 entries; + std::vector 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 entries; + std::vector 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( + std::unique_ptr( 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 > sentMessages; + std::deque > 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 msg( - session.sentMessages.front()); + std::unique_ptr 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 #include #include -#include #include #include #include @@ -86,7 +85,7 @@ public: bool _exists; bool _preExisted; - vespalib::LinkedPtr _lockKeeper; + std::unique_ptr _lockKeeper; mapped_type _value; const char* _clientId; friend class LockableMap; 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; struct BucketReadState { - typedef vespalib::LinkedPtr LP; + using UP = std::unique_ptr; 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> _readState; + std::vector> _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 #include #include -#include #include #include 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 #include #include -#include 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 << "

" << desc << "

\n"; \ HtmlTable matrixTable("Source \\ Target"); \ - typedef vespalib::LinkedPtr LCLP; \ - std::vector matrixData((rs)._diskData.size()); \ + using LCUP = std::unique_ptr; \ + std::vector 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 -#include #include #include #include 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 #include #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 #include #include -#include namespace storage { namespace distributor { @@ -23,7 +22,7 @@ protected: virtual PrioritizedBucket dereference() const = 0; }; - typedef vespalib::LinkedPtr ConstIteratorImplPtr; + using ConstIteratorImplPtr = std::unique_ptr; 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 SP; - typedef vespalib::LinkedPtr LP; typedef std::unique_ptr UP; typedef std::vector Vector; typedef std::map 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 > newCopies; + std::vector > newCopies; std::vector 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( + newCopies.push_back(std::unique_ptr( 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& ownerList, CopyType copyType, +PersistenceFailuresMetricSet::clone(std::vector& 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& ownerList, CopyType copyType, +PersistenceOperationMetricSet::clone(std::vector& 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& ownerList, CopyType copyType, + MetricSet * clone(std::vector& 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& ownerList, CopyType copyType, + MetricSet * clone(std::vector& 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()); + return Result(std::unique_ptr()); } StateChecker::Result @@ -60,7 +60,7 @@ StateChecker::Result::createStoredResult( IdealStateOperation::UP operation, MaintenancePriority::Priority priority) { - return Result(vespalib::LinkedPtr(new StoredResultImpl(std::move(operation), MaintenancePriority(priority)))); + return Result(std::unique_ptr(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 #include #include -#include #include #include @@ -97,7 +96,7 @@ public: class Result { - vespalib::LinkedPtr _impl; + std::unique_ptr _impl; public: IdealStateOperation::UP createOperation() { return (_impl.get() @@ -123,8 +122,8 @@ public: IdealStateOperation::UP operation, MaintenancePriority::Priority priority); private: - Result(const vespalib::LinkedPtr impl) - : _impl(impl) + Result(std::unique_ptr 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& ownerList, CopyType copyType, +VisitorMetricSet::clone(std::vector& 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& ownerList, CopyType copyType, + MetricSet * clone(std::vector& 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& ownerList, +FileStorThreadMetrics::Op::clone(std::vector& 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& ownerList, +FileStorThreadMetrics::OpWithNotFound::clone(std::vector& 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& ownerList, +FileStorThreadMetrics::Update::clone(std::vector& 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& ownerList, +FileStorThreadMetrics::Visitor::clone(std::vector& 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& ownerList, CopyType copyType, + MetricSet * clone(std::vector& 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& ownerList, CopyType copyType, + MetricSet* clone(std::vector& 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& ownerList, CopyType copyType, + MetricSet* clone(std::vector& 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& ownerList, CopyType copyType, + MetricSet * clone(std::vector& 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& entries, + std::vector& 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 entries; + std::vector 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 entries; + std::vector 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 entries; + std::vector 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& entries, + std::vector& 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 _entries; + std::vector _entries; bool _completed; public: @@ -69,11 +69,11 @@ public: return _bucketId; } - const std::vector& getEntries() const { + const std::vector& getEntries() const { return _entries; } - std::vector& getEntries() { + std::vector& 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 >& replies) + std::vector >& replies) { if (replies.empty()) { return; @@ -1184,7 +1184,7 @@ PersistenceThread::flushAllReplies( void PersistenceThread::processMessages(FileStorHandler::LockedMessage & lock) { - std::vector trackers; + std::vector 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& trackers); + std::vector& 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 LP; typedef std::unique_ptr 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 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& entries, + std::vector& 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& entries, + std::vector& 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& entries, + std::vector& 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& docs); void handleDocuments(const document::BucketId& bucketId, - std::vector& entries, + std::vector& entries, HitCounter& hitCounter); std::unique_ptr > _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& entries, + std::vector& 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&, + std::vector&, 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& entries, + std::vector& 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& entries, + std::vector& entries, HitCounter& hitCounter); void completedBucket(const document::BucketId&, HitCounter&); std::set _requestedFields; - typedef vespalib::LinkedPtr CommandPtr; - typedef std::map CommandMap; + using CommandPtr = std::unique_ptr; + using CommandMap = std::map; 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& buckets) void TestVisitor::handleDocuments(const document::BucketId& /*bucketId*/, - std::vector& entries, + std::vector& 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& buckets); void handleDocuments(const document::BucketId& bucketId, - std::vector& entries, + std::vector& 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& entries, + std::vector& entries, HitCounter& hitCounter) = 0; /** diff --git a/storageapi/src/vespa/storageapi/message/batch.cpp b/storageapi/src/vespa/storageapi/message/batch.cpp index a3dcea3d13f..405d5b4c9d2 100644 --- a/storageapi/src/vespa/storageapi/message/batch.cpp +++ b/storageapi/src/vespa/storageapi/message/batch.cpp @@ -46,21 +46,21 @@ BatchPutRemoveCommand::BatchPutRemoveCommand(const document::BucketId& bucketId) void BatchPutRemoveCommand::addPut(document::Document::SP document, uint64_t ts) { - _operations.push_back(vespalib::LinkedPtr(new PutOperation(document, ts))); + _operations.push_back(std::unique_ptr(new PutOperation(document, ts))); _approxSize += document->serialize()->getLength(); } void BatchPutRemoveCommand::addHeaderUpdate(document::Document::SP document, uint64_t ts, uint64_t timestampToUpdate) { - _operations.push_back(vespalib::LinkedPtr(new HeaderUpdateOperation(document, ts, timestampToUpdate))); + _operations.push_back(std::unique_ptr(new HeaderUpdateOperation(document, ts, timestampToUpdate))); _approxSize += document->serialize()->getLength(); } void BatchPutRemoveCommand::addRemove(const document::DocumentId& docId, uint64_t ts) { - _operations.push_back(vespalib::LinkedPtr(new RemoveOperation(docId, ts))); + _operations.push_back(std::unique_ptr(new RemoveOperation(docId, ts))); _approxSize += docId.toString().length(); } diff --git a/storageapi/src/vespa/storageapi/message/batch.h b/storageapi/src/vespa/storageapi/message/batch.h index a1b92fa1f0e..b4788a5ae75 100644 --- a/storageapi/src/vespa/storageapi/message/batch.h +++ b/storageapi/src/vespa/storageapi/message/batch.h @@ -118,7 +118,7 @@ public: DECLARE_STORAGECOMMAND(BatchPutRemoveCommand, onBatchPutRemove) private: - std::vector > _operations; + std::vector > _operations; uint32_t _approxSize; }; diff --git a/storageframework/src/tests/memory/memorymanagertest.cpp b/storageframework/src/tests/memory/memorymanagertest.cpp index 678a40a4b44..50bca7b5b58 100644 --- a/storageframework/src/tests/memory/memorymanagertest.cpp +++ b/storageframework/src/tests/memory/memorymanagertest.cpp @@ -260,8 +260,8 @@ struct MemoryManagerLoadGiver : public document::Runnable, uint32_t _failed; uint32_t _ok; uint32_t _reduced; - typedef vespalib::LinkedPtr MemoryTokenPtr; - std::vector _tokens; + using MemoryTokenUP = std::unique_ptr; + std::vector _tokens; vespalib::Lock _cacheLock; MemoryManagerLoadGiver( @@ -302,7 +302,7 @@ struct MemoryManagerLoadGiver : public document::Runnable, ++_ok; } uint32_t index = randomizer.nextUint32(0, _tokens.size() - 1); - _tokens[index] = MemoryTokenPtr(token.release()); + _tokens[index] = MemoryTokenUP(token.release()); } } }; diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.cpp b/storageframework/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.cpp index 01f1d2583be..c640a5840a6 100644 --- a/storageframework/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.cpp +++ b/storageframework/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.cpp @@ -161,9 +161,9 @@ ComponentRegisterImpl::registerUpdateHook(vespalib::stringref name, SecondTime period) { vespalib::LockGuard lock(_componentLock); - metrics::UpdateHook::LP hookPtr(new MetricHookWrapper(name, hook)); - _hooks.push_back(hookPtr); + metrics::UpdateHook::UP hookPtr(new MetricHookWrapper(name, hook)); _metricManager->addMetricUpdateHook(*hookPtr, period.getTime()); + _hooks.push_back(std::move(hookPtr)); } metrics::MetricLockGuard diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h b/storageframework/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h index 8e472eb9c08..8c3ff58b4db 100644 --- a/storageframework/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h +++ b/storageframework/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h @@ -48,7 +48,7 @@ class ComponentRegisterImpl : public virtual ComponentRegister, std::vector _components; metrics::MetricSet _topMetricSet; - std::vector> _hooks; + std::vector> _hooks; metrics::MetricManager* _metricManager; MemoryManagerInterface* _memoryManager; Clock* _clock; diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorymanager.cpp b/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorymanager.cpp index 7ef2b62ecc8..0ce71866f93 100644 --- a/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorymanager.cpp +++ b/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorymanager.cpp @@ -95,7 +95,7 @@ const MemoryAllocationType& MemoryManager::registerAllocationType(const MemoryAllocationType& type) { vespalib::LockGuard lock(_typeLock); - _types[type.getName()] = MemoryAllocationType::LP( + _types[type.getName()] = MemoryAllocationType::UP( new MemoryAllocationType(type)); return *_types[type.getName()]; } @@ -104,7 +104,7 @@ const MemoryAllocationType& MemoryManager::getAllocationType(const std::string& name) const { vespalib::LockGuard lock(_typeLock); - std::map::const_iterator it( + std::map::const_iterator it( _types.find(name)); if (it == _types.end()) { throw vespalib::IllegalArgumentException( @@ -118,7 +118,7 @@ MemoryManager::getAllocationTypes() const { vespalib::LockGuard lock(_typeLock); std::vector types; - for(std::map::const_iterator it + for(std::map::const_iterator it = _types.begin(); it != _types.end(); ++it) { types.push_back(it->second.get()); diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorymanager.h b/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorymanager.h index 8ce3769fd1c..0db8b7ab4b0 100644 --- a/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorymanager.h +++ b/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorymanager.h @@ -130,7 +130,7 @@ class MemoryManager : public vespalib::Printable, { AllocationLogic::UP _logic; vespalib::Lock _typeLock; - std::map _types; + std::map _types; public: typedef std::unique_ptr UP; diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/memory/nomemorymanager.cpp b/storageframework/src/vespa/storageframework/defaultimplementation/memory/nomemorymanager.cpp index 938c604e053..36f85d25ff1 100644 --- a/storageframework/src/vespa/storageframework/defaultimplementation/memory/nomemorymanager.cpp +++ b/storageframework/src/vespa/storageframework/defaultimplementation/memory/nomemorymanager.cpp @@ -11,7 +11,7 @@ const MemoryAllocationType& NoMemoryManager::registerAllocationType(const MemoryAllocationType& type) { vespalib::LockGuard lock(_typeLock); - _types[type.getName()] = MemoryAllocationType::LP( + _types[type.getName()] = MemoryAllocationType::UP( new MemoryAllocationType(type)); return *_types[type.getName()]; } @@ -20,7 +20,7 @@ const MemoryAllocationType& NoMemoryManager::getAllocationType(const std::string& name) const { vespalib::LockGuard lock(_typeLock); - std::map::const_iterator it( + std::map::const_iterator it( _types.find(name)); if (it == _types.end()) { throw vespalib::IllegalArgumentException( @@ -34,7 +34,7 @@ NoMemoryManager::getAllocationTypes() const { vespalib::LockGuard lock(_typeLock); std::vector types; - for(std::map::const_iterator it + for(std::map::const_iterator it = _types.begin(); it != _types.end(); ++it) { types.push_back(it->second.get()); diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/memory/nomemorymanager.h b/storageframework/src/vespa/storageframework/defaultimplementation/memory/nomemorymanager.h index 0be8e41a05f..870d735b113 100644 --- a/storageframework/src/vespa/storageframework/defaultimplementation/memory/nomemorymanager.h +++ b/storageframework/src/vespa/storageframework/defaultimplementation/memory/nomemorymanager.h @@ -37,7 +37,7 @@ public: class NoMemoryManager : public MemoryManagerInterface { vespalib::Lock _typeLock; - std::map _types; + std::map _types; public: typedef std::unique_ptr UP; diff --git a/storageframework/src/vespa/storageframework/generic/memory/memoryallocationtype.h b/storageframework/src/vespa/storageframework/generic/memory/memoryallocationtype.h index 13ac09604bf..94679212179 100644 --- a/storageframework/src/vespa/storageframework/generic/memory/memoryallocationtype.h +++ b/storageframework/src/vespa/storageframework/generic/memory/memoryallocationtype.h @@ -18,13 +18,13 @@ #pragma once #include -#include +#include namespace storage { namespace framework { struct MemoryAllocationType { - typedef vespalib::LinkedPtr LP; + using UP = std::unique_ptr; enum Flags { NONE = 0x00, diff --git a/storageframework/src/vespa/storageframework/generic/thread/tickingthread.cpp b/storageframework/src/vespa/storageframework/generic/thread/tickingthread.cpp index 2c41e05d72c..d425ff3a1d8 100644 --- a/storageframework/src/vespa/storageframework/generic/thread/tickingthread.cpp +++ b/storageframework/src/vespa/storageframework/generic/thread/tickingthread.cpp @@ -187,12 +187,12 @@ public: } virtual TickingLockGuard freezeAllTicks() { - return TickingLockGuard(vespalib::LinkedPtr( + return TickingLockGuard(std::unique_ptr( new FreezeGuard(*this))); } virtual TickingLockGuard freezeCriticalTicks() { - return TickingLockGuard(vespalib::LinkedPtr( + return TickingLockGuard(std::unique_ptr( new CriticalGuard(_monitor))); } diff --git a/storageframework/src/vespa/storageframework/generic/thread/tickingthread.h b/storageframework/src/vespa/storageframework/generic/thread/tickingthread.h index 8357e50f401..16a67cf709c 100644 --- a/storageframework/src/vespa/storageframework/generic/thread/tickingthread.h +++ b/storageframework/src/vespa/storageframework/generic/thread/tickingthread.h @@ -21,7 +21,6 @@ #include #include #include -#include #include namespace storage { @@ -63,10 +62,10 @@ struct TickingLockGuard { virtual ~Impl() {} virtual void broadcast() = 0; }; - TickingLockGuard(vespalib::LinkedPtr impl) : _impl(impl) {} + TickingLockGuard(std::unique_ptr impl) : _impl(std::move(impl)) {} void broadcast() { _impl->broadcast(); } private: - vespalib::LinkedPtr _impl; + std::unique_ptr _impl; }; struct ThreadLock { diff --git a/storageserver/src/tests/storageservertest.cpp b/storageserver/src/tests/storageservertest.cpp index feff39fb8d4..5b4bae96a2f 100644 --- a/storageserver/src/tests/storageservertest.cpp +++ b/storageserver/src/tests/storageservertest.cpp @@ -693,14 +693,14 @@ namespace { } CPPUNIT_ASSERT_EQUAL(size_t(1), entries.size()); bucket = entries.begin()->first; - StorBucketDatabase::WrappedEntry entry( - entries.begin()->second); + auto *entry = &(*(entries.begin()->second)); + auto *entry_wrapper = &(entries.begin()->second); if (seed % 95 == 93) { // Delete bucket if ((entry->getBucketInfo().getChecksum() & 2) == 0) { cmd.reset(new api::DeleteBucketCommand(bucket)); entry->setChecksum( entry->getBucketInfo().getChecksum() | 2); - entry.write(); + entry_wrapper->write(); sendList.push_back( new mbusprot::StorageCommand(cmd)); } @@ -708,7 +708,8 @@ namespace { if (entry->getBucketInfo().getChecksum() == 0 && bucket.getUsedBits() > 3) { // Remove existing locks we have to not cause // deadlock - entry = StorBucketDatabase::WrappedEntry(); + entry = nullptr; + entry_wrapper = nullptr; entries.clear(); // Then continue document::BucketId super(bucket.getUsedBits() - 1, @@ -750,7 +751,7 @@ namespace { if (entry->getBucketInfo().getChecksum() == 0) { cmd.reset(new api::SplitBucketCommand(bucket)); entry->setChecksum(1); - entry.write(); + entry_wrapper->write(); sendList.push_back( new mbusprot::StorageCommand(cmd)); } diff --git a/streamingvisitors/src/tests/searchvisitor/searchvisitor.cpp b/streamingvisitors/src/tests/searchvisitor/searchvisitor.cpp index 704066ce964..66b7743c3b3 100644 --- a/streamingvisitors/src/tests/searchvisitor/searchvisitor.cpp +++ b/streamingvisitors/src/tests/searchvisitor/searchvisitor.cpp @@ -44,15 +44,15 @@ SearchVisitorTest::SearchVisitorTest() : _component.reset(new StorageComponent(_componentRegister, "storage")); }; -std::vector +std::vector createDocuments(const vespalib::string & dir) { (void) dir; - std::vector documents; + std::vector documents; spi::Timestamp ts; document::Document::UP doc(new document::Document()); - spi::DocEntry::LP e(new spi::DocEntry(ts, 0, std::move(doc))); - documents.push_back(e); + spi::DocEntry::UP e(new spi::DocEntry(ts, 0, std::move(doc))); + documents.push_back(std::move(e)); return documents; } @@ -64,7 +64,7 @@ SearchVisitorTest::testCreateSearchVisitor(const vespalib::string & dir, const v std::unique_ptr sv(static_cast(factory.makeVisitor(*_component, _env, params))); document::OrderingSpecification orderSpec; document::BucketId bucketId; - std::vector documents(createDocuments(dir)); + std::vector documents(createDocuments(dir)); Visitor::HitCounter hitCounter(&orderSpec); sv->handleDocuments(bucketId, documents, hitCounter); } diff --git a/streamingvisitors/src/vespa/searchvisitor/searchenvironment.cpp b/streamingvisitors/src/vespa/searchvisitor/searchenvironment.cpp index 76a1a832ca6..493260814f9 100644 --- a/streamingvisitors/src/vespa/searchvisitor/searchenvironment.cpp +++ b/streamingvisitors/src/vespa/searchvisitor/searchenvironment.cpp @@ -69,7 +69,7 @@ SearchEnvironment::Env & SearchEnvironment::getEnv(const vespalib::string & sear if (_localEnvMap == NULL) { _localEnvMap = new EnvMap; vespalib::LockGuard guard(_lock); - _threadLocals.push_back(EnvMapLP(_localEnvMap)); + _threadLocals.push_back(EnvMapUP(_localEnvMap)); } EnvMap::iterator localFound = _localEnvMap->find(searchCluster); if (localFound == _localEnvMap->end()) { diff --git a/streamingvisitors/src/vespa/searchvisitor/searchenvironment.h b/streamingvisitors/src/vespa/searchvisitor/searchenvironment.h index 0d3b9938089..0da6495bb05 100644 --- a/streamingvisitors/src/vespa/searchvisitor/searchenvironment.h +++ b/streamingvisitors/src/vespa/searchvisitor/searchenvironment.h @@ -32,8 +32,8 @@ private: std::unique_ptr _rankManager; }; typedef vespalib::hash_map EnvMap; - typedef vespalib::LinkedPtr EnvMapLP; - typedef std::vector< vespalib::LinkedPtr > ThreadLocals; + typedef std::unique_ptr EnvMapUP; + typedef std::vector ThreadLocals; static __thread EnvMap * _localEnvMap; EnvMap _envMap; diff --git a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp index 70adaa682e5..16cf83ea0df 100644 --- a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp +++ b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp @@ -866,7 +866,7 @@ SearchVisitor::compatibleDocumentTypes(const document::DocumentType& typeA, void SearchVisitor::handleDocuments(const document::BucketId&, - std::vector& entries, + std::vector& entries, HitCounter& hitCounter) { (void) hitCounter; diff --git a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.h b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.h index 672a420e55a..ff30bf09c48 100644 --- a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.h +++ b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.h @@ -298,7 +298,7 @@ private: // Inherit doc from Visitor void handleDocuments(const document::BucketId&, - std::vector& entries, + std::vector& entries, HitCounter& hitCounter) override; bool compatibleDocumentTypes(const document::DocumentType& typeA, -- cgit v1.2.3