summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHaavard <havardpe@yahoo-inc.com>2017-03-20 13:04:33 +0000
committerHaavard <havardpe@yahoo-inc.com>2017-03-27 09:53:26 +0000
commit23abed1a0bc4f4c5ea47b43fc7ea0645e63a26e6 (patch)
tree6d943bbe31738f7e9b84979e4fd63dfd76eef580
parent8844ccb7297e8a5120dd903c85e923f2f93aa693 (diff)
remove most usage of LinkedPtr from vespa
-rw-r--r--config/src/vespa/config/common/configrequest.h6
-rw-r--r--configd/src/apps/sentinel/config-handler.cpp59
-rw-r--r--configd/src/apps/sentinel/config-handler.h7
-rw-r--r--configd/src/apps/sentinel/service.h3
-rw-r--r--document/src/vespa/document/update/fieldpathupdate.h2
-rw-r--r--documentapi/src/vespa/documentapi/loadtypes/loadtype.h3
-rw-r--r--memfilepersistence/src/tests/device/devicemanagertest.cpp4
-rw-r--r--memfilepersistence/src/tests/device/devicestest.cpp10
-rw-r--r--memfilepersistence/src/tests/device/mountpointlisttest.cpp11
-rw-r--r--memfilepersistence/src/tests/init/filescannertest.cpp2
-rw-r--r--memfilepersistence/src/tests/spi/iteratorhandlertest.cpp38
-rw-r--r--memfilepersistence/src/tests/spi/simplememfileiobuffertest.cpp4
-rw-r--r--memfilepersistence/src/tests/tools/vdsdisktooltest.cpp5
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/common/environment.cpp4
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/common/types.h1
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/device/devicemanager.cpp36
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/device/devicemanager.h20
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/device/directory.h4
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/device/disk.h3
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/device/mountpointlist.cpp22
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/device/mountpointlist.h7
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/device/partition.h6
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/device/partitionmonitor.h3
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/init/filescanner.cpp2
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/mapper/buffer.h3
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.h2
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/mapper/memfilemapper.cpp16
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/mapper/memfilemapper.h4
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.cpp20
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h20
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/mapper/versionserializer.h3
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecache.cpp6
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecache.h8
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/memfile/memfileptr.h8
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/memfile/memslot.h2
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/spi/iteratorhandler.cpp22
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/spi/iteratorhandler.h14
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp2
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/tools/vdsdisktool.cpp4
-rw-r--r--messagebus/src/vespa/messagebus/network/rpcservice.h3
-rw-r--r--messagebus/src/vespa/messagebus/network/rpcservicepool.cpp7
-rw-r--r--messagebus/src/vespa/messagebus/network/rpcservicepool.h2
-rw-r--r--metrics/src/tests/loadmetrictest.cpp6
-rw-r--r--metrics/src/tests/metricsettest.cpp2
-rw-r--r--metrics/src/tests/snapshottest.cpp8
-rw-r--r--metrics/src/tests/stresstest.cpp10
-rw-r--r--metrics/src/tests/valuemetrictest.cpp2
-rw-r--r--metrics/src/vespa/metrics/countmetric.h4
-rw-r--r--metrics/src/vespa/metrics/countmetric.hpp2
-rw-r--r--metrics/src/vespa/metrics/loadmetric.h8
-rw-r--r--metrics/src/vespa/metrics/loadmetric.hpp18
-rw-r--r--metrics/src/vespa/metrics/metric.cpp2
-rw-r--r--metrics/src/vespa/metrics/metric.h16
-rw-r--r--metrics/src/vespa/metrics/metricset.cpp12
-rw-r--r--metrics/src/vespa/metrics/metricset.h9
-rw-r--r--metrics/src/vespa/metrics/metricsnapshot.cpp6
-rw-r--r--metrics/src/vespa/metrics/metricsnapshot.h2
-rw-r--r--metrics/src/vespa/metrics/printutils.cpp2
-rw-r--r--metrics/src/vespa/metrics/summetric.h12
-rw-r--r--metrics/src/vespa/metrics/summetric.hpp30
-rw-r--r--metrics/src/vespa/metrics/updatehook.h3
-rw-r--r--metrics/src/vespa/metrics/valuemetric.h4
-rw-r--r--metrics/src/vespa/metrics/valuemetric.hpp2
-rw-r--r--persistence/src/main/java/com/yahoo/persistence/spi/conformance/ConformanceTest.java4
-rw-r--r--persistence/src/tests/dummyimpl/dummypersistence_test.cpp6
-rw-r--r--persistence/src/tests/proxy/mockprovider.h4
-rw-r--r--persistence/src/vespa/persistence/conformancetest/conformancetest.cpp51
-rw-r--r--persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp66
-rw-r--r--persistence/src/vespa/persistence/dummyimpl/dummypersistence.h22
-rw-r--r--persistence/src/vespa/persistence/proxy/providerproxy.cpp6
-rw-r--r--persistence/src/vespa/persistence/proxy/providerstub.cpp2
-rw-r--r--persistence/src/vespa/persistence/spi/docentry.h5
-rw-r--r--persistence/src/vespa/persistence/spi/result.h10
-rw-r--r--searchcommon/src/vespa/searchcommon/common/iblobconverter.h2
-rw-r--r--searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp2
-rw-r--r--searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp2
-rw-r--r--searchcore/src/tests/proton/metrics/metrics_engine/metrics_engine_test.cpp12
-rw-r--r--searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp2
-rw-r--r--searchcore/src/tests/proton/server/legacy_attribute_metrics_test.cpp36
-rw-r--r--searchcore/src/vespa/searchcore/grouping/groupingsession.h1
-rw-r--r--searchcore/src/vespa/searchcore/proton/feedoperation/lidvectorcontext.h3
-rw-r--r--searchcore/src/vespa/searchcore/proton/feedoperation/pruneremoveddocumentsoperation.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/feedoperation/pruneremoveddocumentsoperation.h4
-rw-r--r--searchcore/src/vespa/searchcore/proton/feedoperation/removedocumentsoperation.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/feedoperation/removedocumentsoperation.h8
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/match_master.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/match_thread.h1
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/partial_result.h5
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/result_processor.cpp16
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/result_processor.h9
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp18
-rw-r--r--searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.cpp35
-rw-r--r--searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.h13
-rw-r--r--searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.h9
-rw-r--r--searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.cpp11
-rw-r--r--searchcore/src/vespa/searchcore/proton/persistenceengine/document_iterator.cpp7
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/docstorevalidator.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/docstorevalidator.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentdb.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/fef/simpletermdata.h1
-rw-r--r--searchlib/src/vespa/searchlib/uca/ucafunctionnode.h2
-rw-r--r--staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.h7
-rw-r--r--staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.hpp10
-rw-r--r--storage/src/tests/distributor/mergelimitertest.cpp3
-rw-r--r--storage/src/tests/persistence/persistencetestutils.cpp2
-rw-r--r--storage/src/tests/persistence/persistencetestutils.h2
-rw-r--r--storage/src/tests/persistence/splitbitdetectortest.cpp16
-rw-r--r--storage/src/tests/storageserver/testvisitormessagesession.cpp2
-rw-r--r--storage/src/tests/storageserver/testvisitormessagesession.h2
-rw-r--r--storage/src/tests/visiting/visitortest.cpp8
-rw-r--r--storage/src/vespa/storage/bucketdb/lockablemap.h3
-rw-r--r--storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp4
-rw-r--r--storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h2
-rw-r--r--storage/src/vespa/storage/bucketmover/run.h1
-rw-r--r--storage/src/vespa/storage/bucketmover/runstatistics.cpp1
-rw-r--r--storage/src/vespa/storage/bucketmover/runstatistics.h4
-rw-r--r--storage/src/vespa/storage/common/hostreporter/cpureporter.cpp1
-rw-r--r--storage/src/vespa/storage/common/hostreporter/hostinfo.h1
-rw-r--r--storage/src/vespa/storage/distributor/maintenance/bucketprioritydatabase.h9
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/idealstateoperation.h1
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp4
-rw-r--r--storage/src/vespa/storage/distributor/persistence_operation_metric_set.cpp4
-rw-r--r--storage/src/vespa/storage/distributor/persistence_operation_metric_set.h4
-rw-r--r--storage/src/vespa/storage/distributor/statechecker.cpp4
-rw-r--r--storage/src/vespa/storage/distributor/statechecker.h7
-rw-r--r--storage/src/vespa/storage/distributor/visitormetricsset.cpp2
-rw-r--r--storage/src/vespa/storage/distributor/visitormetricsset.h2
-rw-r--r--storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp2
-rw-r--r--storage/src/vespa/storage/persistence/filestorage/filestormetrics.cpp8
-rw-r--r--storage/src/vespa/storage/persistence/filestorage/filestormetrics.h8
-rw-r--r--storage/src/vespa/storage/persistence/mergehandler.cpp30
-rw-r--r--storage/src/vespa/storage/persistence/mergehandler.h2
-rw-r--r--storage/src/vespa/storage/persistence/messages.h6
-rw-r--r--storage/src/vespa/storage/persistence/persistencethread.cpp8
-rw-r--r--storage/src/vespa/storage/persistence/persistencethread.h2
-rw-r--r--storage/src/vespa/storage/persistence/persistenceutil.h1
-rw-r--r--storage/src/vespa/storage/persistence/types.h1
-rw-r--r--storage/src/vespa/storage/visiting/countvisitor.cpp2
-rw-r--r--storage/src/vespa/storage/visiting/countvisitor.h2
-rw-r--r--storage/src/vespa/storage/visiting/dumpvisitor.cpp2
-rw-r--r--storage/src/vespa/storage/visiting/dumpvisitor.h2
-rw-r--r--storage/src/vespa/storage/visiting/dumpvisitorsingle.cpp2
-rw-r--r--storage/src/vespa/storage/visiting/dumpvisitorsingle.h2
-rw-r--r--storage/src/vespa/storage/visiting/recoveryvisitor.cpp4
-rw-r--r--storage/src/vespa/storage/visiting/recoveryvisitor.h6
-rw-r--r--storage/src/vespa/storage/visiting/testvisitor.cpp2
-rw-r--r--storage/src/vespa/storage/visiting/testvisitor.h2
-rw-r--r--storage/src/vespa/storage/visiting/visitor.h2
-rw-r--r--storageapi/src/vespa/storageapi/message/batch.cpp6
-rw-r--r--storageapi/src/vespa/storageapi/message/batch.h2
-rw-r--r--storageframework/src/tests/memory/memorymanagertest.cpp6
-rw-r--r--storageframework/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.cpp4
-rw-r--r--storageframework/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h2
-rw-r--r--storageframework/src/vespa/storageframework/defaultimplementation/memory/memorymanager.cpp6
-rw-r--r--storageframework/src/vespa/storageframework/defaultimplementation/memory/memorymanager.h2
-rw-r--r--storageframework/src/vespa/storageframework/defaultimplementation/memory/nomemorymanager.cpp6
-rw-r--r--storageframework/src/vespa/storageframework/defaultimplementation/memory/nomemorymanager.h2
-rw-r--r--storageframework/src/vespa/storageframework/generic/memory/memoryallocationtype.h4
-rw-r--r--storageframework/src/vespa/storageframework/generic/thread/tickingthread.cpp4
-rw-r--r--storageframework/src/vespa/storageframework/generic/thread/tickingthread.h5
-rw-r--r--storageserver/src/tests/storageservertest.cpp11
-rw-r--r--streamingvisitors/src/tests/searchvisitor/searchvisitor.cpp10
-rw-r--r--streamingvisitors/src/vespa/searchvisitor/searchenvironment.cpp2
-rw-r--r--streamingvisitors/src/vespa/searchvisitor/searchenvironment.h4
-rw-r--r--streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp2
-rw-r--r--streamingvisitors/src/vespa/searchvisitor/searchvisitor.h2
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 <memory>
-namespace vespalib {
- template <typename T>
- class LinkedPtr;
-}
-
namespace config {
class ConfigKey;
@@ -25,7 +20,6 @@ private:
ConfigRequest& operator=(const ConfigRequest&);
public:
- typedef vespalib::LinkedPtr<ConfigRequest> LP;
typedef std::unique_ptr<ConfigRequest> 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<vespalib::string, Service::LP> ServiceMap;
+ typedef std::map<vespalib::string, Service::UP> ServiceMap;
ConfigSubscriber _subscriber;
ConfigHandle<SentinelConfig>::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 <vespa/vespalib/util/linkedptr.h>
#include <vespa/vespalib/stllike/string.h>
#include <vespa/config-sentinel.h>
#include <list>
@@ -46,7 +45,7 @@ private:
StartMetrics &_metrics;
public:
- typedef vespalib::LinkedPtr<Service> LP;
+ using UP = std::unique_ptr<Service>;
~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> _fieldPath;
std::shared_ptr<select::Node> _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 <vespa/metrics/loadtype.h>
-#include <vespa/vespalib/util/linkedptr.h>
#include <vespa/documentapi/messagebus/priority.h>
namespace vespalib {
@@ -28,7 +27,7 @@ class LoadType : public metrics::LoadType {
Priority::Value _priority;
public:
- typedef vespalib::LinkedPtr<LoadType> LP;
+ using UP = std::unique_ptr<LoadType>;
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 <vespa/vespalib/io/fileutil.h>
#include <vespa/storageframework/defaultimplementation/clock/fakeclock.h>
-using vespalib::LinkedPtr;
using vespalib::fileExists;
using vespalib::isDirectory;
using vespalib::isSymLink;
@@ -37,8 +36,8 @@ public:
framework::defaultimplementation::FakeClock _clock;
private:
- LinkedPtr<DeviceManager> newDeviceManager() {
- return LinkedPtr<DeviceManager>(
+ 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::string>(),
- vespalib::LinkedPtr<DeviceManager>(
+ DeviceManager::UP(
new DeviceManager(
DeviceMapper::UP(new SimpleDeviceMapper),
_clock)));
@@ -133,7 +132,7 @@ void MountPointList_Test::testStatusFile()
{
MountPointList list(_prefix,
std::vector<vespalib::string>(),
- vespalib::LinkedPtr<DeviceManager>(
+ DeviceManager::UP(
new DeviceManager(
DeviceMapper::UP(new SimpleDeviceMapper),
_clock)));
@@ -195,7 +194,7 @@ void MountPointList_Test::testStatusFile()
{
MountPointList list(_prefix,
std::vector<vespalib::string>(),
- vespalib::LinkedPtr<DeviceManager>(
+ 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::string>(),
- vespalib::LinkedPtr<DeviceManager>(
+ 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<spi::DocEntry::LP> _entries;
+ std::vector<spi::DocEntry::UP> _entries;
};
private:
@@ -144,18 +144,12 @@ IteratorHandlerTest::doIterate(spi::IteratorId id,
std::vector<Chunk> chunks;
while (true) {
- std::vector<spi::DocEntry::LP> 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<IteratorHandlerTest::Chunk>& chunks)
}
size_t
-getRemoveEntryCount(const std::vector<spi::DocEntry::LP>& entries)
+getRemoveEntryCount(const std::vector<spi::DocEntry::UP>& entries)
{
size_t ret = 0;
for (size_t i = 0; i < entries.size(); ++i) {
@@ -191,20 +185,20 @@ getRemoveEntryCount(const std::vector<spi::DocEntry::LP>& 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<spi::DocEntry::LP>
+std::vector<spi::DocEntry::UP>
getEntriesFromChunks(const std::vector<IteratorHandlerTest::Chunk>& chunks)
{
- std::vector<spi::DocEntry::LP> ret;
+ std::vector<spi::DocEntry::UP> 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<DocAndTimestamp>& wanted,
const std::vector<IteratorHandlerTest::Chunk>& chunks,
const std::set<vespalib::string>& removes) const
{
- std::vector<spi::DocEntry::LP> retrieved(
+ std::vector<spi::DocEntry::UP> 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<Chunk> chunks2 = doIterate(iter.getIteratorId(), 10000);
CPPUNIT_ASSERT_EQUAL(size_t(24), chunks2.size());
- std::copy(chunks2.begin(),
- chunks2.end(),
- std::back_insert_iterator<std::vector<Chunk> >(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<Chunk> chunks = doIterate(iter.getIteratorId(), 4096);
- std::vector<spi::DocEntry::LP> entries = getEntriesFromChunks(chunks);
+ std::vector<spi::DocEntry::UP> entries = getEntriesFromChunks(chunks);
CPPUNIT_ASSERT_EQUAL(docs.size(), entries.size());
std::vector<DocAndTimestamp>::const_iterator docIter(
docs.begin());
@@ -495,9 +487,7 @@ IteratorHandlerTest::testDocumentsRemovedBetweenInvocations()
std::vector<Chunk> chunks2 = doIterate(iter.getIteratorId(), 1);
CPPUNIT_ASSERT_EQUAL(size_t(75), chunks2.size());
- std::copy(chunks2.begin(),
- chunks2.end(),
- std::back_insert_iterator<std::vector<Chunk> >(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<Chunk> chunks2 = doIterate(iter.getIteratorId(), 1);
- std::vector<spi::DocEntry::LP> entries = getEntriesFromChunks(chunks2);
+ std::vector<spi::DocEntry::UP> 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<spi::DocEntry::LP> entries(
+ std::vector<spi::DocEntry::UP> 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<SimpleMemFileIOBuffer>;
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<vespalib::string>(),
- _deviceManager);
+ std::make_unique<DeviceManager>(std::make_unique<SimpleDeviceMapper>(), _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<DevicesConfig>(configUri)),
_options(std::make_shared<Options>(*_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<Document> 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<std::string, Partition::LP>::iterator it
+ for (std::map<std::string, Partition::SP>::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<std::string, Directory::LP>::iterator it =
+ std::map<std::string, Directory::SP>::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<std::string, Directory::LP>::iterator it =
+ std::map<std::string, Directory::SP>::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<std::string, Partition::LP>::iterator it(
+ std::map<std::string, Partition::SP>::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<int, Disk::LP>::iterator it = _disks.find(devnr);
+ std::map<int, Disk::SP>::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<int, Disk::LP>::const_iterator diskIt = _disks.begin();
+ for (std::map<int, Disk::SP>::const_iterator diskIt = _disks.begin();
diskIt != _disks.end(); ++diskIt)
{
xos << XmlTag("disk") << XmlAttribute("deviceId", diskIt->first);
- for (std::map<std::string, Partition::LP>::const_iterator partIt
+ for (std::map<std::string, Partition::SP>::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<std::string, Directory::LP>::const_iterator dirIt
+ for (std::map<std::string, Directory::SP>::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<int, Disk::LP> _disks;
- std::map<std::string, Partition::LP> _partitions;
- std::map<std::string, Directory::LP> _directories;
+ std::map<int, Disk::SP> _disks;
+ std::map<std::string, Partition::SP> _partitions;
+ std::map<std::string, Directory::SP> _directories;
std::set<IOEventListener*> _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<DeviceManager> LP;
+ using UP = std::unique_ptr<DeviceManager>;
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<Directory::LP> getDirectories(const Disk& disk) const;
- std::vector<Directory::LP> getDirectories(const Partition& part) const;
+ std::vector<Directory::SP> getDirectories(const Disk& disk) const;
+ std::vector<Directory::SP> 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<Directory> LP;
+ using SP = std::shared_ptr<Directory>;
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 <vespa/memfilepersistence/device/device.h>
-#include <vespa/vespalib/util/linkedptr.h>
namespace storage {
@@ -29,7 +28,7 @@ class Disk : public Device {
friend class DeviceManager;
public:
- typedef vespalib::LinkedPtr<Disk> LP;
+ using SP = std::shared_ptr<Disk>;
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<vespalib::string>& 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<Directory::LP> entries;
+ std::vector<Directory::SP> 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<Directory::LP> entries;
+ std::vector<Directory::SP> 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<Directory::LP>::const_iterator it
+ for (std::vector<Directory::SP>::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<uint32_t, Directory::LP> lackingChunkDef;
+ std::map<uint32_t, Directory::SP> lackingChunkDef;
// Test disks and get chunkinfo
for (uint32_t i=0, n=_mountPoints.size(); i<n; ++i) {
- Directory::LP dir(_mountPoints[i]);
+ Directory::SP dir(_mountPoints[i]);
// Insert NOT_FOUND disk if not found, such that operator[]
// can return only valid pointers
if (!dir.get()) {
@@ -567,10 +567,10 @@ MountPointList::verifyHealthyDisks(int mountPointCount)
}
}
// Write chunkdef files where these are missing
- for (std::map<uint32_t, Directory::LP>::const_iterator it
+ for (std::map<uint32_t, Directory::SP>::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 <vespa/memfilepersistence/device/directory.h>
#include <vespa/storageframework/storageframework.h>
#include <vector>
-#include <vespa/vespalib/util/linkedptr.h>
#include <vespa/persistence/spi/persistenceprovider.h>
namespace storage {
@@ -37,7 +36,7 @@ struct MountPointList : public framework::XmlStatusReporter {
/** Create a mount point list. */
MountPointList(const std::string& vdsRoot,
const std::vector<vespalib::string>& diskPath,
- vespalib::LinkedPtr<DeviceManager>);
+ std::unique_ptr<DeviceManager>);
DeviceManager& getDeviceManager() { return *_deviceManager; }
@@ -122,10 +121,10 @@ struct MountPointList : public framework::XmlStatusReporter {
spi::PartitionStateList getPartitionStates() const;
private:
- vespalib::LinkedPtr<DeviceManager> _deviceManager;
+ std::unique_ptr<DeviceManager> _deviceManager;
std::string _vdsRoot;
std::vector<vespalib::string> _diskPath;
- std::vector<Directory::LP> _mountPoints;
+ std::vector<Directory::SP> _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<Partition> LP;
+ using SP = std::shared_ptr<Partition>;
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 <vespa/vespalib/util/printable.h>
#include <sys/statvfs.h>
#include <vespa/config-stor-devices.h>
-#include <vespa/vespalib/util/linkedptr.h>
#include <vespa/vespalib/util/sync.h>
#include <vespa/vespalib/util/xmlserializable.h>
@@ -28,7 +27,7 @@ class PartitionMonitor : public vespalib::Printable,
public vespalib::XmlSerializable
{
public:
- typedef vespalib::LinkedPtr<PartitionMonitor> LP;
+ using UP = std::unique_ptr<PartitionMonitor>;
/**
* 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<metrics::Metric::LP> newMetrics;
+ std::vector<metrics::Metric::UP> 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 <vespa/vespalib/util/alloc.h>
-#include <vespa/vespalib/util/linkedptr.h>
namespace storage {
namespace memfile {
@@ -24,7 +23,7 @@ class Buffer
size_t _size;
public:
- typedef vespalib::LinkedPtr<Buffer> LP;
+ using UP = std::unique_ptr<Buffer>;
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<MemFileV1Serializer> LP;
+ using UP = std::unique_ptr<MemFileV1Serializer>;
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<FileVersion, VersionSerializer::LP>::iterator it(
+ std::map<FileVersion, VersionSerializer::UP>::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<FileVersion, VersionSerializer::LP>::iterator serializer(
+ std::map<FileVersion, VersionSerializer::UP>::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<FileVersion>(
*reinterpret_cast<uint32_t*>(buffer.getBuffer()));
- std::map<FileVersion, VersionSerializer::LP>::iterator serializer(
+ std::map<FileVersion, VersionSerializer::UP>::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<FileVersion, VersionSerializer::LP>::iterator serializer(
+ std::map<FileVersion, VersionSerializer::UP>::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<FileVersion, VersionSerializer::LP>::iterator serializer(
+ std::map<FileVersion, VersionSerializer::UP>::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<FileVersion, VersionSerializer::LP> _serializers;
+ std::map<FileVersion, VersionSerializer::UP> _serializers;
ThreadMetricProvider& _metricProvider;
void setDefaultMemFileIO(MemFile& file,
vespalib::LazyFile::UP lf,
@@ -84,7 +84,7 @@ public:
void removeAllSlotsExcept(MemFile& file, std::vector<Timestamp>& 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<uint32_t>(bufLP->allocate(sz, align)),
+ return BufferAllocation(bufSP,
+ static_cast<uint32_t>(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<uint32_t>(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<SharedBuffer> LP;
+ using SP = std::shared_ptr<SharedBuffer>;
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<DataMap> _data;
- std::vector<SharedBuffer::LP> _workingBuffers;
+ std::vector<SharedBuffer::SP> _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 <vespa/memfilepersistence/mapper/buffer.h>
#include <vespa/memfilepersistence/mapper/mapperslotoperation.h>
#include <vespa/memfilepersistence/memfile/memfile.h>
-#include <vespa/vespalib/util/linkedptr.h>
#include <vespa/memfilepersistence/memfile/memfileiointerface.h>
namespace storage {
@@ -26,7 +25,7 @@ class MemFileEnvironment;
class Options;
struct VersionSerializer : protected Types {
- typedef vespalib::LinkedPtr<VersionSerializer> LP;
+ using UP = std::unique_ptr<VersionSerializer>;
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<LRUCache::iterator, bool> 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<Entry> LP;
+ using SP = std::shared_ptr<Entry>;
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 <vespa/vespalib/util/linkedptr.h>
-
namespace storage {
namespace memfile {
@@ -33,7 +31,7 @@ public:
* doing it, to prevent cyclic dependency with cache.
*/
struct EntryGuard {
- typedef vespalib::LinkedPtr<EntryGuard> LP;
+ using SP = std::shared_ptr<EntryGuard>;
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<MemSlot> LP;
+ using UP = std::unique_ptr<MemSlot>;
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<document::select::Node> docSelection;
+ std::unique_ptr<document::select::Node> 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 <vespa/memfilepersistence/spi/operationhandler.h>
#include <vespa/persistence/spi/persistenceprovider.h>
#include <vespa/document/fieldset/fieldsetrepo.h>
+#include <vespa/document/select/node.h>
namespace document {
class FieldSet;
-namespace select {
-class Node;
-}
}
namespace storage {
@@ -75,8 +73,8 @@ class IteratorState
{
spi::Bucket _bucket;
spi::Selection _selection;
- vespalib::LinkedPtr<document::FieldSet> _fieldSet;
- vespalib::LinkedPtr<document::select::Node> _documentSelection;
+ std::unique_ptr<document::FieldSet> _fieldSet;
+ std::unique_ptr<document::select::Node> _documentSelection;
std::vector<Types::Timestamp> _remaining;
spi::IncludedVersions _versions;
CachePrefetchRequirements _prefetchRequirements;
@@ -89,12 +87,12 @@ public:
const spi::Selection& sel,
document::FieldSet::UP fieldSet,
spi::IncludedVersions versions,
- vespalib::LinkedPtr<document::select::Node> docSel,
+ std::unique_ptr<document::select::Node> docSel,
const CachePrefetchRequirements& prefetchRequirements)
: _bucket(bucket),
_selection(sel),
- _fieldSet(vespalib::LinkedPtr<document::FieldSet>(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<vespalib::string>(),
- 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 <vespa/slobrok/imirrorapi.h>
-#include <vespa/vespalib/util/linkedptr.h>
#include "rpcserviceaddress.h"
namespace mbus {
@@ -26,7 +25,7 @@ private:
AddressList _addressList;
public:
- typedef vespalib::LinkedPtr<RPCService> LP;
+ using UP = std::unique_ptr<RPCService>;
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<string, RPCService::LP> > ServiceCache;
+ typedef vespalib::lrucache_map< vespalib::LruParam<string, RPCService::UP> > 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<Metric::LP>& ownerList, CopyType copyType,
+ MetricSet* clone(std::vector<Metric::UP> &ownerList, CopyType copyType,
MetricSet* owner, bool includeUnused = false) const override
{
if (copyType != CLONE) {
@@ -86,7 +86,7 @@ LoadMetricTest::testClone(Metric::CopyType copyType)
LoadMetric<MyMetricSet> metric(loadTypes, myset, &top);
metric[loadTypes["foo"]].metric.addValue(5);
- std::vector<Metric::LP> ownerList;
+ std::vector<Metric::UP> ownerList;
MetricSet::UP copy(dynamic_cast<MetricSet*>(top.clone(ownerList, copyType, 0, true)));
CPPUNIT_ASSERT(copy.get());
@@ -116,7 +116,7 @@ LoadMetricTest::testAdding()
LoadMetric<MyMetricSet> metric(loadTypes, myset, &top);
metric[loadTypes["foo"]].metric.addValue(5);
- std::vector<Metric::LP> ownerList;
+ std::vector<Metric::UP> ownerList;
MetricSet::UP copy(dynamic_cast<MetricSet*>(
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<Metric::LP> ownerList;
+ std::vector<Metric::UP> 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<Metric::LP>& ownerList, CopyType copyType,
+ virtual MetricSet* clone(std::vector<Metric::UP> &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<Metric::LP>& ownerList,
+SubSubMetricSet::clone(std::vector<Metric::UP> &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<Metric::LP>& ownerList, CopyType copyType,
+ MetricSet* clone(std::vector<Metric::UP> &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<Metric::LP>& ownerList, CopyType copyType,
+SubMetricSet::clone(std::vector<Metric::UP> &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<Metric::LP>& ownerList, CopyType copyType,
+ MetricSet* clone(std::vector<Metric::UP> &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<Metric::LP>& ownerList, CopyType copyType,
+ InnerMetricSet::clone(std::vector<Metric::UP> &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<Hammer> LP;
+ using UP = std::unique_ptr<Hammer>;
OuterMetricSet& _metrics;
const LoadTypeSet& _loadTypes;
@@ -141,9 +141,9 @@ StressTest::testStress()
LOG(info, "Starting load givers");
FastOS_ThreadPool threadPool(256 * 1024);
- std::vector<Hammer::LP> hammers;
+ std::vector<Hammer::UP> 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<Metric::LP> ownerList;
+ std::vector<Metric::UP> 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<Metric::LP>&, CopyType type, MetricSet* owner,
+ std::vector<Metric::UP> &, CopyType type, MetricSet* owner,
bool /*includeUnused*/) const
{ return new CountMetric<T, SumOnAdd>(*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<Metric::LP>&) const;
+ virtual void addToSnapshot(Metric&, std::vector<Metric::UP> &) const;
};
typedef CountMetric<uint64_t, true> 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<T, SumOnAdd>::dec(T value)
template <typename T, bool SumOnAdd>
void
CountMetric<T, SumOnAdd>::addToSnapshot(
- Metric& other, std::vector<Metric::LP>&) const
+ Metric& other, std::vector<Metric::UP> &) const
{
CountMetric<T, SumOnAdd>& o(
reinterpret_cast<CountMetric<T, SumOnAdd>&>(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<typename MetricType>
class LoadMetric : public MetricSet {
- std::vector<Metric::LP> _ownerList;
- typedef vespalib::LinkedPtr<MetricType> MetricTypeLP;
- using MetricMap = vespalib::hash_map<uint32_t, MetricTypeLP>;
+ std::vector<Metric::UP> _ownerList;
+ using MetricTypeUP = std::unique_ptr<MetricType>;
+ using MetricMap = vespalib::hash_map<uint32_t, MetricTypeUP>;
MetricMap _metrics;
SumMetric<MetricType> _sum;
@@ -49,7 +49,7 @@ public:
*/
LoadMetric(const LoadMetric<MetricType>& other, MetricSet* owner);
~LoadMetric();
- MetricSet* clone(std::vector<Metric::LP>& ownerList,
+ MetricSet* clone(std::vector<Metric::UP> &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<MetricType>::LoadMetric(const LoadTypeSet& loadTypes, const MetricTyp
setTags(metric.getTags());
Tags noTags;
for (uint32_t i=0; i<loadTypes.size(); ++i) {
- MetricTypeLP copy(dynamic_cast<MetricType*>(metric.clone(_ownerList, CLONE, 0, false)));
+ MetricTypeUP copy(dynamic_cast<MetricType*>(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<typename MetricType>
@@ -42,15 +42,15 @@ LoadMetric<MetricType>::LoadMetric(const LoadMetric<MetricType>& other, MetricSe
setTags(other.getTags());
Tags noTags;
for (const auto & metric : other._metrics) {
- MetricTypeLP copy(dynamic_cast<MetricType*>(metric.second->clone(_ownerList, CLONE, 0, false)));
+ MetricTypeUP copy(dynamic_cast<MetricType*>(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<typename MetricType>
@@ -58,7 +58,7 @@ LoadMetric<MetricType>::~LoadMetric() { }
template<typename MetricType>
MetricSet*
-LoadMetric<MetricType>::clone(std::vector<Metric::LP>& ownerList,
+LoadMetric<MetricType>::clone(std::vector<Metric::UP> &ownerList,
CopyType copyType, MetricSet* owner,
bool includeUnused) const
{
@@ -73,7 +73,7 @@ MetricType&
LoadMetric<MetricType>::getMetric(const LoadType& type) {
MetricType* metric;
- typename vespalib::hash_map<uint32_t, MetricTypeLP>::iterator it(
+ typename vespalib::hash_map<uint32_t, MetricTypeUP>::iterator it(
_metrics.find(type.getId()));
if (it == _metrics.end()) {
it = _metrics.find(0);
@@ -89,7 +89,7 @@ template<typename MetricType>
void
LoadMetric<MetricType>::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<MetricType>)
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<Metric::LP> ownerList;
+ std::vector<Metric::UP> ownerList;
const_cast<Metric&>(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 <vespa/vespalib/util/printable.h>
#include <vespa/vespalib/stllike/string.h>
-#include <vespa/vespalib/util/linkedptr.h>
#include <vespa/vespalib/util/regexp.h>
+#include <assert.h>
namespace metrics {
@@ -17,15 +17,6 @@ class XmlWriterMetricVisitor;
class MemoryConsumption;
class NameHash;
-template<typename T>
-void trim(std::vector<T>& v) {
- if (v.size() < v.capacity()) {
- std::vector<T> 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<Metric>;
- using LP = vespalib::LinkedPtr<Metric>;
using SP = std::shared_ptr<Metric>;
using Tags = std::vector<Tag>;
@@ -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<Metric::LP>& ownerList,
+ virtual Metric* clone(std::vector<Metric::UP> &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<Metric::LP>& ownerList) const = 0;
+ virtual void addToSnapshot(Metric& m, std::vector<Metric::UP> &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<Metric::LP>& ownerList,
+ std::vector<Metric::UP> &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<Metric::LP>& ownerList, CopyType type,
+MetricSet::clone(std::vector<Metric::UP> &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<Metric::LP>* ownerList) const
+MetricSet::addTo(Metric& other, std::vector<Metric::UP> *ownerList) const
{
bool mustAdd = (ownerList == 0);
MetricSet& o(static_cast<MetricSet&>(other));
@@ -239,9 +239,9 @@ MetricSet::addTo(Metric& other, std::vector<Metric::LP>* 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 <map>
#include <vespa/metrics/metric.h>
+#include <assert.h>
namespace metrics {
@@ -33,7 +34,7 @@ public:
MetricSet(const String& name, Tags dimensions,
const String& description, MetricSet* owner = 0);
- MetricSet(const MetricSet&, std::vector<Metric::LP>& ownerList,
+ MetricSet(const MetricSet&, std::vector<Metric::UP> &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<Metric::LP>& ownerList, CopyType type,
+ MetricSet* clone(std::vector<Metric::UP> &ownerList, CopyType type,
MetricSet* owner, bool includeUnused = false) const override;
void reset();
@@ -75,7 +76,7 @@ public:
const_cast<const MetricSet*>(this)->getMetric(name));
}
- virtual void addToSnapshot(Metric& m, std::vector<Metric::LP>& o) const
+ virtual void addToSnapshot(Metric& m, std::vector<Metric::UP> &o) const
{ addTo(m, &o); }
const std::vector<Metric*>& getRegisteredMetrics() const
@@ -109,7 +110,7 @@ private:
void tagRegistrationAltered();
const Metric* getMetricInternal(const String& name) const;
- virtual void addTo(Metric&, std::vector<Metric::LP>* ownerList) const;
+ virtual void addTo(Metric&, std::vector<Metric::UP> *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<MetricSet*>(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<Metric::LP> newMetrics;
+ std::vector<Metric::UP> newMetrics;
Metric* m = metrics.clone(newMetrics, Metric::INACTIVE, 0, copyUnset);
assert(m->isMetricSet());
std::unique_ptr<MetricSet> newSnapshot(static_cast<MetricSet*>(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<MetricSet> _snapshot;
// Snapshots must own their own metrics
- mutable std::vector<Metric::LP> _metrics;
+ mutable std::vector<Metric::UP> _metrics;
public:
typedef std::unique_ptr<MetricSnapshot> 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<Metric::LP> ownerList;
+ std::vector<Metric::UP> 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<Metric::LP> _startValueChildren;
+ std::vector<Metric::UP> _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<AddendMetric>& other, std::vector<Metric::LP>& ownerList, MetricSet* owner = 0);
+ SumMetric(const SumMetric<AddendMetric>& other, std::vector<Metric::UP> & ownerList, MetricSet* owner = 0);
~SumMetric();
- Metric* clone( std::vector<Metric::LP>&, CopyType, MetricSet* owner, bool includeUnused = false) const override;
+ Metric* clone( std::vector<Metric::UP> &, 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<Metric::LP>&) const;
+ virtual void addToSnapshot(Metric&, std::vector<Metric::UP> &) const;
private:
friend class MetricManagerTest;
- std::pair<std::vector<Metric::LP>, Metric::LP> generateSum() const;
+ std::pair<std::vector<Metric::UP>, Metric::UP> generateSum() const;
- virtual void addTo(Metric&, std::vector<Metric::LP>* ownerList) const;
+ virtual void addTo(Metric&, std::vector<Metric::UP> *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<AddendMetric>::visit(MetricVisitor& visitor,
{
(void) tagAsAutoGenerated;
if (_metricsToSum.empty()) return true;
- std::pair<std::vector<Metric::LP>, Metric::LP> sum(generateSum());
+ std::pair<std::vector<Metric::UP>, Metric::UP> sum(generateSum());
return sum.second->visit(visitor, true);
}
@@ -31,7 +31,7 @@ SumMetric<AddendMetric>::SumMetric(const String& name, const String& tags,
template<typename AddendMetric>
SumMetric<AddendMetric>::SumMetric(const SumMetric<AddendMetric>& other,
- std::vector<Metric::LP>& ownerList,
+ std::vector<Metric::UP> &ownerList,
MetricSet* owner)
: Metric(other, owner),
_startValue(other._startValue),
@@ -94,7 +94,7 @@ SumMetric<AddendMetric>::~SumMetric() { }
template<typename AddendMetric>
Metric*
-SumMetric<AddendMetric>::clone(std::vector<Metric::LP>& ownerList,
+SumMetric<AddendMetric>::clone(std::vector<Metric::UP> &ownerList,
CopyType copyType, MetricSet* owner,
bool includeUnused) const
{
@@ -139,19 +139,19 @@ template<typename AddendMetric>
void
SumMetric<AddendMetric>::addToPart(Metric& m) const
{
- std::pair<std::vector<Metric::LP>, Metric::LP> sum(generateSum());
+ std::pair<std::vector<Metric::UP>, Metric::UP> sum(generateSum());
sum.second->addToPart(m);
}
template<typename AddendMetric>
void
SumMetric<AddendMetric>::addToSnapshot(
- Metric& m, std::vector<Metric::LP>& ownerList) const
+ Metric& m, std::vector<Metric::UP> &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<std::vector<Metric::LP>, Metric::LP> sum(generateSum());
+ std::pair<std::vector<Metric::UP>, Metric::UP> sum(generateSum());
sum.second->addToSnapshot(m, ownerList);
}
}
@@ -159,16 +159,16 @@ SumMetric<AddendMetric>::addToSnapshot(
template<typename AddendMetric>
void
SumMetric<AddendMetric>::addTo(Metric& m,
- std::vector<Metric::LP>* ownerList) const
+ std::vector<Metric::UP> *ownerList) const
{
if (ownerList == 0) {
- std::pair<std::vector<Metric::LP>, Metric::LP> sum(generateSum());
+ std::pair<std::vector<Metric::UP>, 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<std::vector<Metric::LP>, Metric::LP> sum(generateSum());
+ std::pair<std::vector<Metric::UP>, Metric::UP> sum(generateSum());
sum.second->addToSnapshot(m, *ownerList);
}
}
@@ -220,10 +220,10 @@ SumMetric<AddendMetric>::removeMetricFromSum(const AddendMetric &metric)
}
template<typename AddendMetric>
-std::pair<std::vector<Metric::LP>, Metric::LP>
+std::pair<std::vector<Metric::UP>, Metric::UP>
SumMetric<AddendMetric>::generateSum() const
{
- std::pair<std::vector<Metric::LP>, Metric::LP> retVal;
+ std::pair<std::vector<Metric::UP>, Metric::UP> retVal;
Metric* m = clone(retVal.first, INACTIVE, 0, true);
m->setRegistered(_owner);
retVal.second.reset(m);
@@ -234,7 +234,7 @@ template<typename AddendMetric>
int64_t
SumMetric<AddendMetric>::getLongValue(const stringref & id) const
{
- std::pair<std::vector<Metric::LP>, Metric::LP> sum(generateSum());
+ std::pair<std::vector<Metric::UP>, Metric::UP> sum(generateSum());
if (sum.second.get() == 0) return 0;
return sum.second->getLongValue(id);
}
@@ -243,7 +243,7 @@ template<typename AddendMetric>
double
SumMetric<AddendMetric>::getDoubleValue(const stringref & id) const
{
- std::pair<std::vector<Metric::LP>, Metric::LP> sum(generateSum());
+ std::pair<std::vector<Metric::UP>, Metric::UP> sum(generateSum());
if (sum.second.get() == 0) return 0.0;
return sum.second->getDoubleValue(id);
}
@@ -252,7 +252,7 @@ template<typename AddendMetric>
bool
SumMetric<AddendMetric>::logEvent(const String & fullName) const
{
- std::pair<std::vector<Metric::LP>, Metric::LP> sum(generateSum());
+ std::pair<std::vector<Metric::UP>, Metric::UP> sum(generateSum());
if (sum.second.get() == 0) return false;
return sum.second->logEvent(fullName);
}
@@ -263,7 +263,7 @@ SumMetric<AddendMetric>::print(std::ostream& out, bool verbose,
const std::string& indent,
uint64_t secondsPassed) const
{
- std::pair<std::vector<Metric::LP>, Metric::LP> sum(generateSum());
+ std::pair<std::vector<Metric::UP>, 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 <vespa/vespalib/util/sync.h>
-#include <vespa/vespalib/util/linkedptr.h>
namespace metrics {
@@ -15,7 +14,7 @@ class UpdateHook {
friend class MetricManager;
public:
- typedef vespalib::LinkedPtr<UpdateHook> LP;
+ using UP = std::unique_ptr<UpdateHook>;
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<Metric::LP>&, CopyType type, MetricSet* owner,
+ std::vector<Metric::UP> &, CopyType type, MetricSet* owner,
bool /*includeUnused*/) const
{ return new ValueMetric<AvgVal,TotVal,SumOnAdd>(*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<Metric::LP>&) const;
+ virtual void addToSnapshot(Metric&, std::vector<Metric::UP> &) const;
};
typedef ValueMetric<double, double, true> 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<AvgVal, TotVal, SumOnAdd>::dec(AvgVal decVal)
template<typename AvgVal, typename TotVal, bool SumOnAdd>
void
ValueMetric<AvgVal, TotVal, SumOnAdd>::addToSnapshot(
- Metric& other, std::vector<Metric::LP>&) const
+ Metric& other, std::vector<Metric::UP> &) const
{
ValueMetric<AvgVal, TotVal, SumOnAdd>& o(
reinterpret_cast<ValueMetric<AvgVal, TotVal, SumOnAdd>&>(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<spi::DocEntry::LP>& entries)
+// getRemoveEntryCount(const std::vector<spi::DocEntry::UP>& 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<DocEntry>
// getEntriesFromChunks(const std::vector<Chunk>& chunks)
// {
-// std::vector<spi::DocEntry::LP> ret;
+// std::vector<spi::DocEntry::UP> 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<DocEntry::LP> _entries;
+ std::vector<DocEntry::UP> _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<Chunk> chunks;
while (true) {
- std::vector<DocEntry::LP> 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<spi::DocEntry::LP>& entries)
+getRemoveEntryCount(const std::vector<spi::DocEntry::UP>& entries)
{
size_t ret = 0;
for (size_t i = 0; i < entries.size(); ++i) {
@@ -178,13 +172,13 @@ getRemoveEntryCount(const std::vector<spi::DocEntry::LP>& entries)
return ret;
}
-std::vector<DocEntry::LP>
+std::vector<DocEntry::UP>
getEntriesFromChunks(const std::vector<Chunk>& chunks)
{
- std::vector<spi::DocEntry::LP> ret;
+ std::vector<spi::DocEntry::UP> 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<Chunk>& chunks)
}
-std::vector<DocEntry::LP>
+std::vector<DocEntry::UP>
iterateBucket(PersistenceProvider& spi,
const Bucket& bucket,
IncludedVersions versions)
{
- std::vector<DocEntry::LP> ret;
+ std::vector<DocEntry::UP> ret;
DocumentSelection docSel("");
Selection sel(docSel);
@@ -218,11 +212,10 @@ iterateBucket(PersistenceProvider& spi,
spi.iterate(iter.getIteratorId(),
std::numeric_limits<int64_t>().max(), context);
if (result.getErrorCode() != Result::NONE) {
- return std::vector<DocEntry::LP>();
- }
- for (size_t i = 0; i < result.getEntries().size(); ++i) {
- ret.push_back(result.getEntries()[i]);
+ return std::vector<DocEntry::UP>();
}
+ 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<DocAndTimestamp>& wanted,
const std::vector<Chunk>& chunks,
const std::set<string>& removes = std::set<string>())
{
- std::vector<DocEntry::LP> retrieved(
+ std::vector<DocEntry::UP> 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<DocEntry::LP> entries(
+ std::vector<DocEntry::UP> 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<DocEntry::LP> entries(
+ std::vector<DocEntry::UP> 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<DocEntry::LP> entries(iterateBucket(*spi,
+ std::vector<DocEntry::UP> entries(iterateBucket(*spi,
bucket,
NEWEST_DOCUMENT_ONLY));
CPPUNIT_ASSERT_EQUAL(size_t(0), entries.size());
}
{
- std::vector<DocEntry::LP> entries(iterateBucket(*spi,
+ std::vector<DocEntry::UP> entries(iterateBucket(*spi,
bucket,
NEWEST_DOCUMENT_OR_REMOVE));
@@ -820,7 +813,7 @@ void ConformanceTest::testRemoveMerge() {
// Remove entry should exist afterwards
{
- std::vector<DocEntry::LP> entries(iterateBucket(
+ std::vector<DocEntry::UP> 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<DocEntry::LP> entries(iterateBucket(*spi, bucket, ALL_VERSIONS));
+ std::vector<DocEntry::UP> 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<DocEntry::LP> entries(iterateBucket(*spi, bucket, ALL_VERSIONS));
+ std::vector<DocEntry::UP> 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<Chunk> chunks = doIterate(*spi, iter.getIteratorId(), 4096);
- std::vector<DocEntry::LP> entries = getEntriesFromChunks(chunks);
+ std::vector<DocEntry::UP> 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<BucketEntry>::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<document::select::Node> docSelection;
+ std::unique_ptr<document::select::Node> 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<document::FieldSet>(fs.clone());
+ it->_fieldSet = std::unique_ptr<document::FieldSet>(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<IteratorId, Iterator::LP>::iterator iter(_iterators.find(id));
+ std::map<IteratorId, Iterator::UP>::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<DocEntry::LP> entries;
+ std::vector<DocEntry::UP> 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; i<sour._entries.size(); ++i) {
- DocEntry::LP entry(sour._entries[i].entry);
+ DocEntry::SP entry(sour._entries[i].entry);
document::BucketId bId(
target1.getBucketId().getUsedBits(),
idFactory.getBucketId(*entry->getDocumentId()).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; i<sour._entries.size(); ++i) {
- DocEntry::LP entry(sour._entries[i].entry);
- (*targetGuard)->insert(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<storage::spi::dummy::BucketContent>, document::BucketId::hash) \ No newline at end of file
+VESPALIB_HASH_MAP_INSTANTIATE_H(storage::spi::Bucket, std::shared_ptr<storage::spi::dummy::BucketContent>, 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<BucketContent> LP;
+ using SP = std::shared_ptr<BucketContent>;
std::vector<BucketEntry> _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<Iterator> LP;
+ using UP = std::unique_ptr<Iterator>;
Bucket _bucket;
std::vector<Timestamp> _leftToIterate;
- vespalib::LinkedPtr<document::FieldSet> _fieldSet;
+ std::unique_ptr<document::FieldSet> _fieldSet;
};
class DummyPersistence;
@@ -220,12 +220,12 @@ private:
mutable bool _initialized;
document::DocumentTypeRepo::SP _repo;
PartitionStateList _partitions;
- typedef vespalib::hash_map<Bucket, BucketContent::LP, document::BucketId::hash>
+ typedef vespalib::hash_map<Bucket, BucketContent::SP, document::BucketId::hash>
PartitionContent;
std::vector<PartitionContent> _content;
IteratorId _nextIterator;
- mutable std::map<IteratorId, Iterator::LP> _iterators;
+ mutable std::map<IteratorId, Iterator::UP> _iterators;
vespalib::Monitor _monitor;
std::unique_ptr<ClusterState> _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<DocEntry::LP> &entries = result.getEntries();
+ const vector<DocEntry::UP> &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 <persistence/spi/types.h>
-#include <vespa/vespalib/util/linkedptr.h>
namespace storage {
namespace spi {
@@ -35,8 +34,8 @@ private:
DocumentIdUP _documentId;
DocumentUP _document;
public:
- typedef vespalib::LinkedPtr<DocEntry> LP;
- typedef std::unique_ptr<DocEntry> UP;
+ using UP = std::unique_ptr<DocEntry>;
+ using SP = std::shared_ptr<DocEntry>;
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<DocEntry::LP> List;
+ typedef std::vector<DocEntry::UP> 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<DocEntry::LP> _entries;
+ std::vector<DocEntry::UP> _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 <vespa/vespalib/util/buffer.h>
-#include <vespa/vespalib/util/linkedptr.h>
namespace search {
namespace common {
@@ -12,7 +11,6 @@ class BlobConverter
{
public:
using SP = std::shared_ptr<BlobConverter>;
- using LP = vespalib::LinkedPtr<BlobConverter>;
using UP = std::unique_ptr<BlobConverter>;
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 <vespa/searchcore/proton/server/i_proton_configurer.h>
#include <vespa/searchsummary/config/config-juniperrc.h>
#include <vespa/vespalib/testkit/testapp.h>
-#include <vespa/vespalib/util/linkedptr.h>
#include <vespa/vespalib/util/varholder.h>
#include <mutex>
@@ -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<GroupingSession> LP;
typedef std::unique_ptr<GroupingSession> 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 <vespa/searchlib/query/base.h>
#include <vespa/vespalib/objects/nbostream.h>
-#include <vespa/vespalib/util/linkedptr.h>
#include <vector>
namespace proton {
@@ -17,7 +16,7 @@ private:
size_t _docIdLimit;
enum { ARRAY = 0, BITVECTOR = 1 };
public:
- typedef vespalib::LinkedPtr<LidVectorContext> LP;
+ using SP = std::shared_ptr<LidVectorContext>;
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<uint32_t, LidVectorContext::LP> LidsToRemoveMap;
+ typedef std::map<uint32_t, LidVectorContext::SP> 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 &params,
}
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 <vespa/vespalib/util/linkedptr.h>
#include <vespa/vespalib/util/dual_merge_director.h>
#include <vespa/searchlib/common/rankedhit.h>
#include <vector>
@@ -17,8 +16,8 @@ namespace matching {
class PartialResult : public vespalib::DualMergeDirector::Source
{
public:
- typedef vespalib::LinkedPtr<PartialResult> LP;
- typedef std::pair<const char *, size_t> SortRef;
+ using UP = std::unique_ptr<PartialResult>;
+ using SortRef = std::pair<const char *, size_t>;
private:
std::vector<search::RankedHit> _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<PartialResult>;
+ using PartialResultUP = std::unique_ptr<PartialResult>;
public:
/**
* Sorter selection and owner of additional data needed for
@@ -63,11 +63,11 @@ public:
using GroupingContextUP = std::unique_ptr<GroupingContext>;
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<Result> makeReply();
+ std::unique_ptr<Result> 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 <typename T>
struct SessionCache : SessionCacheBase {
- typedef typename T::LP EntryLP;
typedef typename T::UP EntryUP;
- vespalib::lrucache_map<vespalib::LruParam<SessionId, EntryLP> > _cache;
+ vespalib::lrucache_map<vespalib::LruParam<SessionId, EntryUP> > _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<EntryLP> toDestruct = stealTimedOutSessions(currentTime);
+ std::vector<EntryUP> toDestruct = stealTimedOutSessions(currentTime);
toDestruct.clear();
}
- std::vector<EntryLP> stealTimedOutSessions(fastos::TimeStamp currentTime) {
- std::vector<EntryLP> toDestruct;
+ std::vector<EntryUP> stealTimedOutSessions(fastos::TimeStamp currentTime) {
+ std::vector<EntryUP> 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<Entry>(name);
+ return pos.get();
}
-LegacyAttributeMetrics::List::Entry::LP
+LegacyAttributeMetrics::List::Entry *
LegacyAttributeMetrics::List::get(const std::string &name) const
{
- std::map<std::string, Entry::LP>::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<std::string, Entry::LP>::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<LegacyAttributeMetrics::List::Entry::LP>
+std::vector<LegacyAttributeMetrics::List::Entry::UP>
LegacyAttributeMetrics::List::release()
{
- std::vector<Entry::LP> entries;
- std::map<std::string, Entry::LP>::const_iterator pos = metrics.begin();
- for (; pos != metrics.end(); ++pos) {
- entries.push_back(pos->second);
+ std::vector<Entry::UP> 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 <vespa/metrics/metrics.h>
-#include <vespa/vespalib/util/linkedptr.h>
namespace proton {
@@ -16,22 +15,22 @@ struct LegacyAttributeMetrics : metrics::MetricSet {
struct List : metrics::MetricSet {
struct Entry : metrics::MetricSet {
- typedef vespalib::LinkedPtr<Entry> LP;
+ using UP = std::unique_ptr<Entry>;
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<Entry::LP> release();
+ Entry *add(const std::string &name);
+ Entry *get(const std::string &name) const;
+ Entry::UP remove(const std::string &name);
+ std::vector<Entry::UP> release();
// per attribute metrics will be wired in here (by the metrics engine)
List(metrics::MetricSet *parent);
~List();
private:
- std::map<std::string, Entry::LP> metrics;
+ std::map<std::string, Entry::UP> 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<DocIdPartition> LP;
+ using UP = std::unique_ptr<DocIdPartition>;
DocIdPartition(const std::string &name, metrics::MetricSet *parent);
~DocIdPartition();
void update(const matching::MatchingStats::Partition &stats);
};
- typedef std::vector<DocIdPartition::LP> DocIdPartitions;
-
- typedef vespalib::LinkedPtr<RankProfileMetrics> LP;
+ using DocIdPartitions = std::vector<DocIdPartition::UP>;
+ using UP = std::unique_ptr<RankProfileMetrics>;
metrics::LongCountMetric queries;
metrics::LongCountMetric limited_queries;
@@ -82,7 +81,7 @@ struct LegacyDocumentDBMetrics : metrics::MetricSet
void update(const matching::MatchingStats &stats);
};
- typedef std::map<std::string, RankProfileMetrics::LP> RankProfileMap;
+ using RankProfileMap = std::map<std::string, RankProfileMetrics::UP>;
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<LegacyAttributeMetrics::List::Entry::LP> entries = attributes.list.release();
+ std::vector<LegacyAttributeMetrics::List::Entry::UP> 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<DocId>::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 <vespa/searchlib/query/weight.h>
#include <vector>
+#include <assert.h>
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> _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;
};
@@ -125,6 +126,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.
* Object is then put at head of LRU list.
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
@@ -17,6 +17,16 @@ lrucache_map<P>::insert(const K & key, const V & value) {
}
template< typename P >
+typename lrucache_map<P>::insert_result
+lrucache_map<P>::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<P>::removeOldest(const value_type & v) {
(void) 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 <vespa/vespalib/util/linkedptr.h>
#include <vespa/storage/distributor/operations/idealstate/mergelimiter.h>
#include <vespa/vdstestlib/cppunit/macros.h>
@@ -29,7 +28,7 @@ struct MergeLimiterTest : public CppUnit::TestFixture
CPPUNIT_TEST_SUITE_REGISTRATION(MergeLimiterTest);
namespace {
- typedef vespalib::LinkedPtr<BucketCopy> BucketCopyPtr;
+ using BucketCopyPtr = std::unique_ptr<BucketCopy>;
std::vector<BucketCopyPtr> _bucketDatabase;
struct NodeFactory {
diff --git a/storage/src/tests/persistence/persistencetestutils.cpp b/storage/src/tests/persistence/persistencetestutils.cpp
index e6a401548aa..faaaaac178d 100644
--- a/storage/src/tests/persistence/persistencetestutils.cpp
+++ b/storage/src/tests/persistence/persistencetestutils.cpp
@@ -55,7 +55,7 @@ PersistenceTestEnvironment::PersistenceTestEnvironment(DiskCount numDisks, const
_node.getComponentRegister(), 255, 0));
for (uint32_t i = 0; i < numDisks; i++) {
_diskEnvs.push_back(
- vespalib::LinkedPtr<PersistenceUtil>(
+ std::unique_ptr<PersistenceUtil>(
new PersistenceUtil(
_config.getConfigId(),
_node.getComponentRegister(),
diff --git a/storage/src/tests/persistence/persistencetestutils.h b/storage/src/tests/persistence/persistencetestutils.h
index 4f6c6ba3bbb..4a51faafe05 100644
--- a/storage/src/tests/persistence/persistencetestutils.h
+++ b/storage/src/tests/persistence/persistencetestutils.h
@@ -32,7 +32,7 @@ struct PersistenceTestEnvironment {
StorageComponent _component;
FileStorMetrics _metrics;
std::unique_ptr<FileStorHandler> _handler;
- std::vector<vespalib::LinkedPtr<PersistenceUtil> > _diskEnvs;
+ std::vector<std::unique_ptr<PersistenceUtil> > _diskEnvs;
};
class PersistenceTestUtils : public CppUnit::TestFixture {
diff --git a/storage/src/tests/persistence/splitbitdetectortest.cpp b/storage/src/tests/persistence/splitbitdetectortest.cpp
index cdec8e3e3f6..65ea629ad81 100644
--- a/storage/src/tests/persistence/splitbitdetectortest.cpp
+++ b/storage/src/tests/persistence/splitbitdetectortest.cpp
@@ -28,14 +28,14 @@ struct SplitBitDetectorTest : public CppUnit::TestFixture {
void testZeroDocLimitFallbacksToOneBitIncreaseOnGidCollision();
void findBucketCollisionIds();
- spi::DocEntry::LP
+ spi::DocEntry::UP
generateDocEntry(uint32_t userId,
uint32_t docNum,
spi::Timestamp timestamp)
{
std::ostringstream ost;
ost << "id:storage_test:testdoctype1:n=" << userId << ":" << docNum;
- return spi::DocEntry::LP(new spi::DocEntry(
+ return spi::DocEntry::UP(new spi::DocEntry(
timestamp, 0, document::DocumentId(ost.str())));
};
@@ -68,7 +68,7 @@ SplitBitDetectorTest::testTwoUsers()
provider.createBucket(bucket, context);
- std::vector<spi::DocEntry::LP> entries;
+ std::vector<spi::DocEntry::UP> entries;
for (uint32_t i = 0; i < 5; ++i) {
document::Document::SP doc(
testDocMan.createRandomDocumentAtLocation(1, i, 1, 1));
@@ -102,7 +102,7 @@ SplitBitDetectorTest::testSingleUser()
provider.createBucket(bucket, context);
- std::vector<spi::DocEntry::LP> entries;
+ std::vector<spi::DocEntry::UP> entries;
for (uint32_t i = 0; i < 10; ++i) {
document::Document::SP doc(
testDocMan.createRandomDocumentAtLocation(1, i, 1, 1));
@@ -131,7 +131,7 @@ SplitBitDetectorTest::testMaxBits()
provider.createBucket(bucket, context);
- std::vector<spi::DocEntry::LP> entries;
+ std::vector<spi::DocEntry::UP> entries;
for (uint32_t seed = 0; seed < 10; ++seed) {
int location = 1;
document::Document::SP doc(testDocMan.createRandomDocumentAtLocation(
@@ -160,7 +160,7 @@ SplitBitDetectorTest::testMaxBitsOneBelowMax()
provider.createBucket(bucket, context);
- std::vector<spi::DocEntry::LP> entries;
+ std::vector<spi::DocEntry::UP> entries;
for (uint32_t seed = 0; seed < 10; ++seed) {
int location = 1 | (seed % 2 == 0 ? 0x8000 : 0);
document::Document::SP doc(testDocMan.createRandomDocumentAtLocation(
@@ -198,7 +198,7 @@ SplitBitDetectorTest::testUnsplittable()
provider.createBucket(bucket, context);
- std::vector<spi::DocEntry::LP> entries;
+ std::vector<spi::DocEntry::UP> entries;
for (uint32_t i = 0; i < 10; ++i) {
document::Document::SP doc(
@@ -227,7 +227,7 @@ SplitBitDetectorTest::testUnsplittableMinCount()
provider.createBucket(bucket, context);
- std::vector<spi::DocEntry::LP> entries;
+ std::vector<spi::DocEntry::UP> entries;
for (uint32_t i = 0; i < 10; ++i) {
document::Document::SP doc(
diff --git a/storage/src/tests/storageserver/testvisitormessagesession.cpp b/storage/src/tests/storageserver/testvisitormessagesession.cpp
index 6c8f491162b..aca7c23996d 100644
--- a/storage/src/tests/storageserver/testvisitormessagesession.cpp
+++ b/storage/src/tests/storageserver/testvisitormessagesession.cpp
@@ -50,7 +50,7 @@ TestVisitorMessageSession::send(
} else {
pendingCount++;
sentMessages.push_back(
- vespalib::LinkedPtr<documentapi::DocumentMessage>(
+ std::unique_ptr<documentapi::DocumentMessage>(
message.release()));
guard.broadcast();
return mbus::Result();
diff --git a/storage/src/tests/storageserver/testvisitormessagesession.h b/storage/src/tests/storageserver/testvisitormessagesession.h
index 3ae6ccafb84..9b2f645905d 100644
--- a/storage/src/tests/storageserver/testvisitormessagesession.h
+++ b/storage/src/tests/storageserver/testvisitormessagesession.h
@@ -26,7 +26,7 @@ public:
~TestVisitorMessageSession();
- std::deque<vespalib::LinkedPtr<documentapi::DocumentMessage> > sentMessages;
+ std::deque<std::unique_ptr<documentapi::DocumentMessage> > sentMessages;
TestVisitorMessageSession(VisitorThread& t,
Visitor& v,
diff --git a/storage/src/tests/visiting/visitortest.cpp b/storage/src/tests/visiting/visitortest.cpp
index cddd044ca4c..1e2eda75cc8 100644
--- a/storage/src/tests/visiting/visitortest.cpp
+++ b/storage/src/tests/visiting/visitortest.cpp
@@ -342,8 +342,9 @@ VisitorTest::getMessagesAndReply(
{
vespalib::MonitorGuard guard(session.getMonitor());
CPPUNIT_ASSERT(!session.sentMessages.empty());
- vespalib::LinkedPtr<documentapi::DocumentMessage> msg(
- session.sentMessages.front());
+ std::unique_ptr<documentapi::DocumentMessage> msg(
+ std::move(session.sentMessages.front()));
+ session.sentMessages.pop_front();
CPPUNIT_ASSERT(msg->getPriority() < 16);
switch (msg->getType()) {
@@ -369,7 +370,6 @@ VisitorTest::getMessagesAndReply(
reply = msg->createReply();
reply->swapState(*msg);
- session.sentMessages.pop_front(); // Release linked ptr ref.
reply->setMessage(mbus::Message::UP(msg.release()));
if (result != api::ReturnCode::OK) {
@@ -443,7 +443,7 @@ VisitorTest::sendGetIterReply(GetIterCommand& cmd,
size_t documentCount = maxDocuments != 0 ? maxDocuments : _documents.size();
for (size_t i = 0; i < documentCount; ++i) {
reply->getEntries().push_back(
- spi::DocEntry::LP(
+ spi::DocEntry::UP(
new spi::DocEntry(
spi::Timestamp(1000 + i),
spi::NONE,
diff --git a/storage/src/vespa/storage/bucketdb/lockablemap.h b/storage/src/vespa/storage/bucketdb/lockablemap.h
index 6301014d26b..40e45b72c48 100644
--- a/storage/src/vespa/storage/bucketdb/lockablemap.h
+++ b/storage/src/vespa/storage/bucketdb/lockablemap.h
@@ -17,7 +17,6 @@
#include <map>
#include <vespa/vespalib/util/printable.h>
#include <vespa/vespalib/util/sync.h>
-#include <vespa/vespalib/util/linkedptr.h>
#include <vespa/vespalib/stllike/hash_map.h>
#include <vespa/vespalib/stllike/hash_set.h>
#include <vespa/document/bucket/bucketid.h>
@@ -86,7 +85,7 @@ public:
bool _exists;
bool _preExisted;
- vespalib::LinkedPtr<LockKeeper> _lockKeeper;
+ std::unique_ptr<LockKeeper> _lockKeeper;
mapped_type _value;
const char* _clientId;
friend class LockableMap<Map>;
diff --git a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp
index 79dde3f839a..178731469ba 100644
--- a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp
+++ b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp
@@ -21,7 +21,7 @@ namespace storage {
using BucketSet = vespalib::hash_set<document::BucketId, document::BucketId::hash>;
struct BucketReadState {
- typedef vespalib::LinkedPtr<BucketReadState> LP;
+ using UP = std::unique_ptr<BucketReadState>;
BucketSet _pending;
document::BucketId _databaseIterator;
@@ -132,7 +132,7 @@ StorageBucketDBInitializer::StorageBucketDBInitializer(
// Initialize read state for disks being available
for (uint32_t i=0; i<_system._partitions.size(); ++i) {
if (!_system._partitions[i].isUp()) continue;
- _readState[i] = BucketReadState::LP(new BucketReadState);
+ _readState[i] = BucketReadState::UP(new BucketReadState);
_state._dirsToList += 1;
}
_system._component.registerStatusPage(*this);
diff --git a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h
index 5190be426a5..94afc5b2e1a 100644
--- a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h
+++ b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h
@@ -129,7 +129,7 @@ class StorageBucketDBInitializer : public StorageLink,
System _system;
Metrics _metrics;
GlobalState _state;
- std::vector<vespalib::LinkedPtr<BucketReadState>> _readState;
+ std::vector<std::unique_ptr<BucketReadState>> _readState;
public:
StorageBucketDBInitializer(const config::ConfigUri&,
diff --git a/storage/src/vespa/storage/bucketmover/run.h b/storage/src/vespa/storage/bucketmover/run.h
index 575a9c60183..292b18f63a5 100644
--- a/storage/src/vespa/storage/bucketmover/run.h
+++ b/storage/src/vespa/storage/bucketmover/run.h
@@ -19,7 +19,6 @@
#include <map>
#include <vespa/storage/bucketmover/move.h>
#include <vespa/storage/bucketmover/runstatistics.h>
-#include <vespa/vespalib/util/linkedptr.h>
#include <vespa/vdslib/distribution/distribution.h>
#include <vespa/vdslib/state/nodestate.h>
diff --git a/storage/src/vespa/storage/bucketmover/runstatistics.cpp b/storage/src/vespa/storage/bucketmover/runstatistics.cpp
index 7383e0ca5ef..6ba0dfd463a 100644
--- a/storage/src/vespa/storage/bucketmover/runstatistics.cpp
+++ b/storage/src/vespa/storage/bucketmover/runstatistics.cpp
@@ -6,7 +6,6 @@
#include <iomanip>
#include <vespa/log/log.h>
#include <vespa/storage/bucketmover/htmltable.h>
-#include <vespa/vespalib/util/linkedptr.h>
LOG_SETUP(".bucketmover.run.statistics");
diff --git a/storage/src/vespa/storage/bucketmover/runstatistics.h b/storage/src/vespa/storage/bucketmover/runstatistics.h
index 1483c241eb9..625d7f5fac4 100644
--- a/storage/src/vespa/storage/bucketmover/runstatistics.h
+++ b/storage/src/vespa/storage/bucketmover/runstatistics.h
@@ -19,8 +19,8 @@
if (anyset) { \
out << "<h4>" << desc << "</h4>\n"; \
HtmlTable matrixTable("Source \\ Target"); \
- typedef vespalib::LinkedPtr<LongColumn> LCLP; \
- std::vector<LCLP> matrixData((rs)._diskData.size()); \
+ using LCUP = std::unique_ptr<LongColumn>; \
+ std::vector<LCUP> matrixData((rs)._diskData.size()); \
for (uint32_t i=0; i<(rs)._diskData.size(); ++i) { \
std::ostringstream index; \
index << "Disk " << i; \
diff --git a/storage/src/vespa/storage/common/hostreporter/cpureporter.cpp b/storage/src/vespa/storage/common/hostreporter/cpureporter.cpp
index d7f59e07d4e..59c0f1c36f3 100644
--- a/storage/src/vespa/storage/common/hostreporter/cpureporter.cpp
+++ b/storage/src/vespa/storage/common/hostreporter/cpureporter.cpp
@@ -3,7 +3,6 @@
#include "cpureporter.h"
#include <vespa/log/log.h>
-#include <vespa/vespalib/util/linkedptr.h>
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/text/stringtokenizer.h>
diff --git a/storage/src/vespa/storage/common/hostreporter/hostinfo.h b/storage/src/vespa/storage/common/hostreporter/hostinfo.h
index 340ffdc73c7..3563cbb4af6 100644
--- a/storage/src/vespa/storage/common/hostreporter/hostinfo.h
+++ b/storage/src/vespa/storage/common/hostreporter/hostinfo.h
@@ -2,7 +2,6 @@
#ifndef STORAGE_SRC_CPP_STORAGE_COMMON_HOSTREPORTER_HOSTINFO_H_
#define STORAGE_SRC_CPP_STORAGE_COMMON_HOSTREPORTER_HOSTINFO_H_
-#include <vespa/vespalib/util/linkedptr.h>
#include <vespa/vespalib/util/jsonstream.h>
#include "cpureporter.h"
diff --git a/storage/src/vespa/storage/distributor/maintenance/bucketprioritydatabase.h b/storage/src/vespa/storage/distributor/maintenance/bucketprioritydatabase.h
index 30ccf0040ba..3088e6f5322 100644
--- a/storage/src/vespa/storage/distributor/maintenance/bucketprioritydatabase.h
+++ b/storage/src/vespa/storage/distributor/maintenance/bucketprioritydatabase.h
@@ -4,7 +4,6 @@
#include <vespa/storage/bucketdb/bucketdatabase.h>
#include <vespa/storage/distributor/maintenance/prioritizedbucket.h>
#include <boost/iterator/iterator_facade.hpp>
-#include <vespa/vespalib/util/linkedptr.h>
namespace storage {
namespace distributor {
@@ -23,7 +22,7 @@ protected:
virtual PrioritizedBucket dereference() const = 0;
};
- typedef vespalib::LinkedPtr<ConstIteratorImpl> ConstIteratorImplPtr;
+ using ConstIteratorImplPtr = std::unique_ptr<ConstIteratorImpl>;
public:
class ConstIterator
: public boost::iterator_facade<
@@ -35,9 +34,11 @@ public:
{
ConstIteratorImplPtr _impl;
public:
- ConstIterator(const ConstIteratorImplPtr& impl)
- : _impl(impl)
+ ConstIterator(ConstIteratorImplPtr impl)
+ : _impl(std::move(impl))
{}
+ ConstIterator(const ConstIterator &) = delete;
+ ConstIterator(ConstIterator &&) = default;
virtual ~ConstIterator() {}
private:
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/idealstateoperation.h b/storage/src/vespa/storage/distributor/operations/idealstate/idealstateoperation.h
index 3491eacf066..cf820dd3381 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/idealstateoperation.h
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/idealstateoperation.h
@@ -108,7 +108,6 @@ public:
static const uint32_t MAINTENANCE_MESSAGE_TYPES[];
typedef std::shared_ptr<IdealStateOperation> SP;
- typedef vespalib::LinkedPtr<IdealStateOperation> LP;
typedef std::unique_ptr<IdealStateOperation> UP;
typedef std::vector<SP> Vector;
typedef std::map<document::BucketId, SP> Map;
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp
index f222738cd9a..76fdaded452 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp
@@ -158,13 +158,13 @@ MergeOperation::onStart(DistributorMessageSender& sender)
}
const lib::ClusterState& clusterState(_manager->getDistributorComponent().getClusterState());
- std::vector<vespalib::LinkedPtr<BucketCopy> > newCopies;
+ std::vector<std::unique_ptr<BucketCopy> > newCopies;
std::vector<MergeMetaData> nodes;
for (uint32_t i = 0; i < getNodes().size(); ++i) {
const BucketCopy* copy = entry->getNode(getNodes()[i]);
if (copy == 0) { // New copies?
- newCopies.push_back(vespalib::LinkedPtr<BucketCopy>(
+ newCopies.push_back(std::unique_ptr<BucketCopy>(
new BucketCopy(0, getNodes()[i], api::BucketInfo())));
copy = newCopies.back().get();
}
diff --git a/storage/src/vespa/storage/distributor/persistence_operation_metric_set.cpp b/storage/src/vespa/storage/distributor/persistence_operation_metric_set.cpp
index b7766713b01..8be0450659f 100644
--- a/storage/src/vespa/storage/distributor/persistence_operation_metric_set.cpp
+++ b/storage/src/vespa/storage/distributor/persistence_operation_metric_set.cpp
@@ -41,7 +41,7 @@ PersistenceFailuresMetricSet::PersistenceFailuresMetricSet(MetricSet* owner)
PersistenceFailuresMetricSet::~PersistenceFailuresMetricSet() { }
MetricSet *
-PersistenceFailuresMetricSet::clone(std::vector<Metric::LP>& ownerList, CopyType copyType,
+PersistenceFailuresMetricSet::clone(std::vector<Metric::UP>& ownerList, CopyType copyType,
MetricSet* owner, bool includeUnused) const
{
if (copyType == INACTIVE) {
@@ -61,7 +61,7 @@ PersistenceOperationMetricSet::PersistenceOperationMetricSet(const std::string&
PersistenceOperationMetricSet::~PersistenceOperationMetricSet() { }
MetricSet *
-PersistenceOperationMetricSet::clone(std::vector<Metric::LP>& ownerList, CopyType copyType,
+PersistenceOperationMetricSet::clone(std::vector<Metric::UP>& ownerList, CopyType copyType,
MetricSet* owner, bool includeUnused) const
{
if (copyType == INACTIVE) {
diff --git a/storage/src/vespa/storage/distributor/persistence_operation_metric_set.h b/storage/src/vespa/storage/distributor/persistence_operation_metric_set.h
index 221662a2ba6..b50ca0cb798 100644
--- a/storage/src/vespa/storage/distributor/persistence_operation_metric_set.h
+++ b/storage/src/vespa/storage/distributor/persistence_operation_metric_set.h
@@ -28,7 +28,7 @@ public:
metrics::LongCountMetric inconsistent_bucket;
metrics::LongCountMetric notfound;
- MetricSet * clone(std::vector<Metric::LP>& ownerList, CopyType copyType,
+ MetricSet * clone(std::vector<Metric::UP>& ownerList, CopyType copyType,
metrics::MetricSet* owner, bool includeUnused) const;
};
@@ -42,7 +42,7 @@ public:
PersistenceOperationMetricSet(const std::string& name, metrics::MetricSet* owner = nullptr);
~PersistenceOperationMetricSet();
- MetricSet * clone(std::vector<Metric::LP>& ownerList, CopyType copyType,
+ MetricSet * clone(std::vector<Metric::UP>& ownerList, CopyType copyType,
metrics::MetricSet* owner, bool includeUnused) const override;
/**
diff --git a/storage/src/vespa/storage/distributor/statechecker.cpp b/storage/src/vespa/storage/distributor/statechecker.cpp
index 972397922c2..64a80117fe3 100644
--- a/storage/src/vespa/storage/distributor/statechecker.cpp
+++ b/storage/src/vespa/storage/distributor/statechecker.cpp
@@ -52,7 +52,7 @@ public:
StateChecker::Result
StateChecker::Result::noMaintenanceNeeded()
{
- return Result(vespalib::LinkedPtr<ResultImpl>());
+ return Result(std::unique_ptr<ResultImpl>());
}
StateChecker::Result
@@ -60,7 +60,7 @@ StateChecker::Result::createStoredResult(
IdealStateOperation::UP operation,
MaintenancePriority::Priority priority)
{
- return Result(vespalib::LinkedPtr<ResultImpl>(new StoredResultImpl(std::move(operation), MaintenancePriority(priority))));
+ return Result(std::unique_ptr<ResultImpl>(new StoredResultImpl(std::move(operation), MaintenancePriority(priority))));
}
StateChecker::Context::Context(const DistributorComponent& c,
diff --git a/storage/src/vespa/storage/distributor/statechecker.h b/storage/src/vespa/storage/distributor/statechecker.h
index 48f43cbd00f..9a40b6bbdcd 100644
--- a/storage/src/vespa/storage/distributor/statechecker.h
+++ b/storage/src/vespa/storage/distributor/statechecker.h
@@ -8,7 +8,6 @@
#include <vespa/storage/distributor/bucketgctimecalculator.h>
#include <vespa/storage/distributor/maintenancebucket.h>
#include <vespa/storage/bucketdb/bucketdatabase.h>
-#include <vespa/vespalib/util/linkedptr.h>
#include <unordered_set>
#include <map>
@@ -97,7 +96,7 @@ public:
class Result
{
- vespalib::LinkedPtr<ResultImpl> _impl;
+ std::unique_ptr<ResultImpl> _impl;
public:
IdealStateOperation::UP createOperation() {
return (_impl.get()
@@ -123,8 +122,8 @@ public:
IdealStateOperation::UP operation,
MaintenancePriority::Priority priority);
private:
- Result(const vespalib::LinkedPtr<ResultImpl> impl)
- : _impl(impl)
+ Result(std::unique_ptr<ResultImpl> impl)
+ : _impl(std::move(impl))
{}
};
diff --git a/storage/src/vespa/storage/distributor/visitormetricsset.cpp b/storage/src/vespa/storage/distributor/visitormetricsset.cpp
index fb2bab51d1a..5c81d732c11 100644
--- a/storage/src/vespa/storage/distributor/visitormetricsset.cpp
+++ b/storage/src/vespa/storage/distributor/visitormetricsset.cpp
@@ -25,7 +25,7 @@ VisitorMetricSet::VisitorMetricSet(MetricSet* owner)
VisitorMetricSet::~VisitorMetricSet() { }
MetricSet *
-VisitorMetricSet::clone(std::vector<Metric::LP>& ownerList, CopyType copyType,
+VisitorMetricSet::clone(std::vector<Metric::UP>& ownerList, CopyType copyType,
MetricSet* owner, bool includeUnused) const
{
if (copyType == INACTIVE) {
diff --git a/storage/src/vespa/storage/distributor/visitormetricsset.h b/storage/src/vespa/storage/distributor/visitormetricsset.h
index 34d65b9ec07..04568cfb587 100644
--- a/storage/src/vespa/storage/distributor/visitormetricsset.h
+++ b/storage/src/vespa/storage/distributor/visitormetricsset.h
@@ -15,7 +15,7 @@ struct VisitorMetricSet : public PersistenceOperationMetricSet {
VisitorMetricSet(MetricSet* owner = nullptr);
~VisitorMetricSet();
- MetricSet * clone(std::vector<Metric::LP>& ownerList, CopyType copyType,
+ MetricSet * clone(std::vector<Metric::UP>& ownerList, CopyType copyType,
MetricSet* owner, bool includeUnused) const override;
};
diff --git a/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp b/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp
index d77b62c3c6e..a3c8fc3d671 100644
--- a/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp
+++ b/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp
@@ -228,7 +228,7 @@ FileStorManager::mapOperationToBucketAndDisk(api::BucketCommand& cmd,
cmd.getBucketId().toString().c_str(),
results.begin()->first.toString().c_str());
cmd.remapBucketId(results.begin()->first);
- return results.begin()->second;
+ return std::move(results.begin()->second);
}
std::ostringstream error;
error << "Dropping " << cmd.getType() << " to bucket "
diff --git a/storage/src/vespa/storage/persistence/filestorage/filestormetrics.cpp b/storage/src/vespa/storage/persistence/filestorage/filestormetrics.cpp
index 342240f0be7..519385032d8 100644
--- a/storage/src/vespa/storage/persistence/filestorage/filestormetrics.cpp
+++ b/storage/src/vespa/storage/persistence/filestorage/filestormetrics.cpp
@@ -20,7 +20,7 @@ FileStorThreadMetrics::Op::Op(const std::string& id, const std::string name, Met
FileStorThreadMetrics::Op::~Op() { }
MetricSet *
-FileStorThreadMetrics::Op::clone(std::vector<Metric::LP>& ownerList,
+FileStorThreadMetrics::Op::clone(std::vector<Metric::UP>& ownerList,
CopyType copyType,
MetricSet* owner,
bool includeUnused) const
@@ -40,7 +40,7 @@ FileStorThreadMetrics::OpWithNotFound::OpWithNotFound(const std::string& id, con
FileStorThreadMetrics::OpWithNotFound::~OpWithNotFound() { }
MetricSet *
-FileStorThreadMetrics::OpWithNotFound::clone(std::vector<Metric::LP>& ownerList,
+FileStorThreadMetrics::OpWithNotFound::clone(std::vector<Metric::UP>& ownerList,
CopyType copyType,
MetricSet* owner,
bool includeUnused) const
@@ -61,7 +61,7 @@ FileStorThreadMetrics::Update::Update(MetricSet* owner)
FileStorThreadMetrics::Update::~Update() { }
MetricSet *
-FileStorThreadMetrics::Update::clone(std::vector<Metric::LP>& ownerList,
+FileStorThreadMetrics::Update::clone(std::vector<Metric::UP>& ownerList,
CopyType copyType,
MetricSet* owner,
bool includeUnused) const
@@ -80,7 +80,7 @@ FileStorThreadMetrics::Visitor::Visitor(MetricSet* owner)
FileStorThreadMetrics::Visitor::~Visitor() { }
MetricSet *
-FileStorThreadMetrics::Visitor::clone(std::vector<Metric::LP>& ownerList,
+FileStorThreadMetrics::Visitor::clone(std::vector<Metric::UP>& ownerList,
CopyType copyType,
MetricSet* owner,
bool includeUnused) const
diff --git a/storage/src/vespa/storage/persistence/filestorage/filestormetrics.h b/storage/src/vespa/storage/persistence/filestorage/filestormetrics.h
index 8d4aa670cc6..43310c7a1e8 100644
--- a/storage/src/vespa/storage/persistence/filestorage/filestormetrics.h
+++ b/storage/src/vespa/storage/persistence/filestorage/filestormetrics.h
@@ -28,7 +28,7 @@ struct FileStorThreadMetrics : public metrics::MetricSet
Op(const std::string& id, const std::string name, MetricSet* owner = 0);
~Op();
- MetricSet * clone(std::vector<Metric::LP>& ownerList, CopyType copyType,
+ MetricSet * clone(std::vector<Metric::UP>& ownerList, CopyType copyType,
MetricSet* owner, bool includeUnused) const override;
Op* operator&() { return this; }
};
@@ -37,7 +37,7 @@ struct FileStorThreadMetrics : public metrics::MetricSet
OpWithNotFound(const std::string& id, const std::string name, metrics::MetricSet* owner = 0);
~OpWithNotFound();
- MetricSet* clone(std::vector<Metric::LP>& ownerList, CopyType copyType,
+ MetricSet* clone(std::vector<Metric::UP>& ownerList, CopyType copyType,
MetricSet* owner, bool includeUnused) const override;
OpWithNotFound* operator&() { return this; }
};
@@ -48,7 +48,7 @@ struct FileStorThreadMetrics : public metrics::MetricSet
Update(MetricSet* owner = 0);
~Update();
- MetricSet* clone(std::vector<Metric::LP>& ownerList, CopyType copyType,
+ MetricSet* clone(std::vector<Metric::UP>& ownerList, CopyType copyType,
MetricSet* owner, bool includeUnused) const override;
Update* operator&() { return this; }
};
@@ -59,7 +59,7 @@ struct FileStorThreadMetrics : public metrics::MetricSet
Visitor(MetricSet* owner = 0);
~Visitor();
- MetricSet * clone(std::vector<Metric::LP>& ownerList, CopyType copyType,
+ MetricSet * clone(std::vector<Metric::UP>& ownerList, CopyType copyType,
MetricSet* owner, bool includeUnused) const override;
Visitor* operator&() { return this; }
};
diff --git a/storage/src/vespa/storage/persistence/mergehandler.cpp b/storage/src/vespa/storage/persistence/mergehandler.cpp
index b0e40789f86..9775e53fac7 100644
--- a/storage/src/vespa/storage/persistence/mergehandler.cpp
+++ b/storage/src/vespa/storage/persistence/mergehandler.cpp
@@ -126,13 +126,13 @@ public:
struct IndirectDocEntryTimestampPredicate
{
- bool operator()(const spi::DocEntry::LP& e1,
- const spi::DocEntry::LP& e2) const
+ bool operator()(const spi::DocEntry::UP& e1,
+ const spi::DocEntry::UP& e2) const
{
return e1->getTimestamp() < e2->getTimestamp();
}
- bool operator()(const spi::DocEntry::LP& e,
+ bool operator()(const spi::DocEntry::UP& e,
const spi::Timestamp timestamp) const
{
return e->getTimestamp() < timestamp;
@@ -154,7 +154,7 @@ void
MergeHandler::populateMetaData(
const spi::Bucket& bucket,
Timestamp maxTimestamp,
- std::vector<spi::DocEntry::LP>& entries,
+ std::vector<spi::DocEntry::UP>& entries,
spi::Context& context)
{
spi::DocumentSelection docSel("");
@@ -190,9 +190,8 @@ MergeHandler::populateMetaData(
<< result.getErrorMessage();
throw std::runtime_error(ss.str());
}
- for (size_t i = 0; i < result.getEntries().size(); ++i) {
- entries.push_back(result.getEntries()[i]);
- }
+ auto list = result.steal_entries();
+ std::move(list.begin(), list.end(), std::back_inserter(entries));
if (result.isCompleted()) {
break;
}
@@ -266,7 +265,7 @@ MergeHandler::buildBucketInfoList(
}
}
- std::vector<spi::DocEntry::LP> entries;
+ std::vector<spi::DocEntry::UP> entries;
populateMetaData(bucket, maxTimestamp, entries, context);
for (size_t i = 0; i < entries.size(); ++i) {
@@ -444,7 +443,7 @@ MergeHandler::fetchLocalData(
IteratorGuard iteratorGuard(_spi, iteratorId, context);
// Fetch all entries
- std::vector<spi::DocEntry::LP> entries;
+ std::vector<spi::DocEntry::UP> entries;
entries.reserve(slots.size());
bool fetchedAllLocalData = false;
bool chunkLimitReached = false;
@@ -459,19 +458,20 @@ MergeHandler::fetchLocalData(
<< result.getErrorMessage();
throw std::runtime_error(ss.str());
}
- for (size_t i = 0; i < result.getEntries().size(); ++i) {
- if (result.getEntries()[i]->getSize() <= remainingSize
+ auto list = result.steal_entries();
+ for (size_t i = 0; i < list.size(); ++i) {
+ if (list[i]->getSize() <= remainingSize
|| (entries.empty() && alreadyFilled == 0))
{
- entries.push_back(result.getEntries()[i]);
- remainingSize -= result.getEntries()[i]->getSize();
+ remainingSize -= list[i]->getSize();
LOG(spam, "Added %s, remainingSize is %u",
entries.back()->toString().c_str(),
remainingSize);
+ entries.push_back(std::move(list[i]));
} else {
LOG(spam, "Adding %s would exceed chunk size limit of %u; "
"not filling up any more diffs for current round",
- result.getEntries()[i]->toString().c_str(), _maxChunkSize);
+ list[i]->toString().c_str(), _maxChunkSize);
chunkLimitReached = true;
break;
}
@@ -610,7 +610,7 @@ MergeHandler::applyDiffLocally(
uint32_t addedCount = 0;
uint32_t notNeededByteCount = 0;
- std::vector<spi::DocEntry::LP> entries;
+ std::vector<spi::DocEntry::UP> entries;
populateMetaData(bucket, MAX_TIMESTAMP, entries, context);
FlushGuard flushGuard(_spi, bucket, context);
diff --git a/storage/src/vespa/storage/persistence/mergehandler.h b/storage/src/vespa/storage/persistence/mergehandler.h
index f23dbe0c9b7..812f9d83907 100644
--- a/storage/src/vespa/storage/persistence/mergehandler.h
+++ b/storage/src/vespa/storage/persistence/mergehandler.h
@@ -91,7 +91,7 @@ private:
*/
void populateMetaData(const spi::Bucket&,
Timestamp maxTimestamp,
- std::vector<spi::DocEntry::LP>& entries,
+ std::vector<spi::DocEntry::UP>& entries,
spi::Context& context);
Document::UP deserializeDiffDocument(
diff --git a/storage/src/vespa/storage/persistence/messages.h b/storage/src/vespa/storage/persistence/messages.h
index 75655198fca..aad2d1bedce 100644
--- a/storage/src/vespa/storage/persistence/messages.h
+++ b/storage/src/vespa/storage/persistence/messages.h
@@ -53,7 +53,7 @@ class GetIterReply : public api::InternalReply {
private:
framework::MemoryToken::UP _token;
document::BucketId _bucketId;
- std::vector<spi::DocEntry::LP> _entries;
+ std::vector<spi::DocEntry::UP> _entries;
bool _completed;
public:
@@ -69,11 +69,11 @@ public:
return _bucketId;
}
- const std::vector<spi::DocEntry::LP>& getEntries() const {
+ const std::vector<spi::DocEntry::UP>& getEntries() const {
return _entries;
}
- std::vector<spi::DocEntry::LP>& getEntries() {
+ std::vector<spi::DocEntry::UP>& getEntries() {
return _entries;
}
diff --git a/storage/src/vespa/storage/persistence/persistencethread.cpp b/storage/src/vespa/storage/persistence/persistencethread.cpp
index f0ff2bafdb2..b2848ed3712 100644
--- a/storage/src/vespa/storage/persistence/persistencethread.cpp
+++ b/storage/src/vespa/storage/persistence/persistencethread.cpp
@@ -443,7 +443,7 @@ PersistenceThread::handleGetIter(GetIterCommand& cmd)
cmd.getMaxByteSize(), _context));
if (checkForError(result, *tracker)) {
GetIterReply::SP reply(new GetIterReply(cmd));
- reply->getEntries() = result.getEntries();
+ reply->getEntries() = result.steal_entries();
_env._metrics.visit[cmd.getLoadType()].
documentsPerIterate.addValue(reply->getEntries().size());
if (result.isCompleted()) {
@@ -1120,7 +1120,7 @@ bool hasBucketInfo(const api::StorageMessage& msg)
void
PersistenceThread::flushAllReplies(
const document::BucketId& bucketId,
- std::vector<vespalib::LinkedPtr<MessageTracker> >& replies)
+ std::vector<std::unique_ptr<MessageTracker> >& replies)
{
if (replies.empty()) {
return;
@@ -1184,7 +1184,7 @@ PersistenceThread::flushAllReplies(
void PersistenceThread::processMessages(FileStorHandler::LockedMessage & lock)
{
- std::vector<MessageTracker::LP> trackers;
+ std::vector<MessageTracker::UP> trackers;
document::BucketId bucketId = lock.first->getBucketId();
while (lock.second.get() != 0) {
@@ -1215,7 +1215,7 @@ void PersistenceThread::processMessages(FileStorHandler::LockedMessage & lock)
tracker->getReply()->toString().c_str(),
bucketId.toString().c_str());
- trackers.push_back(MessageTracker::LP(tracker.release()));
+ trackers.push_back(MessageTracker::UP(tracker.release()));
if (trackers.back()->getReply()->getResult().success()) {
_env._fileStorHandler.getNextMessage(
diff --git a/storage/src/vespa/storage/persistence/persistencethread.h b/storage/src/vespa/storage/persistence/persistencethread.h
index 032bc586342..89658b5041e 100644
--- a/storage/src/vespa/storage/persistence/persistencethread.h
+++ b/storage/src/vespa/storage/persistence/persistencethread.h
@@ -106,7 +106,7 @@ private:
spi::Bucket getBucket(const DocumentId& id, const BucketId& bucket) const;
void flushAllReplies(const document::BucketId& bucketId,
- std::vector<MessageTracker::LP>& trackers);
+ std::vector<MessageTracker::UP>& trackers);
friend class TestAndSetHelper;
bool tasConditionExists(const api::TestAndSetCommand & cmd);
diff --git a/storage/src/vespa/storage/persistence/persistenceutil.h b/storage/src/vespa/storage/persistence/persistenceutil.h
index ed4812b3505..c917d4d0149 100644
--- a/storage/src/vespa/storage/persistence/persistenceutil.h
+++ b/storage/src/vespa/storage/persistence/persistenceutil.h
@@ -17,7 +17,6 @@ namespace storage {
class MessageTracker : protected Types {
public:
- typedef vespalib::LinkedPtr<MessageTracker> LP;
typedef std::unique_ptr<MessageTracker> UP;
MessageTracker(FileStorThreadMetrics::Op& metric,
diff --git a/storage/src/vespa/storage/persistence/types.h b/storage/src/vespa/storage/persistence/types.h
index 747b9fbd074..de31145f27b 100644
--- a/storage/src/vespa/storage/persistence/types.h
+++ b/storage/src/vespa/storage/persistence/types.h
@@ -17,7 +17,6 @@ namespace storage {
struct Types {
typedef document::BucketId BucketId;
typedef document::Document Document;
- typedef vespalib::LinkedPtr<Document> DocLP;
typedef document::DocumentId DocumentId;
typedef document::GlobalId GlobalId;
typedef framework::MicroSecTime Timestamp;
diff --git a/storage/src/vespa/storage/visiting/countvisitor.cpp b/storage/src/vespa/storage/visiting/countvisitor.cpp
index 4c1a082893c..c3dd7cc4995 100644
--- a/storage/src/vespa/storage/visiting/countvisitor.cpp
+++ b/storage/src/vespa/storage/visiting/countvisitor.cpp
@@ -23,7 +23,7 @@ CountVisitor::CountVisitor(StorageComponent& component,
void
CountVisitor::handleDocuments(const document::BucketId& /*bucketId*/,
- std::vector<spi::DocEntry::LP>& entries,
+ std::vector<spi::DocEntry::UP>& entries,
HitCounter& hitCounter)
{
for (size_t i = 0; i < entries.size(); ++i) {
diff --git a/storage/src/vespa/storage/visiting/countvisitor.h b/storage/src/vespa/storage/visiting/countvisitor.h
index c2b85c35419..75e0e866553 100644
--- a/storage/src/vespa/storage/visiting/countvisitor.h
+++ b/storage/src/vespa/storage/visiting/countvisitor.h
@@ -22,7 +22,7 @@ public:
private:
void handleDocuments(const document::BucketId& bucketId,
- std::vector<spi::DocEntry::LP>& entries,
+ std::vector<spi::DocEntry::UP>& entries,
HitCounter& hitCounter);
bool _doScheme;
diff --git a/storage/src/vespa/storage/visiting/dumpvisitor.cpp b/storage/src/vespa/storage/visiting/dumpvisitor.cpp
index 271217fb7e7..388f9dc5e19 100644
--- a/storage/src/vespa/storage/visiting/dumpvisitor.cpp
+++ b/storage/src/vespa/storage/visiting/dumpvisitor.cpp
@@ -69,7 +69,7 @@ DumpVisitor::createMultiOperation(const document::BucketId& bucketId,
}
void DumpVisitor::handleDocuments(const document::BucketId& bucketId,
- std::vector<spi::DocEntry::LP>& entries,
+ std::vector<spi::DocEntry::UP>& entries,
HitCounter& hitCounter)
{
LOG(debug, "Visitor %s handling block of %zu documents.",
diff --git a/storage/src/vespa/storage/visiting/dumpvisitor.h b/storage/src/vespa/storage/visiting/dumpvisitor.h
index c4572766a3e..0aa690ce3c0 100644
--- a/storage/src/vespa/storage/visiting/dumpvisitor.h
+++ b/storage/src/vespa/storage/visiting/dumpvisitor.h
@@ -26,7 +26,7 @@ private:
const std::vector<const document::Document*>& docs);
void handleDocuments(const document::BucketId& bucketId,
- std::vector<spi::DocEntry::LP>& entries,
+ std::vector<spi::DocEntry::UP>& entries,
HitCounter& hitCounter);
std::unique_ptr<std::set<std::string> > _requestedFields;
diff --git a/storage/src/vespa/storage/visiting/dumpvisitorsingle.cpp b/storage/src/vespa/storage/visiting/dumpvisitorsingle.cpp
index a7712ee189f..a36ace1d427 100644
--- a/storage/src/vespa/storage/visiting/dumpvisitorsingle.cpp
+++ b/storage/src/vespa/storage/visiting/dumpvisitorsingle.cpp
@@ -20,7 +20,7 @@ DumpVisitorSingle::DumpVisitorSingle(StorageComponent& component,
}
void DumpVisitorSingle::handleDocuments(const document::BucketId& /*bucketId*/,
- std::vector<spi::DocEntry::LP>& entries,
+ std::vector<spi::DocEntry::UP>& entries,
HitCounter& hitCounter)
{
LOG(debug, "Visitor %s handling block of %zu documents.",
diff --git a/storage/src/vespa/storage/visiting/dumpvisitorsingle.h b/storage/src/vespa/storage/visiting/dumpvisitorsingle.h
index f7b3fe66b88..eab10ad2653 100644
--- a/storage/src/vespa/storage/visiting/dumpvisitorsingle.h
+++ b/storage/src/vespa/storage/visiting/dumpvisitorsingle.h
@@ -20,7 +20,7 @@ public:
private:
void handleDocuments(const document::BucketId&,
- std::vector<spi::DocEntry::LP>&,
+ std::vector<spi::DocEntry::UP>&,
HitCounter&);
};
diff --git a/storage/src/vespa/storage/visiting/recoveryvisitor.cpp b/storage/src/vespa/storage/visiting/recoveryvisitor.cpp
index b6fcc0a97c8..9ae18d7b05d 100644
--- a/storage/src/vespa/storage/visiting/recoveryvisitor.cpp
+++ b/storage/src/vespa/storage/visiting/recoveryvisitor.cpp
@@ -30,7 +30,7 @@ RecoveryVisitor::RecoveryVisitor(StorageComponent& component,
void
RecoveryVisitor::handleDocuments(const document::BucketId& bid,
- std::vector<spi::DocEntry::LP>& entries,
+ std::vector<spi::DocEntry::UP>& entries,
HitCounter& hitCounter)
{
vespalib::LockGuard guard(_mutex);
@@ -46,7 +46,7 @@ RecoveryVisitor::handleDocuments(const document::BucketId& bid,
if (iter == _activeCommands.end()) {
CommandPtr ptr(new documentapi::DocumentListMessage(bid));
cmd = ptr.get();
- _activeCommands[bid] = ptr;
+ _activeCommands[bid] = std::move(ptr);
} else {
cmd = iter->second.get();
}
diff --git a/storage/src/vespa/storage/visiting/recoveryvisitor.h b/storage/src/vespa/storage/visiting/recoveryvisitor.h
index b2771c2c64c..b8c64e7d0fd 100644
--- a/storage/src/vespa/storage/visiting/recoveryvisitor.h
+++ b/storage/src/vespa/storage/visiting/recoveryvisitor.h
@@ -25,15 +25,15 @@ public:
private:
void handleDocuments(const document::BucketId& bucketId,
- std::vector<spi::DocEntry::LP>& entries,
+ std::vector<spi::DocEntry::UP>& entries,
HitCounter& hitCounter);
void completedBucket(const document::BucketId&, HitCounter&);
std::set<std::string> _requestedFields;
- typedef vespalib::LinkedPtr<documentapi::DocumentListMessage> CommandPtr;
- typedef std::map<document::BucketId, CommandPtr> CommandMap;
+ using CommandPtr = std::unique_ptr<documentapi::DocumentListMessage>;
+ using CommandMap = std::map<document::BucketId, CommandPtr>;
CommandMap _activeCommands;
vespalib::Lock _mutex;
diff --git a/storage/src/vespa/storage/visiting/testvisitor.cpp b/storage/src/vespa/storage/visiting/testvisitor.cpp
index 5b02ac1271a..07b97b505c1 100644
--- a/storage/src/vespa/storage/visiting/testvisitor.cpp
+++ b/storage/src/vespa/storage/visiting/testvisitor.cpp
@@ -44,7 +44,7 @@ TestVisitor::startingVisitor(const std::vector<document::BucketId>& buckets)
void
TestVisitor::handleDocuments(const document::BucketId& /*bucketId*/,
- std::vector<spi::DocEntry::LP>& entries,
+ std::vector<spi::DocEntry::UP>& entries,
HitCounter& /*hitCounter*/)
{
std::ostringstream ost;
diff --git a/storage/src/vespa/storage/visiting/testvisitor.h b/storage/src/vespa/storage/visiting/testvisitor.h
index 5b32ec62906..9d4bb498ae0 100644
--- a/storage/src/vespa/storage/visiting/testvisitor.h
+++ b/storage/src/vespa/storage/visiting/testvisitor.h
@@ -20,7 +20,7 @@ private:
void startingVisitor(const std::vector<document::BucketId>& buckets);
void handleDocuments(const document::BucketId& bucketId,
- std::vector<spi::DocEntry::LP>& entries,
+ std::vector<spi::DocEntry::UP>& entries,
HitCounter& hitCounter);
void completedBucket(const document::BucketId& bucket, HitCounter& hitCounter);
diff --git a/storage/src/vespa/storage/visiting/visitor.h b/storage/src/vespa/storage/visiting/visitor.h
index 87b894a6d2c..a392374ed5d 100644
--- a/storage/src/vespa/storage/visiting/visitor.h
+++ b/storage/src/vespa/storage/visiting/visitor.h
@@ -404,7 +404,7 @@ public:
* vector of documents arrive from the persistence layer.
*/
virtual void handleDocuments(const document::BucketId&,
- std::vector<spi::DocEntry::LP>& entries,
+ std::vector<spi::DocEntry::UP>& entries,
HitCounter& hitCounter) = 0;
/**
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<Operation>(new PutOperation(document, ts)));
+ _operations.push_back(std::unique_ptr<Operation>(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<Operation>(new HeaderUpdateOperation(document, ts, timestampToUpdate)));
+ _operations.push_back(std::unique_ptr<Operation>(new HeaderUpdateOperation(document, ts, timestampToUpdate)));
_approxSize += document->serialize()->getLength();
}
void
BatchPutRemoveCommand::addRemove(const document::DocumentId& docId, uint64_t ts)
{
- _operations.push_back(vespalib::LinkedPtr<Operation>(new RemoveOperation(docId, ts)));
+ _operations.push_back(std::unique_ptr<Operation>(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<vespalib::LinkedPtr<Operation> > _operations;
+ std::vector<std::unique_ptr<Operation> > _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<MemoryToken> MemoryTokenPtr;
- std::vector<MemoryTokenPtr> _tokens;
+ using MemoryTokenUP = std::unique_ptr<MemoryToken>;
+ std::vector<MemoryTokenUP> _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<ManagedComponent*> _components;
metrics::MetricSet _topMetricSet;
- std::vector<vespalib::LinkedPtr<metrics::UpdateHook>> _hooks;
+ std::vector<std::unique_ptr<metrics::UpdateHook>> _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<std::string, MemoryAllocationType::LP>::const_iterator it(
+ std::map<std::string, MemoryAllocationType::UP>::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<const MemoryAllocationType*> types;
- for(std::map<std::string, MemoryAllocationType::LP>::const_iterator it
+ for(std::map<std::string, MemoryAllocationType::UP>::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<std::string, MemoryAllocationType::LP> _types;
+ std::map<std::string, MemoryAllocationType::UP> _types;
public:
typedef std::unique_ptr<MemoryManager> 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<std::string, MemoryAllocationType::LP>::const_iterator it(
+ std::map<std::string, MemoryAllocationType::UP>::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<const MemoryAllocationType*> types;
- for(std::map<std::string, MemoryAllocationType::LP>::const_iterator it
+ for(std::map<std::string, MemoryAllocationType::UP>::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<std::string, MemoryAllocationType::LP> _types;
+ std::map<std::string, MemoryAllocationType::UP> _types;
public:
typedef std::unique_ptr<NoMemoryManager> 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 <string>
-#include <vespa/vespalib/util/linkedptr.h>
+#include <memory>
namespace storage {
namespace framework {
struct MemoryAllocationType {
- typedef vespalib::LinkedPtr<MemoryAllocationType> LP;
+ using UP = std::unique_ptr<MemoryAllocationType>;
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<TickingLockGuard::Impl>(
+ return TickingLockGuard(std::unique_ptr<TickingLockGuard::Impl>(
new FreezeGuard(*this)));
}
virtual TickingLockGuard freezeCriticalTicks() {
- return TickingLockGuard(vespalib::LinkedPtr<TickingLockGuard::Impl>(
+ return TickingLockGuard(std::unique_ptr<TickingLockGuard::Impl>(
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 <memory>
#include <vespa/storageframework/generic/clock/time.h>
#include <vespa/vespalib/stllike/string.h>
-#include <vespa/vespalib/util/linkedptr.h>
#include <vespa/vespalib/util/sync.h>
namespace storage {
@@ -63,10 +62,10 @@ struct TickingLockGuard {
virtual ~Impl() {}
virtual void broadcast() = 0;
};
- TickingLockGuard(vespalib::LinkedPtr<Impl> impl) : _impl(impl) {}
+ TickingLockGuard(std::unique_ptr<Impl> impl) : _impl(std::move(impl)) {}
void broadcast() { _impl->broadcast(); }
private:
- vespalib::LinkedPtr<Impl> _impl;
+ std::unique_ptr<Impl> _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<spi::DocEntry::LP>
+std::vector<spi::DocEntry::UP>
createDocuments(const vespalib::string & dir)
{
(void) dir;
- std::vector<spi::DocEntry::LP> documents;
+ std::vector<spi::DocEntry::UP> 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<Visitor> sv(static_cast<SearchVisitor *>(factory.makeVisitor(*_component, _env, params)));
document::OrderingSpecification orderSpec;
document::BucketId bucketId;
- std::vector<spi::DocEntry::LP> documents(createDocuments(dir));
+ std::vector<spi::DocEntry::UP> 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> _rankManager;
};
typedef vespalib::hash_map<vespalib::string, Env::SP> EnvMap;
- typedef vespalib::LinkedPtr<EnvMap> EnvMapLP;
- typedef std::vector< vespalib::LinkedPtr<EnvMap> > ThreadLocals;
+ typedef std::unique_ptr<EnvMap> EnvMapUP;
+ typedef std::vector<EnvMapUP> 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<spi::DocEntry::LP>& entries,
+ std::vector<spi::DocEntry::UP>& 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<spi::DocEntry::LP>& entries,
+ std::vector<spi::DocEntry::UP>& entries,
HitCounter& hitCounter) override;
bool compatibleDocumentTypes(const document::DocumentType& typeA,