diff options
60 files changed, 498 insertions, 854 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..2a3559806e9 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h @@ -26,15 +26,14 @@ 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); void setLastFlushTime(fastos::TimeStamp lastFlushTime); void createInvalidSnapshot(SerialNum serialNum); void markValidSnapshot(SerialNum serialNum); @@ -50,6 +49,9 @@ public: const vespalib::string &name); ~AttributeDirectory(); + const vespalib::string & getAttrName() const { return _name; } + vespalib::string getSnapshotDir(SerialNum serialNum); + /* * 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..ca170a5d388 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()); } } @@ -206,21 +192,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->getName().c_str()); _factory.setupEmpty(attr, _currentSerialNum); attr->commit(serialNum, serialNum); } @@ -228,8 +212,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 +230,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 diff --git a/searchlib/src/tests/attribute/attribute_test.cpp b/searchlib/src/tests/attribute/attribute_test.cpp index f44a1c39baf..d4f716acb7a 100644 --- a/searchlib/src/tests/attribute/attribute_test.cpp +++ b/searchlib/src/tests/attribute/attribute_test.cpp @@ -31,19 +31,20 @@ using search::common::FileHeaderContext; using search::index::DummyFileHeaderContext; using search::attribute::BasicType; using search::attribute::IAttributeVector; +using vespalib::stringref; +using vespalib::string; namespace { -vespalib::string empty; -vespalib::string tmpDir("tmp"); -vespalib::string clsDir("clstmp"); -vespalib::string asuDir("asutmp"); +string empty; +string tmpDir("tmp"); +string clsDir("clstmp"); +string asuDir("asutmp"); bool isUnsignedSmallIntAttribute(const BasicType::Type &type) { - switch (type) - { + switch (type) { case BasicType::UINT1: case BasicType::UINT2: case BasicType::UINT4: @@ -68,13 +69,13 @@ expectZero(const BufferType &b) template <> void -expectZero(const vespalib::string &b) +expectZero(const string &b) { EXPECT_EQUAL(empty, b); } uint64_t -statSize(const vespalib::string &fileName) +statSize(const string &fileName) { FastOS_StatInfo statInfo; if (EXPECT_TRUE(FastOS_File::Stat(fileName.c_str(), &statInfo))) { @@ -112,14 +113,14 @@ preciseEstimatedSize(const AttributeVector &a) return true; } -vespalib::string -baseFileName(const vespalib::string &attrName) +string +baseFileName(const string &attrName) { return tmpDir + "/" + attrName; } AttributeVector::SP -createAttribute(const vespalib::string &attrName, const search::attribute::Config &cfg) +createAttribute(stringref attrName, const search::attribute::Config &cfg) { return search::AttributeFactory::createAttribute(baseFileName(attrName), cfg); } @@ -162,7 +163,7 @@ private: template <typename T> void fillNumeric(std::vector<T> & values, uint32_t numValues); - void fillString(std::vector<vespalib::string> & values, uint32_t numValues); + void fillString(std::vector<string> & values, uint32_t numValues); template <typename VectorType, typename BufferType> bool appendToVector(VectorType & v, uint32_t doc, uint32_t valueCount, const std::vector<BufferType> & values); @@ -218,9 +219,7 @@ private: template <typename VectorType, typename BufferType> void - testCompactLidSpace(const Config &config, - bool fs, - bool es); + testCompactLidSpace(const Config &config, bool fs, bool es); template <typename VectorType, typename BufferType> void @@ -427,7 +426,7 @@ void AttributeTest::testReloadString(const AttributePtr & a, const AttributePtr if (a->hasWeightedSetType()) { testReload<StringAttribute, StringAttribute::WeightedString>(a, b, c); } else { - testReload<StringAttribute, vespalib::string>(a, b, c); + testReload<StringAttribute, string>(a, b, c); } } @@ -696,7 +695,7 @@ AttributeTest::testMemorySaverString(const AttributePtr & a, const AttributePtr if (a->hasWeightedSetType()) { testMemorySaver<StringAttribute, StringAttribute::WeightedString>(a, b); } else { - testMemorySaver<StringAttribute, vespalib::string>(a, b); + testMemorySaver<StringAttribute, string>(a, b); } } @@ -762,7 +761,6 @@ AttributeTest::testMemorySaver() } } - template <typename T> void AttributeTest::fillNumeric(std::vector<T> & values, uint32_t numValues) @@ -775,7 +773,7 @@ AttributeTest::fillNumeric(std::vector<T> & values, uint32_t numValues) } void -AttributeTest::fillString(std::vector<vespalib::string> & values, uint32_t numValues) +AttributeTest::fillString(std::vector<string> & values, uint32_t numValues) { values.clear(); values.reserve(numValues); @@ -941,19 +939,19 @@ AttributeTest::testSingle() } { - std::vector<vespalib::string> values; + std::vector<string> values; fillString(values, numUniques); { AttributePtr ptr = createAttribute("sv-string", Config(BasicType::STRING, CollectionType::SINGLE)); addDocs(ptr, numDocs); - testSingle<StringAttribute, vespalib::string, vespalib::string>(ptr, values); + testSingle<StringAttribute, string, string>(ptr, values); } { Config cfg(Config(BasicType::STRING, CollectionType::SINGLE)); cfg.setFastSearch(true); AttributePtr ptr = createAttribute("sv-fs-string", cfg); addDocs(ptr, numDocs); - testSingle<StringAttribute, vespalib::string, vespalib::string>(ptr, values); + testSingle<StringAttribute, string, string>(ptr, values); } } } @@ -1052,7 +1050,6 @@ AttributeTest::testArray(const AttributePtr & ptr, const std::vector<BufferType> } EXPECT_TRUE(!v.remove(ptr->getNumDocs(), values[0], 1)); - // test clearDoc() for (uint32_t doc = 0; doc < ptr->getNumDocs(); ++doc) { uint32_t valueCount = doc % numUniques; @@ -1132,19 +1129,19 @@ AttributeTest::testArray() } } { // StringAttribute - std::vector<vespalib::string> values; + std::vector<string> values; fillString(values, numUniques); { AttributePtr ptr = createAttribute("a-string", Config(BasicType::STRING, CollectionType::ARRAY)); addDocs(ptr, numDocs); - testArray<StringAttribute, vespalib::string>(ptr, values); + testArray<StringAttribute, string>(ptr, values); } { Config cfg(BasicType::STRING, CollectionType::ARRAY); cfg.setFastSearch(true); AttributePtr ptr = createAttribute("afs-string", cfg); addDocs(ptr, numDocs); - testArray<StringAttribute, vespalib::string>(ptr, values); + testArray<StringAttribute, string>(ptr, values); } } } @@ -1266,8 +1263,7 @@ AttributeTest::testWeightedSet() } { - AttributePtr ptr = createAttribute - ("wsint32", Config(BasicType::INT32, CollectionType::WSET)); + AttributePtr ptr = createAttribute("wsint32", Config(BasicType::INT32, CollectionType::WSET)); addDocs(ptr, numDocs); testWeightedSet<IntegerAttribute, AttributeVector::WeightedInt>(ptr, values); } @@ -1319,8 +1315,7 @@ AttributeTest::testWeightedSet() } { - AttributePtr ptr = createAttribute - ("wsstr", Config(BasicType::STRING, CollectionType::WSET)); + AttributePtr ptr = createAttribute("wsstr", Config(BasicType::STRING, CollectionType::WSET)); addDocs(ptr, numDocs); testWeightedSet<StringAttribute, AttributeVector::WeightedString>(ptr, values); } @@ -1571,14 +1566,10 @@ AttributeTest::testMapValueUpdate(const AttributePtr & ptr, BufferType initValue EXPECT_EQUAL(ptr->getStatus().getUpdateCount(), 6u); EXPECT_EQUAL(ptr->getStatus().getNonIdempotentUpdateCount(), 0u); - EXPECT_TRUE(ptr->apply(0, MapVU(initFieldValue, - ArithVU(ArithVU::Add, 10)))); - EXPECT_TRUE(ptr->apply(1, MapVU(initFieldValue, - ArithVU(ArithVU::Sub, 10)))); - EXPECT_TRUE(ptr->apply(2, MapVU(initFieldValue, - ArithVU(ArithVU::Mul, 10)))); - EXPECT_TRUE(ptr->apply(3, MapVU(initFieldValue, - ArithVU(ArithVU::Div, 10)))); + EXPECT_TRUE(ptr->apply(0, MapVU(initFieldValue, ArithVU(ArithVU::Add, 10)))); + EXPECT_TRUE(ptr->apply(1, MapVU(initFieldValue, ArithVU(ArithVU::Sub, 10)))); + EXPECT_TRUE(ptr->apply(2, MapVU(initFieldValue, ArithVU(ArithVU::Mul, 10)))); + EXPECT_TRUE(ptr->apply(3, MapVU(initFieldValue, ArithVU(ArithVU::Div, 10)))); ptr->commit(); EXPECT_EQUAL(ptr->getStatus().getUpdateCount(), 10u); EXPECT_EQUAL(ptr->getStatus().getNonIdempotentUpdateCount(), 4u); @@ -1594,8 +1585,7 @@ AttributeTest::testMapValueUpdate(const AttributePtr & ptr, BufferType initValue EXPECT_EQUAL(buf[0].getWeight(), 10); // removeifzero - EXPECT_TRUE(ptr->apply(4, MapVU(initFieldValue, - ArithVU(ArithVU::Sub, 100)))); + EXPECT_TRUE(ptr->apply(4, MapVU(initFieldValue, ArithVU(ArithVU::Sub, 100)))); ptr->commit(); if (removeIfZero) { EXPECT_EQUAL(ptr->get(4, &buf[0], 2), uint32_t(0)); @@ -1607,8 +1597,7 @@ AttributeTest::testMapValueUpdate(const AttributePtr & ptr, BufferType initValue EXPECT_EQUAL(ptr->getStatus().getNonIdempotentUpdateCount(), 5u); // createifnonexistant - EXPECT_TRUE(ptr->apply(5, MapVU(nonExistant, - ArithVU(ArithVU::Add, 10)))); + EXPECT_TRUE(ptr->apply(5, MapVU(nonExistant, ArithVU(ArithVU::Add, 10)))); ptr->commit(); if (createIfNonExistant) { EXPECT_EQUAL(ptr->get(5, &buf[0], 2), uint32_t(2)); @@ -1639,25 +1628,21 @@ void AttributeTest::testMapValueUpdate() { { // regular set - AttributePtr ptr = createAttribute - ("wsint32", Config(BasicType::INT32, CollectionType::WSET)); + AttributePtr ptr = createAttribute("wsint32", Config(BasicType::INT32, CollectionType::WSET)); testMapValueUpdate<IntegerAttribute, AttributeVector::WeightedInt> - (ptr, AttributeVector::WeightedInt(64, 1), IntFieldValue(64), - IntFieldValue(32), false, false); + (ptr, AttributeVector::WeightedInt(64, 1), IntFieldValue(64), IntFieldValue(32), false, false); } { // remove if zero - AttributePtr ptr = createAttribute - ("wsint32", Config(BasicType::INT32, CollectionType(CollectionType::WSET, true, false))); + AttributePtr ptr = createAttribute("wsint32", Config(BasicType::INT32, + CollectionType(CollectionType::WSET, true, false))); testMapValueUpdate<IntegerAttribute, AttributeVector::WeightedInt> - (ptr, AttributeVector::WeightedInt(64, 1), IntFieldValue(64), - IntFieldValue(32), true, false); + (ptr, AttributeVector::WeightedInt(64, 1), IntFieldValue(64), IntFieldValue(32), true, false); } { // create if non existant - AttributePtr ptr = createAttribute - ("wsint32", Config(BasicType::INT32, CollectionType(CollectionType::WSET, false, true))); + AttributePtr ptr = createAttribute("wsint32", Config(BasicType::INT32, + CollectionType(CollectionType::WSET, false, true))); testMapValueUpdate<IntegerAttribute, AttributeVector::WeightedInt> - (ptr, AttributeVector::WeightedInt(64, 1), IntFieldValue(64), - IntFieldValue(32), false, true); + (ptr, AttributeVector::WeightedInt(64, 1), IntFieldValue(64), IntFieldValue(32), false, true); } Config setCfg(Config(BasicType::STRING, CollectionType::WSET)); @@ -1667,20 +1652,17 @@ AttributeTest::testMapValueUpdate() { // regular set AttributePtr ptr = createAttribute("wsstr", setCfg); testMapValueUpdate<StringAttribute, AttributeVector::WeightedString> - (ptr, AttributeVector::WeightedString("first", 1), StringFieldValue("first"), - StringFieldValue("second"), false, false); + (ptr, AttributeVector::WeightedString("first", 1), StringFieldValue("first"), StringFieldValue("second"), false, false); } { // remove if zero AttributePtr ptr = createAttribute("wsstr", setRemoveCfg); testMapValueUpdate<StringAttribute, AttributeVector::WeightedString> - (ptr, AttributeVector::WeightedString("first", 1), StringFieldValue("first"), - StringFieldValue("second"), true, false); + (ptr, AttributeVector::WeightedString("first", 1), StringFieldValue("first"), StringFieldValue("second"), true, false); } { // create if non existant AttributePtr ptr = createAttribute("wsstr", setCreateCfg); testMapValueUpdate<StringAttribute, AttributeVector::WeightedString> - (ptr, AttributeVector::WeightedString("first", 1), StringFieldValue("first"), - StringFieldValue("second"), false, true); + (ptr, AttributeVector::WeightedString("first", 1), StringFieldValue("first"), StringFieldValue("second"), false, true); } // fast-search - posting lists @@ -1688,46 +1670,38 @@ AttributeTest::testMapValueUpdate() setCfg.setFastSearch(true); AttributePtr ptr = createAttribute("wsfsstr", setCfg); testMapValueUpdate<StringAttribute, AttributeVector::WeightedString> - (ptr, AttributeVector::WeightedString("first", 1), StringFieldValue("first"), - StringFieldValue("second"), false, false); + (ptr, AttributeVector::WeightedString("first", 1), StringFieldValue("first"), StringFieldValue("second"), false, false); } { // remove if zero setRemoveCfg.setFastSearch(true); AttributePtr ptr = createAttribute("wsfsstr", setRemoveCfg); testMapValueUpdate<StringAttribute, AttributeVector::WeightedString> - (ptr, AttributeVector::WeightedString("first", 1), StringFieldValue("first"), - StringFieldValue("second"), true, false); + (ptr, AttributeVector::WeightedString("first", 1), StringFieldValue("first"), StringFieldValue("second"), true, false); } { // create if non existant setCreateCfg.setFastSearch(true); AttributePtr ptr = createAttribute("wsfsstr", setCreateCfg); testMapValueUpdate<StringAttribute, AttributeVector::WeightedString> - (ptr, AttributeVector::WeightedString("first", 1), StringFieldValue("first"), - StringFieldValue("second"), false, true); + (ptr, AttributeVector::WeightedString("first", 1), StringFieldValue("first"), StringFieldValue("second"), false, true); } } - - void AttributeTest::commit(const AttributePtr & ptr) { ptr->commit(); } - void AttributeTest::testStatus() { - std::vector<vespalib::string> values; + std::vector<string> values; fillString(values, 16); uint32_t numDocs = 100; // No posting list - static constexpr size_t LeafNodeSize = - 4 + sizeof(EnumStoreBase::Index) * EnumTreeTraits::LEAF_SLOTS; + static constexpr size_t LeafNodeSize = 4 + sizeof(EnumStoreBase::Index) * EnumTreeTraits::LEAF_SLOTS; static constexpr size_t InternalNodeSize = - 8 + (sizeof(EnumStoreBase::Index) + - sizeof(datastore::EntryRef)) * EnumTreeTraits::INTERNAL_SLOTS; + 8 + (sizeof(EnumStoreBase::Index) + sizeof(datastore::EntryRef)) * EnumTreeTraits::INTERNAL_SLOTS; static constexpr size_t NestedVectorSize = 24; // sizeof(vespalib::Array) { @@ -1782,9 +1756,9 @@ AttributeTest::testNullProtection() size_t len1 = strlen("evil"); size_t len2 = strlen("string"); size_t len = len1 + 1 + len2; - vespalib::string good("good"); - vespalib::string evil("evil string"); - vespalib::string pureEvil("evil"); + string good("good"); + string evil("evil string"); + string pureEvil("evil"); EXPECT_EQUAL(strlen(evil.data()), len); EXPECT_EQUAL(strlen(evil.c_str()), len); evil[len1] = 0; // replace space with '\0' @@ -1797,7 +1771,7 @@ AttributeTest::testNullProtection() EXPECT_EQUAL(evil.size(), len); { // string AttributeVector::DocId docId; - std::vector<vespalib::string> buf(16); + std::vector<string> buf(16); AttributePtr attr = createAttribute("string", Config(BasicType::STRING, CollectionType::SINGLE)); StringAttribute &v = static_cast<StringAttribute &>(*attr.get()); EXPECT_TRUE(v.addDoc(docId)); @@ -1809,7 +1783,7 @@ AttributeTest::testNullProtection() } { // string array AttributeVector::DocId docId; - std::vector<vespalib::string> buf(16); + std::vector<string> buf(16); AttributePtr attr = createAttribute("string", Config(BasicType::STRING, CollectionType::ARRAY)); StringAttribute &v = static_cast<StringAttribute &>(*attr.get()); EXPECT_TRUE(v.addDoc(docId)); @@ -2047,7 +2021,6 @@ AttributeTest::testCompactLidSpace(const Config &config, compare<VectorType, BufferType>(v, v3); } - template <typename VectorType, typename BufferType> void AttributeTest::testCompactLidSpace(const Config &config) @@ -2061,7 +2034,6 @@ AttributeTest::testCompactLidSpace(const Config &config) testCompactLidSpace<VectorType, BufferType>(config, true, true); } - void AttributeTest::testCompactLidSpace(const Config &config) { @@ -2074,28 +2046,24 @@ AttributeTest::testCompactLidSpace(const Config &config) case BasicType::INT32: case BasicType::INT64: if (config.collectionType() == CollectionType::WSET) { - testCompactLidSpace<IntegerAttribute, - IntegerAttribute::WeightedInt>(config); + testCompactLidSpace<IntegerAttribute, IntegerAttribute::WeightedInt>(config); } else { - testCompactLidSpace<IntegerAttribute, - IntegerAttribute::largeint_t>(config); + testCompactLidSpace<IntegerAttribute, IntegerAttribute::largeint_t>(config); } break; case BasicType::FLOAT: case BasicType::DOUBLE: if (config.collectionType() == CollectionType::WSET) { - testCompactLidSpace<FloatingPointAttribute, - FloatingPointAttribute::WeightedFloat>(config); + testCompactLidSpace<FloatingPointAttribute, FloatingPointAttribute::WeightedFloat>(config); } else { testCompactLidSpace<FloatingPointAttribute, double>(config); } break; case BasicType::STRING: if (config.collectionType() == CollectionType::WSET) { - testCompactLidSpace<StringAttribute, - StringAttribute::WeightedString>(config); + testCompactLidSpace<StringAttribute, StringAttribute::WeightedString>(config); } else { - testCompactLidSpace<StringAttribute, vespalib::string>(config); + testCompactLidSpace<StringAttribute, string>(config); } break; default: @@ -2103,58 +2071,33 @@ AttributeTest::testCompactLidSpace(const Config &config) } } - void AttributeTest::testCompactLidSpace() { - TEST_DO(testCompactLidSpace(Config(BasicType::UINT1, - CollectionType::SINGLE))); - TEST_DO(testCompactLidSpace(Config(BasicType::UINT2, - CollectionType::SINGLE))); - TEST_DO(testCompactLidSpace(Config(BasicType::UINT4, - CollectionType::SINGLE))); - TEST_DO(testCompactLidSpace(Config(BasicType::INT8, - CollectionType::SINGLE))); - TEST_DO(testCompactLidSpace(Config(BasicType::INT8, - CollectionType::ARRAY))); - TEST_DO(testCompactLidSpace(Config(BasicType::INT8, - CollectionType::WSET))); - TEST_DO(testCompactLidSpace(Config(BasicType::INT16, - CollectionType::SINGLE))); - TEST_DO(testCompactLidSpace(Config(BasicType::INT16, - CollectionType::ARRAY))); - TEST_DO(testCompactLidSpace(Config(BasicType::INT16, - CollectionType::WSET))); - TEST_DO(testCompactLidSpace(Config(BasicType::INT32, - CollectionType::SINGLE))); - TEST_DO(testCompactLidSpace(Config(BasicType::INT32, - CollectionType::ARRAY))); - TEST_DO(testCompactLidSpace(Config(BasicType::INT32, - CollectionType::WSET))); - TEST_DO(testCompactLidSpace(Config(BasicType::INT64, - CollectionType::SINGLE))); - TEST_DO(testCompactLidSpace(Config(BasicType::INT64, - CollectionType::ARRAY))); - TEST_DO(testCompactLidSpace(Config(BasicType::INT64, - CollectionType::WSET))); - TEST_DO(testCompactLidSpace(Config(BasicType::FLOAT, - CollectionType::SINGLE))); - TEST_DO(testCompactLidSpace(Config(BasicType::FLOAT, - CollectionType::ARRAY))); - TEST_DO(testCompactLidSpace(Config(BasicType::FLOAT, - CollectionType::WSET))); - TEST_DO(testCompactLidSpace(Config(BasicType::DOUBLE, - CollectionType::SINGLE))); - TEST_DO(testCompactLidSpace(Config(BasicType::DOUBLE, - CollectionType::ARRAY))); - TEST_DO(testCompactLidSpace(Config(BasicType::DOUBLE, - CollectionType::WSET))); - TEST_DO(testCompactLidSpace(Config(BasicType::STRING, - CollectionType::SINGLE))); - TEST_DO(testCompactLidSpace(Config(BasicType::STRING, - CollectionType::ARRAY))); - TEST_DO(testCompactLidSpace(Config(BasicType::STRING, - CollectionType::WSET))); + TEST_DO(testCompactLidSpace(Config(BasicType::UINT1, CollectionType::SINGLE))); + TEST_DO(testCompactLidSpace(Config(BasicType::UINT2, CollectionType::SINGLE))); + TEST_DO(testCompactLidSpace(Config(BasicType::UINT4, CollectionType::SINGLE))); + TEST_DO(testCompactLidSpace(Config(BasicType::INT8, CollectionType::SINGLE))); + TEST_DO(testCompactLidSpace(Config(BasicType::INT8, CollectionType::ARRAY))); + TEST_DO(testCompactLidSpace(Config(BasicType::INT8, CollectionType::WSET))); + TEST_DO(testCompactLidSpace(Config(BasicType::INT16, CollectionType::SINGLE))); + TEST_DO(testCompactLidSpace(Config(BasicType::INT16, CollectionType::ARRAY))); + TEST_DO(testCompactLidSpace(Config(BasicType::INT16, CollectionType::WSET))); + TEST_DO(testCompactLidSpace(Config(BasicType::INT32, CollectionType::SINGLE))); + TEST_DO(testCompactLidSpace(Config(BasicType::INT32, CollectionType::ARRAY))); + TEST_DO(testCompactLidSpace(Config(BasicType::INT32, CollectionType::WSET))); + TEST_DO(testCompactLidSpace(Config(BasicType::INT64, CollectionType::SINGLE))); + TEST_DO(testCompactLidSpace(Config(BasicType::INT64, CollectionType::ARRAY))); + TEST_DO(testCompactLidSpace(Config(BasicType::INT64, CollectionType::WSET))); + TEST_DO(testCompactLidSpace(Config(BasicType::FLOAT, CollectionType::SINGLE))); + TEST_DO(testCompactLidSpace(Config(BasicType::FLOAT, CollectionType::ARRAY))); + TEST_DO(testCompactLidSpace(Config(BasicType::FLOAT, CollectionType::WSET))); + TEST_DO(testCompactLidSpace(Config(BasicType::DOUBLE, CollectionType::SINGLE))); + TEST_DO(testCompactLidSpace(Config(BasicType::DOUBLE, CollectionType::ARRAY))); + TEST_DO(testCompactLidSpace(Config(BasicType::DOUBLE, CollectionType::WSET))); + TEST_DO(testCompactLidSpace(Config(BasicType::STRING, CollectionType::SINGLE))); + TEST_DO(testCompactLidSpace(Config(BasicType::STRING, CollectionType::ARRAY))); + TEST_DO(testCompactLidSpace(Config(BasicType::STRING, CollectionType::WSET))); } template <typename AttributeType> @@ -2220,7 +2163,6 @@ AttributeTest::requireThatAddressSpaceUsageIsReported() TEST_DO(requireThatAddressSpaceUsageIsReported<StringAttribute>(Config(BasicType::STRING, CollectionType::ARRAY))); } - template <typename AttributeType, typename BufferType> void AttributeTest::testReaderDuringLastUpdate(const Config &config, bool fs, bool compact) @@ -2230,7 +2172,7 @@ AttributeTest::testReaderDuringLastUpdate(const Config &config, bool fs, bool co config.collectionType().asString() << (fs ? "-fs" : "") << (compact ? "-compact" : ""); - vespalib::string name(ss.str()); + string name(ss.str()); Config cfg = config; cfg.setFastSearch(fs); cfg.setGrowStrategy(GrowStrategy::make(100, 50, 0)); @@ -2261,7 +2203,6 @@ AttributeTest::testReaderDuringLastUpdate(const Config &config, bool fs, bool co } } - template <typename AttributeType, typename BufferType> void AttributeTest::testReaderDuringLastUpdate(const Config &config) @@ -2281,8 +2222,8 @@ AttributeTest::testReaderDuringLastUpdate() TEST_DO((testReaderDuringLastUpdate<FloatingPointAttribute,double>(Config(BasicType::FLOAT, CollectionType::SINGLE)))); TEST_DO((testReaderDuringLastUpdate<FloatingPointAttribute,double>(Config(BasicType::FLOAT, CollectionType::ARRAY)))); TEST_DO((testReaderDuringLastUpdate<FloatingPointAttribute,FloatingPointAttribute::WeightedFloat>(Config(BasicType::FLOAT, CollectionType::WSET)))); - TEST_DO((testReaderDuringLastUpdate<StringAttribute,vespalib::string>(Config(BasicType::STRING, CollectionType::SINGLE)))); - TEST_DO((testReaderDuringLastUpdate<StringAttribute,vespalib::string>(Config(BasicType::STRING, CollectionType::ARRAY)))); + TEST_DO((testReaderDuringLastUpdate<StringAttribute,string>(Config(BasicType::STRING, CollectionType::SINGLE)))); + TEST_DO((testReaderDuringLastUpdate<StringAttribute,string>(Config(BasicType::STRING, CollectionType::ARRAY)))); TEST_DO((testReaderDuringLastUpdate<StringAttribute,StringAttribute::WeightedString>(Config(BasicType::STRING, CollectionType::WSET)))); } @@ -2374,5 +2315,4 @@ int AttributeTest::Main() } - TEST_APPHOOK(search::AttributeTest); diff --git a/searchlib/src/tests/attribute/attributemanager/attributemanager_test.cpp b/searchlib/src/tests/attribute/attributemanager/attributemanager_test.cpp index 3e6760ec5e4..5911d74dcb0 100644 --- a/searchlib/src/tests/attribute/attributemanager/attributemanager_test.cpp +++ b/searchlib/src/tests/attribute/attributemanager/attributemanager_test.cpp @@ -1,6 +1,5 @@ // 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_test"); + #include <vespa/searchlib/attribute/attribute.h> #include <vespa/searchlib/attribute/attributeguard.h> #include <vespa/searchlib/attribute/attributefactory.h> @@ -10,13 +9,16 @@ LOG_SETUP("attribute_test"); #include <vespa/searchlib/attribute/multinumericattribute.hpp> #include <vespa/searchlib/attribute/stringattribute.h> #include <vespa/vespalib/testkit/testapp.h> -#include <algorithm> + +#include <vespa/log/log.h> +LOG_SETUP("attribute_test"); using namespace config; using namespace vespa::config::search; using namespace search; using namespace search::attribute; using std::shared_ptr; +using vespalib::stringref; typedef BasicType BT; typedef CollectionType CT; @@ -59,40 +61,14 @@ class TestAttribute : public TestAttributeBase { public: TestAttribute(const std::string &name) - : - TestAttributeBase(name) - { - } - - generation_t - getGen() const - { - return getCurrentGeneration(); - } - - uint32_t - getRefCount(generation_t gen) const - { - return getGenerationRefCount(gen); - } - - void - incGen() - { - incGeneration(); - } - - void - updateFirstUsedGen() - { - updateFirstUsedGeneration(); - } - - generation_t - getFirstUsedGen() const - { - return getFirstUsedGeneration(); - } + : TestAttributeBase(name) + {} + + generation_t getGen() const { return getCurrentGeneration(); } + uint32_t getRefCount(generation_t gen) const { return getGenerationRefCount(gen); } + void incGen() { incGeneration(); } + void updateFirstUsedGen() { updateFirstUsedGeneration(); } + generation_t getFirstUsedGen() const { return getFirstUsedGeneration(); } }; @@ -216,8 +192,7 @@ AttributeManagerTest::testLoad() bool -AttributeManagerTest::assertDataType(BT::Type exp, - AttributesConfig::Attribute::Datatype in) +AttributeManagerTest::assertDataType(BT::Type exp, AttributesConfig::Attribute::Datatype in) { AttributesConfig::Attribute a; a.datatype = in; @@ -227,10 +202,8 @@ AttributeManagerTest::assertDataType(BT::Type exp, bool AttributeManagerTest:: -assertCollectionType(CollectionType exp, - AttributesConfig::Attribute::Collectiontype in, - bool removeIfZ, - bool createIfNe) +assertCollectionType(CollectionType exp, AttributesConfig::Attribute::Collectiontype in, + bool removeIfZ, bool createIfNe) { AttributesConfig::Attribute a; a.collectiontype = in; @@ -239,8 +212,7 @@ assertCollectionType(CollectionType exp, AttributeVector::Config out = ConfigConverter::convert(a); return EXPECT_EQUAL(exp.type(), out.collectionType().type()) && EXPECT_EQUAL(exp.removeIfZero(), out.collectionType().removeIfZero()) && - EXPECT_EQUAL(exp.createIfNonExistant(), - out.collectionType().createIfNonExistant()); + EXPECT_EQUAL(exp.createIfNonExistant(), out.collectionType().createIfNonExistant()); } @@ -308,14 +280,10 @@ AttributeManagerTest::testContext() { std::vector<AVSP> attrs; // create various attributes vectors - attrs.push_back(AttributeFactory::createAttribute("sint32", - Config(BT::INT32, CT::SINGLE))); - attrs.push_back(AttributeFactory::createAttribute("aint32", - Config(BT::INT32, CT::ARRAY))); - attrs.push_back(AttributeFactory::createAttribute("wsint32", - Config(BT::INT32, CT::WSET))); - attrs.push_back(AttributeFactory::createAttribute("dontcare", - Config(BT::INT32, CT::SINGLE))); + attrs.push_back(AttributeFactory::createAttribute("sint32", Config(BT::INT32, CT::SINGLE))); + attrs.push_back(AttributeFactory::createAttribute("aint32", Config(BT::INT32, CT::ARRAY))); + attrs.push_back(AttributeFactory::createAttribute("wsint32", Config(BT::INT32, CT::WSET))); + attrs.push_back(AttributeFactory::createAttribute("dontcare", Config(BT::INT32, CT::SINGLE))); // add docs for (uint32_t i = 0; i < attrs.size(); ++i) { diff --git a/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp b/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp index 8ec9d59da86..432396d635e 100644 --- a/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp +++ b/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp @@ -103,32 +103,24 @@ public: typedef std::shared_ptr<MemAttr> SP; MemAttr(); - ~MemAttr(); - - // Implements IAttributeSaveTarget - virtual bool setup() override { return true; } - virtual void close() override {} - virtual IAttributeFileWriter &datWriter() override { return _datWriter; } - virtual IAttributeFileWriter &idxWriter() override { return _idxWriter; } - virtual IAttributeFileWriter &weightWriter() override { + ~MemAttr() override; + + bool setup() override { return true; } + void close() override {} + IAttributeFileWriter &datWriter() override { return _datWriter; } + IAttributeFileWriter &idxWriter() override { return _idxWriter; } + IAttributeFileWriter &weightWriter() override { return _weightWriter; } - virtual IAttributeFileWriter &udatWriter() override { return _udatWriter; } + IAttributeFileWriter &udatWriter() override { return _udatWriter; } - bool - bufEqual(const Buffer &lhs, const Buffer &rhs) const; + bool bufEqual(const Buffer &lhs, const Buffer &rhs) const; - bool - operator==(const MemAttr &rhs) const; + bool operator==(const MemAttr &rhs) const; }; -MemAttr::MemAttr() - : _datWriter(), - _idxWriter(), - _weightWriter(), - _udatWriter() -{ } -MemAttr::~MemAttr() {} +MemAttr::MemAttr() = default; +MemAttr::~MemAttr() = default; class EnumeratedSaveTest { @@ -136,20 +128,11 @@ private: typedef AttributeVector::SP AttributePtr; template <typename VectorType> - VectorType & - as(AttributePtr &v); - - IntegerAttribute & - asInt(AttributePtr &v); - - StringAttribute & - asString(AttributePtr &v); - - FloatingPointAttribute & - asFloat(AttributePtr &v); - - void - addDocs(const AttributePtr &v, size_t sz); + VectorType & as(AttributePtr &v); + IntegerAttribute & asInt(AttributePtr &v); + StringAttribute & asString(AttributePtr &v); + FloatingPointAttribute & asFloat(AttributePtr &v); + void addDocs(const AttributePtr &v, size_t sz); template <typename VectorType> void populate(VectorType &v, unsigned seed, BasicType bt); @@ -157,65 +140,34 @@ private: template <typename VectorType, typename BufferType> void compare(VectorType &a, VectorType &b); - void - buildTermQuery(std::vector<char> & buffer, - const vespalib::string & index, - const vespalib::string & term, bool prefix); + void buildTermQuery(std::vector<char> & buffer, const vespalib::string & index, + const vespalib::string & term, bool prefix); template <typename V, typename T> - SearchContextPtr - getSearch(const V & vec, const T & term, bool prefix); + SearchContextPtr getSearch(const V & vec, const T & term, bool prefix); template <typename V> - SearchContextPtr - getSearch(const V & vec); - - MemAttr::SP - saveMem(AttributeVector &v); + SearchContextPtr getSearch(const V & vec); - void - checkMem(AttributeVector &v, const MemAttr &e, bool enumerated); - - MemAttr::SP - saveBoth(AttributePtr v); - - AttributePtr - make(Config cfg, - const vespalib::string &pref, - bool fastSearch = false); - - void - load(AttributePtr v, const vespalib::string &name); + MemAttr::SP saveMem(AttributeVector &v); + void checkMem(AttributeVector &v, const MemAttr &e, bool enumerated); + MemAttr::SP saveBoth(AttributePtr v); + AttributePtr make(Config cfg, const vespalib::string &pref, bool fastSearch = false); + void load(AttributePtr v, const vespalib::string &name); template <typename VectorType, typename BufferType> - void - checkLoad(AttributePtr v, - const vespalib::string &name, - AttributePtr ev); + void checkLoad(AttributePtr v, const vespalib::string &name, AttributePtr ev); template <typename VectorType, typename BufferType> - void - testReload(AttributePtr v0, - AttributePtr v1, - AttributePtr v2, - MemAttr::SP mv0, - MemAttr::SP mv1, - MemAttr::SP mv2, - MemAttr::SP emv0, - MemAttr::SP emv1, - MemAttr::SP emv2, - Config cfg, - const vespalib::string &pref, - bool fastSearch); + void testReload(AttributePtr v0, AttributePtr v1, AttributePtr v2, + MemAttr::SP mv0, MemAttr::SP mv1, MemAttr::SP mv2, + MemAttr::SP emv0, MemAttr::SP emv1, MemAttr::SP emv2, + Config cfg, const vespalib::string &pref, bool fastSearch); public: template <typename VectorType, typename BufferType> - void - test(BasicType bt, CollectionType ct, const vespalib::string &pref); + void test(BasicType bt, CollectionType ct, const vespalib::string &pref); - EnumeratedSaveTest() - { - } }; @@ -605,9 +557,7 @@ EnumeratedSaveTest::saveBoth(AttributePtr v) EnumeratedSaveTest::AttributePtr -EnumeratedSaveTest::make(Config cfg, - const vespalib::string &pref, - bool fastSearch) +EnumeratedSaveTest::make(Config cfg, const vespalib::string &pref, bool fastSearch) { cfg.setFastSearch(fastSearch); AttributePtr v = AttributeFactory::createAttribute(pref, cfg); @@ -751,13 +701,11 @@ EnumeratedSaveTest::test(BasicType bt, CollectionType ct, TEST_DO((testReload<VectorType, BufferType>(v0, v1, v2, mv0, mv1, mv2, emv0, emv1, emv2, - cfg, pref, - false))); + cfg, pref, false))); TEST_DO((testReload<VectorType, BufferType>(v0, v1, v2, mv0, mv1, mv2, emv0, emv1, emv2, - cfg, pref, - true))); + cfg, pref, true))); } TEST_F("Test enumerated save with single value int8", EnumeratedSaveTest) diff --git a/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp b/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp index d5b1c9566c4..c6270e32c85 100644 --- a/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp +++ b/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp @@ -1003,10 +1003,8 @@ PostingListAttributeTest::testMinMax() { Config cfg(Config(BasicType::INT32, CollectionType::WSET)); cfg.setFastSearch(true); - AttributePtr ptr1 = - AttributeFactory::createAttribute("wsint32_1", cfg); - AttributePtr ptr2 = - AttributeFactory::createAttribute("wsint32_2", cfg); + AttributePtr ptr1 = AttributeFactory::createAttribute("wsint32_1", cfg); + AttributePtr ptr2 = AttributeFactory::createAttribute("wsint32_2", cfg); testMinMax<IntegerAttribute>(ptr1, ptr2); } { diff --git a/searchlib/src/tests/attribute/stringattribute/stringattribute_test.cpp b/searchlib/src/tests/attribute/stringattribute/stringattribute_test.cpp index 69aa612d5b8..bc6ce97fc37 100644 --- a/searchlib/src/tests/attribute/stringattribute/stringattribute_test.cpp +++ b/searchlib/src/tests/attribute/stringattribute/stringattribute_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("stringattribute_test"); #include <vespa/vespalib/testkit/testapp.h> #include <vespa/searchlib/attribute/enumstore.h> #include <vespa/searchlib/attribute/singlestringattribute.h> @@ -14,6 +12,9 @@ LOG_SETUP("stringattribute_test"); #include <vespa/searchlib/attribute/multistringattribute.h> #include <vespa/searchlib/attribute/multistringpostattribute.hpp> +#include <vespa/log/log.h> +LOG_SETUP("stringattribute_test"); + namespace search { using attribute::CollectionType; @@ -430,11 +431,8 @@ StringAttributeTest::Main() TEST_INIT("stringattribute_test"); testMultiValue(); - testMultiValueMultipleClearDocBetweenCommit(); - testMultiValueRemove(); - testSingleValue(); TEST_DONE(); diff --git a/searchlib/src/tests/features/prod_features_attributematch.cpp b/searchlib/src/tests/features/prod_features_attributematch.cpp index 4ddb3170efe..e5d37e62bee 100644 --- a/searchlib/src/tests/features/prod_features_attributematch.cpp +++ b/searchlib/src/tests/features/prod_features_attributematch.cpp @@ -1,10 +1,12 @@ // 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(".prod_features_attributematch"); #include "prod_features.h" #include <vespa/searchlib/features/attributematchfeature.h> #include <vespa/searchlib/attribute/attributefactory.h> +#include <vespa/searchlib/attribute/attributevector.h> + +#include <vespa/log/log.h> +LOG_SETUP(".prod_features_attributematch"); using namespace search::features; using namespace search::fef; diff --git a/searchlib/src/vespa/searchlib/attribute/attributefactory.cpp b/searchlib/src/vespa/searchlib/attribute/attributefactory.cpp index fd1a8ffe952..8f03c3b3851 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributefactory.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attributefactory.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "attributefactory.h" +#include "attributevector.h" #include <vespa/log/log.h> LOG_SETUP(".searchlib.attributefactory"); @@ -10,45 +11,45 @@ namespace search { using attribute::CollectionType; AttributeVector::SP -AttributeFactory::createAttribute(const vespalib::string & baseFileName, const Config & cfg) +AttributeFactory::createAttribute(stringref name, const Config & cfg) { AttributeVector::SP ret; if (cfg.collectionType().type() == CollectionType::ARRAY) { if (cfg.fastSearch()) { - ret = createArrayFastSearch(baseFileName, cfg); - if (ret.get() == NULL) { + ret = createArrayFastSearch(name, cfg); + if ( ! ret) { LOG(warning, "Cannot apply fastsearch hint on attribute %s of type array<%s>. " "Falling back to normal. You should correct your .sd file.", - baseFileName.c_str(), cfg.basicType().asString()); - ret = createArrayStd(baseFileName, cfg); + name.data(), cfg.basicType().asString()); + ret = createArrayStd(name, cfg); } } else { - ret = createArrayStd(baseFileName, cfg); + ret = createArrayStd(name, cfg); } } else if (cfg.collectionType().type() == CollectionType::WSET) { // Ignore if noupdate has been set. if (cfg.fastSearch()) { - ret = createSetFastSearch(baseFileName, cfg); - if (ret.get() == NULL) { + ret = createSetFastSearch(name, cfg); + if ( ! ret) { LOG(warning, "Cannot apply fastsearch hint on attribute %s of type set<%s>. " "Falling back to normal. You should correct your .sd file.", - baseFileName.c_str(), cfg.basicType().asString()); - ret = createSetStd(baseFileName, cfg); + name.data(), cfg.basicType().asString()); + ret = createSetStd(name, cfg); } } else { - ret = createSetStd(baseFileName, cfg); + ret = createSetStd(name, cfg); } } else { if (cfg.fastSearch()) { - ret = createSingleFastSearch(baseFileName, cfg); - if (ret.get() == NULL) { + ret = createSingleFastSearch(name, cfg); + if ( ! ret) { LOG(warning, "Cannot apply fastsearch hint on attribute %s of type %s. " "Falling back to normal. You should correct your .sd file.", - baseFileName.c_str(), cfg.basicType().asString()); - ret = createSingleStd(baseFileName, cfg); + name.data(), cfg.basicType().asString()); + ret = createSingleStd(name, cfg); } } else { - ret = createSingleStd(baseFileName, cfg); + ret = createSingleStd(name, cfg); } } return ret; diff --git a/searchlib/src/vespa/searchlib/attribute/attributefactory.h b/searchlib/src/vespa/searchlib/attribute/attributefactory.h index 39f662e040c..edcdee4ff0a 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributefactory.h +++ b/searchlib/src/vespa/searchlib/attribute/attributefactory.h @@ -2,31 +2,31 @@ #pragma once -#include "attributevector.h" +#include <vespa/searchcommon/attribute/config.h> namespace search { +class AttributeVector; + /** * Factory for creating attribute vector instances. **/ class AttributeFactory { private: - typedef attribute::Config Config; - static AttributeVector::SP createArrayStd(const vespalib::string & baseFileName, const Config & cfg); - static AttributeVector::SP createArrayFastSearch(const vespalib::string & baseFileName, const Config & cfg); - static AttributeVector::SP createSetStd(const vespalib::string & baseFileName, const Config & cfg); - static AttributeVector::SP createSetFastSearch(const vespalib::string & baseFileName, const Config & cfg); - static AttributeVector::SP createSingleStd(const vespalib::string & baseFileName, const Config & cfg); - static AttributeVector::SP createSingleFastSearch(const vespalib::string & baseFileName, const Config & cfg); - static AttributeVector::SP createSingleFastAggregate(const vespalib::string & baseFileName, const Config & cfg); - static AttributeVector::SP createArrayFastAggregate(const vespalib::string & baseFileName, const Config & cfg); - static AttributeVector::SP createSetFastAggregate(const vespalib::string & baseFileName, const Config & cfg); - + using stringref = vespalib::stringref; + using Config = attribute::Config; + using AttributeSP = std::shared_ptr<AttributeVector>; + static AttributeSP createArrayStd(stringref name, const Config & cfg); + static AttributeSP createArrayFastSearch(stringref name, const Config & cfg); + static AttributeSP createSetStd(stringref name, const Config & cfg); + static AttributeSP createSetFastSearch(stringref name, const Config & cfg); + static AttributeSP createSingleStd(stringref name, const Config & cfg); + static AttributeSP createSingleFastSearch(stringref name, const Config & cfg); public: /** * Create an attribute vector with the given name based on the given config. **/ - static AttributeVector::SP createAttribute(const vespalib::string & baseFileName, const Config & cfg); + static AttributeSP createAttribute(stringref name, const Config & cfg); }; } diff --git a/searchlib/src/vespa/searchlib/attribute/attributefilesavetarget.h b/searchlib/src/vespa/searchlib/attribute/attributefilesavetarget.h index e961396750e..acb3daf82e0 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributefilesavetarget.h +++ b/searchlib/src/vespa/searchlib/attribute/attributefilesavetarget.h @@ -21,21 +21,20 @@ private: public: AttributeFileSaveTarget(const TuneFileAttributes &tuneFileAttributes, - const search::common::FileHeaderContext & - fileHeaderContext); - ~AttributeFileSaveTarget(); + const search::common::FileHeaderContext &fileHeaderContext); + ~AttributeFileSaveTarget() override; // Implements IAttributeSaveTarget /** Setups this saveTarget by opening the relevant files **/ - virtual bool setup() override; + bool setup() override; /** Closes the files used **/ - virtual void close() override; + void close() override; - virtual IAttributeFileWriter &datWriter() override; - virtual IAttributeFileWriter &idxWriter() override; - virtual IAttributeFileWriter &weightWriter() override; - virtual IAttributeFileWriter &udatWriter() override; + IAttributeFileWriter &datWriter() override; + IAttributeFileWriter &idxWriter() override; + IAttributeFileWriter &weightWriter() override; + IAttributeFileWriter &udatWriter() override; }; } // namespace search diff --git a/searchlib/src/vespa/searchlib/attribute/attributefilewriter.h b/searchlib/src/vespa/searchlib/attribute/attributefilewriter.h index 06f350754ae..85a686ee02a 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributefilewriter.h +++ b/searchlib/src/vespa/searchlib/attribute/attributefilewriter.h @@ -38,9 +38,9 @@ public: const attribute::AttributeHeader &header, const vespalib::string &desc); ~AttributeFileWriter(); - virtual Buffer allocBuf(size_t size) override; - virtual void writeBuf(Buffer buf) override; - virtual std::unique_ptr<BufferWriter> allocBufferWriter() override; + Buffer allocBuf(size_t size) override; + void writeBuf(Buffer buf) override; + std::unique_ptr<BufferWriter> allocBufferWriter() override; bool open(const vespalib::string &fileName); void close(); }; diff --git a/searchlib/src/vespa/searchlib/attribute/attributemanager.cpp b/searchlib/src/vespa/searchlib/attribute/attributemanager.cpp index c129d23fcc5..6e8736a535c 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributemanager.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attributemanager.cpp @@ -161,7 +161,7 @@ AttributeManager::getAttribute(const string & name) const { AttributeGuard::UP attrGuard(new AttributeGuard(VectorHolder())); const VectorHolder * vh = findAndLoadAttribute(name); - if ( vh != NULL ) { + if ( vh != nullptr ) { attrGuard.reset(new AttributeGuard(*vh)); } return attrGuard; diff --git a/searchlib/src/vespa/searchlib/attribute/attributememorysavetarget.h b/searchlib/src/vespa/searchlib/attribute/attributememorysavetarget.h index c4928f8277b..0be594c38d0 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributememorysavetarget.h +++ b/searchlib/src/vespa/searchlib/attribute/attributememorysavetarget.h @@ -38,17 +38,15 @@ public: /** * Write the underlying buffer(s) to file(s). **/ - bool - writeToFile(const TuneFileAttributes &tuneFileAttributes, - const search::common::FileHeaderContext &fileHeaderContext); - - // Implements IAttributeSaveTarget - virtual bool setup() override { return true; } - virtual void close() override {} - virtual IAttributeFileWriter &datWriter() override; - virtual IAttributeFileWriter &idxWriter() override; - virtual IAttributeFileWriter &weightWriter() override; - virtual IAttributeFileWriter &udatWriter() override; + bool writeToFile(const TuneFileAttributes &tuneFileAttributes, + const search::common::FileHeaderContext &fileHeaderContext); + + bool setup() override { return true; } + void close() override {} + IAttributeFileWriter &datWriter() override; + IAttributeFileWriter &idxWriter() override; + IAttributeFileWriter &weightWriter() override; + IAttributeFileWriter &udatWriter() override; }; } // namespace search diff --git a/searchlib/src/vespa/searchlib/attribute/attributesaver.cpp b/searchlib/src/vespa/searchlib/attribute/attributesaver.cpp index 1f4cefb7658..f2852fe3050 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributesaver.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attributesaver.cpp @@ -15,10 +15,7 @@ AttributeSaver::AttributeSaver(GenerationHandler::Guard &&guard, } -AttributeSaver::~AttributeSaver() -{ -} - +AttributeSaver::~AttributeSaver() = default; bool AttributeSaver::save(IAttributeSaveTarget &saveTarget) diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp index 4e3f8247ec2..d0886c25898 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp @@ -460,7 +460,7 @@ const char * AttributeVector::getStringFromEnum(EnumHandle) const { return nullp AttributeVector::SearchContext::SearchContext(const AttributeVector &attr) : _attr(attr), - _plsc(NULL) + _plsc(nullptr) { } AttributeVector::SearchContext::UP @@ -470,8 +470,7 @@ AttributeVector::getSearch(QueryPacketT searchSpec, const SearchContextParams &p } attribute::ISearchContext::UP -AttributeVector::createSearchContext(QueryTermSimpleUP term, - const attribute::SearchContextParams ¶ms) const +AttributeVector::createSearchContext(QueryTermSimpleUP term, const attribute::SearchContextParams ¶ms) const { return getSearch(std::move(term), params); } @@ -481,7 +480,7 @@ AttributeVector::SearchContext::~SearchContext() = default; unsigned int AttributeVector::SearchContext::approximateHits() const { - if (_plsc != NULL) { + if (_plsc != nullptr) { return _plsc->approximateHits(); } return std::max(uint64_t(_attr.getNumDocs()), @@ -492,7 +491,7 @@ SearchIterator::UP AttributeVector::SearchContext:: createIterator(fef::TermFieldMatchData *matchData, bool strict) { - if (_plsc != NULL) { + if (_plsc != nullptr) { SearchIterator::UP res = _plsc->createPostingIterator(matchData, strict); if (res) { return res; @@ -507,25 +506,21 @@ AttributeVector::SearchContext:: createFilterIterator(fef::TermFieldMatchData *matchData, bool strict) { if (!valid()) - return SearchIterator::UP(new queryeval::EmptySearch()); + return std::make_unique<queryeval::EmptySearch>(); if (getIsFilter()) { return SearchIterator::UP(strict ? - new FilterAttributeIteratorStrict<AttributeVector::SearchContext> - (*this, matchData) : - new FilterAttributeIteratorT<AttributeVector::SearchContext> - (*this, matchData)); + new FilterAttributeIteratorStrict<AttributeVector::SearchContext>(*this, matchData) : + new FilterAttributeIteratorT<AttributeVector::SearchContext>(*this, matchData)); } return SearchIterator::UP(strict ? - new AttributeIteratorStrict<AttributeVector::SearchContext> - (*this, matchData) : - new AttributeIteratorT<AttributeVector::SearchContext> - (*this, matchData)); + new AttributeIteratorStrict<AttributeVector::SearchContext>(*this, matchData) : + new AttributeIteratorT<AttributeVector::SearchContext>(*this, matchData)); } void AttributeVector::SearchContext::fetchPostings(bool strict) { - if (_plsc != NULL) + if (_plsc != nullptr) _plsc->fetchPostings(strict); } @@ -536,8 +531,7 @@ AttributeVector::apply(DocId doc, const MapValueUpdate &map) { if (retval) { const ValueUpdate & vu(map.getUpdate()); if (vu.inherits(ArithmeticValueUpdate::classId)) { - const ArithmeticValueUpdate & - au(static_cast<const ArithmeticValueUpdate &>(vu)); + const ArithmeticValueUpdate &au(static_cast<const ArithmeticValueUpdate &>(vu)); retval = applyWeight(doc, map.getKey(), au); } else { retval = false; diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h index 5163457b3c8..8cf4079ccfa 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.h +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h @@ -121,6 +121,7 @@ protected: using QueryTermSimpleUP = std::unique_ptr<QueryTermSimple>; using QueryPacketT = vespalib::stringref; using LoadedBufferUP = std::unique_ptr<fileutil::LoadedBuffer>; + using stringref = vespalib::stringref; public: typedef std::shared_ptr<AttributeVector> SP; class BaseName : public vespalib::string @@ -226,7 +227,7 @@ protected: private: AttributeVector * stealAttr() const { AttributeVector * ret(_attr); - _attr = NULL; + _attr = nullptr; return ret; } @@ -237,8 +238,7 @@ protected: { std::unique_lock<std::shared_timed_mutex> _enumLock; public: - EnumModifier(std::shared_timed_mutex &lock, - attribute::InterlockGuard &interlockGuard) + EnumModifier(std::shared_timed_mutex &lock, attribute::InterlockGuard &interlockGuard) : _enumLock(lock) { (void) interlockGuard; @@ -557,8 +557,8 @@ public: }; SearchContext::UP getSearch(QueryPacketT searchSpec, const attribute::SearchContextParams ¶ms) const; - virtual attribute::ISearchContext::UP createSearchContext(QueryTermSimpleUP term, - const attribute::SearchContextParams ¶ms) const override; + attribute::ISearchContext::UP createSearchContext(QueryTermSimpleUP term, + const attribute::SearchContextParams ¶ms) const override; virtual SearchContext::UP getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams ¶ms) const = 0; virtual const EnumStoreBase *getEnumStoreBase() const; virtual const attribute::MultiValueMappingBase *getMultiValueBase() const; @@ -648,15 +648,15 @@ public: bool hasPostings(); virtual uint64_t getUniqueValueCount() const; virtual uint64_t getTotalValueCount() const; - virtual void compactLidSpace(uint32_t wantedLidLimit) override; + void compactLidSpace(uint32_t wantedLidLimit) override; virtual void clearDocs(DocId lidLow, DocId lidLimit); bool wantShrinkLidSpace() const { return _committedDocIdLimit < getNumDocs(); } - virtual bool canShrinkLidSpace() const override; - virtual void shrinkLidSpace() override; + bool canShrinkLidSpace() const override; + void shrinkLidSpace() override; virtual void onShrinkLidSpace(); - virtual size_t getEstimatedShrinkLidSpaceGain() const override; + size_t getEstimatedShrinkLidSpaceGain() const override; - virtual std::unique_ptr<attribute::AttributeReadGuard> makeReadGuard(bool stableEnumGuard) const override; + std::unique_ptr<attribute::AttributeReadGuard> makeReadGuard(bool stableEnumGuard) const override; void setInterlock(const std::shared_ptr<attribute::Interlock> &interlock); diff --git a/searchlib/src/vespa/searchlib/attribute/attrvector.cpp b/searchlib/src/vespa/searchlib/attribute/attrvector.cpp index 41945dff1fe..0304aa8f38e 100644 --- a/searchlib/src/vespa/searchlib/attribute/attrvector.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attrvector.cpp @@ -18,7 +18,7 @@ StringDirectAttribute(const vespalib::string & baseFileName, const Config & c) { } -StringDirectAttribute::~StringDirectAttribute() {} +StringDirectAttribute::~StringDirectAttribute() = default; bool StringDirectAttribute::findEnum(const char * key, EnumHandle & e) const { diff --git a/searchlib/src/vespa/searchlib/attribute/createarrayfastsearch.cpp b/searchlib/src/vespa/searchlib/attribute/createarrayfastsearch.cpp index 79266fb7128..17e6c91daba 100644 --- a/searchlib/src/vespa/searchlib/attribute/createarrayfastsearch.cpp +++ b/searchlib/src/vespa/searchlib/attribute/createarrayfastsearch.cpp @@ -28,7 +28,7 @@ using attribute::BasicType; #define CREATEFLOATARRAY(T, fname, info) static_cast<AttributeVector *>(new FLOATARRAY(T)(fname, info)) AttributeVector::SP -AttributeFactory::createArrayFastSearch(const vespalib::string & baseFileName, const Config & info) +AttributeFactory::createArrayFastSearch(stringref name, const Config & info) { assert(info.collectionType().type() == attribute::CollectionType::ARRAY); assert(info.fastSearch()); @@ -39,25 +39,25 @@ AttributeFactory::createArrayFastSearch(const vespalib::string & baseFileName, c case BasicType::UINT4: break; case BasicType::INT8: - ret.reset(static_cast<AttributeVector *>(new FlagAttribute(baseFileName, info))); + ret.reset(static_cast<AttributeVector *>(new FlagAttribute(name, info))); break; case BasicType::INT16: - ret.reset(CREATEINTARRAY(int16_t, baseFileName, info)); + ret.reset(CREATEINTARRAY(int16_t, name, info)); break; case BasicType::INT32: - ret.reset(CREATEINTARRAY(int32_t, baseFileName, info)); + ret.reset(CREATEINTARRAY(int32_t, name, info)); break; case BasicType::INT64: - ret.reset(CREATEINTARRAY(int64_t, baseFileName, info)); + ret.reset(CREATEINTARRAY(int64_t, name, info)); break; case BasicType::FLOAT: - ret.reset(CREATEFLOATARRAY(float, baseFileName, info)); + ret.reset(CREATEFLOATARRAY(float, name, info)); break; case BasicType::DOUBLE: - ret.reset(CREATEFLOATARRAY(double, baseFileName, info)); + ret.reset(CREATEFLOATARRAY(double, name, info)); break; case BasicType::STRING: - ret.reset(static_cast<AttributeVector *>(new ArrayStringPostingAttribute(baseFileName, info))); + ret.reset(static_cast<AttributeVector *>(new ArrayStringPostingAttribute(name, info))); break; default: break; diff --git a/searchlib/src/vespa/searchlib/attribute/createarraystd.cpp b/searchlib/src/vespa/searchlib/attribute/createarraystd.cpp index 9e2d4d764e7..ac82e4ba27a 100644 --- a/searchlib/src/vespa/searchlib/attribute/createarraystd.cpp +++ b/searchlib/src/vespa/searchlib/attribute/createarraystd.cpp @@ -22,7 +22,7 @@ using attribute::BasicType; AttributeVector::SP -AttributeFactory::createArrayStd(const vespalib::string & baseFileName, const Config & info) +AttributeFactory::createArrayStd(stringref name, const Config & info) { assert(info.collectionType().type() == attribute::CollectionType::ARRAY); AttributeVector::SP ret; @@ -32,25 +32,25 @@ AttributeFactory::createArrayStd(const vespalib::string & baseFileName, const Co case BasicType::UINT4: break; case BasicType::INT8: - ret.reset(CREATEINTARRAY(int8_t, baseFileName, info)); + ret.reset(CREATEINTARRAY(int8_t, name, info)); break; case BasicType::INT16: - ret.reset(CREATEINTARRAY(int16_t, baseFileName, info)); + ret.reset(CREATEINTARRAY(int16_t, name, info)); break; case BasicType::INT32: - ret.reset(CREATEINTARRAY(int32_t, baseFileName, info)); + ret.reset(CREATEINTARRAY(int32_t, name, info)); break; case BasicType::INT64: - ret.reset(CREATEINTARRAY(int64_t, baseFileName, info)); + ret.reset(CREATEINTARRAY(int64_t, name, info)); break; case BasicType::FLOAT: - ret.reset(CREATEFLOATARRAY(float, baseFileName, info)); + ret.reset(CREATEFLOATARRAY(float, name, info)); break; case BasicType::DOUBLE: - ret.reset(CREATEFLOATARRAY(double, baseFileName, info)); + ret.reset(CREATEFLOATARRAY(double, name, info)); break; case BasicType::STRING: - ret.reset(static_cast<AttributeVector *>(new ArrayStringAttribute(baseFileName, info))); + ret.reset(static_cast<AttributeVector *>(new ArrayStringAttribute(name, info))); break; default: break; diff --git a/searchlib/src/vespa/searchlib/attribute/createsetfastsearch.cpp b/searchlib/src/vespa/searchlib/attribute/createsetfastsearch.cpp index 1068032eecf..323d073589f 100644 --- a/searchlib/src/vespa/searchlib/attribute/createsetfastsearch.cpp +++ b/searchlib/src/vespa/searchlib/attribute/createsetfastsearch.cpp @@ -29,7 +29,7 @@ using attribute::BasicType; AttributeVector::SP -AttributeFactory::createSetFastSearch(const vespalib::string & baseFileName, const Config & info) +AttributeFactory::createSetFastSearch(stringref name, const Config & info) { assert(info.collectionType().type() == attribute::CollectionType::WSET); assert(info.fastSearch()); @@ -40,25 +40,25 @@ AttributeFactory::createSetFastSearch(const vespalib::string & baseFileName, con case BasicType::UINT4: break; case BasicType::INT8: - ret.reset(CREATEINTSET(int8_t, baseFileName, info)); + ret.reset(CREATEINTSET(int8_t, name, info)); break; case BasicType::INT16: - ret.reset(CREATEINTSET(int16_t, baseFileName, info)); + ret.reset(CREATEINTSET(int16_t, name, info)); break; case BasicType::INT32: - ret.reset(CREATEINTSET(int32_t, baseFileName, info)); + ret.reset(CREATEINTSET(int32_t, name, info)); break; case BasicType::INT64: - ret.reset(CREATEINTSET(int64_t, baseFileName, info)); + ret.reset(CREATEINTSET(int64_t, name, info)); break; case BasicType::FLOAT: - ret.reset(CREATEFLOATSET(float, baseFileName, info)); + ret.reset(CREATEFLOATSET(float, name, info)); break; case BasicType::DOUBLE: - ret.reset(CREATEFLOATSET(double, baseFileName, info)); + ret.reset(CREATEFLOATSET(double, name, info)); break; case BasicType::STRING: - ret.reset(static_cast<AttributeVector *>(new WeightedSetStringPostingAttribute(baseFileName, info))); + ret.reset(static_cast<AttributeVector *>(new WeightedSetStringPostingAttribute(name, info))); break; default: break; diff --git a/searchlib/src/vespa/searchlib/attribute/createsetstd.cpp b/searchlib/src/vespa/searchlib/attribute/createsetstd.cpp index 8ef75de2b44..74e478c67b8 100644 --- a/searchlib/src/vespa/searchlib/attribute/createsetstd.cpp +++ b/searchlib/src/vespa/searchlib/attribute/createsetstd.cpp @@ -21,7 +21,7 @@ using attribute::BasicType; AttributeVector::SP -AttributeFactory::createSetStd(const vespalib::string & baseFileName, const Config & info) +AttributeFactory::createSetStd(stringref name, const Config & info) { assert(info.collectionType().type() == attribute::CollectionType::WSET); AttributeVector::SP ret; @@ -31,25 +31,25 @@ AttributeFactory::createSetStd(const vespalib::string & baseFileName, const Conf case BasicType::UINT4: break; case BasicType::INT8: - ret.reset(CREATEINTSET(int8_t, baseFileName, info)); + ret.reset(CREATEINTSET(int8_t, name, info)); break; case BasicType::INT16: - ret.reset(CREATEINTSET(int16_t, baseFileName, info)); + ret.reset(CREATEINTSET(int16_t, name, info)); break; case BasicType::INT32: - ret.reset(CREATEINTSET(int32_t, baseFileName, info)); + ret.reset(CREATEINTSET(int32_t, name, info)); break; case BasicType::INT64: - ret.reset(CREATEINTSET(int64_t, baseFileName, info)); + ret.reset(CREATEINTSET(int64_t, name, info)); break; case BasicType::FLOAT: - ret.reset(CREATEFLOATSET(float, baseFileName, info)); + ret.reset(CREATEFLOATSET(float, name, info)); break; case BasicType::DOUBLE: - ret.reset(CREATEFLOATSET(double, baseFileName, info)); + ret.reset(CREATEFLOATSET(double, name, info)); break; case BasicType::STRING: - ret.reset(static_cast<AttributeVector *>(new WeightedSetStringAttribute(baseFileName, info))); + ret.reset(static_cast<AttributeVector *>(new WeightedSetStringAttribute(name, info))); break; default: break; diff --git a/searchlib/src/vespa/searchlib/attribute/createsinglefastsearch.cpp b/searchlib/src/vespa/searchlib/attribute/createsinglefastsearch.cpp index ec200124286..f3dd642828e 100644 --- a/searchlib/src/vespa/searchlib/attribute/createsinglefastsearch.cpp +++ b/searchlib/src/vespa/searchlib/attribute/createsinglefastsearch.cpp @@ -23,7 +23,7 @@ namespace search { using attribute::BasicType; AttributeVector::SP -AttributeFactory::createSingleFastSearch(const vespalib::string & baseFileName, const Config & info) +AttributeFactory::createSingleFastSearch(stringref name, const Config & info) { assert(info.collectionType().type() == attribute::CollectionType::SINGLE); assert(info.fastSearch()); @@ -34,25 +34,25 @@ AttributeFactory::createSingleFastSearch(const vespalib::string & baseFileName, case BasicType::UINT4: break; case BasicType::INT8: - ret.reset(new INTPOSTING(int8_t)(baseFileName, info)); + ret.reset(new INTPOSTING(int8_t)(name, info)); break; case BasicType::INT16: - ret.reset(new INTPOSTING(int16_t)(baseFileName, info)); + ret.reset(new INTPOSTING(int16_t)(name, info)); break; case BasicType::INT32: - ret.reset(new INTPOSTING(int32_t)(baseFileName, info)); + ret.reset(new INTPOSTING(int32_t)(name, info)); break; case BasicType::INT64: - ret.reset(new INTPOSTING(int64_t)(baseFileName, info)); + ret.reset(new INTPOSTING(int64_t)(name, info)); break; case BasicType::FLOAT: - ret.reset(new FLOATPOSTING(float)(baseFileName, info)); + ret.reset(new FLOATPOSTING(float)(name, info)); break; case BasicType::DOUBLE: - ret.reset(new FLOATPOSTING(double)(baseFileName, info)); + ret.reset(new FLOATPOSTING(double)(name, info)); break; case BasicType::STRING: - ret.reset(new SingleValueStringPostingAttribute(baseFileName, info)); + ret.reset(new SingleValueStringPostingAttribute(name, info)); break; default: break; diff --git a/searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp b/searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp index 6fefc7a1852..cc3d9fe4b37 100644 --- a/searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp +++ b/searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp @@ -18,54 +18,54 @@ namespace search { using attribute::BasicType; AttributeVector::SP -AttributeFactory::createSingleStd(const vespalib::string & baseFileName, const Config & info) +AttributeFactory::createSingleStd(stringref name, const Config & info) { assert(info.collectionType().type() == attribute::CollectionType::SINGLE); AttributeVector::SP ret; switch(info.basicType().type()) { case BasicType::UINT1: - ret.reset(new SingleValueBitNumericAttribute(baseFileName, info.getGrowStrategy())); + ret.reset(new SingleValueBitNumericAttribute(name, info.getGrowStrategy())); break; case BasicType::UINT2: - ret.reset(new SingleValueSemiNibbleNumericAttribute(baseFileName, info.getGrowStrategy())); + ret.reset(new SingleValueSemiNibbleNumericAttribute(name, info.getGrowStrategy())); break; case BasicType::UINT4: - ret.reset(new SingleValueNibbleNumericAttribute(baseFileName, info.getGrowStrategy())); + ret.reset(new SingleValueNibbleNumericAttribute(name, info.getGrowStrategy())); break; case BasicType::INT8: - ret.reset(new SingleValueNumericAttribute<IntegerAttributeTemplate<int8_t> >(baseFileName, info)); + ret.reset(new SingleValueNumericAttribute<IntegerAttributeTemplate<int8_t> >(name, info)); break; case BasicType::INT16: // XXX: Unneeded since we don't have short document fields in java. - ret.reset(new SingleValueNumericAttribute<IntegerAttributeTemplate<int16_t> >(baseFileName, info)); + ret.reset(new SingleValueNumericAttribute<IntegerAttributeTemplate<int16_t> >(name, info)); break; case BasicType::INT32: - ret.reset(new SingleValueNumericAttribute<IntegerAttributeTemplate<int32_t> >(baseFileName, info)); + ret.reset(new SingleValueNumericAttribute<IntegerAttributeTemplate<int32_t> >(name, info)); break; case BasicType::INT64: - ret.reset(new SingleValueNumericAttribute<IntegerAttributeTemplate<int64_t> >(baseFileName, info)); + ret.reset(new SingleValueNumericAttribute<IntegerAttributeTemplate<int64_t> >(name, info)); break; case BasicType::FLOAT: - ret.reset(new SingleValueNumericAttribute<FloatingPointAttributeTemplate<float> >(baseFileName, info)); + ret.reset(new SingleValueNumericAttribute<FloatingPointAttributeTemplate<float> >(name, info)); break; case BasicType::DOUBLE: - ret.reset(new SingleValueNumericAttribute<FloatingPointAttributeTemplate<double> >(baseFileName, info)); + ret.reset(new SingleValueNumericAttribute<FloatingPointAttributeTemplate<double> >(name, info)); break; case BasicType::STRING: - ret.reset(new SingleValueStringAttribute(baseFileName, info)); + ret.reset(new SingleValueStringAttribute(name, info)); break; case BasicType::PREDICATE: - ret.reset(new PredicateAttribute(baseFileName, info)); + ret.reset(new PredicateAttribute(name, info)); break; case BasicType::TENSOR: if (info.tensorType().is_dense()) { - ret.reset(new tensor::DenseTensorAttribute(baseFileName, info)); + ret.reset(new tensor::DenseTensorAttribute(name, info)); } else { - ret.reset(new tensor::GenericTensorAttribute(baseFileName, info)); + ret.reset(new tensor::GenericTensorAttribute(name, info)); } break; case BasicType::REFERENCE: - ret = std::make_shared<attribute::ReferenceAttribute>(baseFileName, info); + ret = std::make_shared<attribute::ReferenceAttribute>(name, info); break; default: break; diff --git a/searchlib/src/vespa/searchlib/attribute/extendableattributes.h b/searchlib/src/vespa/searchlib/attribute/extendableattributes.h index dde8dda46f7..ce57daa775d 100644 --- a/searchlib/src/vespa/searchlib/attribute/extendableattributes.h +++ b/searchlib/src/vespa/searchlib/attribute/extendableattributes.h @@ -108,7 +108,7 @@ protected: using QueryTermSimpleUP = AttributeVector::QueryTermSimpleUP; MultiExtAttribute(const vespalib::string &name, const attribute::CollectionType &ctype) - : Super(name, Config(BasicType::fromType(T()), ctype)) + : Super(name, Config(BasicType::fromType(T()), ctype)) { } private: AttributeVector::SearchContext::UP diff --git a/searchlib/src/vespa/searchlib/attribute/flagattribute.cpp b/searchlib/src/vespa/searchlib/attribute/flagattribute.cpp index 0e5027ea46e..449ec0cd86d 100644 --- a/searchlib/src/vespa/searchlib/attribute/flagattribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/flagattribute.cpp @@ -65,10 +65,10 @@ FlagAttributeT<B>::getSearch(QueryTermSimple::UP qTerm, template <typename B> void FlagAttributeT<B>::clearOldValues(DocId doc) { - const typename B::WType * values(NULL); + const typename B::WType * values(nullptr); for (uint32_t i(0), m(this->get(doc, values)); i < m; i++) { BitVector * bv = _bitVectors[getOffset(values[i].value())]; - if (bv != NULL) { + if (bv != nullptr) { bv->clearBit(doc); } } diff --git a/searchlib/src/vespa/searchlib/attribute/iattributefilewriter.h b/searchlib/src/vespa/searchlib/attribute/iattributefilewriter.h index 7de103ee770..bb00124c9fc 100644 --- a/searchlib/src/vespa/searchlib/attribute/iattributefilewriter.h +++ b/searchlib/src/vespa/searchlib/attribute/iattributefilewriter.h @@ -4,8 +4,7 @@ #include <vespa/vespalib/data/databuffer.h> -namespace search -{ +namespace search { class BufferWriter; diff --git a/searchlib/src/vespa/searchlib/attribute/iattributesavetarget.h b/searchlib/src/vespa/searchlib/attribute/iattributesavetarget.h index 838e9a78744..9f90544bb83 100644 --- a/searchlib/src/vespa/searchlib/attribute/iattributesavetarget.h +++ b/searchlib/src/vespa/searchlib/attribute/iattributesavetarget.h @@ -2,9 +2,6 @@ #pragma once -#include <vespa/vespalib/stllike/string.h> -#include <vespa/vespalib/data/databuffer.h> -#include <stdint.h> #include "iattributefilewriter.h" #include "attribute_header.h" @@ -21,6 +18,7 @@ protected: public: IAttributeSaveTarget() : _header() {} void setHeader(const attribute::AttributeHeader & header) { _header = header; } + const attribute::AttributeHeader & getHeader() const { return _header; } bool getEnumerated() const { return _header.getEnumerated(); } diff --git a/searchlib/src/vespa/searchlib/attribute/multienumattribute.h b/searchlib/src/vespa/searchlib/attribute/multienumattribute.h index b58ed8c4ae8..bcad27f046e 100644 --- a/searchlib/src/vespa/searchlib/attribute/multienumattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/multienumattribute.h @@ -2,9 +2,9 @@ #pragma once -#include <vespa/searchlib/attribute/multivalueattribute.h> -#include <vespa/searchlib/attribute/enumstorebase.h> -#include <vespa/searchlib/attribute/loadedenumvalue.h> +#include "multivalueattribute.h" +#include "enumstorebase.h" +#include "loadedenumvalue.h" namespace search { diff --git a/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp index d5432bf56de..158343ef7c0 100644 --- a/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp @@ -2,8 +2,8 @@ #pragma once -#include <vespa/searchlib/attribute/multienumattribute.h> -#include <vespa/searchlib/attribute/multivalueattribute.hpp> +#include "multienumattribute.h" +#include "multivalueattribute.hpp" #include "multienumattributesaver.h" #include "load_utils.h" diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.hpp index 004c754bb3a..d94a59555bd 100644 --- a/searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.hpp @@ -16,8 +16,7 @@ using fileutil::LoadedBuffer; template <typename B, typename M> MultiValueNumericEnumAttribute<B, M>:: -MultiValueNumericEnumAttribute(const vespalib::string & baseFileName, - const AttributeVector::Config & cfg) +MultiValueNumericEnumAttribute(const vespalib::string & baseFileName, const AttributeVector::Config & cfg) : MultiValueEnumAttribute<B, M>(baseFileName, cfg) { } @@ -70,14 +69,10 @@ MultiValueNumericEnumAttribute<B, M>::onLoadEnumerated(ReaderBase &attrReader) EnumVector enumHist; if (this->hasPostings()) { loaded.reserve(numValues); - this->fillEnumIdx(attrReader, - eidxs, - loaded); + this->fillEnumIdx(attrReader, eidxs, loaded); } else { EnumVector(eidxs.size(), 0).swap(enumHist); - this->fillEnumIdx(attrReader, - eidxs, - enumHist); + this->fillEnumIdx(attrReader, eidxs, enumHist); } EnumIndexVector().swap(eidxs); if (this->hasPostings()) { @@ -131,15 +126,15 @@ MultiValueNumericEnumAttribute<B, M>::getSearch(QueryTermSimple::UP qTerm, QueryTermSimple::RangeResult<T> res = qTerm->getRange<T>(); if (this->hasArrayType()) { if (res.isEqual()) { - return AttributeVector::SearchContext::UP(new ArraySearchContext(std::move(qTerm), *this)); + return std::make_unique<ArraySearchContext>(std::move(qTerm), *this); } else { - return AttributeVector::SearchContext::UP(new ArraySearchContext(std::move(qTerm), *this)); + return std::make_unique<ArraySearchContext>(std::move(qTerm), *this); } } else { if (res.isEqual()) { - return AttributeVector::SearchContext::UP(new SetSearchContext(std::move(qTerm), *this)); + return std::make_unique<SetSearchContext>(std::move(qTerm), *this); } else { - return AttributeVector::SearchContext::UP(new SetSearchContext(std::move(qTerm), *this)); + return std::make_unique<SetSearchContext>(std::move(qTerm), *this); } } } @@ -162,7 +157,7 @@ std::unique_ptr<queryeval::SearchIterator> MultiValueNumericEnumAttribute<B, M>::SetSearchContext::createFilterIterator(fef::TermFieldMatchData * matchData, bool strict) { if (!valid()) { - return queryeval::SearchIterator::UP(new queryeval::EmptySearch()); + return std::make_unique<queryeval::EmptySearch>(); } if (getIsFilter()) { return queryeval::SearchIterator::UP @@ -181,7 +176,7 @@ std::unique_ptr<queryeval::SearchIterator> MultiValueNumericEnumAttribute<B, M>::ArraySearchContext::createFilterIterator(fef::TermFieldMatchData * matchData, bool strict) { if (!valid()) { - return queryeval::SearchIterator::UP(new queryeval::EmptySearch()); + return std::make_unique<queryeval::EmptySearch>(); } if (getIsFilter()) { return queryeval::SearchIterator::UP diff --git a/searchlib/src/vespa/searchlib/attribute/predicate_attribute.cpp b/searchlib/src/vespa/searchlib/attribute/predicate_attribute.cpp index 424405a520e..3d197fc59cd 100644 --- a/searchlib/src/vespa/searchlib/attribute/predicate_attribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/predicate_attribute.cpp @@ -1,12 +1,12 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "predicate_attribute.h" +#include "iattributesavetarget.h" +#include "attribute_header.h" #include <vespa/searchlib/util/fileutil.h> #include <vespa/document/fieldvalue/predicatefieldvalue.h> #include <vespa/document/predicate/predicate.h> #include <vespa/vespalib/data/slime/slime.h> -#include "iattributesavetarget.h" -#include "attribute_header.h" #include <vespa/log/log.h> LOG_SETUP(".searchlib.attribute.predicate_attribute"); @@ -154,8 +154,7 @@ struct DocIdLimitFinderAndMinFeatureFiller : SimpleIndexDeserializeObserver<> { uint32_t _highest_doc_id; V & _min_feature; PredicateIndex &_index; - DocIdLimitFinderAndMinFeatureFiller(V & min_feature, - PredicateIndex &index) : + DocIdLimitFinderAndMinFeatureFiller(V & min_feature, PredicateIndex &index) : _highest_doc_id(0), _min_feature(min_feature), _index(index) @@ -195,15 +194,13 @@ bool PredicateAttribute::onLoad() DocId highest_doc_id; if (version == 0) { DocIdLimitFinderAndMinFeatureFiller<MinFeatureVector> observer(_min_feature, *_index); - _index.reset(new PredicateIndex(getGenerationHandler(), getGenerationHolder(), - _limit_provider, createSimpleIndexConfig(getConfig()), - buffer, observer, 0)); + _index = std::make_unique<PredicateIndex>(getGenerationHandler(), getGenerationHolder(), _limit_provider, + createSimpleIndexConfig(getConfig()), buffer, observer, 0); highest_doc_id = observer._highest_doc_id; } else { DummyObserver observer; - _index.reset( - new PredicateIndex(getGenerationHandler(), getGenerationHolder(), _limit_provider, - createSimpleIndexConfig(getConfig()), buffer, observer, version)); + _index = std::make_unique<PredicateIndex>(getGenerationHandler(), getGenerationHolder(), _limit_provider, + createSimpleIndexConfig(getConfig()), buffer, observer, version); highest_doc_id = buffer.readInt32(); // Deserialize min feature vector _min_feature.ensure_size(highest_doc_id + 1, PredicateAttribute::MIN_FEATURE_FILL); @@ -264,8 +261,7 @@ PredicateAttribute::updateValue(uint32_t doc_id, const PredicateFieldValue &valu return; } PredicateTreeAnnotations result; - PredicateTreeAnnotator::annotate(inspector, result, - _lower_bound, _upper_bound); + PredicateTreeAnnotator::annotate(inspector, result, _lower_bound, _upper_bound); _index->indexDocument(doc_id, result); assert(result.min_feature <= MAX_MIN_FEATURE); uint8_t minFeature = static_cast<uint8_t>(result.min_feature); diff --git a/searchlib/src/vespa/searchlib/attribute/predicate_attribute.h b/searchlib/src/vespa/searchlib/attribute/predicate_attribute.h index f318e39f4fa..18a3664a8bd 100644 --- a/searchlib/src/vespa/searchlib/attribute/predicate_attribute.h +++ b/searchlib/src/vespa/searchlib/attribute/predicate_attribute.h @@ -55,8 +55,7 @@ public: uint32_t clearDoc(DocId doc_id) override; uint32_t getValueCount(DocId doc) const override; - void updateValue(uint32_t doc_id, - const document::PredicateFieldValue &value); + void updateValue(uint32_t doc_id, const document::PredicateFieldValue &value); /** * Will return a handle with a pointer to the min_features and how many there are. @@ -97,8 +96,7 @@ public: static constexpr uint8_t MIN_FEATURE_FILL = 255; static constexpr uint32_t PREDICATE_ATTRIBUTE_VERSION = 2; - virtual uint32_t getVersion() const override; - + uint32_t getVersion() const override; }; } // namespace search diff --git a/searchlib/src/vespa/searchlib/attribute/readerbase.cpp b/searchlib/src/vespa/searchlib/attribute/readerbase.cpp index a8c042c1a44..62936ecaaf4 100644 --- a/searchlib/src/vespa/searchlib/attribute/readerbase.cpp +++ b/searchlib/src/vespa/searchlib/attribute/readerbase.cpp @@ -97,7 +97,7 @@ ReaderBase::ReaderBase(AttributeVector &attr) } -ReaderBase::~ReaderBase() { } +ReaderBase::~ReaderBase() = default; bool ReaderBase::hasWeight() const { diff --git a/searchlib/src/vespa/searchlib/attribute/readerbase.h b/searchlib/src/vespa/searchlib/attribute/readerbase.h index e1c3b64b8a9..09db52f5e25 100644 --- a/searchlib/src/vespa/searchlib/attribute/readerbase.h +++ b/searchlib/src/vespa/searchlib/attribute/readerbase.h @@ -32,8 +32,7 @@ public: } static bool - extractFileSize(const vespalib::GenericHeader &header, - FastOS_FileInterface &file, uint64_t &fileSize); + extractFileSize(const vespalib::GenericHeader &header, FastOS_FileInterface &file, uint64_t &fileSize); size_t getNumValues(); int32_t getNextWeight() { return _weightReader.readHostOrder(); } diff --git a/searchlib/src/vespa/searchlib/attribute/reference_attribute.h b/searchlib/src/vespa/searchlib/attribute/reference_attribute.h index 004339573bc..1670ebdc969 100644 --- a/searchlib/src/vespa/searchlib/attribute/reference_attribute.h +++ b/searchlib/src/vespa/searchlib/attribute/reference_attribute.h @@ -67,9 +67,9 @@ public: DECLARE_IDENTIFIABLE_ABSTRACT(ReferenceAttribute); ReferenceAttribute(const vespalib::stringref baseFileName, const Config & cfg); - virtual ~ReferenceAttribute(); - virtual bool addDoc(DocId &doc) override; - virtual uint32_t clearDoc(DocId doc) override; + ~ReferenceAttribute() override; + bool addDoc(DocId &doc) override; + uint32_t clearDoc(DocId doc) override; void update(DocId doc, const GlobalId &gid); const Reference *getReference(DocId doc); void setGidToLidMapperFactory(std::shared_ptr<IGidToLidMapperFactory> gidToLidMapperFactory); @@ -83,8 +83,8 @@ public: void notifyReferencedPut(const GlobalId &gid, DocId targetLid); void notifyReferencedRemove(const GlobalId &gid); void populateTargetLids(); - virtual void clearDocs(DocId lidLow, DocId lidLimit) override; - virtual void onShrinkLidSpace() override; + void clearDocs(DocId lidLow, DocId lidLimit) override; + void onShrinkLidSpace() override; template <typename FunctionType> void diff --git a/searchlib/src/vespa/searchlib/attribute/stringbase.cpp b/searchlib/src/vespa/searchlib/attribute/stringbase.cpp index 04ca9d216a3..855bf6c7a57 100644 --- a/searchlib/src/vespa/searchlib/attribute/stringbase.cpp +++ b/searchlib/src/vespa/searchlib/attribute/stringbase.cpp @@ -231,13 +231,13 @@ StringAttribute::StringSearchContext::StringSearchContext(QueryTermSimple::UP qT _buffer() { if (isRegex()) { - _regex.reset(new Regexp(_queryTerm->getTerm(), Regexp::Flags().enableICASE())); + _regex = std::make_unique<Regexp>(_queryTerm->getTerm(), Regexp::Flags().enableICASE()); } } StringAttribute::StringSearchContext::~StringSearchContext() { - if (_buffer != NULL) { + if (_buffer != nullptr) { delete [] _buffer; } } @@ -386,13 +386,9 @@ StringAttribute::onLoadEnumerated(ReaderBase &attrReader) timer.SetNow(); LOG(debug, "start fillEnumIdx"); if(hasPostings()) { - fillEnumIdx(attrReader, - eidxs, - loaded); + fillEnumIdx(attrReader, eidxs, loaded); } else { - fillEnumIdx(attrReader, - eidxs, - enumHist); + fillEnumIdx(attrReader, eidxs, enumHist); } LOG(debug, "done fillEnumIdx, %8.3f s elapsed", timer.MilliSecsToNow() / 1000); @@ -405,8 +401,7 @@ StringAttribute::onLoadEnumerated(ReaderBase &attrReader) attribute::sortLoadedByEnum(loaded); - LOG(debug, "done sort loaded, %8.3f s elapsed", - timer.MilliSecsToNow() / 1000); + LOG(debug, "done sort loaded, %8.3f s elapsed", timer.MilliSecsToNow() / 1000); LOG(debug, "start fillPostingsFixupEnum"); timer.SetNow(); @@ -473,74 +468,53 @@ bool StringAttribute::onLoad() } bool -StringAttribute::onAddDoc(DocId doc) +StringAttribute::onAddDoc(DocId ) { - (void) doc; return false; } -void StringAttribute::fillPostings(LoadedVector & loaded) +void StringAttribute::fillPostings(LoadedVector &) { - (void) loaded; } -void StringAttribute::fillEnum(LoadedVector & loaded) +void StringAttribute::fillEnum(LoadedVector &) { - (void) loaded; } -void StringAttribute::fillValues(LoadedVector & loaded) +void StringAttribute::fillValues(LoadedVector & ) { - (void) loaded; } void -StringAttribute::fillEnum0(const void *src, - size_t srcLen, - EnumIndexVector &eidxs) +StringAttribute::fillEnum0(const void *, size_t , EnumIndexVector &) { - (void) src; - (void) srcLen; - (void) eidxs; fprintf(stderr, "StringAttribute::fillEnum0\n"); } void -StringAttribute::fillEnumIdx(ReaderBase &attrReader, - const EnumIndexVector &eidxs, - LoadedEnumAttributeVector &loaded) +StringAttribute::fillEnumIdx(ReaderBase &, const EnumIndexVector &, LoadedEnumAttributeVector &) { - (void) attrReader; - (void) eidxs; - (void) loaded; fprintf(stderr, "StringAttribute::fillEnumIdx (loaded)\n"); } void -StringAttribute::fillEnumIdx(ReaderBase &attrReader, - const EnumIndexVector &eidxs, - EnumVector &enumHist) +StringAttribute::fillEnumIdx(ReaderBase &, const EnumIndexVector &, EnumVector &) { - (void) attrReader; - (void) eidxs; - (void) enumHist; fprintf(stderr, "StringAttribute::fillEnumIdx (enumHist)\n"); } void -StringAttribute::fillPostingsFixupEnum(const LoadedEnumAttributeVector &loaded) +StringAttribute::fillPostingsFixupEnum(const LoadedEnumAttributeVector &) { - (void) loaded; fprintf(stderr, "StringAttribute::fillPostingsFixupEnum\n"); } void -StringAttribute::fixupEnumRefCounts(const EnumVector &enumHist) +StringAttribute::fixupEnumRefCounts(const EnumVector &) { - (void) enumHist; fprintf(stderr, "StringAttribute::fixupEnumRefCounts\n"); } diff --git a/searchlib/src/vespa/searchlib/features/attributefeature.cpp b/searchlib/src/vespa/searchlib/features/attributefeature.cpp index e7f4ab0e352..b3ebd0f3822 100644 --- a/searchlib/src/vespa/searchlib/features/attributefeature.cpp +++ b/searchlib/src/vespa/searchlib/features/attributefeature.cpp @@ -274,9 +274,7 @@ AttributeBlueprint::AttributeBlueprint() : { } -AttributeBlueprint::~AttributeBlueprint() -{ -} +AttributeBlueprint::~AttributeBlueprint() = default; void AttributeBlueprint::visitDumpFeatures(const search::fef::IIndexEnvironment &, diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp index 932d5a8d038..e669e31e2cf 100644 --- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp +++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp @@ -16,9 +16,7 @@ using vespalib::tensor::MutableDenseTensorView; using vespalib::tensor::Tensor; using vespalib::tensor::TensorMapper; -namespace search { - -namespace tensor { +namespace search::tensor { namespace { @@ -59,7 +57,7 @@ TensorReader::TensorReader(AttributeVector &attr) } _unboundDimSizes.resize(_numUnboundDims); } -TensorReader::~TensorReader() { } +TensorReader::~TensorReader() = default; size_t TensorReader::getNumCells() { @@ -73,8 +71,7 @@ TensorReader::getNumCells() { } size_t numCells = _numBoundCells; if (_numUnboundDims != 0) { - _datFile->ReadBuf(&_unboundDimSizes[0], - _numUnboundDims * sizeof(uint32_t)); + _datFile->ReadBuf(&_unboundDimSizes[0], _numUnboundDims * sizeof(uint32_t)); for (auto i = 0u; i < _numUnboundDims; ++i) { assert(_unboundDimSizes[i] != 0u); numCells *= _unboundDimSizes[i]; @@ -189,6 +186,4 @@ DenseTensorAttribute::getVersion() const return DENSE_TENSOR_ATTRIBUTE_VERSION; } -} // namespace search::tensor - -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute_saver.h b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute_saver.h index 8799bed2329..1f6596e82f5 100644 --- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute_saver.h +++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute_saver.h @@ -2,12 +2,10 @@ #pragma once -#include <vespa/searchlib/attribute/attributesaver.h> #include "tensor_attribute.h" +#include <vespa/searchlib/attribute/attributesaver.h> -namespace search { - -namespace tensor { +namespace search::tensor { class DenseTensorStore; @@ -23,16 +21,12 @@ private: const DenseTensorStore &_tensorStore; using GenerationHandler = vespalib::GenerationHandler; - virtual bool onSave(IAttributeSaveTarget &saveTarget) override; + bool onSave(IAttributeSaveTarget &saveTarget) override; public: - DenseTensorAttributeSaver(GenerationHandler::Guard &&guard, - const attribute::AttributeHeader &header, - RefCopyVector &&refs, - const DenseTensorStore &tensorStore); + DenseTensorAttributeSaver(GenerationHandler::Guard &&guard, const attribute::AttributeHeader &header, + RefCopyVector &&refs, const DenseTensorStore &tensorStore); - virtual ~DenseTensorAttributeSaver(); + ~DenseTensorAttributeSaver() override; }; -} // namespace search::tensor - -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/tensor/generic_tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/generic_tensor_attribute.cpp index 31eab642a77..77abe876d87 100644 --- a/searchlib/src/vespa/searchlib/tensor/generic_tensor_attribute.cpp +++ b/searchlib/src/vespa/searchlib/tensor/generic_tensor_attribute.cpp @@ -13,9 +13,7 @@ using vespalib::eval::ValueType; using vespalib::tensor::Tensor; using vespalib::tensor::TensorMapper; -namespace search { - -namespace tensor { +namespace search::tensor { namespace { @@ -36,8 +34,8 @@ public: } -GenericTensorAttribute::GenericTensorAttribute(vespalib::stringref baseFileName, const Config &cfg) - : TensorAttribute(baseFileName, cfg, _genericTensorStore) +GenericTensorAttribute::GenericTensorAttribute(stringref name, const Config &cfg) + : TensorAttribute(name, cfg, _genericTensorStore) { } @@ -120,7 +118,4 @@ GenericTensorAttribute::compactWorst() doCompactWorst<GenericTensorStore::RefType>(); } - -} // namespace search::tensor - -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp index 494c12dcff9..ac7dac0086a 100644 --- a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp +++ b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp @@ -38,10 +38,8 @@ shouldCreateMapper(const ValueType &tensorType) } -TensorAttribute::TensorAttribute(vespalib::stringref baseFileName, - const Config &cfg, - TensorStore &tensorStore) - : NotImplementedAttribute(baseFileName, cfg), +TensorAttribute::TensorAttribute(vespalib::stringref name, const Config &cfg, TensorStore &tensorStore) + : NotImplementedAttribute(name, cfg), _refVector(cfg.getGrowStrategy().getDocsInitialCapacity(), cfg.getGrowStrategy().getDocsGrowPercent(), cfg.getGrowStrategy().getDocsGrowDelta(), @@ -56,9 +54,7 @@ TensorAttribute::TensorAttribute(vespalib::stringref baseFileName, } -TensorAttribute::~TensorAttribute() -{ -} +TensorAttribute::~TensorAttribute() = default; const ITensorAttribute * TensorAttribute::asTensorAttribute() const diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.h b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.h index 1ef3d8a1a96..c50ec0b2f72 100644 --- a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.h +++ b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.h @@ -8,9 +8,7 @@ #include <vespa/searchlib/common/rcuvector.h> #include <vespa/eval/tensor/tensor_mapper.h> -namespace search { - -namespace tensor { +namespace search::tensor { /** * Attribute vector class used to store tensors for all documents in memory. @@ -32,28 +30,24 @@ protected: public: DECLARE_IDENTIFIABLE_ABSTRACT(TensorAttribute); using RefCopyVector = vespalib::Array<RefType>; - TensorAttribute(vespalib::stringref baseFileName, const Config &cfg, - TensorStore &tensorStore); - virtual ~TensorAttribute(); - virtual const ITensorAttribute *asTensorAttribute() const override; - - virtual uint32_t clearDoc(DocId docId) override; - virtual void onCommit() override; - virtual void onUpdateStat() override; - virtual void removeOldGenerations(generation_t firstUsed) override; - virtual void onGenerationChange(generation_t generation) override; - virtual bool addDoc(DocId &docId) override; - virtual std::unique_ptr<Tensor> getEmptyTensor() const override; - virtual vespalib::eval::ValueType getTensorType() const override; - virtual void clearDocs(DocId lidLow, DocId lidLimit) override; - virtual void onShrinkLidSpace() override; - virtual uint32_t getVersion() const override; + TensorAttribute(vespalib::stringref name, const Config &cfg, TensorStore &tensorStore); + ~TensorAttribute() override; + const ITensorAttribute *asTensorAttribute() const override; + + uint32_t clearDoc(DocId docId) override; + void onCommit() override; + void onUpdateStat() override; + void removeOldGenerations(generation_t firstUsed) override; + void onGenerationChange(generation_t generation) override; + bool addDoc(DocId &docId) override; + std::unique_ptr<Tensor> getEmptyTensor() const override; + vespalib::eval::ValueType getTensorType() const override; + void clearDocs(DocId lidLow, DocId lidLimit) override; + void onShrinkLidSpace() override; + uint32_t getVersion() const override; RefCopyVector getRefCopy() const; virtual void setTensor(DocId docId, const Tensor &tensor) = 0; virtual void compactWorst() = 0; }; - -} // namespace search::tensor - -} // namespace search +} |