summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-05-26 14:55:53 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-05-26 14:55:53 +0000
commit6df2abaedf8a033a2e775f24a4c3ae785b5c6cd9 (patch)
tree8705f9392cb9f57adaa9212cba96fb8633cbbc14 /searchcore
parenta9375271a7306a1b503c6093b06ff54605631dc8 (diff)
Move the AttributeSpec and hide the Config
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/tests/proton/attribute/CMakeLists.txt1
-rw-r--r--searchcore/src/tests/proton/attribute/attribute_aspect_delayer/attribute_aspect_delayer_test.cpp11
-rw-r--r--searchcore/src/tests/proton/attribute/attribute_initializer/attribute_initializer_test.cpp4
-rw-r--r--searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp9
-rw-r--r--searchcore/src/tests/proton/attribute/attribute_populator/attribute_populator_test.cpp10
-rw-r--r--searchcore/src/tests/proton/attribute/attribute_test.cpp35
-rw-r--r--searchcore/src/tests/proton/attribute/attributes_state_explorer/attributes_state_explorer_test.cpp1
-rw-r--r--searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp7
-rw-r--r--searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/CMakeLists.txt1
-rw-r--r--searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/attribute_reprocessing_initializer_test.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.cpp18
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.h20
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attribute_spec.cpp11
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attribute_spec.h12
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp37
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h12
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/attribute_writer_factory.h4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp7
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/i_attribute_writer_factory.h4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp8
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt1
-rw-r--r--searchcore/src/vespa/searchcore/proton/test/attribute_utils.cpp76
-rw-r--r--searchcore/src/vespa/searchcore/proton/test/attribute_utils.h52
-rw-r--r--searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h2
31 files changed, 208 insertions, 153 deletions
diff --git a/searchcore/src/tests/proton/attribute/CMakeLists.txt b/searchcore/src/tests/proton/attribute/CMakeLists.txt
index 56c0d7301b2..bea3e7c2416 100644
--- a/searchcore/src/tests/proton/attribute/CMakeLists.txt
+++ b/searchcore/src/tests/proton/attribute/CMakeLists.txt
@@ -7,6 +7,7 @@ vespa_add_executable(searchcore_attribute_test_app TEST
searchcore_attribute
searchcore_flushengine
searchcore_pcommon
+ searchcore_test
searchlib_test
GTest::GTest
)
diff --git a/searchcore/src/tests/proton/attribute/attribute_aspect_delayer/attribute_aspect_delayer_test.cpp b/searchcore/src/tests/proton/attribute/attribute_aspect_delayer/attribute_aspect_delayer_test.cpp
index a0d0958d095..0ce67e8bfcb 100644
--- a/searchcore/src/tests/proton/attribute/attribute_aspect_delayer/attribute_aspect_delayer_test.cpp
+++ b/searchcore/src/tests/proton/attribute/attribute_aspect_delayer/attribute_aspect_delayer_test.cpp
@@ -24,16 +24,11 @@ using vespa::config::search::SummaryConfigBuilder;
using vespa::config::search::SummarymapConfig;
using vespa::config::search::SummarymapConfigBuilder;
using search::attribute::Config;
-using search::attribute::BasicType;
-using search::attribute::CollectionType;
-namespace std
-{
+namespace std {
-ostream &operator<<(ostream &os, const SummarymapConfig::Override &override)
-{
- os << "{field=" << override.field << ", command=" << override.command << ", arguments=" << override.arguments << "}";
- return os;
+ostream &operator<<(ostream &os, const SummarymapConfig::Override &override) {
+ return os << "{field=" << override.field << ", command=" << override.command << ", arguments=" << override.arguments << "}";
}
}
diff --git a/searchcore/src/tests/proton/attribute/attribute_initializer/attribute_initializer_test.cpp b/searchcore/src/tests/proton/attribute/attribute_initializer/attribute_initializer_test.cpp
index b16f7810cca..93cb456cc06 100644
--- a/searchcore/src/tests/proton/attribute/attribute_initializer/attribute_initializer_test.cpp
+++ b/searchcore/src/tests/proton/attribute/attribute_initializer/attribute_initializer_test.cpp
@@ -1,14 +1,16 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/searchcore/proton/attribute/attribute_directory.h>
#include <vespa/searchcore/proton/attribute/attribute_factory.h>
#include <vespa/searchcore/proton/attribute/attribute_initializer.h>
#include <vespa/searchcore/proton/attribute/attributedisklayout.h>
#include <vespa/searchcore/proton/test/attribute_utils.h>
#include <vespa/searchlib/attribute/attributefactory.h>
+#include <vespa/searchlib/attribute/integerbase.h>
#include <vespa/searchlib/test/directory_handler.h>
+#include <vespa/searchcommon/attribute/config.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
+#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/log/log.h>
LOG_SETUP("attribute_initializer_test");
diff --git a/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp b/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp
index a49a5e52743..b446ca367c0 100644
--- a/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp
+++ b/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp
@@ -31,6 +31,7 @@
#include <vespa/searchlib/test/mock_gid_to_lid_mapping.h>
#include <vespa/searchcommon/attribute/i_attribute_functor.h>
#include <vespa/searchcommon/attribute/iattributevector.h>
+#include <vespa/searchcommon/attribute/config.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/foreground_thread_executor.h>
#include <vespa/vespalib/util/foregroundtaskexecutor.h>
@@ -106,19 +107,19 @@ public:
}
const string test_dir = "test_output";
-const AVConfig INT32_SINGLE = AttributeUtils::getInt32Config();
-const AVConfig INT32_ARRAY = AttributeUtils::getInt32ArrayConfig();
+const AVConfig & INT32_SINGLE = AttributeUtils::getInt32Config();
+const AVConfig & INT32_ARRAY = AttributeUtils::getInt32ArrayConfig();
void
fillAttribute(const AttributeVector::SP &attr, uint32_t numDocs, int64_t value, uint64_t lastSyncToken)
{
- AttributeUtils::fillAttribute(attr, numDocs, value, lastSyncToken);
+ AttributeUtils::fillAttribute(*attr, numDocs, value, lastSyncToken);
}
void
fillAttribute(const AttributeVector::SP &attr, uint32_t from, uint32_t to, int64_t value, uint64_t lastSyncToken)
{
- AttributeUtils::fillAttribute(attr, from, to, value, lastSyncToken);
+ AttributeUtils::fillAttribute(*attr, from, to, value, lastSyncToken);
}
search::SerialNum getCreateSerialNum(const AttributeGuard::UP &guard)
diff --git a/searchcore/src/tests/proton/attribute/attribute_populator/attribute_populator_test.cpp b/searchcore/src/tests/proton/attribute/attribute_populator/attribute_populator_test.cpp
index 7ad427f303f..0d09d45c33a 100644
--- a/searchcore/src/tests/proton/attribute/attribute_populator/attribute_populator_test.cpp
+++ b/searchcore/src/tests/proton/attribute/attribute_populator/attribute_populator_test.cpp
@@ -1,9 +1,5 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/document/datatype/documenttype.h>
-#include <vespa/document/fieldvalue/document.h>
-#include <vespa/document/fieldvalue/intfieldvalue.h>
-#include <vespa/document/repo/configbuilder.h>
#include <vespa/searchcore/proton/attribute/attribute_populator.h>
#include <vespa/searchcore/proton/attribute/attributemanager.h>
#include <vespa/searchcore/proton/common/hw_info.h>
@@ -11,6 +7,12 @@
#include <vespa/searchlib/attribute/interlock.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
#include <vespa/searchlib/test/directory_handler.h>
+#include <vespa/searchlib/attribute/attributevector.h>
+#include <vespa/searchcommon/attribute/config.h>
+#include <vespa/document/datatype/documenttype.h>
+#include <vespa/document/fieldvalue/document.h>
+#include <vespa/document/fieldvalue/intfieldvalue.h>
+#include <vespa/document/repo/configbuilder.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/foreground_thread_executor.h>
#include <vespa/vespalib/util/foregroundtaskexecutor.h>
diff --git a/searchcore/src/tests/proton/attribute/attribute_test.cpp b/searchcore/src/tests/proton/attribute/attribute_test.cpp
index bcce3b8d07a..800cb8aa0ce 100644
--- a/searchcore/src/tests/proton/attribute/attribute_test.cpp
+++ b/searchcore/src/tests/proton/attribute/attribute_test.cpp
@@ -1,20 +1,5 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/config-attributes.h>
-#include <vespa/document/datatype/documenttype.h>
-#include <vespa/document/datatype/mapdatatype.h>
-#include <vespa/document/datatype/tensor_data_type.h>
-#include <vespa/document/fieldvalue/document.h>
-#include <vespa/document/predicate/predicate_slime_builder.h>
-#include <vespa/document/update/arithmeticvalueupdate.h>
-#include <vespa/document/update/assignvalueupdate.h>
-#include <vespa/document/update/documentupdate.h>
-#include <vespa/eval/eval/simple_value.h>
-#include <vespa/eval/eval/tensor_spec.h>
-#include <vespa/eval/eval/test/value_compare.h>
-#include <vespa/eval/eval/value.h>
-#include <vespa/searchcommon/attribute/attributecontent.h>
-#include <vespa/searchcommon/attribute/iattributevector.h>
#include <vespa/searchcore/proton/attribute/attribute_collection_spec_factory.h>
#include <vespa/searchcore/proton/attribute/attribute_writer.h>
#include <vespa/searchcore/proton/attribute/attributemanager.h>
@@ -39,6 +24,22 @@
#include <vespa/searchlib/tensor/dense_tensor_attribute.h>
#include <vespa/searchlib/tensor/tensor_attribute.h>
#include <vespa/searchlib/test/directory_handler.h>
+#include <vespa/searchcommon/attribute/attributecontent.h>
+#include <vespa/searchcommon/attribute/iattributevector.h>
+#include <vespa/searchcommon/attribute/config.h>
+#include <vespa/config-attributes.h>
+#include <vespa/document/datatype/documenttype.h>
+#include <vespa/document/datatype/mapdatatype.h>
+#include <vespa/document/datatype/tensor_data_type.h>
+#include <vespa/document/fieldvalue/document.h>
+#include <vespa/document/predicate/predicate_slime_builder.h>
+#include <vespa/document/update/arithmeticvalueupdate.h>
+#include <vespa/document/update/assignvalueupdate.h>
+#include <vespa/document/update/documentupdate.h>
+#include <vespa/eval/eval/simple_value.h>
+#include <vespa/eval/eval/tensor_spec.h>
+#include <vespa/eval/eval/test/value_compare.h>
+#include <vespa/eval/eval/value.h>
#include <vespa/vespalib/btree/btreeroot.hpp>
#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/vespalib/test/insertion_operators.h>
@@ -118,13 +119,13 @@ const AVConfig INT32_ARRAY = unregister(AVConfig(AVBasicType::INT32, AVCollectio
void
fillAttribute(const AttributeVector::SP &attr, uint32_t numDocs, int64_t value, uint64_t lastSyncToken)
{
- AttributeUtils::fillAttribute(attr, numDocs, value, lastSyncToken);
+ AttributeUtils::fillAttribute(*attr, numDocs, value, lastSyncToken);
}
void
fillAttribute(const AttributeVector::SP &attr, uint32_t from, uint32_t to, int64_t value, uint64_t lastSyncToken)
{
- AttributeUtils::fillAttribute(attr, from, to, value, lastSyncToken);
+ AttributeUtils::fillAttribute(*attr, from, to, value, lastSyncToken);
}
const std::shared_ptr<IDestructorCallback> emptyCallback;
diff --git a/searchcore/src/tests/proton/attribute/attributes_state_explorer/attributes_state_explorer_test.cpp b/searchcore/src/tests/proton/attribute/attributes_state_explorer/attributes_state_explorer_test.cpp
index 1209ab3e578..a7d41b6234c 100644
--- a/searchcore/src/tests/proton/attribute/attributes_state_explorer/attributes_state_explorer_test.cpp
+++ b/searchcore/src/tests/proton/attribute/attributes_state_explorer/attributes_state_explorer_test.cpp
@@ -8,6 +8,7 @@
#include <vespa/searchlib/attribute/interlock.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
#include <vespa/searchlib/test/directory_handler.h>
+#include <vespa/searchcommon/attribute/config.h>
#include <vespa/vespalib/data/slime/slime.h>
#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/vespalib/util/foreground_thread_executor.h>
diff --git a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp
index 290b4546a5e..cb3acdb7ec8 100644
--- a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp
@@ -1,8 +1,5 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/config-bucketspaces.h>
-#include <vespa/config/subscription/sourcespec.h>
-#include <vespa/document/test/make_bucket_space.h>
#include <vespa/searchcore/proton/attribute/imported_attributes_repo.h>
#include <vespa/searchcore/proton/bucketdb/bucketdbhandler.h>
#include <vespa/searchcore/proton/common/hw_info.h>
@@ -31,6 +28,10 @@
#include <vespa/searchlib/attribute/interlock.h>
#include <vespa/searchlib/index/docbuilder.h>
#include <vespa/searchlib/test/directory_handler.h>
+#include <vespa/searchcommon/attribute/config.h>
+#include <vespa/config-bucketspaces.h>
+#include <vespa/config/subscription/sourcespec.h>
+#include <vespa/document/test/make_bucket_space.h>
#include <vespa/vespalib/test/insertion_operators.h>
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/destructor_callbacks.h>
diff --git a/searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/CMakeLists.txt b/searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/CMakeLists.txt
index 99b7ad3821d..70906aa92f1 100644
--- a/searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/CMakeLists.txt
+++ b/searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/CMakeLists.txt
@@ -6,6 +6,7 @@ vespa_add_executable(searchcore_attribute_reprocessing_initializer_test_app TEST
searchcore_reprocessing
searchcore_attribute
searchcore_pcommon
+ searchcore_test
GTest::GTest
)
vespa_add_test(NAME searchcore_attribute_reprocessing_initializer_test_app COMMAND searchcore_attribute_reprocessing_initializer_test_app)
diff --git a/searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/attribute_reprocessing_initializer_test.cpp b/searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/attribute_reprocessing_initializer_test.cpp
index c2664d4e143..ebec0841ebf 100644
--- a/searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/attribute_reprocessing_initializer_test.cpp
+++ b/searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/attribute_reprocessing_initializer_test.cpp
@@ -14,6 +14,8 @@
#include <vespa/searchlib/attribute/interlock.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
#include <vespa/searchlib/test/directory_handler.h>
+#include <vespa/searchlib/attribute/attributevector.h>
+#include <vespa/searchcommon/attribute/config.h>
#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/vespalib/test/insertion_operators.h>
#include <vespa/vespalib/util/foreground_thread_executor.h>
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.cpp
index 17707c99705..35c54d31fd0 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.cpp
@@ -4,15 +4,23 @@
namespace proton {
-AttributeCollectionSpec::AttributeCollectionSpec(const AttributeList &attributes,
- uint32_t docIdLimit,
- SerialNum currentSerialNum)
- : _attributes(attributes),
+AttributeCollectionSpec::AttributeCollectionSpec(AttributeList && attributes, uint32_t docIdLimit, SerialNum currentSerialNum)
+ : _attributes(std::move(attributes)),
_docIdLimit(docIdLimit),
_currentSerialNum(currentSerialNum)
{
}
-AttributeCollectionSpec::~AttributeCollectionSpec() { }
+AttributeCollectionSpec::~AttributeCollectionSpec() = default;
+
+bool
+AttributeCollectionSpec::hasAttribute(const vespalib::string &name) const {
+ for (const auto &attr : _attributes) {
+ if (attr.getName() == name) {
+ return true;
+ }
+ }
+ return false;
+}
}
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 1357d56c472..73f1febd822 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.h
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.h
@@ -14,9 +14,7 @@ namespace proton {
class AttributeCollectionSpec
{
public:
- typedef std::unique_ptr<AttributeCollectionSpec> UP;
-
- typedef std::vector<AttributeSpec> AttributeList;
+ using AttributeList = std::vector<AttributeSpec>;
private:
typedef search::SerialNum SerialNum;
@@ -26,27 +24,21 @@ private:
SerialNum _currentSerialNum;
public:
- AttributeCollectionSpec(const AttributeList &attributes,
- uint32_t docIdLimit,
- SerialNum currentSerialNum);
+ AttributeCollectionSpec(AttributeList && attributes, uint32_t docIdLimit, SerialNum currentSerialNum);
~AttributeCollectionSpec();
const AttributeList &getAttributes() const {
return _attributes;
}
+ AttributeList stealAttributes() {
+ return std::move(_attributes);
+ }
uint32_t getDocIdLimit() const {
return _docIdLimit;
}
SerialNum getCurrentSerialNum() const {
return _currentSerialNum;
}
- bool hasAttribute(const vespalib::string &name) const {
- for (const auto &attr : _attributes) {
- if (attr.getName() == name) {
- return true;
- }
- }
- return false;
- }
+ bool hasAttribute(const vespalib::string &name) const;
};
} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp
index 4752c06ec18..19e387a2b64 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp
@@ -233,13 +233,13 @@ AttributeInitializer::createAndSetupEmptyAttribute() const
AttributeInitializer::AttributeInitializer(const std::shared_ptr<AttributeDirectory> &attrDir,
const vespalib::string &documentSubDbName,
- const AttributeSpec &spec,
+ AttributeSpec && spec,
uint64_t currentSerialNum,
const IAttributeFactory &factory,
vespalib::Executor& shared_executor)
: _attrDir(attrDir),
_documentSubDbName(documentSubDbName),
- _spec(spec),
+ _spec(std::move(spec)),
_currentSerialNum(currentSerialNum),
_factory(factory),
_shared_executor(shared_executor),
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.h
index 78a798c929e..a3844219d24 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.h
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.h
@@ -47,7 +47,7 @@ private:
public:
AttributeInitializer(const std::shared_ptr<AttributeDirectory> &attrDir, const vespalib::string &documentSubDbName,
- const AttributeSpec &spec, uint64_t currentSerialNum, const IAttributeFactory &factory,
+ AttributeSpec && spec, uint64_t currentSerialNum, const IAttributeFactory &factory,
vespalib::Executor& shared_executor);
~AttributeInitializer();
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_spec.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_spec.cpp
index ffbf5720b4b..11e03595caf 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_spec.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_spec.cpp
@@ -1,21 +1,16 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "attribute_spec.h"
+#include <vespa/searchcommon/attribute/config.h>
namespace proton {
-AttributeSpec::AttributeSpec(const vespalib::string &name,
- const search::attribute::Config &cfg)
+AttributeSpec::AttributeSpec(const vespalib::string &name, const Config &cfg)
: _name(name),
- _cfg(cfg)
+ _cfg(std::make_unique<Config>(cfg))
{
}
-AttributeSpec::AttributeSpec(const AttributeSpec &) = default;
-
-AttributeSpec &
-AttributeSpec::operator=(const AttributeSpec &) = default;
-
AttributeSpec::AttributeSpec(AttributeSpec &&) noexcept = default;
AttributeSpec &
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_spec.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_spec.h
index d56510709b2..8b63837b69a 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_spec.h
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_spec.h
@@ -2,7 +2,10 @@
#pragma once
-#include <vespa/searchcommon/attribute/config.h>
+#include <vespa/vespalib/stllike/string.h>
+#include <memory>
+
+namespace search::attribute { class Config; }
namespace proton {
@@ -13,17 +16,16 @@ namespace proton {
class AttributeSpec
{
private:
+ using Config = search::attribute::Config;
vespalib::string _name;
- search::attribute::Config _cfg;
+ std::unique_ptr<Config> _cfg;
public:
AttributeSpec(const vespalib::string &name, const search::attribute::Config &cfg);
- AttributeSpec(const AttributeSpec &);
- AttributeSpec & operator=(const AttributeSpec &);
AttributeSpec(AttributeSpec &&) noexcept;
AttributeSpec & operator=(AttributeSpec &&) noexcept;
~AttributeSpec();
const vespalib::string &getName() const { return _name; }
- const search::attribute::Config &getConfig() const { return _cfg; }
+ const Config &getConfig() const { return *_cfg; }
bool operator==(const AttributeSpec &rhs) const;
};
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp
index 59378930785..6fb0279733f 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp
@@ -120,11 +120,12 @@ AttributeManager::FlushableWrap::FlushableWrap(FlushableAttributeSP flusher, Shr
AttributeManager::FlushableWrap::~FlushableWrap() = default;
AttributeVector::SP
-AttributeManager::internalAddAttribute(const AttributeSpec &spec,
+AttributeManager::internalAddAttribute(AttributeSpec && spec,
uint64_t serialNum,
const IAttributeFactory &factory)
{
- AttributeInitializer initializer(_diskLayout->createAttributeDir(spec.getName()), _documentSubDbName, spec, serialNum, factory, _shared_executor);
+ vespalib::string name = spec.getName();
+ AttributeInitializer initializer(_diskLayout->createAttributeDir(name), _documentSubDbName, std::move(spec), serialNum, factory, _shared_executor);
AttributeInitializerResult result = initializer.init();
if (result) {
result.getAttribute()->setInterlock(_interlock);
@@ -166,15 +167,15 @@ AttributeManager::findFlushable(const vespalib::string &name) const
return (itr != _flushables.end()) ? &itr->second : nullptr;
}
-void
+AttributeCollectionSpec::AttributeList
AttributeManager::transferExistingAttributes(const AttributeManager &currMgr,
- const Spec &newSpec,
- Spec::AttributeList &toBeAdded)
+ Spec::AttributeList && newAttributes)
{
+ Spec::AttributeList toBeAdded;
vespalib::Gate gate;
{
auto gateCallback = std::make_shared<vespalib::GateCallback>(gate);
- for (const auto &aspec: newSpec.getAttributes()) {
+ for (auto &aspec: newAttributes) {
AttributeVector::SP av = currMgr.findAttribute(aspec.getName());
if (matchingTypes(av, aspec.getConfig())) { // transfer attribute
LOG(debug,
@@ -192,24 +193,25 @@ AttributeManager::transferExistingAttributes(const AttributeManager &currMgr,
av->update_config(cfg);
});
} else {
- toBeAdded.push_back(aspec);
+ toBeAdded.push_back(std::move(aspec));
}
}
}
gate.await();
+ return toBeAdded;
}
void
AttributeManager::addNewAttributes(const Spec &newSpec,
- const Spec::AttributeList &toBeAdded,
+ Spec::AttributeList && toBeAdded,
IAttributeInitializerRegistry &initializerRegistry)
{
- for (const auto &aspec : toBeAdded) {
+ for (auto &aspec : toBeAdded) {
LOG(debug, "Creating initializer for attribute vector '%s': docIdLimit=%u, serialNumber=%" PRIu64,
aspec.getName().c_str(), newSpec.getDocIdLimit(), newSpec.getCurrentSerialNum());
auto initializer = std::make_unique<AttributeInitializer>(_diskLayout->createAttributeDir(aspec.getName()),
- _documentSubDbName, aspec, newSpec.getCurrentSerialNum(),
+ _documentSubDbName, std::move(aspec), newSpec.getCurrentSerialNum(),
*_factory, _shared_executor);
initializerRegistry.add(std::move(initializer));
@@ -289,7 +291,7 @@ AttributeManager::AttributeManager(const vespalib::string &baseDir,
}
AttributeManager::AttributeManager(const AttributeManager &currMgr,
- const Spec &newSpec,
+ Spec && newSpec,
IAttributeInitializerRegistry &initializerRegistry)
: proton::IAttributeManager(),
_attributes(),
@@ -306,18 +308,17 @@ AttributeManager::AttributeManager(const AttributeManager &currMgr,
_hwInfo(currMgr._hwInfo),
_importedAttributes()
{
- Spec::AttributeList toBeAdded;
- transferExistingAttributes(currMgr, newSpec, toBeAdded);
- addNewAttributes(newSpec, toBeAdded, initializerRegistry);
+ Spec::AttributeList toBeAdded = transferExistingAttributes(currMgr, newSpec.stealAttributes());
+ addNewAttributes(newSpec, std::move(toBeAdded), initializerRegistry);
transferExtraAttributes(currMgr);
}
AttributeManager::~AttributeManager() = default;
AttributeVector::SP
-AttributeManager::addAttribute(const AttributeSpec &spec, uint64_t serialNum)
+AttributeManager::addAttribute(AttributeSpec && spec, uint64_t serialNum)
{
- return internalAddAttribute(spec, serialNum, *_factory);
+ return internalAddAttribute(std::move(spec), serialNum, *_factory);
}
void
@@ -482,10 +483,10 @@ AttributeManager::createContext() const
}
proton::IAttributeManager::SP
-AttributeManager::create(const Spec &spec) const
+AttributeManager::create(Spec && spec) const
{
SequentialAttributesInitializer initializer(spec.getDocIdLimit());
- proton::AttributeManager::SP result = std::make_shared<AttributeManager>(*this, spec, initializer);
+ proton::AttributeManager::SP result = std::make_shared<AttributeManager>(*this, std::move(spec), initializer);
result->addInitializedAttributes(initializer.getInitializedAttributes());
return result;
}
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h
index 41e553b47d1..2d5b75e71f4 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h
@@ -84,7 +84,7 @@ private:
HwInfo _hwInfo;
std::unique_ptr<ImportedAttributesRepo> _importedAttributes;
- AttributeVectorSP internalAddAttribute(const AttributeSpec &spec, uint64_t serialNum, const IAttributeFactory &factory);
+ AttributeVectorSP internalAddAttribute(AttributeSpec && spec, uint64_t serialNum, const IAttributeFactory &factory);
void addAttribute(const AttributeWrap &attribute, const ShrinkerSP &shrinker);
@@ -92,9 +92,9 @@ private:
const FlushableWrap *findFlushable(const vespalib::string &name) const;
- void transferExistingAttributes(const AttributeManager &currMgr, const Spec &newSpec, Spec::AttributeList &toBeAdded);
+ Spec::AttributeList transferExistingAttributes(const AttributeManager &currMgr, Spec::AttributeList && newAttributes);
- void addNewAttributes(const Spec &newSpec, const Spec::AttributeList &toBeAdded,
+ void addNewAttributes(const Spec &newSpec, Spec::AttributeList && toBeAdded,
IAttributeInitializerRegistry &initializerRegistry);
void transferExtraAttributes(const AttributeManager &currMgr);
@@ -121,11 +121,11 @@ public:
const IAttributeFactory::SP &factory,
const HwInfo &hwInfo);
- AttributeManager(const AttributeManager &currMgr, const Spec &newSpec,
+ AttributeManager(const AttributeManager &currMgr, Spec && newSpec,
IAttributeInitializerRegistry &initializerRegistry);
~AttributeManager() override;
- AttributeVectorSP addAttribute(const AttributeSpec &spec, uint64_t serialNum);
+ AttributeVectorSP addAttribute(AttributeSpec && spec, uint64_t serialNum);
void addInitializedAttributes(const std::vector<AttributeInitializerResult> &attributes);
@@ -155,7 +155,7 @@ public:
// Implements proton::IAttributeManager
- proton::IAttributeManager::SP create(const Spec &spec) const override;
+ proton::IAttributeManager::SP create(Spec && spec) const override;
std::vector<IFlushTargetSP> getFlushTargets() const override;
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp
index d0caf92be17..88475db472c 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp
@@ -78,7 +78,7 @@ FilterAttributeManager::createContext() const {
}
IAttributeManager::SP
-FilterAttributeManager::create(const AttributeCollectionSpec &) const {
+FilterAttributeManager::create(AttributeCollectionSpec &&) const {
throw vespalib::IllegalArgumentException("Not implemented");
}
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h
index e291aca6922..1a0fdcb32aa 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h
+++ b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h
@@ -38,7 +38,7 @@ public:
std::unique_ptr<search::attribute::AttributeReadGuard> getAttributeReadGuard(const vespalib::string &name, bool stableEnumGuard) const override;
// Implements proton::IAttributeManager
- IAttributeManager::SP create(const AttributeCollectionSpec &) const override;
+ IAttributeManager::SP create(AttributeCollectionSpec &&) const override;
std::vector<searchcorespi::IFlushTarget::SP> getFlushTargets() const override;
search::SerialNum getOldestFlushedSerialNumber() const override;
search::SerialNum getNewestFlushedSerialNumber() const override;
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h b/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h
index d32052fe4fa..4b6b8dc687c 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h
+++ b/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h
@@ -39,7 +39,7 @@ struct IAttributeManager : public search::IAttributeManager
* Create a new attribute manager based on the content of the current one and
* the given attribute collection spec.
*/
- virtual IAttributeManager::SP create(const AttributeCollectionSpec &spec) const = 0;
+ virtual IAttributeManager::SP create(AttributeCollectionSpec && spec) const = 0;
/**
* Return the list of flush targets for this attribute manager.
diff --git a/searchcore/src/vespa/searchcore/proton/server/attribute_writer_factory.h b/searchcore/src/vespa/searchcore/proton/server/attribute_writer_factory.h
index d95dfd1314e..6ca4556d666 100644
--- a/searchcore/src/vespa/searchcore/proton/server/attribute_writer_factory.h
+++ b/searchcore/src/vespa/searchcore/proton/server/attribute_writer_factory.h
@@ -14,11 +14,11 @@ struct AttributeWriterFactory : public IAttributeWriterFactory
{
AttributeWriterFactory() {}
IAttributeWriter::SP create(const IAttributeWriter::SP &old,
- const AttributeCollectionSpec &attrSpec) const override
+ AttributeCollectionSpec && attrSpec) const override
{
const AttributeWriter &oldAdapter = dynamic_cast<const AttributeWriter &>(*old.get());
const proton::IAttributeManager::SP &oldMgr = oldAdapter.getAttributeManager();
- proton::IAttributeManager::SP newMgr = oldMgr->create(attrSpec);
+ proton::IAttributeManager::SP newMgr = oldMgr->create(std::move(attrSpec));
return std::make_shared<AttributeWriter>(newMgr);
}
};
diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp
index 6f9cbf42efe..4c04dc694fa 100644
--- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp
@@ -47,10 +47,11 @@ FastAccessDocSubDBConfigurer::~FastAccessDocSubDBConfigurer() = default;
IReprocessingInitializer::UP
FastAccessDocSubDBConfigurer::reconfigure(const DocumentDBConfig &newConfig,
const DocumentDBConfig &oldConfig,
- const AttributeCollectionSpec &attrSpec)
+ AttributeCollectionSpec && attrSpec)
{
FastAccessFeedView::SP oldView = _feedView.get();
- IAttributeWriter::SP writer = _factory->create(oldView->getAttributeWriter(), attrSpec);
+ search::SerialNum currentSerialNum = attrSpec.getCurrentSerialNum();
+ IAttributeWriter::SP writer = _factory->create(oldView->getAttributeWriter(), std::move(attrSpec));
reconfigureFeedView(*oldView, newConfig.getSchemaSP(), newConfig.getDocumentTypeRepoSP(), writer);
const document::DocumentType *newDocType = newConfig.getDocumentType();
@@ -62,7 +63,7 @@ FastAccessDocSubDBConfigurer::reconfigure(const DocumentDBConfig &newConfig,
return std::make_unique<AttributeReprocessingInitializer>
(ARIConfig(writer->getAttributeManager(), *newConfig.getSchemaSP()),
ARIConfig(oldView->getAttributeWriter()->getAttributeManager(), *oldConfig.getSchemaSP()),
- inspector, oldIndexschemaInspector, _subDbName, attrSpec.getCurrentSerialNum());
+ inspector, oldIndexschemaInspector, _subDbName, currentSerialNum);
}
} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h
index 6cde1a71794..9435cc14e30 100644
--- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h
+++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h
@@ -35,7 +35,7 @@ public:
IReprocessingInitializer::UP reconfigure(const DocumentDBConfig &newConfig,
const DocumentDBConfig &oldConfig,
- const AttributeCollectionSpec &attrSpec);
+ AttributeCollectionSpec && attrSpec);
};
} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/i_attribute_writer_factory.h b/searchcore/src/vespa/searchcore/proton/server/i_attribute_writer_factory.h
index da1f76b7a38..7662d1cb164 100644
--- a/searchcore/src/vespa/searchcore/proton/server/i_attribute_writer_factory.h
+++ b/searchcore/src/vespa/searchcore/proton/server/i_attribute_writer_factory.h
@@ -12,9 +12,9 @@ namespace proton {
struct IAttributeWriterFactory
{
using UP = std::unique_ptr<IAttributeWriterFactory>;
- virtual ~IAttributeWriterFactory() {}
+ virtual ~IAttributeWriterFactory() = default;
virtual IAttributeWriter::SP create(const IAttributeWriter::SP &old,
- const AttributeCollectionSpec &attrSpec) const = 0;
+ AttributeCollectionSpec && attrSpec) const = 0;
};
} // namespace proton
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 89c8f3de0b1..a182c4efb5c 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
@@ -174,14 +174,14 @@ createAttributeReprocessingInitializer(const DocumentDBConfig &newConfig,
IReprocessingInitializer::UP
SearchableDocSubDBConfigurer::reconfigure(const DocumentDBConfig &newConfig,
const DocumentDBConfig &oldConfig,
- const AttributeCollectionSpec &attrSpec,
+ AttributeCollectionSpec && attrSpec,
const ReconfigParams &params,
IDocumentDBReferenceResolver &resolver)
{
bool shouldMatchViewChange = false;
bool shouldSearchViewChange = false;
bool shouldFeedViewChange = params.shouldSchemaChange();
-
+ search::SerialNum currentSerialNum = attrSpec.getCurrentSerialNum();
SearchView::SP searchView = _searchView.get();
Matchers::SP matchers = searchView->getMatchers();
if (params.shouldMatchersChange()) {
@@ -197,7 +197,7 @@ SearchableDocSubDBConfigurer::reconfigure(const DocumentDBConfig &newConfig,
IAttributeManager::SP attrMgr = searchView->getAttributeManager();
IAttributeWriter::SP attrWriter = _feedView.get()->getAttributeWriter();
if (params.shouldAttributeManagerChange()) {
- IAttributeManager::SP newAttrMgr = attrMgr->create(attrSpec);
+ IAttributeManager::SP newAttrMgr = attrMgr->create(std::move(attrSpec));
newAttrMgr->setImportedAttributes(resolver.resolve(*newAttrMgr, *attrMgr,
searchView->getDocumentMetaStore(),
newConfig.getMaintenanceConfigSP()->getVisibilityDelay()));
@@ -209,7 +209,7 @@ SearchableDocSubDBConfigurer::reconfigure(const DocumentDBConfig &newConfig,
attrWriter = newAttrWriter;
shouldFeedViewChange = true;
initializer = createAttributeReprocessingInitializer(newConfig, newAttrMgr, oldConfig, oldAttrMgr,
- _subDbName, attrSpec.getCurrentSerialNum());
+ _subDbName, currentSerialNum);
} else if (params.shouldAttributeWriterChange()) {
attrWriter = std::make_shared<AttributeWriter>(attrMgr);
shouldFeedViewChange = true;
diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h
index 7112cf7931e..b19ebb1546e 100644
--- a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h
+++ b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h
@@ -90,7 +90,7 @@ public:
IReprocessingInitializer::UP
reconfigure(const DocumentDBConfig &newConfig,
const DocumentDBConfig &oldConfig,
- const AttributeCollectionSpec &attrSpec,
+ AttributeCollectionSpec && attrSpec,
const ReconfigParams &params,
IDocumentDBReferenceResolver &resolver);
};
diff --git a/searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt
index 5df9060ea07..25570c4ad0c 100644
--- a/searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt
+++ b/searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt
@@ -1,6 +1,7 @@
# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
vespa_add_library(searchcore_test STATIC
SOURCES
+ attribute_utils.cpp
attribute_vectors.cpp
bucketfactory.cpp
buckethandler.cpp
diff --git a/searchcore/src/vespa/searchcore/proton/test/attribute_utils.cpp b/searchcore/src/vespa/searchcore/proton/test/attribute_utils.cpp
new file mode 100644
index 00000000000..9dde79b342a
--- /dev/null
+++ b/searchcore/src/vespa/searchcore/proton/test/attribute_utils.cpp
@@ -0,0 +1,76 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include "attribute_utils.h"
+#include <vespa/vespalib/util/hdr_abort.h>
+#include <vespa/searchcommon/attribute/config.h>
+#include <vespa/searchlib/attribute/integerbase.h>
+
+using search::attribute::Config;
+using search::attribute::BasicType;
+using search::attribute::CollectionType;
+
+namespace proton::test {
+
+void
+AttributeUtils::fillAttribute(search::AttributeVector & attr, uint32_t numDocs, int64_t value, uint64_t lastSyncToken) {
+ search::IntegerAttribute &ia = static_cast<search::IntegerAttribute &>(attr);
+ ia.addDocs(numDocs);
+ for (uint32_t i = 1; i < ia.getNumDocs(); ++i) {
+ ia.update(i, value);
+ }
+ ia.commit(search::CommitParam(lastSyncToken));
+}
+
+void
+AttributeUtils::fillAttribute(search::AttributeVector & attr, uint32_t from, uint32_t to, int64_t value, uint64_t lastSyncToken) {
+ search::IntegerAttribute &ia = static_cast<search::IntegerAttribute &>(attr);
+ while (ia.getNumDocs() < to) {
+ uint32_t docId;
+ if (!ia.addDoc(docId)) { HDR_ABORT("should not be reached"); }
+ }
+ for (uint32_t i = from; i < to; ++i) {
+ ia.update(i, value);
+ }
+ ia.commit(search::CommitParam(lastSyncToken));
+}
+
+const Config &
+AttributeUtils::getInt32Config() {
+ static Config cfg(BasicType::INT32);
+ return cfg;
+}
+
+const Config &
+AttributeUtils::getInt32ArrayConfig() {
+ static Config cfg(BasicType::INT32, CollectionType::ARRAY);
+ return cfg;
+}
+
+const Config &
+AttributeUtils::getStringConfig() {
+ static Config cfg(BasicType::STRING);
+ return cfg;
+}
+
+const Config &
+AttributeUtils::getPredicateConfig() {
+ static Config cfg(BasicType::PREDICATE);
+ return cfg;
+}
+
+namespace {
+
+Config tensorConfig() {
+ return Config(BasicType::TENSOR).setTensorType(vespalib::eval::ValueType::from_spec("tensor(x{},y{})"));
+}
+
+}
+
+const Config &
+AttributeUtils::getTensorConfig() {
+ static Config cfg = tensorConfig();
+ return cfg;
+}
+
+}
+
diff --git a/searchcore/src/vespa/searchcore/proton/test/attribute_utils.h b/searchcore/src/vespa/searchcore/proton/test/attribute_utils.h
index c296129984b..bb0a7318b21 100644
--- a/searchcore/src/vespa/searchcore/proton/test/attribute_utils.h
+++ b/searchcore/src/vespa/searchcore/proton/test/attribute_utils.h
@@ -1,51 +1,23 @@
// 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/searchcommon/attribute/config.h>
-#include <vespa/searchlib/attribute/integerbase.h>
+#include <cstdint>
+
+namespace search { class AttributeVector; }
+namespace search::attribute { class Config; }
namespace proton::test {
struct AttributeUtils
{
- static void fillAttribute(const search::AttributeVector::SP &attr,
- uint32_t numDocs, int64_t value, uint64_t lastSyncToken) {
- search::IntegerAttribute &ia = static_cast<search::IntegerAttribute &>(*attr);
- ia.addDocs(numDocs);
- for (uint32_t i = 1; i < ia.getNumDocs(); ++i) {
- ia.update(i, value);
- }
- ia.commit(search::CommitParam(lastSyncToken));
- }
- static void fillAttribute(const search::AttributeVector::SP &attr,
- uint32_t from, uint32_t to, int64_t value, uint64_t lastSyncToken) {
- search::IntegerAttribute &ia = static_cast<search::IntegerAttribute &>(*attr);
- while (ia.getNumDocs() < to) {
- uint32_t docId;
- if (!ia.addDoc(docId)) { HDR_ABORT("should not be reached"); }
- }
- for (uint32_t i = from; i < to; ++i) {
- ia.update(i, value);
- }
- ia.commit(search::CommitParam(lastSyncToken));
- }
- static search::attribute::Config getInt32Config() {
- return search::attribute::Config(search::attribute::BasicType::INT32);
- }
- static search::attribute::Config getInt32ArrayConfig() {
- return search::attribute::Config(search::attribute::BasicType::INT32,
- search::attribute::CollectionType::ARRAY);
- }
- static search::attribute::Config getStringConfig() {
- return search::attribute::Config(search::attribute::BasicType::STRING);
- }
- static search::attribute::Config getPredicateConfig() {
- return search::attribute::Config(search::attribute::BasicType::PREDICATE);
- }
- static search::attribute::Config getTensorConfig() {
- return search::attribute::Config(search::attribute::BasicType::TENSOR).setTensorType(vespalib::eval::ValueType::from_spec("tensor(x{},y{})"));
- }
+ using Config = search::attribute::Config;
+ static void fillAttribute(search::AttributeVector &attr, uint32_t numDocs, int64_t value, uint64_t lastSyncToken);
+ static void fillAttribute(search::AttributeVector &attr, uint32_t from, uint32_t to, int64_t value, uint64_t lastSyncToken);
+ static const Config & getInt32Config();
+ static const Config & getInt32ArrayConfig();
+ static const Config & getStringConfig();
+ static const Config & getPredicateConfig();
+ static const Config & getTensorConfig();
};
}
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 4549f24d4e3..75bb3291dd0 100644
--- a/searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h
+++ b/searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h
@@ -49,7 +49,7 @@ public:
search::attribute::IAttributeContext::UP createContext() const override {
return _mock.createContext();
}
- IAttributeManager::SP create(const AttributeCollectionSpec &) const override {
+ IAttributeManager::SP create(AttributeCollectionSpec &&) const override {
return IAttributeManager::SP();
}
std::vector<searchcorespi::IFlushTarget::SP> getFlushTargets() const override {