summaryrefslogtreecommitdiffstats
path: root/vsm
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-02-05 23:32:00 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-02-06 00:26:08 +0000
commit4c5a7cac411b30b9b4bd3ca067efcc9f3719b0ea (patch)
tree2e09c62b854357bbb1c8d433898d004e3f3995a5 /vsm
parentb84ef936b1cedce0b99f79e03b2fe25a8db5f7c3 (diff)
Reduce code visibility and include only what you need from config library.
Diffstat (limited to 'vsm')
-rw-r--r--vsm/src/vespa/vsm/vsm/vsm-adapter.cpp20
-rw-r--r--vsm/src/vespa/vsm/vsm/vsm-adapter.h15
-rw-r--r--vsm/src/vespa/vsm/vsm/vsm-adapter.hpp18
3 files changed, 36 insertions, 17 deletions
diff --git a/vsm/src/vespa/vsm/vsm/vsm-adapter.cpp b/vsm/src/vespa/vsm/vsm/vsm-adapter.cpp
index 784b5ea38ba..09594832c4a 100644
--- a/vsm/src/vespa/vsm/vsm/vsm-adapter.cpp
+++ b/vsm/src/vespa/vsm/vsm/vsm-adapter.cpp
@@ -1,6 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include "vsm-adapter.h"
+#include "vsm-adapter.hpp"
#include "docsumconfig.h"
#include "i_matching_elements_filler.h"
#include <vespa/searchlib/common/matching_elements.h>
@@ -24,7 +24,7 @@ GetDocsumsStateCallback::GetDocsumsStateCallback() :
void GetDocsumsStateCallback::FillSummaryFeatures(GetDocsumsState * state, IDocsumEnvironment * env)
{
(void) env;
- if (_summaryFeatures.get() != NULL) { // set the summary features to write to the docsum
+ if (_summaryFeatures) { // set the summary features to write to the docsum
state->_summaryFeatures = _summaryFeatures;
state->_summaryFeaturesCached = true;
}
@@ -33,7 +33,7 @@ void GetDocsumsStateCallback::FillSummaryFeatures(GetDocsumsState * state, IDocs
void GetDocsumsStateCallback::FillRankFeatures(GetDocsumsState * state, IDocsumEnvironment * env)
{
(void) env;
- if (_rankFeatures.get() != NULL) { // set the rank features to write to the docsum
+ if (_rankFeatures) { // set the rank features to write to the docsum
state->_rankFeatures = _rankFeatures;
}
}
@@ -119,10 +119,10 @@ VSMAdapter::configure(const VSMConfigSnapshot & snapshot)
std::lock_guard guard(_lock);
LOG(debug, "(re-)configure VSM (docsum tools)");
- std::shared_ptr<SummaryConfig> summary(snapshot.getConfig<SummaryConfig>().release());
- std::shared_ptr<SummarymapConfig> summaryMap(snapshot.getConfig<SummarymapConfig>().release());
- std::shared_ptr<VsmsummaryConfig> vsmSummary(snapshot.getConfig<VsmsummaryConfig>().release());
- std::shared_ptr<JuniperrcConfig> juniperrc(snapshot.getConfig<JuniperrcConfig>().release());
+ std::shared_ptr<SummaryConfig> summary(snapshot.getConfig<SummaryConfig>());
+ std::shared_ptr<SummarymapConfig> summaryMap(snapshot.getConfig<SummarymapConfig>());
+ std::shared_ptr<VsmsummaryConfig> vsmSummary(snapshot.getConfig<VsmsummaryConfig>());
+ std::shared_ptr<JuniperrcConfig> juniperrc(snapshot.getConfig<JuniperrcConfig>());
_fieldsCfg.set(snapshot.getConfig<VsmfieldsConfig>().release());
_fieldsCfg.latch();
@@ -175,6 +175,12 @@ VSMAdapter::configure(const VSMConfigSnapshot & snapshot)
}
}
+VSMConfigSnapshot::VSMConfigSnapshot(const vespalib::string & configId, const config::ConfigSnapshot & snapshot)
+ : _configId(configId),
+ _snapshot(std::make_unique<config::ConfigSnapshot>(snapshot))
+{ }
+VSMConfigSnapshot::~VSMConfigSnapshot() = default;
+
VSMAdapter::VSMAdapter(const vespalib::string & highlightindexes, const vespalib::string & configId, Fast_WordFolder & wordFolder)
: _highlightindexes(highlightindexes),
_configId(configId),
diff --git a/vsm/src/vespa/vsm/vsm/vsm-adapter.h b/vsm/src/vespa/vsm/vsm/vsm-adapter.h
index dacf01aec08..f13befa14a1 100644
--- a/vsm/src/vespa/vsm/vsm/vsm-adapter.h
+++ b/vsm/src/vespa/vsm/vsm/vsm-adapter.h
@@ -3,7 +3,6 @@
#pragma once
#include <vespa/searchlib/query/base.h>
-#include <vespa/config/retriever/configsnapshot.h>
#include <vespa/vsm/config/vsm-cfif.h>
#include <vespa/config-summary.h>
#include <vespa/config-summarymap.h>
@@ -25,6 +24,7 @@ using vespa::config::search::SummaryConfig;
using vespa::config::search::SummarymapConfig;
using vespa::config::search::summary::JuniperrcConfig;
+namespace config { class ConfigSnapshot; }
namespace vsm {
class IMatchingElementsFiller;
@@ -97,17 +97,12 @@ typedef std::shared_ptr<DocsumTools> DocsumToolsPtr;
class VSMConfigSnapshot {
private:
const vespalib::string _configId;
- const config::ConfigSnapshot _snapshot;
+ std::unique_ptr<config::ConfigSnapshot> _snapshot;
public:
- VSMConfigSnapshot(const vespalib::string & configId, const config::ConfigSnapshot & snapshot)
- : _configId(configId),
- _snapshot(snapshot)
- { }
+ VSMConfigSnapshot(const vespalib::string & configId, const config::ConfigSnapshot & snapshot);
+ ~VSMConfigSnapshot();
template <typename ConfigType>
- std::unique_ptr<ConfigType> getConfig() const
- {
- return _snapshot.getConfig<ConfigType>(_configId);
- }
+ std::unique_ptr<ConfigType> getConfig() const;
};
class VSMAdapter
diff --git a/vsm/src/vespa/vsm/vsm/vsm-adapter.hpp b/vsm/src/vespa/vsm/vsm/vsm-adapter.hpp
new file mode 100644
index 00000000000..f071dbb2015
--- /dev/null
+++ b/vsm/src/vespa/vsm/vsm/vsm-adapter.hpp
@@ -0,0 +1,18 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include "vsm-adapter.h"
+#include <vespa/config/retriever/configsnapshot.hpp>
+
+namespace vsm {
+
+template <typename ConfigType>
+std::unique_ptr<ConfigType>
+VSMConfigSnapshot::getConfig() const
+{
+ return _snapshot->getConfig<ConfigType>(_configId);
+}
+
+} // namespace vsm
+