summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-05-26 15:22:28 +0200
committerGitHub <noreply@github.com>2022-05-26 15:22:28 +0200
commitfd13f73b5ef66dcc81f60a6319be4f01b5e1d68e (patch)
treea2b2cac4a6587186052d47a588539603be96099f
parent5d74f1d1a1d7a524b0826196b2182f8e70d48976 (diff)
parente91c60422644b0ceaed798ae0838a1df60df5897 (diff)
Merge pull request #22766 from vespa-engine/balder/use-up-for-config
Use unique_ptr for Config in AttributeVector
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.h1
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec_factory.h13
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attribute_config_inspector.cpp8
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attribute_config_inspector.h7
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp1
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_initializer.cpp6
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp11
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h8
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp7
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp1
-rw-r--r--searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h5
-rw-r--r--searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp7
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attribute_operation.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attributevector.cpp19
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attributevector.h24
-rw-r--r--searchlib/src/vespa/searchlib/attribute/floatbase.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/integerbase.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlenumericattribute.h8
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlenumericattribute.hpp14
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp6
-rw-r--r--searchlib/src/vespa/searchlib/tensor/tensor_attribute.h4
26 files changed, 102 insertions, 64 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.h
index 607be32e952..1357d56c472 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.h
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.h
@@ -4,7 +4,6 @@
#include "attribute_spec.h"
#include <vespa/searchlib/common/serialnum.h>
-#include <memory>
#include <vector>
namespace proton {
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec_factory.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec_factory.h
index 3565b533e02..8ef06f20bac 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec_factory.h
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec_factory.h
@@ -3,10 +3,10 @@
#pragma once
#include "attribute_collection_spec.h"
-#include <vespa/searchcommon/attribute/config.h>
#include <vespa/searchcore/proton/common/alloc_strategy.h>
#include <vespa/searchlib/common/serialnum.h>
-#include <vespa/config-attributes.h>
+
+namespace vespa::config::search::internal { class InternalAttributesType; };
namespace proton {
@@ -17,19 +17,16 @@ namespace proton {
class AttributeCollectionSpecFactory
{
private:
- typedef vespa::config::search::AttributesConfig AttributesConfig;
+ using AttributesConfig = const vespa::config::search::internal::InternalAttributesType;
const AllocStrategy _alloc_strategy;
const bool _fastAccessOnly;
public:
- AttributeCollectionSpecFactory(const AllocStrategy& alloc_strategy,
- bool fastAccessOnly);
+ AttributeCollectionSpecFactory(const AllocStrategy& alloc_strategy, bool fastAccessOnly);
~AttributeCollectionSpecFactory();
- AttributeCollectionSpec::UP create(const AttributesConfig &attrCfg,
- uint32_t docIdLimit,
- search::SerialNum serialNum) const;
+ std::unique_ptr<AttributeCollectionSpec> create(const AttributesConfig &attrCfg, uint32_t docIdLimit, search::SerialNum serialNum) const;
};
} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_config_inspector.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_config_inspector.cpp
index f4692013cdf..444b8973a9c 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_config_inspector.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_config_inspector.cpp
@@ -2,10 +2,12 @@
#include "attribute_config_inspector.h"
#include <vespa/searchlib/attribute/configconverter.h>
+#include <vespa/searchcommon/attribute/config.h>
#include <vespa/config-attributes.h>
#include <vespa/vespalib/stllike/hash_map.hpp>
using search::attribute::ConfigConverter;
+using search::attribute::Config;
namespace proton {
@@ -13,18 +15,18 @@ AttributeConfigInspector::AttributeConfigInspector(const AttributesConfig& confi
: _hash()
{
for (auto& attr : config.attribute) {
- auto res = _hash.insert(std::make_pair(attr.name, ConfigConverter::convert(attr)));
+ auto res = _hash.insert(std::make_pair(attr.name, std::make_unique<Config>(ConfigConverter::convert(attr))));
assert(res.second);
}
}
AttributeConfigInspector::~AttributeConfigInspector() = default;
-const search::attribute::Config*
+const Config*
AttributeConfigInspector::get_config(const vespalib::string& name) const
{
auto itr = _hash.find(name);
- return (itr != _hash.end()) ? &itr->second : nullptr;
+ return (itr != _hash.end()) ? itr->second.get() : nullptr;
}
}
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_config_inspector.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_config_inspector.h
index 42c920fcc5f..23c0fb3b685 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_config_inspector.h
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_config_inspector.h
@@ -4,9 +4,9 @@
#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/stllike/hash_map.h>
-#include <vespa/searchcommon/attribute/config.h>
namespace vespa::config::search::internal { class InternalAttributesType; }
+namespace search::attribute { class Config; }
namespace proton {
@@ -15,12 +15,13 @@ namespace proton {
* from config server.
*/
class AttributeConfigInspector {
- vespalib::hash_map<vespalib::string, search::attribute::Config> _hash;
+ using Config = search::attribute::Config;
+ vespalib::hash_map<vespalib::string, std::unique_ptr<Config>> _hash;
public:
using AttributesConfig = const vespa::config::search::internal::InternalAttributesType;
AttributeConfigInspector(const AttributesConfig& config);
~AttributeConfigInspector();
- const search::attribute::Config* get_config(const vespalib::string& name) const;
+ const Config* get_config(const vespalib::string& name) const;
};
}
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp
index 713582bf1ce..4752c06ec18 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp
@@ -9,6 +9,7 @@
#include <vespa/vespalib/data/fileheader.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/searchcommon/attribute/persistent_predicate_params.h>
+#include <vespa/searchcommon/attribute/config.h>
#include <vespa/searchlib/util/fileutil.h>
#include <vespa/searchlib/attribute/attribute_header.h>
#include <vespa/searchlib/attribute/attributevector.h>
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_initializer.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_initializer.cpp
index d8c2d4e6e72..fb99ca51e3a 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_initializer.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_initializer.cpp
@@ -132,7 +132,7 @@ AttributeInitializerTasksBuilder::add(AttributeInitializer::UP initializer) {
}
-AttributeCollectionSpec::UP
+std::unique_ptr<AttributeCollectionSpec>
AttributeManagerInitializer::createAttributeSpec() const
{
uint32_t docIdLimit = 1; // The real docIdLimit is used after attributes are loaded to pad them
@@ -161,8 +161,8 @@ AttributeManagerInitializer::AttributeManagerInitializer(SerialNum configSerialN
{
addDependency(documentMetaStoreInitTask);
AttributeInitializerTasksBuilder tasksBuilder(*this, documentMetaStoreInitTask, documentMetaStore, _attributesResult);
- AttributeCollectionSpec::UP attrSpec = createAttributeSpec();
- _attrMgr = std::make_shared<AttributeManager>(*baseAttrMgr, *attrSpec, tasksBuilder);
+ std::unique_ptr<AttributeCollectionSpec> attrSpec = createAttributeSpec();
+ _attrMgr = std::make_shared<AttributeManager>(*baseAttrMgr, std::move(*attrSpec), tasksBuilder);
}
AttributeManagerInitializer::~AttributeManagerInitializer() = default;
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp
index 92989da9b99..59378930785 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp
@@ -10,6 +10,7 @@
#include "imported_attributes_repo.h"
#include "sequential_attributes_initializer.h"
#include <vespa/searchcommon/attribute/i_attribute_functor.h>
+#include <vespa/searchcommon/attribute/config.h>
#include <vespa/searchcore/proton/flushengine/shrink_lid_space_flush_target.h>
#include <vespa/searchlib/attribute/attribute_read_guard.h>
#include <vespa/searchlib/attribute/attributecontext.h>
@@ -24,6 +25,7 @@
#include <vespa/vespalib/util/gate.h>
#include <vespa/vespalib/util/isequencedtaskexecutor.h>
#include <vespa/vespalib/util/threadexecutor.h>
+#include <cassert>
#include <vespa/log/log.h>
LOG_SETUP(".proton.attribute.attributemanager");
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp
index 1888b2c4a52..dafb0affc0f 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp
@@ -5,8 +5,6 @@
#include "operation_listener.h"
#include "search_context.h"
#include "document_meta_store_versions.h"
-#include <vespa/fastos/file.h>
-#include <vespa/persistence/spi/bucket_limits.h>
#include <vespa/searchcore/proton/bucketdb/bucketsessionbase.h>
#include <vespa/searchcore/proton/bucketdb/joinbucketssession.h>
#include <vespa/searchcore/proton/bucketdb/remove_batch_entry.h>
@@ -16,6 +14,8 @@
#include <vespa/searchlib/common/i_gid_to_lid_mapper.h>
#include <vespa/searchlib/query/query_term_simple.h>
#include <vespa/searchlib/util/bufferwriter.h>
+#include <vespa/searchcommon/attribute/config.h>
+#include <vespa/persistence/spi/bucket_limits.h>
#include <vespa/vespalib/btree/btree.hpp>
#include <vespa/vespalib/btree/btreebuilder.hpp>
#include <vespa/vespalib/btree/btreenodeallocator.hpp>
@@ -24,6 +24,7 @@
#include <vespa/vespalib/datastore/buffer_type.hpp>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/util/rcuvector.hpp>
+#include <vespa/fastos/file.h>
#include <vespa/log/log.h>
LOG_SETUP(".proton.documentmetastore");
@@ -403,7 +404,13 @@ DocumentMetaStore::unload()
unloadBucket(*_bucketDB, prev, prevDelta);
}
+DocumentMetaStore::DocumentMetaStore(BucketDBOwnerSP bucketDB)
+ : DocumentMetaStore(std::move(bucketDB), getFixedName())
+{}
+DocumentMetaStore::DocumentMetaStore(BucketDBOwnerSP bucketDB, const vespalib::string &name)
+ : DocumentMetaStore(std::move(bucketDB), name, search::GrowStrategy())
+{}
DocumentMetaStore::DocumentMetaStore(BucketDBOwnerSP bucketDB,
const vespalib::string &name,
const GrowStrategy &grow,
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h
index adb2778c2d2..d1672eeb6dd 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h
@@ -9,9 +9,9 @@
#include "lid_hold_list.h"
#include "raw_document_meta_data.h"
#include <vespa/searchcore/proton/common/subdbtype.h>
-#include <vespa/searchlib/attribute/singlesmallnumericattribute.h>
#include <vespa/searchlib/queryeval/blueprint.h>
#include <vespa/searchlib/docstore/ibucketizer.h>
+#include <vespa/searchcommon/common/growstrategy.h>
#include <vespa/vespalib/util/rcuvector.h>
namespace proton::bucketdb {
@@ -148,9 +148,11 @@ public:
sizeof(uint32_t) + GlobalId::LENGTH + sizeof(uint8_t) +
sizeof(Timestamp);
+ DocumentMetaStore(BucketDBOwnerSP bucketDB);
+ DocumentMetaStore(BucketDBOwnerSP bucketDB, const vespalib::string & name);
DocumentMetaStore(BucketDBOwnerSP bucketDB,
- const vespalib::string & name=getFixedName(),
- const search::GrowStrategy & grow=search::GrowStrategy(),
+ const vespalib::string & name,
+ const search::GrowStrategy & grow,
SubDbType subDbType = SubDbType::READY);
~DocumentMetaStore();
diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp
index 228a46123a4..73d08785d5f 100644
--- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp
@@ -16,7 +16,6 @@
#include <vespa/searchcore/proton/matching/sessionmanager.h>
#include <vespa/searchcore/proton/reprocessing/attribute_reprocessing_initializer.h>
#include <vespa/searchcore/proton/reprocessing/reprocess_documents_task.h>
-#include <vespa/searchlib/docstore/document_store_visitor_progress.h>
#include <vespa/vespalib/util/destructor_callbacks.h>
#include <vespa/log/log.h>
@@ -104,7 +103,7 @@ FastAccessDocSubDB::setupAttributeManager(AttributeManager::SP attrMgrResult)
}
-AttributeCollectionSpec::UP
+std::unique_ptr<AttributeCollectionSpec>
FastAccessDocSubDB::createAttributeSpec(const AttributesConfig &attrCfg, const AllocStrategy& alloc_strategy, SerialNum serialNum) const
{
uint32_t docIdLimit(_dms->getCommittedDocIdLimit());
@@ -267,10 +266,10 @@ FastAccessDocSubDB::applyConfig(const DocumentDBConfig &newConfigSnapshot, const
FastAccessDocSubDBConfigurer configurer(_fastAccessFeedView,
std::make_unique<AttributeWriterFactory>(), getSubDbName());
proton::IAttributeManager::SP oldMgr = extractAttributeManager(_fastAccessFeedView.get());
- AttributeCollectionSpec::UP attrSpec =
+ std::unique_ptr<AttributeCollectionSpec> attrSpec =
createAttributeSpec(newConfigSnapshot.getAttributesConfig(), alloc_strategy, serialNum);
IReprocessingInitializer::UP initializer =
- configurer.reconfigure(newConfigSnapshot, oldConfigSnapshot, *attrSpec);
+ configurer.reconfigure(newConfigSnapshot, oldConfigSnapshot, std::move(*attrSpec));
if (initializer->hasReprocessors()) {
tasks.push_back(IReprocessingTask::SP(createReprocessingTask(*initializer,
newConfigSnapshot.getDocumentTypeRepoSP()).release()));
diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp
index 2d5f9ff826b..89c8f3de0b1 100644
--- a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp
@@ -144,7 +144,7 @@ reconfigure(const DocumentDBConfig &newConfig,
{
assert(!params.shouldAttributeManagerChange());
AttributeCollectionSpec attrSpec(AttributeCollectionSpec::AttributeList(), 0, 0);
- reconfigure(newConfig, oldConfig, attrSpec, params, resolver);
+ reconfigure(newConfig, oldConfig, std::move(attrSpec), params, resolver);
}
namespace {
diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp
index 6e87f33e1c6..ca731d1e379 100644
--- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp
@@ -147,10 +147,10 @@ SearchableDocSubDB::applyConfig(const DocumentDBConfig &newConfigSnapshot, const
}
if (params.shouldAttributeManagerChange()) {
proton::IAttributeManager::SP oldMgr = getAttributeManager();
- AttributeCollectionSpec::UP attrSpec =
+ std::unique_ptr<AttributeCollectionSpec> attrSpec =
createAttributeSpec(newConfigSnapshot.getAttributesConfig(), alloc_strategy, serialNum);
IReprocessingInitializer::UP initializer =
- _configurer.reconfigure(newConfigSnapshot, oldConfigSnapshot, *attrSpec, params, resolver);
+ _configurer.reconfigure(newConfigSnapshot, oldConfigSnapshot, std::move(*attrSpec), params, resolver);
if (initializer && initializer->hasReprocessors()) {
tasks.emplace_back(createReprocessingTask(*initializer, newConfigSnapshot.getDocumentTypeRepoSP()));
}
diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp
index 2736a1eaa6f..9f8afa0ad19 100644
--- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp
@@ -24,6 +24,7 @@
#include <vespa/searchlib/common/flush_token.h>
#include <vespa/searchlib/docstore/document_store_visitor_progress.h>
#include <vespa/searchlib/util/fileheadertk.h>
+#include <vespa/searchcommon/attribute/config.h>
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/util/exceptions.h>
diff --git a/searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h b/searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h
index 0e2491e62fa..4549f24d4e3 100644
--- a/searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h
+++ b/searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h
@@ -1,10 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <vespa/vespalib/util/hdr_abort.h>
-#include <vespa/searchlib/test/mock_attribute_manager.h>
#include <vespa/searchcore/proton/attribute/i_attribute_manager.h>
#include <vespa/searchcore/proton/attribute/imported_attributes_repo.h>
+#include <vespa/searchlib/test/mock_attribute_manager.h>
+#include <vespa/vespalib/util/hdr_abort.h>
+#include <cassert>
namespace proton::test {
diff --git a/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp b/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp
index e58954e1e93..ad082b3375a 100644
--- a/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp
+++ b/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/gtest/gtest.h>
-#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/document/update/arithmeticvalueupdate.h>
#include <vespa/searchlib/attribute/attribute.h>
@@ -13,12 +12,14 @@
#include <vespa/searchlib/attribute/multistringpostattribute.h>
#include <vespa/searchlib/common/growablebitvector.h>
#include <vespa/searchlib/queryeval/executeinfo.h>
+#include <vespa/searchlib/fef/termfieldmatchdata.h>
#include <vespa/searchlib/parsequery/parse.h>
-#include <vespa/searchlib/attribute/enumstore.hpp>
+#include <vespa/searchcommon/attribute/config.h>
+#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/util/compress.h>
-#include <vespa/searchlib/fef/termfieldmatchdata.h>
#include <vespa/fastos/file.h>
+#include <vespa/searchlib/attribute/enumstore.hpp>
#include <iostream>
#include <vespa/log/log.h>
diff --git a/searchlib/src/vespa/searchlib/attribute/attribute_operation.cpp b/searchlib/src/vespa/searchlib/attribute/attribute_operation.cpp
index 347793be4c6..e21e272f225 100644
--- a/searchlib/src/vespa/searchlib/attribute/attribute_operation.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/attribute_operation.cpp
@@ -96,7 +96,7 @@ struct UpdateFast {
void operator()(uint32_t docid) { attr->set(docid, op(attr->getFast(docid))); }
bool valid() const {
return (attr != nullptr) &&
- (attr->getConfig().isMutable()); }
+ (attr->isMutable()); }
};
template <typename OP>
diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
index d7c9bb8d224..2ad95a584ab 100644
--- a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
@@ -14,6 +14,7 @@
#include <vespa/document/update/mapvalueupdate.h>
#include <vespa/fastlib/io/bufferedfile.h>
#include <vespa/searchcommon/attribute/attribute_utils.h>
+#include <vespa/searchcommon/attribute/config.h>
#include <vespa/searchlib/common/tunefileinfo.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
#include <vespa/searchlib/query/query_term_decoder.h>
@@ -136,7 +137,7 @@ make_memory_allocator(const vespalib::string& name, const search::attribute::Con
AttributeVector::AttributeVector(vespalib::stringref baseFileName, const Config &c)
: _baseFileName(baseFileName),
- _config(c),
+ _config(std::make_unique<Config>(c)),
_interlock(std::make_shared<attribute::Interlock>()),
_enumLock(),
_genHandler(),
@@ -170,6 +171,16 @@ AttributeVector::updateStat(bool force) {
bool AttributeVector::hasEnum() const { return _hasEnum; }
uint32_t AttributeVector::getMaxValueCount() const { return _highestValueCount.load(std::memory_order_relaxed); }
+bool AttributeVector::hasMultiValue() const { return _config->collectionType().isMultiValue(); }
+bool AttributeVector::hasWeightedSetType() const { return _config->collectionType().isWeightedSet(); }
+size_t AttributeVector::getFixedWidth() const { return _config->basicType().fixedSize(); }
+attribute::BasicType AttributeVector::getInternalBasicType() const { return _config->basicType(); }
+attribute::CollectionType AttributeVector::getInternalCollectionType() const { return _config->collectionType(); }
+bool AttributeVector::hasArrayType() const { return _config->collectionType().isArray(); }
+bool AttributeVector::getIsFilter() const { return _config->getIsFilter(); }
+bool AttributeVector::getIsFastSearch() const { return _config->fastSearch(); }
+bool AttributeVector::isMutable() const { return _config->isMutable(); }
+bool AttributeVector::getEnableOnlyBitVector() const { return _config->getEnableOnlyBitVector(); }
bool
AttributeVector::isEnumerated(const vespalib::GenericHeader &header)
@@ -774,12 +785,12 @@ void
AttributeVector::update_config(const Config& cfg)
{
commit(true);
- _config.setGrowStrategy(cfg.getGrowStrategy());
- if (cfg.getCompactionStrategy() == _config.getCompactionStrategy()) {
+ _config->setGrowStrategy(cfg.getGrowStrategy());
+ if (cfg.getCompactionStrategy() == _config->getCompactionStrategy()) {
return;
}
drain_hold(1_Mi); // Wait until 1MiB or less on hold
- _config.setCompactionStrategy(cfg.getCompactionStrategy());
+ _config->setCompactionStrategy(cfg.getCompactionStrategy());
updateStat(true);
commit(); // might trigger compaction
drain_hold(1_Mi); // Wait until 1MiB or less on hold
diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h
index 09dc27f0451..983c4c4ae22 100644
--- a/searchlib/src/vespa/searchlib/attribute/attributevector.h
+++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h
@@ -59,6 +59,7 @@ namespace search {
class InterlockGuard;
class SearchContext;
class MultiValueMappingBase;
+ class Config;
}
namespace fileutil {
@@ -352,18 +353,23 @@ public:
void logEnumStoreEvent(const char *reason, const char *stage);
/** Return the fixed length of the attribute. If 0 then you must inquire each document. */
- size_t getFixedWidth() const override { return _config.basicType().fixedSize(); }
- const Config &getConfig() const noexcept { return _config; }
+ size_t getFixedWidth() const override;
+ BasicType getInternalBasicType() const;
+ CollectionType getInternalCollectionType() const;
+ bool hasArrayType() const;
+ bool getIsFilter() const override final;
+ bool getIsFastSearch() const override final;
+ bool isMutable() const;
+ bool getEnableOnlyBitVector() const;
+
+ const Config &getConfig() const noexcept { return *_config; }
void update_config(const Config& cfg);
- BasicType getInternalBasicType() const { return _config.basicType(); }
- CollectionType getInternalCollectionType() const { return _config.collectionType(); }
const BaseName & getBaseFileName() const { return _baseFileName; }
void setBaseFileName(vespalib::stringref name) { _baseFileName = name; }
bool isUpdateableInMemoryOnly() const { return _isUpdateableInMemoryOnly; }
const vespalib::string & getName() const override final { return _baseFileName.getAttributeName(); }
- bool hasArrayType() const { return _config.collectionType().isArray(); }
bool hasEnum() const override final;
uint32_t getMaxValueCount() const override;
uint32_t getEnumMax() const { return _enumMax; }
@@ -388,8 +394,6 @@ public:
BasicType::Type getBasicType() const override final { return getInternalBasicType().type(); }
CollectionType::Type getCollectionType() const override final { return getInternalCollectionType().type(); }
- bool getIsFilter() const override final { return _config.getIsFilter(); }
- bool getIsFastSearch() const override final { return _config.fastSearch(); }
uint32_t getCommittedDocIdLimit() const override final { return _committedDocIdLimit.load(std::memory_order_acquire); }
bool isImported() const override;
@@ -490,7 +494,7 @@ private:
BaseName _baseFileName;
- Config _config;
+ std::unique_ptr<Config> _config;
std::shared_ptr<attribute::Interlock> _interlock;
mutable std::shared_mutex _enumLock;
GenerationHandler _genHandler;
@@ -533,8 +537,8 @@ private:
friend class AttributeManagerTest;
public:
bool headerTypeOK(const vespalib::GenericHeader &header) const;
- bool hasMultiValue() const override final { return _config.collectionType().isMultiValue(); }
- bool hasWeightedSetType() const override final { return _config.collectionType().isWeightedSet(); }
+ bool hasMultiValue() const override final;
+ bool hasWeightedSetType() const override final;
/**
* Should be called by the writer thread.
*/
diff --git a/searchlib/src/vespa/searchlib/attribute/floatbase.h b/searchlib/src/vespa/searchlib/attribute/floatbase.h
index 8ca6eda6421..787273c2050 100644
--- a/searchlib/src/vespa/searchlib/attribute/floatbase.h
+++ b/searchlib/src/vespa/searchlib/attribute/floatbase.h
@@ -60,7 +60,7 @@ public:
using LoadedVector = SequentialReadModifyWriteInterface<LoadedNumericValueT>;
virtual T get(DocId doc) const = 0;
virtual T getFromEnum(EnumHandle e) const = 0;
- T defaultValue() const { return getConfig().isMutable() ? 0.0 : attribute::getUndefined<T>(); }
+ T defaultValue() const { return isMutable() ? 0.0 : attribute::getUndefined<T>(); }
protected:
FloatingPointAttributeTemplate(const vespalib::string & name);
FloatingPointAttributeTemplate(const vespalib::string & name, const Config & c);
diff --git a/searchlib/src/vespa/searchlib/attribute/integerbase.h b/searchlib/src/vespa/searchlib/attribute/integerbase.h
index 65d16ce934a..42f169a0c1a 100644
--- a/searchlib/src/vespa/searchlib/attribute/integerbase.h
+++ b/searchlib/src/vespa/searchlib/attribute/integerbase.h
@@ -58,7 +58,7 @@ public:
using LoadedVector = SequentialReadModifyWriteInterface<LoadedNumericValueT>;
virtual T get(DocId doc) const = 0;
virtual T getFromEnum(EnumHandle e) const = 0;
- T defaultValue() const { return getConfig().isMutable() ? 0 : attribute::getUndefined<T>(); }
+ T defaultValue() const { return isMutable() ? 0 : attribute::getUndefined<T>(); }
protected:
IntegerAttributeTemplate(const vespalib::string & name);
IntegerAttributeTemplate(const vespalib::string & name, const Config & c);
diff --git a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp
index b0765680f78..a5bb901be31 100644
--- a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp
@@ -10,6 +10,7 @@
#include <vespa/searchlib/query/query_term_simple.h>
#include <vespa/searchlib/queryeval/emptysearch.h>
#include <vespa/searchlib/util/file_settings.h>
+#include <vespa/searchcommon/attribute/config.h>
#include <vespa/vespalib/data/databuffer.h>
#include <vespa/vespalib/util/size_literals.h>
diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.h b/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.h
index cf3fa85a060..2e9303bef62 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.h
@@ -41,12 +41,8 @@ protected:
}
public:
- SingleValueNumericAttribute(const vespalib::string & baseFileName,
- const AttributeVector::Config & c =
- AttributeVector::Config(AttributeVector::
- BasicType::fromType(T()),
- attribute::CollectionType::SINGLE));
-
+ SingleValueNumericAttribute(const vespalib::string & baseFileName); // Only for testing
+ SingleValueNumericAttribute(const vespalib::string & baseFileName, const AttributeVector::Config & c);
~SingleValueNumericAttribute();
diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.hpp
index 0a3c6a9ac4f..15f745cf311 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.hpp
@@ -10,14 +10,22 @@
#include "singlenumericattributesaver.h"
#include "single_numeric_search_context.h"
#include <vespa/searchlib/query/query_term_simple.h>
+#include <vespa/searchcommon/attribute/config.h>
namespace search {
template <typename B>
SingleValueNumericAttribute<B>::
-SingleValueNumericAttribute(const vespalib::string & baseFileName, const AttributeVector::Config & c) :
- B(baseFileName, c),
- _data(c.getGrowStrategy().to_generic_strategy(), getGenerationHolder(), this->get_initial_alloc())
+SingleValueNumericAttribute(const vespalib::string & baseFileName)
+ : SingleValueNumericAttribute(baseFileName, attribute::Config(attribute::BasicType::fromType(T()),
+ attribute::CollectionType::SINGLE))
+{ }
+
+template <typename B>
+SingleValueNumericAttribute<B>::
+SingleValueNumericAttribute(const vespalib::string & baseFileName, const AttributeVector::Config & c)
+ : B(baseFileName, c),
+ _data(c.getGrowStrategy().to_generic_strategy(), getGenerationHolder(), this->get_initial_alloc())
{ }
template <typename B>
diff --git a/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp b/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp
index 3bc2cb8f96a..3ee2671d7e1 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp
@@ -7,6 +7,7 @@
#include "single_small_numeric_search_context.h"
#include <vespa/searchlib/query/query_term_simple.h>
#include <vespa/searchlib/util/file_settings.h>
+#include <vespa/searchcommon/attribute/config.h>
#include <vespa/vespalib/data/databuffer.h>
#include <vespa/vespalib/util/size_literals.h>
diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp
index e000afedadc..4a6dfecb388 100644
--- a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp
@@ -5,6 +5,7 @@
#include <vespa/document/datatype/tensor_data_type.h>
#include <vespa/searchlib/attribute/address_space_components.h>
#include <vespa/searchlib/util/state_explorer_utils.h>
+#include <vespa/searchcommon/attribute/config.h>
#include <vespa/vespalib/data/slime/cursor.h>
#include <vespa/vespalib/data/slime/inserter.h>
#include <vespa/vespalib/util/shared_string_repo.h>
@@ -311,6 +312,11 @@ TensorAttribute::complete_set_tensor(DocId docid, const vespalib::eval::Value& t
(void) prepare_result;
}
+attribute::DistanceMetric
+TensorAttribute::distance_metric() const {
+ return getConfig().distance_metric();
+}
+
IMPLEMENT_IDENTIFIABLE_ABSTRACT(TensorAttribute, AttributeVector);
}
diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.h b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.h
index 518caef9dc9..505e072fa31 100644
--- a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.h
+++ b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.h
@@ -68,9 +68,7 @@ public:
virtual void update_tensor(DocId docId,
const document::TensorUpdate &update,
bool create_empty_if_non_existing);
- DistanceMetric distance_metric() const override {
- return getConfig().distance_metric();
- }
+ DistanceMetric distance_metric() const override;
uint32_t get_num_docs() const override { return getNumDocs(); }
/**