diff options
author | Tor Egge <Tor.Egge@online.no> | 2023-07-14 10:42:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-14 10:42:31 +0200 |
commit | 0a38c6b813cd118e7aab833699a2c8547d1c8e14 (patch) | |
tree | d8e5fd52c92cb974dded54b486bb951bbd67855b | |
parent | bf480e663efe4e7390285d624a7b383de66a1a10 (diff) |
Revert "- Pack data closer to let config fit in 2 cache lines instead of 4."
33 files changed, 347 insertions, 333 deletions
diff --git a/eval/src/vespa/eval/eval/value_type.h b/eval/src/vespa/eval/eval/value_type.h index 5c0d9e3317d..49f88edb2f9 100644 --- a/eval/src/vespa/eval/eval/value_type.h +++ b/eval/src/vespa/eval/eval/value_type.h @@ -25,13 +25,13 @@ public: : name(name_in), size(npos) {} Dimension(const vespalib::string &name_in, size_type size_in) noexcept : name(name_in), size(size_in) {} - bool operator==(const Dimension &rhs) const noexcept { + bool operator==(const Dimension &rhs) const { return ((name == rhs.name) && (size == rhs.size)); } - bool operator!=(const Dimension &rhs) const noexcept { return !(*this == rhs); } - bool is_mapped() const noexcept { return (size == npos); } - bool is_indexed() const noexcept { return (size != npos); } - bool is_trivial() const noexcept { return (size == 1); } + bool operator!=(const Dimension &rhs) const { return !(*this == rhs); } + bool is_mapped() const { return (size == npos); } + bool is_indexed() const { return (size != npos); } + bool is_trivial() const { return (size == 1); } }; private: @@ -39,10 +39,10 @@ private: CellType _cell_type; std::vector<Dimension> _dimensions; - ValueType() noexcept + ValueType() : _error(true), _cell_type(CellType::DOUBLE), _dimensions() {} - ValueType(CellType cell_type_in, std::vector<Dimension> &&dimensions_in) noexcept + ValueType(CellType cell_type_in, std::vector<Dimension> &&dimensions_in) : _error(false), _cell_type(cell_type_in), _dimensions(std::move(dimensions_in)) {} static ValueType error_if(bool has_error, ValueType else_type); @@ -57,7 +57,7 @@ public: CellMeta cell_meta() const { return {_cell_type, is_double()}; } bool is_error() const { return _error; } bool is_double() const; - bool has_dimensions() const noexcept { return !_dimensions.empty(); } + bool has_dimensions() const { return !_dimensions.empty(); } bool is_sparse() const; bool is_dense() const; bool is_mixed() const; @@ -70,12 +70,12 @@ public: std::vector<Dimension> mapped_dimensions() const; size_t dimension_index(const vespalib::string &name) const; std::vector<vespalib::string> dimension_names() const; - bool operator==(const ValueType &rhs) const noexcept { + bool operator==(const ValueType &rhs) const { return ((_error == rhs._error) && (_cell_type == rhs._cell_type) && (_dimensions == rhs._dimensions)); } - bool operator!=(const ValueType &rhs) const noexcept { return !(*this == rhs); } + bool operator!=(const ValueType &rhs) const { return !(*this == rhs); } ValueType map() const; ValueType reduce(const std::vector<vespalib::string> &dimensions_in) const; diff --git a/searchlib/src/tests/attribute/compaction/attribute_compaction_test.cpp b/searchlib/src/tests/attribute/compaction/attribute_compaction_test.cpp index 79ef6e42bb2..c5d70109015 100644 --- a/searchlib/src/tests/attribute/compaction/attribute_compaction_test.cpp +++ b/searchlib/src/tests/attribute/compaction/attribute_compaction_test.cpp @@ -123,7 +123,7 @@ void hammerAttribute(AttributePtr &v, DocIdRange range, uint32_t count) Config compactAddressSpaceAttributeConfig(bool enableAddressSpaceCompact) { Config cfg(BasicType::INT8, CollectionType::ARRAY); - cfg.setCompactionStrategy({ 1.0f, (enableAddressSpaceCompact ? 0.2f : 1.0f) }); + cfg.setCompactionStrategy({ 1.0, (enableAddressSpaceCompact ? 0.2 : 1.0) }); return cfg; } diff --git a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp index 5370eff78cf..0d64683b4a6 100644 --- a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp +++ b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp @@ -1022,7 +1022,7 @@ TEST_F("require that lid space can be increased after being compacted and then s TEST_F("require that there is control of static memory usage", Fixture) { vespalib::MemoryUsage usage = f.store.getMemoryUsage(); - EXPECT_EQUAL(520u + sizeof(LogDataStore::NameIdSet) + sizeof(std::mutex), sizeof(LogDataStore)); + EXPECT_EQUAL(536u + sizeof(LogDataStore::NameIdSet) + sizeof(std::mutex), sizeof(LogDataStore)); EXPECT_EQUAL(74108u, usage.allocatedBytes()); EXPECT_EQUAL(384u, usage.usedBytes()); } diff --git a/searchlib/src/vespa/searchcommon/attribute/basictype.h b/searchlib/src/vespa/searchcommon/attribute/basictype.h index 407348fea92..46387dd2738 100644 --- a/searchlib/src/vespa/searchcommon/attribute/basictype.h +++ b/searchlib/src/vespa/searchcommon/attribute/basictype.h @@ -9,7 +9,7 @@ namespace search::attribute { class BasicType { public: - enum Type : uint8_t { + enum Type { NONE = 0, STRING = 1, BOOL = 2, @@ -28,33 +28,33 @@ class BasicType MAX_TYPE }; - explicit BasicType(int t) noexcept : _type(Type(t)) { } - explicit BasicType(unsigned int t) noexcept : _type(Type(t)) { } - BasicType(Type t) noexcept : _type(t) { } + explicit BasicType(int t) : _type(Type(t)) { } + explicit BasicType(unsigned int t) : _type(Type(t)) { } + BasicType(Type t) : _type(t) { } explicit BasicType(const vespalib::string & t) : _type(asType(t)) { } - Type type() const noexcept { return _type; } - const char * asString() const noexcept { return asString(_type); } - size_t fixedSize() const noexcept { return fixedSize(_type); } - static BasicType fromType(bool) noexcept { return BOOL; } - static BasicType fromType(int8_t) noexcept { return INT8; } - static BasicType fromType(int16_t) noexcept { return INT16; } - static BasicType fromType(int32_t) noexcept { return INT32; } - static BasicType fromType(int64_t) noexcept { return INT64; } - static BasicType fromType(float) noexcept { return FLOAT; } - static BasicType fromType(double) noexcept { return DOUBLE; } - bool operator==(const BasicType &b) const noexcept { return _type == b._type; } - bool operator!=(const BasicType &b) const noexcept { return _type != b._type; } + Type type() const { return _type; } + const char * asString() const { return asString(_type); } + size_t fixedSize() const { return fixedSize(_type); } + static BasicType fromType(bool) { return BOOL; } + static BasicType fromType(int8_t) { return INT8; } + static BasicType fromType(int16_t) { return INT16; } + static BasicType fromType(int32_t) { return INT32; } + static BasicType fromType(int64_t) { return INT64; } + static BasicType fromType(float) { return FLOAT; } + static BasicType fromType(double) { return DOUBLE; } + bool operator==(const BasicType &b) const { return _type == b._type; } + bool operator!=(const BasicType &b) const { return _type != b._type; } private: - static const char * asString(Type t) noexcept { return _typeTable[t]._name; } - static size_t fixedSize(Type t) noexcept { return _typeTable[t]._fixedSize; } + static const char * asString(Type t) { return _typeTable[t]._name; } + static size_t fixedSize(Type t) { return _typeTable[t]._fixedSize; } static Type asType(const vespalib::string & t); Type _type; struct TypeInfo { - Type _type; + Type _type; unsigned int _fixedSize; const char * _name; }; diff --git a/searchlib/src/vespa/searchcommon/attribute/collectiontype.h b/searchlib/src/vespa/searchcommon/attribute/collectiontype.h index 05fad8cbc64..35cb7612ed0 100644 --- a/searchlib/src/vespa/searchcommon/attribute/collectiontype.h +++ b/searchlib/src/vespa/searchcommon/attribute/collectiontype.h @@ -9,7 +9,7 @@ namespace search::attribute { class CollectionType { public: - enum Type : uint8_t { + enum Type { /** * Single value type with one value stored for each document. **/ @@ -26,30 +26,32 @@ class CollectionType MAX_TYPE }; - CollectionType(Type t = SINGLE, bool remove = false, bool create = false) noexcept - : _type(t), - _removeIfZero(remove), - _createIfNonExistant(create) - { } + CollectionType(Type t = SINGLE, bool remove = false, bool create = false) : + _type(t), + _removeIfZero(remove), + _createIfNonExistant(create) + { + } explicit - CollectionType(const vespalib::string & t, bool remove = false, bool create = false) - : _type(asType(t)), - _removeIfZero(remove), - _createIfNonExistant(create) - { } + CollectionType(const vespalib::string & t, bool remove = false, bool create = false) : + _type(asType(t)), + _removeIfZero(remove), + _createIfNonExistant(create) + { + } - Type type() const noexcept { return _type; } - bool isMultiValue() const noexcept { return _type != SINGLE; } - bool isWeightedSet() const noexcept { return _type == WSET; } - bool isArray() const noexcept { return _type == ARRAY; } - bool removeIfZero() const noexcept { return _removeIfZero; } - bool createIfNonExistant() const noexcept { return _createIfNonExistant; } - const char * asString() const noexcept { return asString(_type); } - void removeIfZero(bool newValue) noexcept { _removeIfZero = newValue; } - void createIfNonExistant(bool newValue) noexcept { _createIfNonExistant = newValue; } - bool operator!=(const CollectionType &b) const noexcept { return !(operator==(b)); } - bool operator==(const CollectionType &b) const noexcept { + Type type() const { return _type; } + bool isMultiValue() const { return _type != SINGLE; } + bool isWeightedSet() const { return _type == WSET; } + bool isArray() const { return _type == ARRAY; } + bool removeIfZero() const { return _removeIfZero; } + bool createIfNonExistant() const { return _createIfNonExistant; } + const char * asString() const { return asString(_type); } + void removeIfZero(bool newValue) { _removeIfZero = newValue; } + void createIfNonExistant(bool newValue) { _createIfNonExistant = newValue; } + bool operator!=(const CollectionType &b) const { return !(operator==(b)); } + bool operator==(const CollectionType &b) const { return _type == b._type && _removeIfZero == b._removeIfZero && _createIfNonExistant == b._createIfNonExistant; @@ -61,12 +63,12 @@ class CollectionType const char * _name; }; - static const char * asString(Type t) noexcept { return _typeTable[t]._name; } + static const char * asString(Type t) { return _typeTable[t]._name; } static Type asType(const vespalib::string &t); - Type _type : 4; - bool _removeIfZero : 1; - bool _createIfNonExistant : 1; + Type _type; + bool _removeIfZero; + bool _createIfNonExistant; static const TypeInfo _typeTable[MAX_TYPE]; }; diff --git a/searchlib/src/vespa/searchcommon/attribute/config.cpp b/searchlib/src/vespa/searchcommon/attribute/config.cpp index 7c302a10731..af29bd64ad6 100644 --- a/searchlib/src/vespa/searchcommon/attribute/config.cpp +++ b/searchlib/src/vespa/searchcommon/attribute/config.cpp @@ -23,14 +23,14 @@ Config::Config(BasicType bt, CollectionType ct, bool fastSearch_) noexcept _fastAccess(false), _mutable(false), _paged(false), - _distance_metric(DistanceMetric::Euclidean), + _maxUnCommittedMemory(MAX_UNCOMMITTED_MEMORY), _match(Match::UNCASED), _dictionary(), - _maxUnCommittedMemory(MAX_UNCOMMITTED_MEMORY), _growStrategy(), _compactionStrategy(), _predicateParams(), _tensorType(vespalib::eval::ValueType::error_type()), + _distance_metric(DistanceMetric::Euclidean), _hnsw_index_params() { } @@ -42,7 +42,7 @@ Config & Config::operator = (Config &&) noexcept = default; Config::~Config() = default; bool -Config::operator==(const Config &b) const noexcept +Config::operator==(const Config &b) const { return _basicType == b._basicType && _type == b._type && diff --git a/searchlib/src/vespa/searchcommon/attribute/config.h b/searchlib/src/vespa/searchcommon/attribute/config.h index 17c762267cc..b368885240c 100644 --- a/searchlib/src/vespa/searchcommon/attribute/config.h +++ b/searchlib/src/vespa/searchcommon/attribute/config.h @@ -21,7 +21,7 @@ namespace search::attribute { */ class Config { public: - enum class Match : uint8_t { CASED, UNCASED }; + enum class Match { CASED, UNCASED }; using CompactionStrategy = vespalib::datastore::CompactionStrategy; Config() noexcept; Config(BasicType bt) noexcept : Config(bt, CollectionType::SINGLE) { } @@ -33,27 +33,27 @@ public: Config & operator = (Config &&) noexcept; ~Config(); - BasicType basicType() const noexcept { return _basicType; } - CollectionType collectionType() const noexcept { return _type; } - bool fastSearch() const noexcept { return _fastSearch; } - bool paged() const noexcept { return _paged; } - const PredicateParams &predicateParams() const noexcept { return _predicateParams; } - const vespalib::eval::ValueType & tensorType() const noexcept { return _tensorType; } - DistanceMetric distance_metric() const noexcept { return _distance_metric; } + BasicType basicType() const { return _basicType; } + CollectionType collectionType() const { return _type; } + bool fastSearch() const { return _fastSearch; } + bool paged() const { return _paged; } + const PredicateParams &predicateParams() const { return _predicateParams; } + const vespalib::eval::ValueType & tensorType() const { return _tensorType; } + DistanceMetric distance_metric() const { return _distance_metric; } const std::optional<HnswIndexParams>& hnsw_index_params() const { return _hnsw_index_params; } /** * Check if attribute posting list can consist of only a bitvector with * no corresponding btree. */ - bool getIsFilter() const noexcept { return _isFilter; } - bool isMutable() const noexcept { return _mutable; } + bool getIsFilter() const { return _isFilter; } + bool isMutable() const { return _mutable; } /** * Check if this attribute should be fast accessible at all times. * If so, attribute is kept in memory also for non-searchable documents. */ - bool fastAccess() const noexcept { return _fastAccess; } + bool fastAccess() const { return _fastAccess; } const GrowStrategy & getGrowStrategy() const { return _growStrategy; } const CompactionStrategy &getCompactionStrategy() const { return _compactionStrategy; } @@ -92,28 +92,28 @@ public: } Config & set_dictionary_config(const DictionaryConfig & cfg) { _dictionary = cfg; return *this; } Config & set_match(Match match) { _match = match; return *this; } - bool operator!=(const Config &b) const noexcept { return !(operator==(b)); } - bool operator==(const Config &b) const noexcept ; + bool operator!=(const Config &b) const { return !(operator==(b)); } + bool operator==(const Config &b) const; - uint64_t getMaxUnCommittedMemory() const noexcept { return _maxUnCommittedMemory; } + uint64_t getMaxUnCommittedMemory() const { return _maxUnCommittedMemory; } Config & setMaxUnCommittedMemory(uint64_t value) { _maxUnCommittedMemory = value; return *this; } private: BasicType _basicType; CollectionType _type; - bool _fastSearch : 1; - bool _isFilter : 1; - bool _fastAccess : 1; - bool _mutable : 1; - bool _paged : 1; - DistanceMetric _distance_metric; + bool _fastSearch; + bool _isFilter; + bool _fastAccess; + bool _mutable; + bool _paged; + uint64_t _maxUnCommittedMemory; Match _match; DictionaryConfig _dictionary; - uint64_t _maxUnCommittedMemory; GrowStrategy _growStrategy; CompactionStrategy _compactionStrategy; PredicateParams _predicateParams; vespalib::eval::ValueType _tensorType; + DistanceMetric _distance_metric; std::optional<HnswIndexParams> _hnsw_index_params; }; diff --git a/searchlib/src/vespa/searchcommon/attribute/distance_metric.h b/searchlib/src/vespa/searchcommon/attribute/distance_metric.h index 35f5fb4fe6b..9f9f45810b9 100644 --- a/searchlib/src/vespa/searchcommon/attribute/distance_metric.h +++ b/searchlib/src/vespa/searchcommon/attribute/distance_metric.h @@ -2,10 +2,8 @@ #pragma once -#include <cstdint> - namespace search::attribute { -enum DistanceMetric : uint8_t { Euclidean, Angular, GeoDegrees, InnerProduct, Hamming, PrenormalizedAngular, Dotproduct }; +enum class DistanceMetric { Euclidean, Angular, GeoDegrees, InnerProduct, Hamming, PrenormalizedAngular, Dotproduct }; } diff --git a/searchlib/src/vespa/searchcommon/attribute/persistent_predicate_params.h b/searchlib/src/vespa/searchcommon/attribute/persistent_predicate_params.h index 205a75c188f..d81eb9c5d3c 100644 --- a/searchlib/src/vespa/searchcommon/attribute/persistent_predicate_params.h +++ b/searchlib/src/vespa/searchcommon/attribute/persistent_predicate_params.h @@ -10,23 +10,24 @@ namespace search::attribute { * Persistent parameters for predicate attributes. */ class PersistentPredicateParams { + uint32_t _arity; int64_t _lower_bound; int64_t _upper_bound; - uint32_t _arity; public: - PersistentPredicateParams() noexcept - : _lower_bound(std::numeric_limits<int64_t>::min()), - _upper_bound(std::numeric_limits<int64_t>::max()), - _arity(8) - { } - uint32_t arity() const noexcept { return _arity; } - int64_t lower_bound() const noexcept { return _lower_bound; } - int64_t upper_bound() const noexcept { return _upper_bound; } - void setArity(uint32_t v) noexcept { _arity = v; } - void setBounds(int64_t lower, int64_t upper) noexcept { _lower_bound = lower; _upper_bound = upper; } + PersistentPredicateParams() + : _arity(8), + _lower_bound(std::numeric_limits<int64_t>::min()), + _upper_bound(std::numeric_limits<int64_t>::max()) + { + } + uint32_t arity() const { return _arity; } + int64_t lower_bound() const { return _lower_bound; } + int64_t upper_bound() const { return _upper_bound; } + void setArity(uint32_t v) { _arity = v; } + void setBounds(int64_t lower, int64_t upper) { _lower_bound = lower; _upper_bound = upper; } - bool operator==(const PersistentPredicateParams &rhs) const noexcept { + bool operator==(const PersistentPredicateParams &rhs) const { return ((_arity == rhs._arity) && (_lower_bound == rhs._lower_bound) && (_upper_bound == rhs._upper_bound)); diff --git a/searchlib/src/vespa/searchcommon/attribute/predicate_params.h b/searchlib/src/vespa/searchcommon/attribute/predicate_params.h index 7e9258ab5db..133b7331689 100644 --- a/searchlib/src/vespa/searchcommon/attribute/predicate_params.h +++ b/searchlib/src/vespa/searchcommon/attribute/predicate_params.h @@ -11,16 +11,17 @@ namespace search::attribute { */ class PredicateParams : public PersistentPredicateParams { - float _dense_posting_list_threshold; + double _dense_posting_list_threshold; public: - PredicateParams() noexcept + PredicateParams() : PersistentPredicateParams(), _dense_posting_list_threshold(0.4) - { } + { + } - float dense_posting_list_threshold() const noexcept { return _dense_posting_list_threshold; } - void setDensePostingListThreshold(float v) noexcept { _dense_posting_list_threshold = v; } - bool operator==(const PredicateParams &rhs) const noexcept { + double dense_posting_list_threshold() const { return _dense_posting_list_threshold; } + void setDensePostingListThreshold(double v) { _dense_posting_list_threshold = v; } + bool operator==(const PredicateParams &rhs) const { return (PersistentPredicateParams::operator==(rhs) && (_dense_posting_list_threshold == rhs._dense_posting_list_threshold)); } diff --git a/searchlib/src/vespa/searchcommon/common/dictionary_config.h b/searchlib/src/vespa/searchcommon/common/dictionary_config.h index f504439c5a3..f51341ad799 100644 --- a/searchlib/src/vespa/searchcommon/common/dictionary_config.h +++ b/searchlib/src/vespa/searchcommon/common/dictionary_config.h @@ -3,7 +3,6 @@ #pragma once #include <iosfwd> -#include <cstdint> namespace search { @@ -12,8 +11,8 @@ namespace search { */ class DictionaryConfig { public: - enum class Type : uint8_t { BTREE, HASH, BTREE_AND_HASH }; - enum class Match : uint8_t { CASED, UNCASED }; + enum class Type { BTREE, HASH, BTREE_AND_HASH }; + enum class Match { CASED, UNCASED }; DictionaryConfig() noexcept : _type(Type::BTREE), _match(Match::UNCASED) {} DictionaryConfig(Type type) noexcept : _type(type), _match(Match::UNCASED) {} DictionaryConfig(Type type, Match match) noexcept : _type(type), _match(match) {} @@ -21,8 +20,8 @@ public: Match getMatch() const { return _match; } bool operator == (const DictionaryConfig & b) const { return (_type == b._type) && (_match == b._match); } private: - Type _type : 4; - Match _match : 4; + Type _type; + Match _match; }; std::ostream& operator<<(std::ostream& os, const DictionaryConfig & cfg); diff --git a/searchlib/src/vespa/searchcommon/common/growstrategy.h b/searchlib/src/vespa/searchcommon/common/growstrategy.h index 86750eafbfc..8766989ded0 100644 --- a/searchlib/src/vespa/searchcommon/common/growstrategy.h +++ b/searchlib/src/vespa/searchcommon/common/growstrategy.h @@ -23,17 +23,17 @@ public: { } - static GrowStrategy make(uint32_t docsInitialCapacity, float docsGrowFactor, uint32_t docsGrowDelta) noexcept { + static GrowStrategy make(uint32_t docsInitialCapacity, float docsGrowFactor, uint32_t docsGrowDelta) { return {docsInitialCapacity, docsGrowFactor, docsGrowDelta, 0, 0.2}; } - float getMultiValueAllocGrowFactor() const noexcept { return _multiValueAllocGrowFactor; } + float getMultiValueAllocGrowFactor() const { return _multiValueAllocGrowFactor; } - bool operator==(const GrowStrategy & rhs) const noexcept { + bool operator==(const GrowStrategy & rhs) const { return vespalib::GrowStrategy::operator==(rhs) && (_multiValueAllocGrowFactor == rhs._multiValueAllocGrowFactor); } - bool operator!=(const GrowStrategy & rhs) const noexcept { + bool operator!=(const GrowStrategy & rhs) const { return !(operator==(rhs)); } }; diff --git a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp index 152fcef5e8b..1c6455dec84 100644 --- a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp @@ -129,10 +129,26 @@ private: public: AttributeFieldBlueprint(const FieldSpec &field, const IAttributeVector &attribute, - const string &query_stack, const SearchContextParams ¶ms); + const string &query_stack, const SearchContextParams ¶ms) + : AttributeFieldBlueprint(field, attribute, QueryTermDecoder::decodeTerm(query_stack), params) + { } AttributeFieldBlueprint(const FieldSpec &field, const IAttributeVector &attribute, - QueryTermSimple::UP term, const SearchContextParams ¶ms); - ~AttributeFieldBlueprint() override; + QueryTermSimple::UP term, const SearchContextParams ¶ms) + : SimpleLeafBlueprint(field), + _attr(attribute), + _query_term(term->getTermString()), + _search_context(attribute.createSearchContext(std::move(term), params)), + _type(OTHER) + { + uint32_t estHits = _search_context->approximateHits(); + HitEstimate estimate(estHits, estHits == 0); + setEstimate(estimate); + if (attribute.isFloatingPointType()) { + _type = FLOAT; + } else if (attribute.isIntegerType()) { + _type = INT; + } + } SearchIteratorUP createLeafSearch(const TermFieldMatchDataArray &tfmda, bool strict) const override { assert(tfmda.size() == 1); @@ -164,30 +180,6 @@ public: bool getRange(vespalib::string &from, vespalib::string &to) const override; }; -AttributeFieldBlueprint::~AttributeFieldBlueprint() = default; - -AttributeFieldBlueprint::AttributeFieldBlueprint(const FieldSpec &field, const IAttributeVector &attribute, - const string &query_stack, const SearchContextParams ¶ms) - : AttributeFieldBlueprint(field, attribute, QueryTermDecoder::decodeTerm(query_stack), params) -{ } -AttributeFieldBlueprint::AttributeFieldBlueprint(const FieldSpec &field, const IAttributeVector &attribute, - QueryTermSimple::UP term, const SearchContextParams ¶ms) - : SimpleLeafBlueprint(field), - _attr(attribute), - _query_term(term->getTermString()), - _search_context(attribute.createSearchContext(std::move(term), params)), - _type(OTHER) -{ - uint32_t estHits = _search_context->approximateHits(); - HitEstimate estimate(estHits, estHits == 0); - setEstimate(estimate); - if (attribute.isFloatingPointType()) { - _type = FLOAT; - } else if (attribute.isIntegerType()) { - _type = INT; - } -} - vespalib::string get_type(const IAttributeVector& attr) { diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp index d606daaa3e0..b053b386593 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp @@ -125,8 +125,6 @@ bool AttributeVector::hasArrayType() const { return _config->collectionType().is bool AttributeVector::getIsFilter() const { return _config->getIsFilter(); } bool AttributeVector::getIsFastSearch() const { return _config->fastSearch(); } bool AttributeVector::isMutable() const { return _config->isMutable(); } -attribute::BasicType::Type AttributeVector::getBasicType() const { return _config->basicType().type(); } -attribute::CollectionType::Type AttributeVector::getCollectionType() const { return _config->collectionType().type(); } bool AttributeVector::isEnumerated(const vespalib::GenericHeader &header) diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h index 68dfe52643f..5fd6cb915fa 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.h +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h @@ -319,8 +319,8 @@ public: AddressSpaceUsage getAddressSpaceUsage() const; - BasicType::Type getBasicType() const override final; - CollectionType::Type getCollectionType() const override final; + BasicType::Type getBasicType() const override final { return getInternalBasicType().type(); } + CollectionType::Type getCollectionType() const override final { return getInternalCollectionType().type(); } uint32_t getCommittedDocIdLimit() const override final { return _committedDocIdLimit.load(std::memory_order_acquire); } bool isImported() const override; diff --git a/searchlib/src/vespa/searchlib/attribute/string_search_helper.cpp b/searchlib/src/vespa/searchlib/attribute/string_search_helper.cpp index 6e56f5477c2..17a0e6256d4 100644 --- a/searchlib/src/vespa/searchlib/attribute/string_search_helper.cpp +++ b/searchlib/src/vespa/searchlib/attribute/string_search_helper.cpp @@ -41,7 +41,7 @@ StringSearchHelper::StringSearchHelper(StringSearchHelper&&) noexcept = default; StringSearchHelper::~StringSearchHelper() = default; bool -StringSearchHelper::isMatch(const char *src) const noexcept { +StringSearchHelper::isMatch(const char *src) const { if (__builtin_expect(isRegex(), false)) { return getRegex().valid() && getRegex().partial_match(std::string_view(src)); } diff --git a/searchlib/src/vespa/searchlib/attribute/string_search_helper.h b/searchlib/src/vespa/searchlib/attribute/string_search_helper.h index 0c52692ee04..7bfcf0e4292 100644 --- a/searchlib/src/vespa/searchlib/attribute/string_search_helper.h +++ b/searchlib/src/vespa/searchlib/attribute/string_search_helper.h @@ -22,7 +22,7 @@ public: StringSearchHelper(const StringSearchHelper &) = delete; StringSearchHelper & operator =(const StringSearchHelper &) = delete; ~StringSearchHelper(); - bool isMatch(const char *src) const noexcept; + bool isMatch(const char *src) const; bool isPrefix() const noexcept { return _isPrefix; } bool isRegex() const noexcept { return _isRegex; } bool isCased() const noexcept { return _isCased; } diff --git a/searchlib/src/vespa/searchlib/fef/properties.cpp b/searchlib/src/vespa/searchlib/fef/properties.cpp index 2cc4e50b593..6f334630dc5 100644 --- a/searchlib/src/vespa/searchlib/fef/properties.cpp +++ b/searchlib/src/vespa/searchlib/fef/properties.cpp @@ -11,7 +11,7 @@ const Property::Value Property::_emptyValue; const Property::Values Property::_emptyValues; const Property::Value & -Property::getAt(uint32_t idx) const noexcept +Property::getAt(uint32_t idx) const { if (idx < (*_values).size()) { return (*_values)[idx]; @@ -22,7 +22,7 @@ Property::getAt(uint32_t idx) const noexcept //----------------------------------------------------------------------------- uint32_t -Properties::rawHash(const void *buf, uint32_t len) noexcept +Properties::rawHash(const void *buf, uint32_t len) { uint32_t res = 0; unsigned const char *pt = (unsigned const char *) buf; @@ -33,7 +33,7 @@ Properties::rawHash(const void *buf, uint32_t len) noexcept return res; } -Properties::Properties() noexcept +Properties::Properties() : _numValues(0), _data() { @@ -59,7 +59,7 @@ Properties::add(vespalib::stringref key, vespalib::stringref value) } uint32_t -Properties::count(vespalib::stringref key) const noexcept +Properties::count(vespalib::stringref key) const { if (!key.empty()) { auto node = _data.find(key); @@ -112,14 +112,14 @@ Properties::clear() } bool -Properties::operator==(const Properties &rhs) const noexcept +Properties::operator==(const Properties &rhs) const { return (_numValues == rhs._numValues && _data == rhs._data); } uint32_t -Properties::hashCode() const noexcept +Properties::hashCode() const { uint32_t hash = numKeys() + numValues(); for (const auto& elem : _data) { @@ -159,7 +159,7 @@ Properties::visitNamespace(vespalib::stringref ns, } Property -Properties::lookup(vespalib::stringref key) const noexcept +Properties::lookup(vespalib::stringref key) const { if (key.empty()) { return Property(); @@ -172,7 +172,7 @@ Properties::lookup(vespalib::stringref key) const noexcept } Property Properties::lookup(vespalib::stringref namespace1, - vespalib::stringref key) const noexcept + vespalib::stringref key) const { if (namespace1.empty() || key.empty()) { return Property(); @@ -184,7 +184,7 @@ Property Properties::lookup(vespalib::stringref namespace1, Property Properties::lookup(vespalib::stringref namespace1, vespalib::stringref namespace2, - vespalib::stringref key) const noexcept + vespalib::stringref key) const { if (namespace1.empty() || namespace2.empty() || key.empty()) { return Property(); @@ -197,7 +197,7 @@ Property Properties::lookup(vespalib::stringref namespace1, Property Properties::lookup(vespalib::stringref namespace1, vespalib::stringref namespace2, vespalib::stringref namespace3, - vespalib::stringref key) const noexcept + vespalib::stringref key) const { if (namespace1.empty() || namespace2.empty() || namespace3.empty() || key.empty()) { return Property(); @@ -207,7 +207,7 @@ Property Properties::lookup(vespalib::stringref namespace1, return lookup(fullKey); } -void Properties::swap(Properties & rhs) noexcept +void Properties::swap(Properties & rhs) { _data.swap(rhs._data); std::swap(_numValues, rhs._numValues); diff --git a/searchlib/src/vespa/searchlib/fef/properties.h b/searchlib/src/vespa/searchlib/fef/properties.h index 80e8c70939c..a6ae83b0339 100644 --- a/searchlib/src/vespa/searchlib/fef/properties.h +++ b/searchlib/src/vespa/searchlib/fef/properties.h @@ -37,7 +37,7 @@ private: * * @param values the values for this property **/ - Property(const Values &values) noexcept : _values(&values) { } + Property(const Values &values) : _values(&values) { } public: /** @@ -46,14 +46,14 @@ public: * object on the stack in the application, and will also be used * by the @ref Properties class when a lookup gives no results. **/ - Property() noexcept : _values(&_emptyValues) { } + Property() : _values(&_emptyValues) { } /** * Check if we found what we were looking for or not. * * @return true if the key we looked up had at least one value **/ - bool found() const noexcept { + bool found() const { return !(*_values).empty(); } @@ -63,7 +63,7 @@ public: * * @return first value for the looked up key, or "" **/ - const Value &get() const noexcept { + const Value &get() const { if ((*_values).empty()) { return _emptyValue; } @@ -78,7 +78,7 @@ public: * @return first value for the looked up key, or fallBack * @param fallBack value to return if no values were found **/ - const Value & get(const Value &fallBack) const noexcept { + const Value & get(const Value &fallBack) const { if ((*_values).empty()) { return fallBack; } @@ -90,7 +90,7 @@ public: * * @return number of values for this property **/ - uint32_t size() const noexcept { return (*_values).size(); } + uint32_t size() const { return (*_values).size(); } /** * Obtain a specific value for the looked up key. @@ -98,7 +98,7 @@ public: * @return the requested value, or "" if idx was out of bounds * @param idx the index of the value we want to access **/ - const Value &getAt(uint32_t idx) const noexcept; + const Value &getAt(uint32_t idx) const; }; //----------------------------------------------------------------------------- @@ -127,7 +127,7 @@ public: /** * Virtual destructor to allow safe subclassing. **/ - virtual ~IPropertiesVisitor() = default; + virtual ~IPropertiesVisitor() {} }; //----------------------------------------------------------------------------- @@ -156,7 +156,7 @@ private: * @param buf data pointer * @param len data length **/ - static uint32_t rawHash(const void *buf, uint32_t len) noexcept; + static uint32_t rawHash(const void *buf, uint32_t len); public: using UP = std::unique_ptr<Properties>; @@ -164,7 +164,7 @@ public: /** * Create an empty properties object. **/ - Properties() noexcept; + Properties(); Properties(Properties &&) noexcept = default; Properties & operator=(Properties &&) noexcept = default; Properties(const Properties &); @@ -192,7 +192,7 @@ public: * @return number of values for the given key * @param key the key **/ - uint32_t count(vespalib::stringref key) const noexcept; + uint32_t count(vespalib::stringref key) const; /** * Remove all values for the given key. @@ -226,14 +226,14 @@ public: * * @return number of keys **/ - uint32_t numKeys() const noexcept { return _data.size(); } + uint32_t numKeys() const { return _data.size(); } /** * Obtain the total number of values stored in this object. * * @return number of values **/ - uint32_t numValues() const noexcept { return _numValues; } + uint32_t numValues() const { return _numValues; } /** * Check if rhs contains the same key/value pairs as this @@ -242,14 +242,14 @@ public: * * @return true if we are equal to rhs **/ - bool operator==(const Properties &rhs) const noexcept; + bool operator==(const Properties &rhs) const; /** * Calculate a hash code for this object * * @return hash code for this object **/ - uint32_t hashCode() const noexcept; + uint32_t hashCode() const; /** * Visit all key/value pairs @@ -275,7 +275,7 @@ public: * @return object encapsulating lookup result * @param key the key to look up **/ - Property lookup(vespalib::stringref key) const noexcept; + Property lookup(vespalib::stringref key) const; /** * Look up a key inside a namespace using the proposed namespace @@ -289,7 +289,7 @@ public: * @param key the key to look up **/ Property lookup(vespalib::stringref namespace1, - vespalib::stringref key) const noexcept; + vespalib::stringref key) const; /** * Look up a key inside a namespace using the proposed namespace @@ -305,7 +305,7 @@ public: **/ Property lookup(vespalib::stringref namespace1, vespalib::stringref namespace2, - vespalib::stringref key) const noexcept; + vespalib::stringref key) const; /** * Look up a key inside a namespace using the proposed namespace @@ -323,13 +323,13 @@ public: Property lookup(vespalib::stringref namespace1, vespalib::stringref namespace2, vespalib::stringref namespace3, - vespalib::stringref key) const noexcept; + vespalib::stringref key) const; - void swap(Properties & rhs) noexcept ; + void swap(Properties & rhs); }; inline void -swap(Properties & a, Properties & b) noexcept +swap(Properties & a, Properties & b) { a.swap(b); } diff --git a/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp index 3f6085ef7ff..488c58e3119 100644 --- a/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp @@ -87,7 +87,7 @@ Blueprint::sat_sum(const std::vector<HitEstimate> &data, uint32_t docid_limit) return { uint32_t(std::min(sum, uint64_t(limit))), empty }; } -Blueprint::State::State() noexcept +Blueprint::State::State() : _fields(), _estimateHits(0), _tree_size(1), @@ -97,13 +97,13 @@ Blueprint::State::State() noexcept _cost_tier(COST_TIER_NORMAL) {} -Blueprint::State::State(FieldSpecBase field) noexcept +Blueprint::State::State(FieldSpecBase field) : State() { _fields.add(field); } -Blueprint::State::State(FieldSpecBaseList fields_in) noexcept +Blueprint::State::State(FieldSpecBaseList fields_in) : _fields(std::move(fields_in)), _estimateHits(0), _tree_size(1), @@ -116,7 +116,7 @@ Blueprint::State::State(FieldSpecBaseList fields_in) noexcept Blueprint::State::~State() = default; -Blueprint::Blueprint() noexcept +Blueprint::Blueprint() : _parent(0), _sourceId(0xffffffff), _docid_limit(0), @@ -383,7 +383,7 @@ StateCache::notifyChange() { IntermediateBlueprint::~IntermediateBlueprint() = default; void -IntermediateBlueprint::setDocIdLimit(uint32_t limit) noexcept +IntermediateBlueprint::setDocIdLimit(uint32_t limit) { Blueprint::setDocIdLimit(limit); for (Blueprint::UP &child : _children) { @@ -576,7 +576,7 @@ IntermediateBlueprint::createSearch(fef::MatchData &md, bool strict) const return createIntermediateSearch(std::move(subSearches), strict, md); } -IntermediateBlueprint::IntermediateBlueprint() noexcept = default; +IntermediateBlueprint::IntermediateBlueprint() = default; IntermediateBlueprint & IntermediateBlueprint::addChild(Blueprint::UP child) @@ -737,6 +737,13 @@ LeafBlueprint::optimize(Blueprint* &self) } void +LeafBlueprint::setEstimate(HitEstimate est) +{ + _state.estimate(est); + notifyChange(); +} + +void LeafBlueprint::set_cost_tier(uint32_t value) { assert(value < 0x100); @@ -745,6 +752,13 @@ LeafBlueprint::set_cost_tier(uint32_t value) } void +LeafBlueprint::set_allow_termwise_eval(bool value) +{ + _state.allow_termwise_eval(value); + notifyChange(); +} + +void LeafBlueprint::set_want_global_filter(bool value) { _state.want_global_filter(value); diff --git a/searchlib/src/vespa/searchlib/queryeval/blueprint.h b/searchlib/src/vespa/searchlib/queryeval/blueprint.h index 8d230b6ec01..dc7a0992d82 100644 --- a/searchlib/src/vespa/searchlib/queryeval/blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/blueprint.h @@ -48,11 +48,11 @@ public: uint32_t estHits; bool empty; - HitEstimate() noexcept : estHits(0), empty(true) {} - HitEstimate(uint32_t estHits_, bool empty_) noexcept + HitEstimate() : estHits(0), empty(true) {} + HitEstimate(uint32_t estHits_, bool empty_) : estHits(estHits_), empty(empty_) {} - bool operator < (const HitEstimate &other) const noexcept { + bool operator < (const HitEstimate &other) const { if (empty == other.empty) { return (estHits < other.estHits); } else { @@ -77,21 +77,21 @@ public: static constexpr uint8_t COST_TIER_EXPENSIVE = 2; static constexpr uint8_t COST_TIER_MAX = 255; - State() noexcept; - State(FieldSpecBase field) noexcept; - State(FieldSpecBaseList fields_in) noexcept; + State(); + State(FieldSpecBase field); + State(FieldSpecBaseList fields_in); State(const State &rhs) = delete; State(State &&rhs) noexcept = default; State &operator=(const State &rhs) = delete; State &operator=(State &&rhs) noexcept = default; ~State(); - bool isTermLike() const noexcept { return !_fields.empty(); } - const FieldSpecBaseList &fields() const noexcept { return _fields; } + bool isTermLike() const { return !_fields.empty(); } + const FieldSpecBaseList &fields() const { return _fields; } - size_t numFields() const noexcept { return _fields.size(); } - const FieldSpecBase &field(size_t idx) const noexcept { return _fields[idx]; } - const FieldSpecBase *lookupField(uint32_t fieldId) const noexcept { + size_t numFields() const { return _fields.size(); } + const FieldSpecBase &field(size_t idx) const { return _fields[idx]; } + const FieldSpecBase *lookupField(uint32_t fieldId) const { for (const FieldSpecBase & field : _fields) { if (field.getFieldId() == fieldId) { return &field; @@ -100,27 +100,27 @@ public: return nullptr; } - void estimate(HitEstimate est) noexcept { + void estimate(HitEstimate est) { _estimateHits = est.estHits; _estimateEmpty = est.empty; } - HitEstimate estimate() const noexcept { return HitEstimate(_estimateHits, _estimateEmpty); } - double hit_ratio(uint32_t docid_limit) const noexcept { + HitEstimate estimate() const { return HitEstimate(_estimateHits, _estimateEmpty); } + double hit_ratio(uint32_t docid_limit) const { uint32_t total_hits = _estimateHits; uint32_t total_docs = std::max(total_hits, docid_limit); return (total_docs == 0) ? 0.0 : double(total_hits) / double(total_docs); } - void tree_size(uint32_t value) noexcept { + void tree_size(uint32_t value) { assert(value < 0x100000); _tree_size = value; } - uint32_t tree_size() const noexcept { return _tree_size; } - void allow_termwise_eval(bool value) noexcept { _allow_termwise_eval = value; } - bool allow_termwise_eval() const noexcept { return _allow_termwise_eval; } - void want_global_filter(bool value) noexcept { _want_global_filter = value; } - bool want_global_filter() const noexcept { return _want_global_filter; } - void cost_tier(uint8_t value) noexcept { _cost_tier = value; } - uint8_t cost_tier() const noexcept { return _cost_tier; } + uint32_t tree_size() const { return _tree_size; } + void allow_termwise_eval(bool value) { _allow_termwise_eval = value; } + bool allow_termwise_eval() const { return _allow_termwise_eval; } + void want_global_filter(bool value) { _want_global_filter = value; } + bool want_global_filter() const { return _want_global_filter; } + void cost_tier(uint8_t value) { _cost_tier = value; } + uint8_t cost_tier() const { return _cost_tier; } }; // utility that just takes maximum estimate @@ -137,7 +137,7 @@ public: // utility to get the greater estimate to sort first, higher tiers last struct TieredGreaterEstimate { - bool operator () (const auto &a, const auto &b) const noexcept { + bool operator () (const auto &a, const auto &b) const { const auto &lhs = a->getState(); const auto &rhs = b->getState(); if (lhs.cost_tier() != rhs.cost_tier()) { @@ -149,7 +149,7 @@ public: // utility to get the lesser estimate to sort first, higher tiers last struct TieredLessEstimate { - bool operator () (const auto &a, const auto &b) const noexcept { + bool operator () (const auto &a, const auto &b) const { const auto &lhs = a->getState(); const auto &rhs = b->getState(); if (lhs.cost_tier() != rhs.cost_tier()) { @@ -189,20 +189,20 @@ public: // hit that isn't certain to be a match). enum class FilterConstraint { UPPER_BOUND, LOWER_BOUND }; - Blueprint() noexcept; + Blueprint(); Blueprint(const Blueprint &) = delete; Blueprint &operator=(const Blueprint &) = delete; virtual ~Blueprint(); - void setParent(Blueprint *parent) noexcept { _parent = parent; } - Blueprint *getParent() const noexcept { return _parent; } + void setParent(Blueprint *parent) { _parent = parent; } + Blueprint *getParent() const { return _parent; } bool has_parent() const { return (_parent != nullptr); } - Blueprint &setSourceId(uint32_t sourceId) noexcept { _sourceId = sourceId; return *this; } - uint32_t getSourceId() const noexcept { return _sourceId; } + Blueprint &setSourceId(uint32_t sourceId) { _sourceId = sourceId; return *this; } + uint32_t getSourceId() const { return _sourceId; } - virtual void setDocIdLimit(uint32_t limit) noexcept { _docid_limit = limit; } - uint32_t get_docid_limit() const noexcept { return _docid_limit; } + virtual void setDocIdLimit(uint32_t limit) { _docid_limit = limit; } + uint32_t get_docid_limit() const { return _docid_limit; } static Blueprint::UP optimize(Blueprint::UP bp); virtual void optimize(Blueprint* &self) = 0; @@ -227,7 +227,7 @@ public: virtual const State &getState() const = 0; const Blueprint &root() const; - double hit_ratio() const noexcept { return getState().hit_ratio(_docid_limit); } + double hit_ratio() const { return getState().hit_ratio(_docid_limit); } virtual void fetchPostings(const ExecuteInfo &execInfo) = 0; virtual void freeze() = 0; @@ -319,10 +319,10 @@ protected: public: using IndexList = std::vector<size_t>; - IntermediateBlueprint() noexcept; + IntermediateBlueprint(); ~IntermediateBlueprint() override; - void setDocIdLimit(uint32_t limit) noexcept final; + void setDocIdLimit(uint32_t limit) final; void optimize(Blueprint* &self) final; void set_global_filter(const GlobalFilter &global_filter, double estimated_hit_ratio) override; @@ -360,30 +360,24 @@ private: State _state; protected: void optimize(Blueprint* &self) final; - void setEstimate(HitEstimate est) { - _state.estimate(est); - notifyChange(); - } + void setEstimate(HitEstimate est); void set_cost_tier(uint32_t value); - void set_allow_termwise_eval(bool value) { - _state.allow_termwise_eval(value); - notifyChange(); - } + void set_allow_termwise_eval(bool value); void set_want_global_filter(bool value); void set_tree_size(uint32_t value); - LeafBlueprint(bool allow_termwise_eval) noexcept + LeafBlueprint(bool allow_termwise_eval) : _state() { _state.allow_termwise_eval(allow_termwise_eval); } - LeafBlueprint(FieldSpecBase field, bool allow_termwise_eval) noexcept + LeafBlueprint(FieldSpecBase field, bool allow_termwise_eval) : _state(field) { _state.allow_termwise_eval(allow_termwise_eval); } - LeafBlueprint(FieldSpecBaseList fields, bool allow_termwise_eval) noexcept + LeafBlueprint(FieldSpecBaseList fields, bool allow_termwise_eval) : _state(std::move(fields)) { _state.allow_termwise_eval(allow_termwise_eval); @@ -392,7 +386,7 @@ protected: public: ~LeafBlueprint() override = default; const State &getState() const final { return _state; } - void setDocIdLimit(uint32_t limit) noexcept final { Blueprint::setDocIdLimit(limit); } + void setDocIdLimit(uint32_t limit) final { Blueprint::setDocIdLimit(limit); } void fetchPostings(const ExecuteInfo &execInfo) override; void freeze() final; SearchIteratorUP createSearch(fef::MatchData &md, bool strict) const override; @@ -403,15 +397,15 @@ public: // for leaf nodes representing a single term struct SimpleLeafBlueprint : LeafBlueprint { - explicit SimpleLeafBlueprint() noexcept : LeafBlueprint(true) {} - explicit SimpleLeafBlueprint(FieldSpecBase field) noexcept : LeafBlueprint(field, true) {} - explicit SimpleLeafBlueprint(FieldSpecBaseList fields) noexcept: LeafBlueprint(std::move(fields), true) {} + explicit SimpleLeafBlueprint() : LeafBlueprint(true) {} + explicit SimpleLeafBlueprint(FieldSpecBase field) : LeafBlueprint(field, true) {} + explicit SimpleLeafBlueprint(FieldSpecBaseList fields) : LeafBlueprint(std::move(fields), true) {} }; // for leaf nodes representing more complex structures like wand/phrase struct ComplexLeafBlueprint : LeafBlueprint { - explicit ComplexLeafBlueprint(FieldSpecBase field) noexcept : LeafBlueprint(field, false) {} - explicit ComplexLeafBlueprint(FieldSpecBaseList fields) noexcept : LeafBlueprint(std::move(fields), false) {} + explicit ComplexLeafBlueprint(FieldSpecBase field) : LeafBlueprint(field, false) {} + explicit ComplexLeafBlueprint(FieldSpecBaseList fields) : LeafBlueprint(std::move(fields), false) {} }; //----------------------------------------------------------------------------- diff --git a/searchlib/src/vespa/searchlib/queryeval/field_spec.cpp b/searchlib/src/vespa/searchlib/queryeval/field_spec.cpp index cd1ddd5b92e..121591723e2 100644 --- a/searchlib/src/vespa/searchlib/queryeval/field_spec.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/field_spec.cpp @@ -5,9 +5,9 @@ namespace search::queryeval { -FieldSpecBase::FieldSpecBase(uint32_t fieldId, fef::TermFieldHandle handle, bool isFilter_) noexcept - : _fieldId(fieldId | (isFilter_ ? 0x1000000u : 0)), - _handle(handle) +FieldSpecBase::FieldSpecBase(uint32_t fieldId, fef::TermFieldHandle handle, bool isFilter_) : + _fieldId(fieldId | (isFilter_ ? 0x1000000u : 0)), + _handle(handle) { assert(fieldId < 0x1000000); // Can be represented by 24 bits } diff --git a/searchlib/src/vespa/searchlib/queryeval/field_spec.h b/searchlib/src/vespa/searchlib/queryeval/field_spec.h index c4cd1ac2de8..fd925fdf4ff 100644 --- a/searchlib/src/vespa/searchlib/queryeval/field_spec.h +++ b/searchlib/src/vespa/searchlib/queryeval/field_spec.h @@ -19,15 +19,15 @@ namespace search::queryeval { class FieldSpecBase { public: - FieldSpecBase(uint32_t fieldId, fef::TermFieldHandle handle, bool isFilter_ = false) noexcept; + FieldSpecBase(uint32_t fieldId, fef::TermFieldHandle handle, bool isFilter_ = false); // resolve where to put match information for this term/field combination fef::TermFieldMatchData *resolve(fef::MatchData &md) const; const fef::TermFieldMatchData *resolve(const fef::MatchData &md) const; - uint32_t getFieldId() const noexcept { return _fieldId & 0xffffff; } - fef::TermFieldHandle getHandle() const noexcept { return _handle; } + uint32_t getFieldId() const { return _fieldId & 0xffffff; } + fef::TermFieldHandle getHandle() const { return _handle; } /// a filter produces less detailed match data - bool isFilter() const noexcept { return _fieldId & 0x1000000; } + bool isFilter() const { return _fieldId & 0x1000000; } private: uint32_t _fieldId; // field id in ranking framework fef::TermFieldHandle _handle; // handle used when exposing match data to ranking framework @@ -40,13 +40,13 @@ class FieldSpec : public FieldSpecBase { public: FieldSpec(const vespalib::string & name, uint32_t fieldId, - fef::TermFieldHandle handle, bool isFilter_ = false) noexcept + fef::TermFieldHandle handle, bool isFilter_ = false) : FieldSpecBase(fieldId, handle, isFilter_), _name(name) {} ~FieldSpec(); - const vespalib::string & getName() const noexcept { return _name; } + const vespalib::string & getName() const { return _name; } private: vespalib::string _name; // field name }; @@ -61,7 +61,7 @@ private: List _list; public: - FieldSpecBaseList() noexcept = default; + FieldSpecBaseList() = default; FieldSpecBaseList(FieldSpecBaseList &&) noexcept = default; FieldSpecBaseList & operator=(FieldSpecBaseList &&) noexcept = default; FieldSpecBaseList(const FieldSpecBaseList &) = default; @@ -69,15 +69,15 @@ public: ~FieldSpecBaseList(); void reserve(size_t sz) { _list.reserve(sz); } using const_iterator = const FieldSpecBase *; - FieldSpecBaseList &add(const FieldSpecBase &spec) noexcept { + FieldSpecBaseList &add(const FieldSpecBase &spec) { _list.push_back(spec); return *this; } - bool empty() const noexcept { return _list.empty(); } - size_t size() const noexcept { return _list.size(); } - const_iterator begin() const noexcept { return _list.begin(); } - const_iterator end() const noexcept { return _list.end(); } - const FieldSpecBase &operator[](size_t i) const noexcept { return _list[i]; } + bool empty() const { return _list.empty(); } + size_t size() const { return _list.size(); } + const_iterator begin() const { return _list.begin(); } + const_iterator end() const { return _list.end(); } + const FieldSpecBase &operator[](size_t i) const { return _list[i]; } }; /** @@ -89,7 +89,7 @@ private: vespalib::SmallVector<FieldSpec, 1> _list; public: - FieldSpecList() noexcept = default; + FieldSpecList() = default; FieldSpecList(FieldSpecList &&) noexcept = delete; FieldSpecList & operator=(FieldSpecList &&) noexcept = delete; FieldSpecList(const FieldSpecList &) noexcept = delete; @@ -99,9 +99,9 @@ public: _list.push_back(spec); return *this; } - bool empty() const noexcept { return _list.empty(); } - size_t size() const noexcept { return _list.size(); } - const FieldSpec &operator[](size_t i) const noexcept { return _list[i]; } + bool empty() const { return _list.empty(); } + size_t size() const { return _list.size(); } + const FieldSpec &operator[](size_t i) const { return _list[i]; } void clear() { _list.clear(); } }; diff --git a/vespalib/src/vespa/vespalib/datastore/compaction_strategy.cpp b/vespalib/src/vespa/vespalib/datastore/compaction_strategy.cpp index eea49e80135..4eb4ff16864 100644 --- a/vespalib/src/vespa/vespalib/datastore/compaction_strategy.cpp +++ b/vespalib/src/vespa/vespalib/datastore/compaction_strategy.cpp @@ -10,19 +10,19 @@ namespace vespalib::datastore { bool -CompactionStrategy::should_compact_memory(const MemoryUsage& memory_usage) const noexcept +CompactionStrategy::should_compact_memory(const MemoryUsage& memory_usage) const { return should_compact_memory(memory_usage.usedBytes(), memory_usage.deadBytes()); } bool -CompactionStrategy::should_compact_address_space(const AddressSpace& address_space) const noexcept +CompactionStrategy::should_compact_address_space(const AddressSpace& address_space) const { return should_compact_address_space(address_space.used(), address_space.dead()); } CompactionSpec -CompactionStrategy::should_compact(const MemoryUsage& memory_usage, const AddressSpace& address_space) const noexcept +CompactionStrategy::should_compact(const MemoryUsage& memory_usage, const AddressSpace& address_space) const { return CompactionSpec(should_compact_memory(memory_usage), should_compact_address_space(address_space)); } @@ -36,7 +36,7 @@ std::ostream& operator<<(std::ostream& os, const CompactionStrategy& compaction_ } CompactionStrategy -CompactionStrategy::make_compact_all_active_buffers_strategy() noexcept +CompactionStrategy::make_compact_all_active_buffers_strategy() { return CompactionStrategy(0.0, 0.0, std::numeric_limits<uint32_t>::max(), 1.0); } diff --git a/vespalib/src/vespa/vespalib/datastore/compaction_strategy.h b/vespalib/src/vespa/vespalib/datastore/compaction_strategy.h index c0c1857deae..f78e123e5de 100644 --- a/vespalib/src/vespa/vespalib/datastore/compaction_strategy.h +++ b/vespalib/src/vespa/vespalib/datastore/compaction_strategy.h @@ -25,15 +25,15 @@ public: static constexpr size_t DEAD_BYTES_SLACK = 0x10000u; static constexpr size_t DEAD_ADDRESS_SPACE_SLACK = 0x10000u; private: - float _maxDeadBytesRatio; // Max ratio of dead bytes before compaction - float _maxDeadAddressSpaceRatio; // Max ratio of dead address space before compaction - float _active_buffers_ratio; // Ratio of active buffers to compact for each reason (memory usage, address space usage) + double _maxDeadBytesRatio; // Max ratio of dead bytes before compaction + double _maxDeadAddressSpaceRatio; // Max ratio of dead address space before compaction uint32_t _max_buffers; // Max number of buffers to compact for each reason (memory usage, address space usage) - bool should_compact_memory(size_t used_bytes, size_t dead_bytes) const noexcept { + double _active_buffers_ratio; // Ratio of active buffers to compact for each reason (memory usage, address space usage) + bool should_compact_memory(size_t used_bytes, size_t dead_bytes) const { return ((dead_bytes >= DEAD_BYTES_SLACK) && (dead_bytes > used_bytes * getMaxDeadBytesRatio())); } - bool should_compact_address_space(size_t used_address_space, size_t dead_address_space) const noexcept { + bool should_compact_address_space(size_t used_address_space, size_t dead_address_space) const { return ((dead_address_space >= DEAD_ADDRESS_SPACE_SLACK) && (dead_address_space > used_address_space * getMaxDeadAddressSpaceRatio())); } @@ -41,37 +41,40 @@ public: CompactionStrategy() noexcept : _maxDeadBytesRatio(0.05), _maxDeadAddressSpaceRatio(0.2), - _active_buffers_ratio(0.1), - _max_buffers(1) - { } - CompactionStrategy(float maxDeadBytesRatio, float maxDeadAddressSpaceRatio) noexcept + _max_buffers(1), + _active_buffers_ratio(0.1) + { + } + CompactionStrategy(double maxDeadBytesRatio, double maxDeadAddressSpaceRatio) noexcept : _maxDeadBytesRatio(maxDeadBytesRatio), _maxDeadAddressSpaceRatio(maxDeadAddressSpaceRatio), - _active_buffers_ratio(0.1), - _max_buffers(1) - { } - CompactionStrategy(float maxDeadBytesRatio, float maxDeadAddressSpaceRatio, uint32_t max_buffers, float active_buffers_ratio) noexcept + _max_buffers(1), + _active_buffers_ratio(0.1) + { + } + CompactionStrategy(double maxDeadBytesRatio, double maxDeadAddressSpaceRatio, uint32_t max_buffers, double active_buffers_ratio) noexcept : _maxDeadBytesRatio(maxDeadBytesRatio), _maxDeadAddressSpaceRatio(maxDeadAddressSpaceRatio), - _active_buffers_ratio(active_buffers_ratio), - _max_buffers(max_buffers) - { } - float getMaxDeadBytesRatio() const noexcept { return _maxDeadBytesRatio; } - float getMaxDeadAddressSpaceRatio() const noexcept { return _maxDeadAddressSpaceRatio; } + _max_buffers(max_buffers), + _active_buffers_ratio(active_buffers_ratio) + { + } + double getMaxDeadBytesRatio() const { return _maxDeadBytesRatio; } + double getMaxDeadAddressSpaceRatio() const { return _maxDeadAddressSpaceRatio; } uint32_t get_max_buffers() const noexcept { return _max_buffers; } - float get_active_buffers_ratio() const noexcept { return _active_buffers_ratio; } - bool operator==(const CompactionStrategy & rhs) const noexcept { + double get_active_buffers_ratio() const noexcept { return _active_buffers_ratio; } + bool operator==(const CompactionStrategy & rhs) const { return (_maxDeadBytesRatio == rhs._maxDeadBytesRatio) && (_maxDeadAddressSpaceRatio == rhs._maxDeadAddressSpaceRatio) && (_max_buffers == rhs._max_buffers) && (_active_buffers_ratio == rhs._active_buffers_ratio); } - bool operator!=(const CompactionStrategy & rhs) const noexcept { return !(operator==(rhs)); } + bool operator!=(const CompactionStrategy & rhs) const { return !(operator==(rhs)); } - bool should_compact_memory(const MemoryUsage& memory_usage) const noexcept; - bool should_compact_address_space(const AddressSpace& address_space) const noexcept; - CompactionSpec should_compact(const MemoryUsage& memory_usage, const AddressSpace& address_space) const noexcept; - static CompactionStrategy make_compact_all_active_buffers_strategy() noexcept; + bool should_compact_memory(const MemoryUsage& memory_usage) const; + bool should_compact_address_space(const AddressSpace& address_space) const; + CompactionSpec should_compact(const MemoryUsage& memory_usage, const AddressSpace& address_space) const; + static CompactionStrategy make_compact_all_active_buffers_strategy(); }; std::ostream& operator<<(std::ostream& os, const CompactionStrategy& compaction_strategy); diff --git a/vespalib/src/vespa/vespalib/text/lowercase.h b/vespalib/src/vespa/vespalib/text/lowercase.h index 5c4e3e34e07..dc081c6ba2d 100644 --- a/vespalib/src/vespa/vespalib/text/lowercase.h +++ b/vespalib/src/vespa/vespalib/text/lowercase.h @@ -43,9 +43,9 @@ public: * @param codepoint the character codepoint to be lowercased. * @return lowercase UCS-4 character (codepoint if no lowercasing is performed). **/ - static uint32_t convert(uint32_t codepoint) noexcept + static uint32_t convert(uint32_t codepoint) { - if (codepoint < 0x100) [[likely]] { + if (codepoint < 0x100) { return lowercase_0_block[codepoint]; } else if (codepoint < 0x600) { return lowercase_0_5_blocks[codepoint]; diff --git a/vespalib/src/vespa/vespalib/text/utf8.cpp b/vespalib/src/vespa/vespalib/text/utf8.cpp index c950f62985f..cae2bbae682 100644 --- a/vespalib/src/vespa/vespalib/text/utf8.cpp +++ b/vespalib/src/vespa/vespalib/text/utf8.cpp @@ -16,16 +16,18 @@ void Utf8::throwX(const char *msg, unsigned int number) throw IllegalArgumentException(what); } -uint32_t Utf8Reader::getComplexChar(unsigned char firstbyte, uint32_t fallback) noexcept +uint32_t Utf8Reader::getComplexChar(unsigned char firstbyte, uint32_t fallback) { if (_pos == size()) { // this shouldn't happen ... - LOG(warning, "last byte %02X of Utf8Reader block was incomplete UTF-8", firstbyte); + LOG(warning, "last byte %02X of Utf8Reader block was incomplete UTF-8", + firstbyte); return fallback; } assert(hasMore()); // should never fall out of range if (! Utf8::validFirstByte(firstbyte)) { - LOG(debug, "invalid first byte %02X in Utf8Reader data block", firstbyte); + LOG(debug, "invalid first byte %02X in Utf8Reader data block", + firstbyte); return fallback; } int need = Utf8::numContBytes(firstbyte); @@ -46,7 +48,8 @@ uint32_t Utf8Reader::getComplexChar(unsigned char firstbyte, uint32_t fallback) // check > 0x7F ? return r; } else { - LOG(debug, "invalid continuation byte %02X in Utf8Reader data block", contbyte); + LOG(debug, "invalid continuation byte %02X in Utf8Reader data block", + contbyte); return fallback; } } @@ -66,7 +69,8 @@ uint32_t Utf8Reader::getComplexChar(unsigned char firstbyte, uint32_t fallback) // check > 0x7FF ? return r; } else { - LOG(debug, "invalid continuation bytes %02X/%02X in Utf8Reader data block", contbyte1, contbyte2); + LOG(debug, "invalid continuation bytes %02X/%02X in Utf8Reader data block", + contbyte1, contbyte2); return fallback; } } @@ -91,10 +95,11 @@ uint32_t Utf8Reader::getComplexChar(unsigned char firstbyte, uint32_t fallback) uint32_t -Utf8ReaderForZTS::getComplexChar(unsigned char firstbyte, uint32_t fallback) noexcept +Utf8ReaderForZTS::getComplexChar(unsigned char firstbyte, uint32_t fallback) { if (! Utf8::validFirstByte(firstbyte)) { - LOG(debug, "invalid first byte %02X in Utf8Reader data block", firstbyte); + LOG(debug, "invalid first byte %02X in Utf8Reader data block", + firstbyte); return fallback; } int need = Utf8::numContBytes(firstbyte); @@ -103,7 +108,8 @@ Utf8ReaderForZTS::getComplexChar(unsigned char firstbyte, uint32_t fallback) noe if (need == 1) { if (_p[0] == 0) { - LOG(debug, "incomplete character (first byte %02X) in Utf8ReaderZTS", firstbyte); + LOG(debug, "incomplete character (first byte %02X) in Utf8ReaderZTS", + firstbyte); return fallback; } unsigned char contbyte = _p[0]; @@ -113,14 +119,16 @@ Utf8ReaderForZTS::getComplexChar(unsigned char firstbyte, uint32_t fallback) noe // check > 0x7F ? return r; } else { - LOG(debug, "invalid continuation byte %02X in Utf8Reader data block", contbyte); + LOG(debug, "invalid continuation byte %02X in Utf8Reader data block", + contbyte); return fallback; } } if (need == 2) { if (_p[0] == 0 || _p[1] == 0) { - LOG(debug, "incomplete character (first byte %02X) in Utf8ReaderZTS", firstbyte); + LOG(debug, "incomplete character (first byte %02X) in Utf8ReaderZTS", + firstbyte); return fallback; } unsigned char contbyte1 = _p[0]; @@ -137,14 +145,16 @@ Utf8ReaderForZTS::getComplexChar(unsigned char firstbyte, uint32_t fallback) noe // check > 0x7FF ? return r; } else { - LOG(debug, "invalid continuation bytes %02X/%02X in Utf8Reader data block", contbyte1, contbyte2); + LOG(debug, "invalid continuation bytes %02X/%02X in Utf8Reader data block", + contbyte1, contbyte2); return fallback; } } assert(need == 3); if (_p[0] == 0 || _p[1] == 0 || _p[2] == 0) { - LOG(debug, "incomplete character (first byte %02X) in Utf8ReaderZTS", firstbyte); + LOG(debug, "incomplete character (first byte %02X) in Utf8ReaderZTS", + firstbyte); return fallback; } unsigned char contbyte1 = _p[0]; @@ -158,7 +168,8 @@ Utf8ReaderForZTS::getComplexChar(unsigned char firstbyte, uint32_t fallback) noe // check > 0xFFFF? return decode4(firstbyte, contbyte1, contbyte2, contbyte3); } else { - LOG(debug, "invalid continuation bytes %02X/%02X/%02X in Utf8Reader data block", contbyte1, contbyte2, contbyte3); + LOG(debug, "invalid continuation bytes %02X/%02X/%02X in Utf8Reader data block", + contbyte1, contbyte2, contbyte3); return fallback; } } @@ -223,7 +234,7 @@ template class Utf8Writer<vespalib::string>; template class Utf8Writer<std::string>; template <typename T> -T Utf8::filter_invalid_sequences(const T& input) noexcept +T Utf8::filter_invalid_sequences(const T& input) { T retval; Utf8Reader reader(input.c_str(), input.size()); diff --git a/vespalib/src/vespa/vespalib/text/utf8.h b/vespalib/src/vespa/vespalib/text/utf8.h index 3367bd5b3d2..98e06ca5faf 100644 --- a/vespalib/src/vespa/vespalib/text/utf8.h +++ b/vespalib/src/vespa/vespalib/text/utf8.h @@ -34,14 +34,14 @@ public: * UTF-8 encoded surrogates are also considered invalid. **/ template <typename T> - static T filter_invalid_sequences(const T& input) noexcept; + static T filter_invalid_sequences(const T& input); /** * check if a byte is valid as the first byte of an UTF-8 character. * @param c the byte to be checked * @return true if a valid UTF-8 character can start with this byte **/ - static bool validFirstByte(unsigned char c) noexcept { + static bool validFirstByte(unsigned char c) { return (c < 0x80 || (c > 0xC1 && c < 0xF5)); } @@ -52,12 +52,12 @@ public: * @param c the first byte (must pass validFirstByte check) * @return 0, 1, 2, or 3 **/ - static int numContBytes(unsigned char c) noexcept { + static int numContBytes(unsigned char c) { if (c < 0x80) return 0; if (c > 0xC1 && c < 0xE0) return 1; if (c > 0xDF && c < 0xF0) return 2; if (c > 0xEF && c < 0xF5) return 3; - return -1; + throwX("invalid first byte of UTF8 sequence", c); } /** @@ -65,7 +65,7 @@ public: * @param c the byte to be checked * @return true if a valid UTF-8 character can contain this byte **/ - static bool validContByte(unsigned char c) noexcept { + static bool validContByte(unsigned char c) { return (c > 0x7F && c < 0xC0); } @@ -82,7 +82,8 @@ public: * @param contbyte second byte in this UTF-8 character * @return decoded UCS-4 codepoint in range [0, 0x7FF] **/ - static uint32_t decode2(unsigned char firstbyte, unsigned char contbyte) noexcept + static uint32_t decode2(unsigned char firstbyte, + unsigned char contbyte) { uint32_t r = (firstbyte & low_5bits_mask); r <<= 6; @@ -107,7 +108,7 @@ public: **/ static uint32_t decode3(unsigned char firstbyte, unsigned char contbyte1, - unsigned char contbyte2) noexcept + unsigned char contbyte2) { uint32_t r = (firstbyte & low_4bits_mask); r <<= 6; @@ -137,7 +138,7 @@ public: static uint32_t decode4(unsigned char firstbyte, unsigned char contbyte1, unsigned char contbyte2, - unsigned char contbyte3) noexcept + unsigned char contbyte3) { uint32_t r = (firstbyte & low_3bits_mask); r <<= 6; @@ -176,14 +177,14 @@ class Utf8Reader private: size_type _pos; - uint32_t getComplexChar(unsigned char firstbyte, uint32_t fallback) noexcept; + uint32_t getComplexChar(unsigned char firstbyte, uint32_t fallback); public: /** * Construct a reader for the given block of data * @param input data to read UTF-8 from (can be read-only) **/ - Utf8Reader(stringref input) noexcept + Utf8Reader(stringref input) : stringref(input), _pos(0) {} @@ -192,7 +193,7 @@ public: * @param start pointer to the start of the block * @param sz size of the block in bytes **/ - Utf8Reader(const char *start, size_t sz) noexcept + Utf8Reader(const char *start, size_t sz) : stringref(start, sz), _pos(0) {} @@ -200,7 +201,7 @@ public: * check if the buffer has more data. * @return true if there is more data **/ - bool hasMore() const noexcept { return _pos < size(); } + bool hasMore() const { return _pos < size(); } /** * Decode the UTF-8 character at the current position. @@ -210,7 +211,7 @@ public: * @param fallback the value to return if invalid UTF-8 is found * @return a valid UCS-4 codepoint (or the fallback value) **/ - uint32_t getChar(uint32_t fallback) noexcept { + uint32_t getChar(uint32_t fallback) { unsigned char firstbyte = (*this)[_pos++]; // always steps at least 1 position if (firstbyte < 0x80) { return firstbyte; @@ -231,13 +232,13 @@ public: * * @return a valid UCS-4 codepoint **/ - uint32_t getChar() noexcept { return getChar(Utf8::REPLACEMENT_CHAR); } + uint32_t getChar() { return getChar(Utf8::REPLACEMENT_CHAR); } /** * obtain the current byte offset position * @return position in bytes **/ - size_type getPos() const noexcept { return _pos; } + size_type getPos() const { return _pos; } }; @@ -251,7 +252,7 @@ class Utf8ReaderForZTS { private: const char * &_p; - uint32_t getComplexChar(unsigned char firstbyte, uint32_t fallback) noexcept; + uint32_t getComplexChar(unsigned char firstbyte, uint32_t fallback); public: /** @@ -264,7 +265,7 @@ public: * * @param start pointer to the start of the block **/ - Utf8ReaderForZTS(const char * &start) noexcept + Utf8ReaderForZTS(const char * &start) : _p(start) {} @@ -272,7 +273,7 @@ public: * check if the buffer has more data. * @return true if there is more data **/ - bool hasMore() const noexcept { + bool hasMore() const { return (*_p) != '\0'; } @@ -284,9 +285,9 @@ public: * @param fallback the value to return if invalid UTF-8 is found * @return a valid UCS-4 codepoint (or the fallback value) **/ - uint32_t getChar(uint32_t fallback) noexcept { + uint32_t getChar(uint32_t fallback) { unsigned char firstbyte = *_p++; // always steps at least 1 position - if (firstbyte < 0x80) [[likely]] { + if (firstbyte < 0x80) { return firstbyte; } else { return getComplexChar(firstbyte, fallback); @@ -305,7 +306,7 @@ public: * * @return a valid UCS-4 codepoint **/ - uint32_t getChar() noexcept{ return getChar(Utf8::REPLACEMENT_CHAR); } + uint32_t getChar() { return getChar(Utf8::REPLACEMENT_CHAR); } /** * count the number of UCS-4 characters will be returned when @@ -313,7 +314,7 @@ public: * "strlen" does not count the zero termination, but bytes * that aren't valid UTF-8 will count as one character each. **/ - static size_t countChars(const char *p) noexcept { + static size_t countChars(const char *p) { Utf8ReaderForZTS reader(p); size_t i; for (i = 0; reader.hasMore(); ++i) { @@ -339,7 +340,7 @@ public: * that the writer will append to. Must be writable * and must be kept alive while the writer is active. **/ - Utf8Writer(Target &target) noexcept : _target(target) {} + Utf8Writer(Target &target) : _target(target) {} /** * append the given character to the target string. diff --git a/vespalib/src/vespa/vespalib/util/alloc.cpp b/vespalib/src/vespa/vespalib/util/alloc.cpp index 2ba3bc252ae..204d80340aa 100644 --- a/vespalib/src/vespa/vespalib/util/alloc.cpp +++ b/vespalib/src/vespa/vespalib/util/alloc.cpp @@ -292,7 +292,7 @@ HeapAllocator::alloc(size_t sz) const { PtrAndSize HeapAllocator::salloc(size_t sz) { if (sz == 0) { - return PtrAndSize(); + return PtrAndSize(nullptr, sz); } void * ptr = malloc(sz); if (ptr == nullptr) { @@ -311,7 +311,7 @@ void HeapAllocator::sfree(PtrAndSize alloc) noexcept { PtrAndSize AlignedHeapAllocator::alloc(size_t sz) const { - if (!sz) { return PtrAndSize(); } + if (!sz) { return PtrAndSize(nullptr, 0); } void* ptr; int result = posix_memalign(&ptr, _alignment, sz); if (result != 0) { diff --git a/vespalib/src/vespa/vespalib/util/alloc.h b/vespalib/src/vespa/vespalib/util/alloc.h index dca4d633b43..a27bcca0b47 100644 --- a/vespalib/src/vespa/vespalib/util/alloc.h +++ b/vespalib/src/vespa/vespalib/util/alloc.h @@ -49,7 +49,7 @@ public: } return *this; } - Alloc() noexcept : _alloc(), _allocator(nullptr) { } + Alloc() noexcept : _alloc(nullptr, 0), _allocator(nullptr) { } ~Alloc() noexcept { reset(); } @@ -83,9 +83,10 @@ private: Alloc(const MemoryAllocator * allocator, size_t sz) noexcept : _alloc(allocator->alloc(sz)), _allocator(allocator) - { } + { + } Alloc(const MemoryAllocator * allocator) noexcept - : _alloc(), + : _alloc(nullptr, 0), _allocator(allocator) { } void clear() noexcept { diff --git a/vespalib/src/vespa/vespalib/util/growstrategy.h b/vespalib/src/vespa/vespalib/util/growstrategy.h index 643e3f03023..02e18e44925 100644 --- a/vespalib/src/vespa/vespalib/util/growstrategy.h +++ b/vespalib/src/vespa/vespalib/util/growstrategy.h @@ -4,15 +4,14 @@ #include <algorithm> #include <cstddef> -#include <cstdint> namespace vespalib { class GrowStrategy { private: - uint32_t _initialCapacity; - uint32_t _minimumCapacity; - uint32_t _growDelta; + size_t _initialCapacity; + size_t _minimumCapacity; + size_t _growDelta; float _growFactor; public: GrowStrategy() noexcept @@ -34,7 +33,7 @@ public: void setInitialCapacity(size_t v) noexcept { _initialCapacity = v; } void setGrowDelta(size_t v) noexcept { _growDelta = v; } - size_t calc_new_size(size_t base_size) const noexcept { + size_t calc_new_size(size_t base_size) const { size_t delta = (base_size * getGrowFactor()) + getGrowDelta(); size_t new_size = base_size + std::max(delta, static_cast<size_t>(1)); return std::max(new_size, getMinimumCapacity()); diff --git a/vespalib/src/vespa/vespalib/util/mmap_file_allocator.cpp b/vespalib/src/vespa/vespalib/util/mmap_file_allocator.cpp index 2c0d0f4339d..9ed4806385d 100644 --- a/vespalib/src/vespa/vespalib/util/mmap_file_allocator.cpp +++ b/vespalib/src/vespa/vespalib/util/mmap_file_allocator.cpp @@ -46,7 +46,7 @@ PtrAndSize MmapFileAllocator::alloc(size_t sz) const { if (sz == 0) { - return PtrAndSize(); // empty allocation + return PtrAndSize(nullptr, 0); // empty allocation } sz = round_up_to_page_size(sz); uint64_t offset = alloc_area(sz); diff --git a/vespalib/src/vespa/vespalib/util/small_vector.h b/vespalib/src/vespa/vespalib/util/small_vector.h index ba166362d33..b47cb5903b9 100644 --- a/vespalib/src/vespa/vespalib/util/small_vector.h +++ b/vespalib/src/vespa/vespalib/util/small_vector.h @@ -216,7 +216,7 @@ public: template <typename T, size_t N, size_t M> bool operator==(const SmallVector<T,N> &a, - const SmallVector<T,M> &b) noexcept + const SmallVector<T,M> &b) { if (a.size() != b.size()) { return false; |