diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-08-20 23:43:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-20 23:43:08 +0200 |
commit | 5f4168bb32e20f5700b8e63a38b52e3d83a0e3a0 (patch) | |
tree | fd342a92b69b41fac2a35038e3a21cb2eeb89294 /searchcore | |
parent | 3f91e18528b4982398332a30728eed8f7d2b580c (diff) | |
parent | 1d930cbddc00bf9a761eae48a2fd89bd6c5cc570 (diff) |
Merge pull request #6630 from vespa-engine/balder/make-shared-unique-plusplus
Use std::make_xxx
Diffstat (limited to 'searchcore')
19 files changed, 134 insertions, 265 deletions
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 4957d3aead2..b28e04f659f 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 @@ -8,7 +8,6 @@ #include <vespa/searchcore/proton/test/attribute_utils.h> #include <vespa/searchlib/attribute/attributefactory.h> #include <vespa/searchlib/test/directory_handler.h> -#include <vespa/vespalib/stllike/string.h> #include <vespa/log/log.h> LOG_SETUP("attribute_initializer_test"); @@ -88,7 +87,7 @@ Fixture::Fixture() { } -Fixture::~Fixture() {} +Fixture::~Fixture() = default; std::unique_ptr<AttributeInitializer> Fixture::createInitializer(const AttributeSpec &spec, SerialNum serialNum) diff --git a/searchcore/src/tests/proton/attribute/exclusive_attribute_read_accessor/exclusive_attribute_read_accessor_test.cpp b/searchcore/src/tests/proton/attribute/exclusive_attribute_read_accessor/exclusive_attribute_read_accessor_test.cpp index c5ae0f97875..420e18db5af 100644 --- a/searchcore/src/tests/proton/attribute/exclusive_attribute_read_accessor/exclusive_attribute_read_accessor_test.cpp +++ b/searchcore/src/tests/proton/attribute/exclusive_attribute_read_accessor/exclusive_attribute_read_accessor_test.cpp @@ -4,6 +4,7 @@ #include <vespa/searchcore/proton/attribute/exclusive_attribute_read_accessor.h> #include <vespa/searchcommon/attribute/config.h> #include <vespa/searchlib/attribute/attributefactory.h> +#include <vespa/searchlib/attribute/attributevector.h> #include <vespa/searchlib/common/sequencedtaskexecutor.h> #include <vespa/vespalib/util/gate.h> 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 72e558fd25f..219c2c42bd7 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 @@ -1,6 +1,4 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/log/log.h> -LOG_SETUP("attribute_reprocessing_initializer_test"); #include <vespa/searchcore/proton/attribute/attribute_directory.h> #include <vespa/searchcore/proton/attribute/attribute_populator.h> @@ -19,6 +17,9 @@ LOG_SETUP("attribute_reprocessing_initializer_test"); #include <vespa/vespalib/test/insertion_operators.h> #include <vespa/vespalib/testkit/testapp.h> +#include <vespa/log/log.h> +LOG_SETUP("attribute_reprocessing_initializer_test"); + using namespace proton; using namespace search; using namespace search::index; @@ -91,7 +92,7 @@ MyConfig::MyConfig() _attributeFieldWriter, _hwInfo)), _schema() {} -MyConfig::~MyConfig() {} +MyConfig::~MyConfig() = default; struct MyDocTypeInspector : public IDocumentTypeInspector { @@ -162,17 +163,13 @@ struct Fixture "test", INIT_SERIAL_NUM)); _initializer->initialize(_handler); } - Fixture &addOldConfig(const StringVector &fields, - const StringVector &attrs) { + Fixture &addOldConfig(const StringVector &fields, const StringVector &attrs) { return addConfig(fields, attrs, _oldCfg); } - Fixture &addNewConfig(const StringVector &fields, - const StringVector &attrs) { + Fixture &addNewConfig(const StringVector &fields, const StringVector &attrs) { return addConfig(fields, attrs, _newCfg); } - Fixture &addConfig(const StringVector &fields, - const StringVector &attrs, - MyConfig &cfg) { + Fixture &addConfig(const StringVector &fields, const StringVector &attrs, MyConfig &cfg) { cfg.addFields(fields); cfg.addAttrs(attrs); return *this; @@ -181,10 +178,8 @@ struct Fixture if (expAttrs.empty()) { if (!EXPECT_TRUE(_handler._reader.get() == nullptr)) return false; } else { - const AttributePopulator &populator = - dynamic_cast<const AttributePopulator &>(*_handler._reader); - std::vector<search::AttributeVector *> attrList = - populator.getWriter().getWritableAttributes(); + const auto & populator = dynamic_cast<const AttributePopulator &>(*_handler._reader); + std::vector<search::AttributeVector *> attrList = populator.getWriter().getWritableAttributes(); std::set<vespalib::string> actAttrs; for (const auto attr : attrList) { actAttrs.insert(attr->getName()); @@ -199,8 +194,7 @@ struct Fixture } else { StringSet actFields; for (auto rewriter : _handler._rewriters) { - const DocumentFieldPopulator &populator = - dynamic_cast<const DocumentFieldPopulator &>(*rewriter); + const auto & populator = dynamic_cast<const DocumentFieldPopulator &>(*rewriter); actFields.insert(populator.getAttribute().getName()); } if (!EXPECT_EQUAL(expFields, actFields)) return false; @@ -273,16 +267,14 @@ TEST_F("require that initializer can setup both attribute and document field pop TEST_F("require that tensor fields are not populated from attribute", Fixture) { - f.addOldConfig({"a", "b", "c", "d", "tensor"}, - {"a", "b", "c", "d", "tensor"}). + f.addOldConfig({"a", "b", "c", "d", "tensor"}, {"a", "b", "c", "d", "tensor"}). addNewConfig({"a", "b", "c", "d", "tensor"}, {"a", "b"}).init(); EXPECT_TRUE(f.assertFields({"c", "d"})); } TEST_F("require that predicate fields are not populated from attribute", Fixture) { - f.addOldConfig({"a", "b", "c", "d", "predicate"}, - {"a", "b", "c", "d", "predicate"}). + f.addOldConfig({"a", "b", "c", "d", "predicate"}, {"a", "b", "c", "d", "predicate"}). addNewConfig({"a", "b", "c", "d", "predicate"}, {"a", "b"}).init(); EXPECT_TRUE(f.assertFields({"c", "d"})); } diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h index 6127e12b94a..603727dbb75 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h @@ -26,12 +26,12 @@ public: private: std::weak_ptr<AttributeDiskLayout> _diskLayout; - const vespalib::string _name; - fastos::TimeStamp _lastFlushTime; - Writer *_writer; // current writer - mutable std::mutex _mutex; + const vespalib::string _name; + fastos::TimeStamp _lastFlushTime; + Writer *_writer; // current writer + mutable std::mutex _mutex; std::condition_variable _cv; - search::IndexMetaInfo _snapInfo; + search::IndexMetaInfo _snapInfo; void saveSnapInfo(); vespalib::string getSnapshotDir(SerialNum serialNum); @@ -50,6 +50,8 @@ public: const vespalib::string &name); ~AttributeDirectory(); + const vespalib::string & getAttrName() const { return _name; } + /* * Class to make changes to an attribute directory in a * controlled manner. An exclusive lock is held during lifetime to diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_factory.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_factory.cpp index 063886ab64f..7d91538f657 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_factory.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_factory.cpp @@ -2,18 +2,17 @@ #include "attribute_factory.h" #include <vespa/searchlib/attribute/attributefactory.h> +#include <vespa/searchlib/attribute/attributevector.h> + namespace proton { using search::AttributeVector; -AttributeFactory::AttributeFactory() -{ -} +AttributeFactory::AttributeFactory() = default; AttributeVector::SP -AttributeFactory::create(const vespalib::string &name, - const search::attribute::Config &cfg) const +AttributeFactory::create(const vespalib::string &name, const search::attribute::Config &cfg) const { AttributeVector::SP v(search::AttributeFactory::createAttribute(name, cfg)); v->enableEnumeratedSave(true); @@ -21,8 +20,7 @@ AttributeFactory::create(const vespalib::string &name, } void -AttributeFactory::setupEmpty(const AttributeVector::SP &vec, - search::SerialNum serialNum) const +AttributeFactory::setupEmpty(const AttributeVector::SP &vec, search::SerialNum serialNum) const { vec->setCreateSerialNum(serialNum); vec->addReservedDoc(); diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_factory.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_factory.h index e25715eaa14..21abad1a2a6 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_factory.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_factory.h @@ -15,13 +15,8 @@ public: typedef std::shared_ptr<AttributeFactory> SP; AttributeFactory(); - // Implements IAttributeFactory - virtual AttributeVectorSP create(const vespalib::string &name, - const search::attribute::Config &cfg) const override; - - virtual void setupEmpty(const AttributeVectorSP &vec, - search::SerialNum serialNum) const override; + AttributeVectorSP create(const vespalib::string &name, const search::attribute::Config &cfg) const override; + void setupEmpty(const AttributeVectorSP &vec, search::SerialNum serialNum) const override; }; -} // 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 a98becb7af7..d8970d79ef2 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp @@ -121,30 +121,21 @@ extractHeader(const vespalib::string &attrFileName) } void -logAttributeTooNew(const AttributeVector::SP &attr, - const AttributeHeader &header, - uint64_t serialNum) +logAttributeTooNew(const AttributeHeader &header, uint64_t serialNum) { LOG(info, "Attribute vector '%s' is too new (%" PRIu64 " > %" PRIu64 ")", - attr->getBaseFileName().c_str(), - header.getCreateSerialNum(), - serialNum); + header.getFileName().c_str(), header.getCreateSerialNum(), serialNum); } void -logAttributeTooOld(const AttributeVector::SP &attr, - search::SerialNum flushedSerialNum, - uint64_t serialNum) +logAttributeTooOld(const AttributeHeader &header, uint64_t flushedSerialNum, uint64_t serialNum) { LOG(info, "Attribute vector '%s' is too old (%" PRIu64 " < %" PRIu64 ")", - attr->getBaseFileName().c_str(), - flushedSerialNum, - serialNum); + header.getFileName().c_str(), flushedSerialNum, serialNum); } void -logAttributeWrongType(const AttributeVector::SP &attr, - const AttributeHeader &header) +logAttributeWrongType(const AttributeVector::SP &attr, const AttributeHeader &header) { const Config &cfg(attr->getConfig()); vespalib::string extraCfgType = extraType(cfg); @@ -152,13 +143,8 @@ logAttributeWrongType(const AttributeVector::SP &attr, vespalib::string cfgCollStr = collectionTypeString(cfg.collectionType(), true); vespalib::string headerCollStr = collectionTypeString(header.getCollectionType(), header.getCollectionTypeParamsSet()); LOG(info, "Attribute vector '%s' is of wrong type (expected %s/%s/%s, got %s/%s/%s)", - attr->getBaseFileName().c_str(), - cfg.basicType().asString(), - cfgCollStr.c_str(), - extraCfgType.c_str(), - header.getBasicType().asString(), - headerCollStr.c_str(), - extraHeaderType.c_str()); + header.getFileName().c_str(), cfg.basicType().asString(), cfgCollStr.c_str(), extraCfgType.c_str(), + header.getBasicType().asString(), headerCollStr.c_str(), extraHeaderType.c_str()); } } @@ -192,9 +178,8 @@ AttributeInitializer::loadAttribute(const AttributeVectorSP &attr, fastos::TimeStamp startTime = fastos::ClockSystem::now(); EventLogger::loadAttributeStart(_documentSubDbName, attr->getName()); if (!attr->load()) { - LOG(warning, "Could not load attribute vector '%s' from disk. " - "Returning empty attribute vector", - attr->getBaseFileName().c_str()); + LOG(warning, "Could not load attribute vector '%s' from disk. Returning empty attribute vector", + attr->getBaseFileName().c_str()); return false; } else { attr->commit(serialNum, serialNum); @@ -206,21 +191,19 @@ AttributeInitializer::loadAttribute(const AttributeVectorSP &attr, } void -AttributeInitializer::setupEmptyAttribute(AttributeVectorSP &attr, - search::SerialNum serialNum, +AttributeInitializer::setupEmptyAttribute(AttributeVectorSP &attr, search::SerialNum serialNum, const AttributeHeader &header) const { if (header.getCreateSerialNum() > _currentSerialNum) { - logAttributeTooNew(attr, header, _currentSerialNum); + logAttributeTooNew(header, _currentSerialNum); } if (serialNum < _currentSerialNum) { - logAttributeTooOld(attr, serialNum, _currentSerialNum); + logAttributeTooOld(header, serialNum, _currentSerialNum); } if (!headerTypeOK(header, attr->getConfig())) { logAttributeWrongType(attr, header); } - LOG(info, "Returning empty attribute vector for '%s'", - attr->getBaseFileName().c_str()); + LOG(info, "Returning empty attribute vector for '%s'", attr->getBaseFileName().c_str()); _factory.setupEmpty(attr, _currentSerialNum); attr->commit(serialNum, serialNum); } @@ -228,8 +211,7 @@ AttributeInitializer::setupEmptyAttribute(AttributeVectorSP &attr, AttributeVector::SP AttributeInitializer::createAndSetupEmptyAttribute() const { - vespalib::string attrFileName = _attrDir->getAttributeFileName(0); - AttributeVector::SP attr = _factory.create(attrFileName, _spec.getConfig()); + AttributeVector::SP attr = _factory.create(_attrDir->getAttrName(), _spec.getConfig()); _factory.setupEmpty(attr, _currentSerialNum); return attr; } @@ -247,7 +229,7 @@ AttributeInitializer::AttributeInitializer(const std::shared_ptr<AttributeDirect { } -AttributeInitializer::~AttributeInitializer() {} +AttributeInitializer::~AttributeInitializer() = default; AttributeInitializerResult AttributeInitializer::init() const diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.h index 5c03a657f4f..c2ea83812cb 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.h @@ -8,9 +8,7 @@ #include <vespa/searchlib/common/serialnum.h> #include <vespa/searchcommon/attribute/persistent_predicate_params.h> -namespace search { -namespace attribute { class AttributeHeader; } -} +namespace search::attribute { class AttributeHeader; } namespace proton { @@ -35,21 +33,16 @@ private: AttributeVectorSP tryLoadAttribute() const; - bool loadAttribute(const AttributeVectorSP &attr, - search::SerialNum serialNum) const; + bool loadAttribute(const AttributeVectorSP &attr, search::SerialNum serialNum) const; - void setupEmptyAttribute(AttributeVectorSP &attr, - search::SerialNum serialNum, + void setupEmptyAttribute(AttributeVectorSP &attr, search::SerialNum serialNum, const search::attribute::AttributeHeader &header) const; AttributeVectorSP createAndSetupEmptyAttribute() const; public: - AttributeInitializer(const std::shared_ptr<AttributeDirectory> &attrDir, - const vespalib::string &documentSubDbName, - const AttributeSpec &spec, - uint64_t currentSerialNum, - const IAttributeFactory &factory); + AttributeInitializer(const std::shared_ptr<AttributeDirectory> &attrDir, const vespalib::string &documentSubDbName, + const AttributeSpec &spec, uint64_t currentSerialNum, const IAttributeFactory &factory); ~AttributeInitializer(); AttributeInitializerResult init() const; diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_spec.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_spec.cpp index 45b800c64cf..20e6798c79b 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_spec.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_spec.cpp @@ -21,7 +21,7 @@ AttributeSpec::AttributeSpec(AttributeSpec &&) = default; AttributeSpec & AttributeSpec::operator=(AttributeSpec &&) = default; -AttributeSpec::~AttributeSpec() { } +AttributeSpec::~AttributeSpec() = default; bool AttributeSpec::operator==(const AttributeSpec &rhs) const diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp index a675927b85f..5f057bbd7dc 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp @@ -17,9 +17,7 @@ AttributeDiskLayout::AttributeDiskLayout(const vespalib::string &baseDir, Privat vespalib::File::sync(vespalib::dirname(_baseDir)); } -AttributeDiskLayout::~AttributeDiskLayout() -{ -} +AttributeDiskLayout::~AttributeDiskLayout() = default; std::vector<vespalib::string> AttributeDiskLayout::listAttributes() diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp index abe4863955f..87248e060c9 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp @@ -145,7 +145,7 @@ AttributeManager::internalAddAttribute(const AttributeSpec &spec, void AttributeManager::addAttribute(const AttributeWrap &attribute, const ShrinkerSP &shrinker) { - LOG(debug, "Adding attribute vector '%s'", attribute.getAttribute()->getBaseFileName().c_str()); + LOG(debug, "Adding attribute vector '%s'", attribute.getAttribute()->getName().c_str()); _attributes[attribute.getAttribute()->getName()] = attribute; assert(attribute.getAttribute()->getInterlock() == _interlock); if ( ! attribute.isExtra() ) { diff --git a/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp b/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp index da6700739b6..1d4133c8162 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp @@ -2,20 +2,20 @@ #include "attributedisklayout.h" #include "flushableattribute.h" +#include "attribute_directory.h" #include <vespa/searchlib/attribute/attributefilesavetarget.h> #include <vespa/searchlib/attribute/attributesaver.h> #include <vespa/searchlib/util/dirtraverse.h> #include <vespa/searchlib/util/filekit.h> #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/util/closuretask.h> -#include <fstream> #include <vespa/searchlib/common/serialnumfileheadercontext.h> #include <vespa/searchlib/common/isequencedtaskexecutor.h> #include <vespa/searchlib/attribute/attributememorysavetarget.h> #include <vespa/searchlib/attribute/attributevector.h> -#include <future> -#include "attribute_directory.h" #include <vespa/vespalib/util/stringfmt.h> +#include <fstream> +#include <future> #include <vespa/log/log.h> LOG_SETUP(".proton.attribute.flushableattribute"); @@ -166,10 +166,7 @@ FlushableAttribute::FlushableAttribute(const AttributeVectorSP attr, search::ISequencedTaskExecutor & attributeFieldWriter, const HwInfo &hwInfo) - : IFlushTarget(vespalib::make_string( - "attribute.flush.%s", - attr->getName().c_str()), - Type::SYNC, Component::ATTRIBUTE), + : IFlushTarget(make_string("attribute.flush.%s", attr->getName().c_str()), Type::SYNC, Component::ATTRIBUTE), _attr(attr), _cleanUpAfterFlush(true), _lastStats(), @@ -183,10 +180,7 @@ FlushableAttribute::FlushableAttribute(const AttributeVectorSP attr, } -FlushableAttribute::~FlushableAttribute() -{ -} - +FlushableAttribute::~FlushableAttribute() = default; IFlushTarget::SerialNum FlushableAttribute::getFlushedSerialNum() const diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp index 4be05d7d64a..c03c93b5fd9 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp @@ -301,10 +301,8 @@ DocumentMetaStore::onLoad() } bool -DocumentMetaStore::checkBuckets(const GlobalId &gid, - const BucketId &bucketId, - const TreeType::Iterator &itr, - bool found) +DocumentMetaStore::checkBuckets(const GlobalId &gid, const BucketId &bucketId, + const TreeType::Iterator &itr, bool found) { bool success = true; #if 0 @@ -394,8 +392,7 @@ DocumentMetaStore::updateMetaDataAndBucketDB(const GlobalId &gid, } -namespace -{ +namespace { void unloadBucket(BucketDBOwner &db, const BucketId &id, const BucketState &delta) diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h index d8384de3596..2fd3bcdae64 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h @@ -17,17 +17,15 @@ #include <vespa/searchlib/queryeval/blueprint.h> #include <vespa/searchlib/docstore/ibucketizer.h> -namespace proton { - -namespace bucketdb { - -class SplitBucketSession; -class JoinBucketsSession; - +namespace proton::bucketdb { + class SplitBucketSession; + class JoinBucketsSession; } -namespace documentmetastore { class Reader; } +namespace proton::documentmetastore { class Reader; } +namespace proton { + /** * This class provides a storage of <lid, meta data> pairs (local * document id, meta data (including global document id)) and mapping @@ -63,10 +61,8 @@ private: // Lids are stored as keys in the tree, sorted by their gid // counterpart. The LidGidKeyComparator class maps from lids -> metadata by // using the metadata store. - typedef search::btree::BTree<DocId, - search::btree::BTreeNoLeafData, - search::btree::NoAggregated, - const KeyComp &> TreeType; + typedef search::btree::BTree<DocId, search::btree::BTreeNoLeafData, + search::btree::NoAggregated, const KeyComp &> TreeType; MetaDataStore _metaDataStore; TreeType _gidToLidMap; @@ -164,14 +160,9 @@ public: * map is then re-built the same way it was originally where add() * was used to create the <lid, gid> pairs. **/ - Result put(const GlobalId &gid, - const BucketId &bucketId, - const Timestamp ×tamp, - uint32_t docSize, - DocId lid) override; - bool updateMetaData(DocId lid, - const BucketId &bucketId, - const Timestamp ×tamp) override; + Result put(const GlobalId &gid, const BucketId &bucketId, + const Timestamp ×tamp, uint32_t docSize, DocId lid) override; + bool updateMetaData(DocId lid, const BucketId &bucketId, const Timestamp ×tamp) override; bool remove(DocId lid) override; BucketId getBucketOf(const vespalib::GenerationHandler::Guard & guard, uint32_t lid) const override; @@ -213,8 +204,7 @@ public: */ SearchContext::UP getSearch(std::unique_ptr<search::QueryTermSimple> qTerm, - const search::attribute::SearchContextParams ¶ms) - const override; + const search::attribute::SearchContextParams ¶ms) const override; /** * Implements proton::IDocumentMetaStore @@ -270,11 +260,11 @@ public: */ void unblockShrinkLidSpace(); void onShrinkLidSpace() override; - virtual size_t getEstimatedShrinkLidSpaceGain() const override; + size_t getEstimatedShrinkLidSpaceGain() const override; uint64_t getEstimatedSaveByteSize() const override; - virtual uint32_t getVersion() const override; + uint32_t getVersion() const override; void setTrackDocumentSizes(bool trackDocumentSizes) { _trackDocumentSizes = trackDocumentSizes; } - virtual void foreach(const search::IGidToLidMapperVisitor &visitor) const override; + void foreach(const search::IGidToLidMapperVisitor &visitor) const override; }; } diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp index 241a2449e17..56ecdaa0cb0 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp @@ -48,14 +48,9 @@ public: bool flush(AttributeDirectory::Writer &writer); void updateStats(); bool cleanUp(AttributeDirectory::Writer &writer); - // Implements vespalib::Executor::Task - virtual void run() override; + void run() override; - virtual SerialNum - getFlushSerial() const override - { - return _syncToken; - } + SerialNum getFlushSerial() const override { return _syncToken; } }; DocumentMetaStoreFlushTarget::Flusher:: @@ -163,12 +158,9 @@ DocumentMetaStoreFlushTarget::Flusher::run() } DocumentMetaStoreFlushTarget:: -DocumentMetaStoreFlushTarget(const DocumentMetaStore::SP dms, - ITlsSyncer &tlsSyncer, - const vespalib::string & baseDir, - const TuneFileAttributes &tuneFileAttributes, - const FileHeaderContext &fileHeaderContext, - const HwInfo &hwInfo) +DocumentMetaStoreFlushTarget(const DocumentMetaStore::SP dms, ITlsSyncer &tlsSyncer, + const vespalib::string & baseDir, const TuneFileAttributes &tuneFileAttributes, + const FileHeaderContext &fileHeaderContext, const HwInfo &hwInfo) : IFlushTarget("documentmetastore.flush", Type::SYNC, Component::ATTRIBUTE), _dms(dms), _tlsSyncer(tlsSyncer), @@ -186,9 +178,7 @@ DocumentMetaStoreFlushTarget(const DocumentMetaStore::SP dms, } -DocumentMetaStoreFlushTarget::~DocumentMetaStoreFlushTarget() -{ -} +DocumentMetaStoreFlushTarget::~DocumentMetaStoreFlushTarget() = default; IFlushTarget::SerialNum @@ -225,21 +215,18 @@ DocumentMetaStoreFlushTarget::initFlush(SerialNum currentSerial) { // Called by document db executor _dms->removeAllOldGenerations(); - SerialNum syncToken = std::max(currentSerial, - _dms->getStatus().getLastSyncToken()); + SerialNum syncToken = std::max(currentSerial, _dms->getStatus().getLastSyncToken()); auto writer = _dmsDir->tryGetWriter(); if (!writer) { return Task::UP(); } if (syncToken <= getFlushedSerialNum()) { writer->setLastFlushTime(fastos::ClockSystem::now()); - LOG(debug, - "No document meta store to flush." - " Update flush time to current: lastFlushTime(%f)", + LOG(debug, "No document meta store to flush. Update flush time to current: lastFlushTime(%f)", getLastFlushTime().sec()); return Task::UP(); } - return Task::UP(new Flusher(*this, syncToken, *writer)); + return std::make_unique<Flusher>(*this, syncToken, *writer); } @@ -249,5 +236,4 @@ DocumentMetaStoreFlushTarget::getApproxBytesToWriteToDisk() const return _dms->getEstimatedSaveByteSize(); } - } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.h index fb2ce5845a7..5cc674d3614 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.h @@ -6,20 +6,9 @@ #include <vespa/searchlib/common/tunefileinfo.h> #include <vespa/searchcore/proton/common/hw_info.h> -namespace search -{ - -namespace common -{ - -class FileHeaderContext; +namespace search::common { class FileHeaderContext; } -} - -} - -namespace proton -{ +namespace proton { class ITlsSyncer; class AttributeDiskLayout; @@ -57,30 +46,23 @@ public: * Creates a new instance using the given attribute vector and the * given base dir where all attribute vectors are located. **/ - DocumentMetaStoreFlushTarget(const DocumentMetaStoreSP dms, - ITlsSyncer &tlsSyncer, - const vespalib::string &baseDir, - const search::TuneFileAttributes & - tuneFileAttributes, - const search::common::FileHeaderContext & - fileHeaderContext, - const HwInfo &hwInfo); + DocumentMetaStoreFlushTarget(const DocumentMetaStoreSP dms, ITlsSyncer &tlsSyncer, + const vespalib::string &baseDir, const search::TuneFileAttributes &tuneFileAttributes, + const search::common::FileHeaderContext &fileHeaderContext, const HwInfo &hwInfo); - virtual - ~DocumentMetaStoreFlushTarget(); + ~DocumentMetaStoreFlushTarget() override; void setCleanUpAfterFlush(bool cleanUp) { _cleanUpAfterFlush = cleanUp; } - // Implements IFlushTarget - virtual MemoryGain getApproxMemoryGain() const override; - virtual DiskGain getApproxDiskGain() const override; - virtual Time getLastFlushTime() const override; - virtual SerialNum getFlushedSerialNum() const override; - virtual Task::UP initFlush(SerialNum currentSerial) override; - virtual FlushStats getLastFlushStats() const override { return _lastStats; } + MemoryGain getApproxMemoryGain() const override; + DiskGain getApproxDiskGain() const override; + Time getLastFlushTime() const override; + SerialNum getFlushedSerialNum() const override; + Task::UP initFlush(SerialNum currentSerial) override; + FlushStats getLastFlushStats() const override { return _lastStats; } static void initCleanup(const vespalib::string &baseDir); - virtual uint64_t getApproxBytesToWriteToDisk() const override; + uint64_t getApproxBytesToWriteToDisk() const override; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp index 53f6a047fc9..5703f03b32e 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp @@ -13,8 +13,7 @@ using vespalib::IllegalStateException; using proton::initializer::InitializerTask; using vespalib::make_string; -namespace proton { -namespace documentmetastore { +namespace proton::documentmetastore { DocumentMetaStoreInitializer:: DocumentMetaStoreInitializer(const vespalib::string baseDir, @@ -61,7 +60,4 @@ DocumentMetaStoreInitializer::run() } } - -} // namespace proton::documentmetastore - -} // namespace proton +} diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.h index 86f05866c72..6f313645cb2 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.h @@ -8,11 +8,7 @@ #include <vespa/searchcommon/common/growstrategy.h> #include <vespa/vespalib/stllike/string.h> -namespace proton -{ - -namespace documentmetastore -{ +namespace proton::documentmetastore { /* * Class representing an Initializer task for loading document meta store @@ -33,10 +29,8 @@ public: const vespalib::string &subDbName, const vespalib::string &docTypeName, DocumentMetaStore::SP dms); - virtual void run() override; + void run() override; }; -} // namespace proton::documentmetastore - -} // namespace proton +} diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp index 2d3c204d259..acdda10a7ef 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp @@ -62,13 +62,10 @@ IIndexWriter::SP nullIndexWriter; } -StoreOnlyDocSubDB::Config::Config(const DocTypeName &docTypeName, - const vespalib::string &subName, +StoreOnlyDocSubDB::Config::Config(const DocTypeName &docTypeName, const vespalib::string &subName, const vespalib::string &baseDir, - const search::GrowStrategy &attributeGrow, - size_t attributeGrowNumDocs, - uint32_t subDbId, - SubDbType subDbType) + const search::GrowStrategy &attributeGrow, size_t attributeGrowNumDocs, + uint32_t subDbId, SubDbType subDbType) : _docTypeName(docTypeName), _subName(subName), _baseDir(baseDir + "/" + subName), @@ -77,7 +74,7 @@ StoreOnlyDocSubDB::Config::Config(const DocTypeName &docTypeName, _subDbId(subDbId), _subDbType(subDbType) { } -StoreOnlyDocSubDB::Config::~Config() { } +StoreOnlyDocSubDB::Config::~Config() = default; StoreOnlyDocSubDB::Context::Context(IDocumentSubDBOwner &owner, search::transactionlog::SyncProxy &tlSyncer, @@ -102,7 +99,7 @@ StoreOnlyDocSubDB::Context::Context(IDocumentSubDBOwner &owner, _configMutex(configMutex), _hwInfo(hwInfo) { } -StoreOnlyDocSubDB::Context::~Context() { } +StoreOnlyDocSubDB::Context::~Context() = default; StoreOnlyDocSubDB::StoreOnlyDocSubDB(const Config &cfg, const Context &ctx) : DocSubDB(ctx._owner, ctx._tlSyncer), @@ -161,11 +158,7 @@ StoreOnlyDocSubDB::clearViews() { size_t StoreOnlyDocSubDB::getNumDocs() const { - if (_metaStoreCtx) { - return _metaStoreCtx->get().getNumUsedLids(); - } else { - return 0u; - } + return (_metaStoreCtx) ? _metaStoreCtx->get().getNumUsedLids() : 0u; } size_t @@ -209,9 +202,8 @@ StoreOnlyDocSubDB::onReplayDone() void -StoreOnlyDocSubDB::onReprocessDone(SerialNum serialNum) +StoreOnlyDocSubDB::onReprocessDone(SerialNum) { - (void) serialNum; _commitTimeTracker.setReplayDone(); } @@ -292,9 +284,8 @@ StoreOnlyDocSubDB::setupDocumentMetaStore(DocumentMetaStoreInitializerResult::SP if (dms->isLoaded()) { _flushedDocumentMetaStoreSerialNum = dms->getStatus().getLastSyncToken(); } - _bucketDBHandlerInitializer. - addDocumentMetaStore(dms.get(), _flushedDocumentMetaStoreSerialNum); - _metaStoreCtx.reset(new DocumentMetaStoreContext(dms)); + _bucketDBHandlerInitializer.addDocumentMetaStore(dms.get(), _flushedDocumentMetaStoreSerialNum); + _metaStoreCtx = std::make_shared<DocumentMetaStoreContext>(dms); LOG(debug, "Added document meta store '%s' with flushed serial num %lu", name.c_str(), _flushedDocumentMetaStoreSerialNum); _dms = dms; @@ -313,18 +304,15 @@ StoreOnlyDocSubDB::createInitializer(const DocumentDBConfig &configSnapshot, Ser { (void) configSerialNum; (void) indexCfg; - auto result = std::make_unique<DocumentSubDbInitializer> - (const_cast<StoreOnlyDocSubDB &>(*this), - _writeService.master()); - auto dmsInitTask = - createDocumentMetaStoreInitializer(configSnapshot.getTuneFileDocumentDBSP()->_attr, - result->writableResult().writableDocumentMetaStore()); + auto result = std::make_unique<DocumentSubDbInitializer>(const_cast<StoreOnlyDocSubDB &>(*this), + _writeService.master()); + auto dmsInitTask = createDocumentMetaStoreInitializer(configSnapshot.getTuneFileDocumentDBSP()->_attr, + result->writableResult().writableDocumentMetaStore()); result->addDocumentMetaStoreInitTask(dmsInitTask); - auto summaryTask = - createSummaryManagerInitializer(configSnapshot.getStoreConfig(), - configSnapshot.getTuneFileDocumentDBSP()->_summary, - result->result().documentMetaStore()->documentMetaStore(), - result->writableResult().writableSummaryManager()); + auto summaryTask = createSummaryManagerInitializer(configSnapshot.getStoreConfig(), + configSnapshot.getTuneFileDocumentDBSP()->_summary, + result->result().documentMetaStore()->documentMetaStore(), + result->writableResult().writableSummaryManager()); result->addDependency(summaryTask); summaryTask->addDependency(dmsInitTask); @@ -348,8 +336,7 @@ StoreOnlyDocSubDB::getFlushTargets() { IFlushTarget::List ret; for (const auto &target : getFlushTargetsInternal()) { - ret.push_back(IFlushTarget::SP - (new ThreadedFlushTarget(_writeService.master(), _getSerialNum, target, _subName))); + ret.push_back(std::make_shared<ThreadedFlushTarget>(_writeService.master(), _getSerialNum, target, _subName)); } return ret; } @@ -366,13 +353,9 @@ StoreOnlyDocSubDB::getFlushTargetsInternal() StoreOnlyFeedView::Context StoreOnlyDocSubDB::getStoreOnlyFeedViewContext(const DocumentDBConfig &configSnapshot) { - return StoreOnlyFeedView::Context(getSummaryAdapter(), - configSnapshot.getSchemaSP(), - _metaStoreCtx, - *_gidToLidChangeHandler, - configSnapshot.getDocumentTypeRepoSP(), - _writeService, - *_lidReuseDelayer, _commitTimeTracker); + return StoreOnlyFeedView::Context(getSummaryAdapter(), configSnapshot.getSchemaSP(), _metaStoreCtx, + *_gidToLidChangeHandler, configSnapshot.getDocumentTypeRepoSP(), _writeService, + *_lidReuseDelayer, _commitTimeTracker); } StoreOnlyFeedView::PersistentParams @@ -384,8 +367,7 @@ StoreOnlyDocSubDB::getFeedViewPersistentParams() } void -StoreOnlyDocSubDB::initViews(const DocumentDBConfig &configSnapshot, - const SessionManager::SP &sessionManager) +StoreOnlyDocSubDB::initViews(const DocumentDBConfig &configSnapshot, const SessionManager::SP &sessionManager) { assert(_writeService.master().isCurrentThread()); _iSearchView.set(ISearchHandler::SP(new EmptySearchView)); @@ -400,9 +382,8 @@ void StoreOnlyDocSubDB::initFeedView(const DocumentDBConfig &configSnapshot) { assert(_writeService.master().isCurrentThread()); - StoreOnlyFeedView::UP feedView(new StoreOnlyFeedView( - getStoreOnlyFeedViewContext(configSnapshot), - getFeedViewPersistentParams())); + auto feedView = std::make_unique<StoreOnlyFeedView>(getStoreOnlyFeedViewContext(configSnapshot), + getFeedViewPersistentParams()); // XXX: Not exception safe. _iFeedView.set(StoreOnlyFeedView::SP(feedView.release())); @@ -414,8 +395,7 @@ StoreOnlyDocSubDB::getSubDbName() const { } void -StoreOnlyDocSubDB::updateLidReuseDelayer(const DocumentDBConfig * - newConfigSnapshot) +StoreOnlyDocSubDB::updateLidReuseDelayer(const DocumentDBConfig * newConfigSnapshot) { LidReuseDelayerConfig lidReuseDelayerConfig(*newConfigSnapshot); updateLidReuseDelayer(lidReuseDelayerConfig); @@ -485,11 +465,9 @@ StoreOnlyDocSubDB::pruneRemovedFields(SerialNum) } void -StoreOnlyDocSubDB::setIndexSchema(const Schema::SP &schema, SerialNum serialNum) +StoreOnlyDocSubDB::setIndexSchema(const Schema::SP &, SerialNum ) { assert(_writeService.master().isCurrentThread()); - (void) schema; - (void) serialNum; } search::SearchableStats @@ -501,12 +479,9 @@ StoreOnlyDocSubDB::getSearchableStats() const IDocumentRetriever::UP StoreOnlyDocSubDB::getDocumentRetriever() { - return IDocumentRetriever::UP(new MinimalDocumentRetriever( - _docTypeName, - _iFeedView.get()->getDocumentTypeRepo(), - *_metaStoreCtx, - _iSummaryMgr->getBackingStore(), - _subDbType != SubDbType::REMOVED)); + return std::make_unique<MinimalDocumentRetriever>(_docTypeName, _iFeedView.get()->getDocumentTypeRepo(), + *_metaStoreCtx, _iSummaryMgr->getBackingStore(), + _subDbType != SubDbType::REMOVED); } MatchingStats @@ -548,17 +523,13 @@ StoreOnlySubDBFileHeaderContext(StoreOnlyDocSubDB &owner, _subDB() { size_t pos = baseDir.rfind('/'); - if (pos != vespalib::string::npos) - _subDB = baseDir.substr(pos + 1); - else - _subDB = baseDir; + _subDB = (pos != vespalib::string::npos) ? baseDir.substr(pos + 1) : baseDir; } -StoreOnlySubDBFileHeaderContext::~StoreOnlySubDBFileHeaderContext() {} +StoreOnlySubDBFileHeaderContext::~StoreOnlySubDBFileHeaderContext() = default; void -StoreOnlyDocSubDB::tearDownReferences(IDocumentDBReferenceResolver &resolver) +StoreOnlyDocSubDB::tearDownReferences(IDocumentDBReferenceResolver &) { - (void) resolver; } void @@ -571,5 +542,4 @@ addTags(vespalib::GenericHeader &header, const vespalib::string &name) const header.putTag(Tag("subDB", _subDB)); } - } // namespace proton |