summaryrefslogtreecommitdiffstats
path: root/streamingvisitors
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-12-13 23:02:15 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2017-12-13 23:02:15 +0100
commit92aa7222852ac9dba38246faec0be6ec80425d2c (patch)
tree51b13698fc5ca7b5321ac9112f11e10cba5bc5fd /streamingvisitors
parent99e5cde1894e5fdc5a0dd75c7ca7013c473d3c7f (diff)
Exception to construction should not create an empty entry in the map.
Diffstat (limited to 'streamingvisitors')
-rw-r--r--streamingvisitors/src/vespa/searchvisitor/searchenvironment.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/streamingvisitors/src/vespa/searchvisitor/searchenvironment.cpp b/streamingvisitors/src/vespa/searchvisitor/searchenvironment.cpp
index 64c2c9a6429..7ebb71f1855 100644
--- a/streamingvisitors/src/vespa/searchvisitor/searchenvironment.cpp
+++ b/streamingvisitors/src/vespa/searchvisitor/searchenvironment.cpp
@@ -15,9 +15,7 @@ __thread SearchEnvironment::EnvMap * SearchEnvironment::_localEnvMap=0;
SearchEnvironment::Env::Env(const vespalib::string & muffens, const config::ConfigUri & configUri, Fast_NormalizeWordFolder & wf) :
_configId(configUri.getConfigId()),
- _configurer(config::SimpleConfigRetriever::UP(
- new config::SimpleConfigRetriever(createKeySet(configUri.getConfigId()), configUri.getContext())),
- this),
+ _configurer(std::make_unique<config::SimpleConfigRetriever>(createKeySet(configUri.getConfigId()), configUri.getContext()), this),
_vsmAdapter(new VSMAdapter(muffens, _configId, wf)),
_rankManager(new RankManager(_vsmAdapter.get()))
{
@@ -63,13 +61,15 @@ SearchEnvironment::~SearchEnvironment()
_threadLocals.clear();
}
-SearchEnvironment::Env & SearchEnvironment::getEnv(const vespalib::string & searchCluster)
+SearchEnvironment::Env &
+SearchEnvironment::getEnv(const vespalib::string & searchCluster)
{
config::ConfigUri searchClusterUri(_configUri.createWithNewId(searchCluster));
if (_localEnvMap == NULL) {
- _localEnvMap = new EnvMap;
+ EnvMapUP envMap = std::make_unique<EnvMap>();
+ _localEnvMap = envMap.get();
vespalib::LockGuard guard(_lock);
- _threadLocals.push_back(EnvMapUP(_localEnvMap));
+ _threadLocals.emplace_back(std::move(envMap));
}
EnvMap::iterator localFound = _localEnvMap->find(searchCluster);
if (localFound == _localEnvMap->end()) {
@@ -77,7 +77,8 @@ SearchEnvironment::Env & SearchEnvironment::getEnv(const vespalib::string & sear
EnvMap::iterator found = _envMap.find(searchCluster);
if (found == _envMap.end()) {
LOG(debug, "Init VSMAdapter with config id = '%s'", searchCluster.c_str());
- _envMap[searchCluster].reset(new Env("*", searchClusterUri, _wordFolder));
+ Env::SP env = std::make_shared<Env>("*", searchClusterUri, _wordFolder);
+ _envMap[searchCluster] = std::move(env);
found = _envMap.find(searchCluster);
}
_localEnvMap->insert(*found);