diff options
16 files changed, 67 insertions, 82 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/common/attributefieldvaluenode.cpp b/searchcore/src/vespa/searchcore/proton/common/attributefieldvaluenode.cpp index 46c21d97d7d..94473c10d3c 100644 --- a/searchcore/src/vespa/searchcore/proton/common/attributefieldvaluenode.cpp +++ b/searchcore/src/vespa/searchcore/proton/common/attributefieldvaluenode.cpp @@ -4,7 +4,6 @@ #include "selectcontext.h" #include <vespa/searchcommon/attribute/attributecontent.h> #include <vespa/searchlib/attribute/attributevector.h> -#include <vespa/searchlib/attribute/stringbase.h> #include <vespa/searchlib/attribute/attribute_read_guard.h> #include <vespa/vespalib/util/exceptions.h> #include <cassert> @@ -41,23 +40,24 @@ AttributeFieldValueNode(const vespalib::string& doctype, std::unique_ptr<document::select::Value> -AttributeFieldValueNode::getValue(const Context &context) const +AttributeFieldValueNode:: +getValue(const Context &context) const { const auto &sc(static_cast<const SelectContext &>(context)); uint32_t docId(sc._docId); assert(docId != 0u); const auto& v = sc.guarded_attribute_at_index(_attr_guard_index); + if (v.isUndefined(docId)) { + return std::make_unique<NullValue>(); + } switch (v.getBasicType()) { case BasicType::STRING: { - const auto & s = static_cast<const search::StringAttribute &>(v); - const char * value = s.get(docId); - if (search::attribute::isUndefined<const char *>(value)) { - return std::make_unique<NullValue>(); - } else { - return std::make_unique<StringValue>(value); - } - } + AttributeContent<const char *> content; + content.fill(v, docId); + assert(content.size() == 1u); + return std::make_unique<StringValue>(content[0]); + }; case BasicType::BOOL: case BasicType::UINT2: case BasicType::UINT4: @@ -66,9 +66,6 @@ AttributeFieldValueNode::getValue(const Context &context) const case BasicType::INT32: case BasicType::INT64: { - if (v.isUndefined(docId)) { - return std::make_unique<NullValue>(); - } AttributeContent<IAttributeVector::largeint_t> content; content.fill(v, docId); assert(content.size() == 1u); @@ -77,14 +74,11 @@ AttributeFieldValueNode::getValue(const Context &context) const case BasicType::FLOAT: case BasicType::DOUBLE: { - if (v.isUndefined(docId)) { - return std::make_unique<NullValue>(); - } AttributeContent<double> content; content.fill(v, docId); assert(content.size() == 1u); return std::make_unique<FloatValue>(content[0]); - } + }; case BasicType::NONE: case BasicType::PREDICATE: case BasicType::TENSOR: @@ -95,7 +89,7 @@ AttributeFieldValueNode::getValue(const Context &context) const case BasicType::MAX_TYPE: throw IllegalStateException(make_string("Attribute '%s' has illegal type '%d'", v.getName().c_str(), v.getBasicType())); } - return std::make_unique<NullValue>(); + return std::make_unique<NullValue>();; } diff --git a/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp b/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp index 6cb805d701b..1a1e18a6eae 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp +++ b/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp @@ -40,7 +40,7 @@ EnumStoreStringComparator::EnumStoreStringComparator(const DataStoreType& data_s } bool -EnumStoreStringComparator::less(vespalib::datastore::EntryRef lhs, vespalib::datastore::EntryRef rhs) const { +EnumStoreStringComparator::less(const vespalib::datastore::EntryRef lhs, const vespalib::datastore::EntryRef rhs) const { switch (_compare_strategy) { case CompareStrategy::UNCASED: return (use_prefix() diff --git a/searchlib/src/vespa/searchlib/attribute/enumcomparator.h b/searchlib/src/vespa/searchlib/attribute/enumcomparator.h index 59dbb3a8cc3..cfff8d286a5 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumcomparator.h +++ b/searchlib/src/vespa/searchlib/attribute/enumcomparator.h @@ -18,7 +18,7 @@ public: using ParentType = vespalib::datastore::UniqueStoreComparator<EntryT, IEnumStore::InternalIndex>; using DataStoreType = typename ParentType::DataStoreType; - explicit EnumStoreComparator(const DataStoreType& data_store) + EnumStoreComparator(const DataStoreType& data_store) : ParentType(data_store) {} @@ -34,7 +34,7 @@ public: return *this; } EnumStoreComparator<EntryT> make_for_lookup(const EntryT& lookup_value) const { - return {this->_store, lookup_value}; + return EnumStoreComparator<EntryT>(this->_store, lookup_value); } }; @@ -76,9 +76,6 @@ private: }; public: - explicit EnumStoreStringComparator(const DataStoreType& data_store) - : EnumStoreStringComparator(data_store, CompareStrategy::UNCASED_THEN_CASED) - {} EnumStoreStringComparator(const DataStoreType& data_store, bool cased) : EnumStoreStringComparator(data_store, cased ? CompareStrategy::CASED : CompareStrategy::UNCASED_THEN_CASED) {} @@ -94,15 +91,15 @@ private: EnumStoreStringComparator(const DataStoreType& data_store, CompareStrategy compare_strategy, const char* lookup_value, bool prefix); public: - bool less(vespalib::datastore::EntryRef lhs, vespalib::datastore::EntryRef rhs) const override; + bool less(const vespalib::datastore::EntryRef lhs, const vespalib::datastore::EntryRef rhs) const override; EnumStoreStringComparator make_folded() const { - return {_store, _compare_strategy == CompareStrategy::UNCASED_THEN_CASED ? CompareStrategy::UNCASED : _compare_strategy}; + return EnumStoreStringComparator(_store, _compare_strategy == CompareStrategy::UNCASED_THEN_CASED ? CompareStrategy::UNCASED : _compare_strategy); } EnumStoreStringComparator make_for_lookup(const char* lookup_value) const { - return {_store, _compare_strategy, lookup_value}; + return EnumStoreStringComparator(_store, _compare_strategy, lookup_value); } EnumStoreStringComparator make_for_prefix_lookup(const char* lookup_value) const { - return {_store, _compare_strategy, lookup_value, true}; + return EnumStoreStringComparator(_store, _compare_strategy, lookup_value, true); } private: inline bool use_prefix() const noexcept { return _prefix; } diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.h b/searchlib/src/vespa/searchlib/attribute/enumstore.h index 3489afdd3f8..d63274c95fe 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumstore.h +++ b/searchlib/src/vespa/searchlib/attribute/enumstore.h @@ -35,7 +35,7 @@ namespace search { * It has special handling of type 'const char *' for strings. */ template <class EntryT> -class EnumStoreT final : public IEnumStore { +class EnumStoreT : public IEnumStore { public: using EntryType = EntryT; static constexpr bool has_string_type = std::is_same_v<EntryType, const char *>; @@ -61,6 +61,9 @@ private: EntryType _default_value; AtomicIndex _default_value_ref; + EnumStoreT(const EnumStoreT & rhs) = delete; + EnumStoreT & operator=(const EnumStoreT & rhs) = delete; + void free_value_if_unused(Index idx, IndexList &unused) override; const vespalib::datastore::UniqueStoreEntryBase& get_entry_base(Index idx) const { @@ -73,8 +76,6 @@ private: std::unique_ptr<EntryComparator> allocate_optionally_folded_comparator(bool folded) const; ComparatorType make_optionally_folded_comparator(bool folded) const; public: - EnumStoreT(const EnumStoreT & rhs) = delete; - EnumStoreT & operator=(const EnumStoreT & rhs) = delete; EnumStoreT(bool has_postings, const search::DictionaryConfig& dict_cfg, std::shared_ptr<vespalib::alloc::MemoryAllocator> memory_allocator, EntryType default_value); EnumStoreT(bool has_postings, const search::DictionaryConfig & dict_cfg); ~EnumStoreT() override; @@ -158,7 +159,7 @@ public: IndexList _possibly_unused; public: - explicit BatchUpdater(EnumStoreType& store) + BatchUpdater(EnumStoreType& store) : _store(store), _possibly_unused() {} diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp index 210d0e4e052..3f15f64d191 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp +++ b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp @@ -102,7 +102,7 @@ EnumStoreT<EntryT>::EnumStoreT(bool has_postings, const DictionaryConfig& dict_c template <typename EntryT> EnumStoreT<EntryT>::EnumStoreT(bool has_postings, const DictionaryConfig& dict_cfg) - : EnumStoreT(has_postings, dict_cfg, {}, attribute::getUndefined<EntryType>()) + : EnumStoreT<EntryT>(has_postings, dict_cfg, {}, attribute::getUndefined<EntryType>()) { } @@ -270,7 +270,7 @@ EnumStoreT<EntryT>::consider_compact_values(const CompactionStrategy& compaction if (!_store.get_data_store().has_held_buffers() && _compaction_spec.get_values().compact()) { return compact_worst_values(_compaction_spec.get_values(), compaction_strategy); } - return {}; + return std::unique_ptr<IEnumStore::EnumIndexRemapper>(); } template <typename EntryT> diff --git a/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp b/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp index cb196e9a54e..57513586908 100644 --- a/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp @@ -234,8 +234,9 @@ ReferenceAttribute::onLoad(vespalib::Executor *) setCreateSerialNum(attrReader.getCreateSerialNum()); assert(attrReader.getEnumerated()); assert(!attrReader.hasIdx()); + size_t numDocs(0); uint64_t numValues = attrReader.getEnumCount(); - size_t numDocs = numValues; + numDocs = numValues; auto udatBuffer = attribute::LoadUtils::loadUDAT(*this); const GenericHeader &header = udatBuffer->getHeader(); uint32_t uniqueValueCount = extractUniqueValueCount(header); diff --git a/searchlib/src/vespa/searchlib/attribute/reference_attribute.h b/searchlib/src/vespa/searchlib/attribute/reference_attribute.h index 7b36f975c7e..e2c2db319d0 100644 --- a/searchlib/src/vespa/searchlib/attribute/reference_attribute.h +++ b/searchlib/src/vespa/searchlib/attribute/reference_attribute.h @@ -33,12 +33,11 @@ public: using ReferenceStore = vespalib::datastore::UniqueStore<Reference>; using ReferenceStoreIndices = vespalib::RcuVectorBase<AtomicEntryRef>; // Class used to map from target lid to source lids - using ReverseMapping = vespalib::btree::BTreeStore<uint32_t, - vespalib::btree::BTreeNoLeafData, - vespalib::btree::NoAggregated, - std::less<uint32_t>, - vespalib::btree::BTreeDefaultTraits, - vespalib::btree::NoAggrCalc>; + using ReverseMapping = vespalib::btree::BTreeStore<uint32_t, vespalib::btree::BTreeNoLeafData, + vespalib::btree::NoAggregated, + std::less<uint32_t>, + vespalib::btree::BTreeDefaultTraits, + vespalib::btree::NoAggrCalc>; using TargetLids = ReferenceMappings::TargetLids; // Class used to map from target lid to source lids using ReverseMappingRefs = ReferenceMappings::ReverseMappingRefs; diff --git a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp index d1a2c26a75d..845622a68a6 100644 --- a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp +++ b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp @@ -3,33 +3,13 @@ #include "stackdumpiterator.h" #include <vespa/vespalib/util/compress.h> #include <vespa/vespalib/objects/nbo.h> +#include <cassert> +#include <charconv> using search::query::PredicateQueryTerm; namespace search { -namespace { - -uint64_t -readUint64(const char *&p) -{ - uint64_t value; - memcpy(&value, p, sizeof(value)); - p += sizeof(value); - return vespalib::nbo::n2h(value); -} - -double -read_double(const char *&p) -{ - double value; - memcpy(&value, p, sizeof(value)); - p += sizeof(value); - return vespalib::nbo::n2h(value); -} - -} - SimpleQueryStackDumpIterator::SimpleQueryStackDumpIterator(vespalib::stringref buf) : _buf(buf.begin()), _bufEnd(buf.end()), @@ -66,6 +46,24 @@ SimpleQueryStackDumpIterator::read_stringref(const char *&p) } uint64_t +SimpleQueryStackDumpIterator::readUint64(const char *&p) +{ + uint64_t value; + memcpy(&value, p, sizeof(value)); + p += sizeof(value); + return vespalib::nbo::n2h(value); +} + +double +SimpleQueryStackDumpIterator::read_double(const char *&p) +{ + double value; + memcpy(&value, p, sizeof(value)); + p += sizeof(value); + return vespalib::nbo::n2h(value); +} + +uint64_t SimpleQueryStackDumpIterator::readCompressedPositiveInt(const char *&p) { uint64_t tmp; diff --git a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h index dece4ecc0b6..2f862de46fe 100644 --- a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h +++ b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h @@ -48,6 +48,8 @@ private: query::PredicateQueryTerm::UP _predicate_query_term; VESPA_DLL_LOCAL vespalib::stringref read_stringref(const char *&p); + VESPA_DLL_LOCAL uint64_t readUint64(const char *&p); + VESPA_DLL_LOCAL double read_double(const char *&p); VESPA_DLL_LOCAL uint64_t readCompressedPositiveInt(const char *&p); VESPA_DLL_LOCAL bool readPredicate(const char *&p); VESPA_DLL_LOCAL bool readNN(const char *&p); @@ -58,12 +60,12 @@ public: /** * Make an iterator on a buffer. To get the first item, next must be called. */ - explicit SimpleQueryStackDumpIterator(vespalib::stringref buf); + SimpleQueryStackDumpIterator(vespalib::stringref buf); SimpleQueryStackDumpIterator(const SimpleQueryStackDumpIterator &) = delete; SimpleQueryStackDumpIterator& operator=(const SimpleQueryStackDumpIterator &) = delete; ~SimpleQueryStackDumpIterator(); - vespalib::stringref getStack() const noexcept { return vespalib::stringref(_buf, _bufEnd - _buf); } + vespalib::stringref getStack() const { return vespalib::stringref(_buf, _bufEnd - _buf); } size_t getPosition() const { return _currPos; } /** diff --git a/vespalib/src/vespa/vespalib/data/memory.cpp b/vespalib/src/vespa/vespalib/data/memory.cpp index fe9d3e97638..f20e3a27f73 100644 --- a/vespalib/src/vespa/vespalib/data/memory.cpp +++ b/vespalib/src/vespa/vespalib/data/memory.cpp @@ -11,8 +11,7 @@ Memory::make_string() const return vespalib::string(data, size); } -std::ostream & -operator<<(std::ostream &os, const Memory &memory) { +std::ostream &operator<<(std::ostream &os, const Memory &memory) { uint32_t written = 0; uint32_t hexCount = 25; os << "size: " << memory.size << "(bytes)" << std::endl; @@ -21,7 +20,7 @@ operator<<(std::ostream &os, const Memory &memory) { os << std::endl; written = 0; } - os << make_string("0x%02x ", memory.data[i] & 0xff); + os << vespalib::make_string("0x%02x ", memory.data[i] & 0xff); } if (written > 0) { os << std::endl; diff --git a/vespalib/src/vespa/vespalib/datastore/datastorebase.cpp b/vespalib/src/vespa/vespalib/datastore/datastorebase.cpp index c15d4784cc9..af320136815 100644 --- a/vespalib/src/vespa/vespalib/datastore/datastorebase.cpp +++ b/vespalib/src/vespa/vespalib/datastore/datastorebase.cpp @@ -110,8 +110,8 @@ DataStoreBase::switch_primary_buffer(uint32_t typeId, size_t entries_needed) { size_t buffer_id = getFirstFreeBufferId(); if (buffer_id >= getMaxNumBuffers()) { - LOG_ABORT(make_string("switch_primary_buffer(%u, %zu): did not find a free buffer", - typeId, entries_needed).c_str()); + LOG_ABORT(vespalib::make_string("switch_primary_buffer(%u, %zu): did not find a free buffer", + typeId, entries_needed).c_str()); } on_active(buffer_id, typeId, entries_needed); _primary_buffer_ids[typeId] = buffer_id; @@ -402,7 +402,7 @@ DataStoreBase::on_active(uint32_t bufferId, uint32_t typeId, size_t entries_need BufferAndMeta & bufferMeta = _buffers[bufferId]; BufferState *state = bufferMeta.get_state_relaxed(); if (state == nullptr) { - auto & newState = _stash.create<BufferState>(); + BufferState & newState = _stash.create<BufferState>(); if (_disable_entry_hold_list) { newState.disable_entry_hold_list(); } diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store.h b/vespalib/src/vespa/vespalib/datastore/unique_store.h index 04bcc3fc10d..71346719932 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store.h +++ b/vespalib/src/vespa/vespalib/datastore/unique_store.h @@ -51,8 +51,7 @@ private: using generation_t = vespalib::GenerationHandler::generation_t; public: - UniqueStore(std::shared_ptr<alloc::MemoryAllocator> memory_allocator, const std::function<ComparatorType(const DataStoreType&)>& comparator_factory); - explicit UniqueStore(std::shared_ptr<alloc::MemoryAllocator> memory_allocator); + UniqueStore(std::shared_ptr<alloc::MemoryAllocator> memory_allocator, const std::function<ComparatorType(const DataStoreType&)>& comparator_factory = [](const auto& data_store) { return ComparatorType(data_store);}); ~UniqueStore(); void set_dictionary(std::unique_ptr<IUniqueStoreDictionary> dict); UniqueStoreAddResult add(EntryConstRefType value); diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store.hpp b/vespalib/src/vespa/vespalib/datastore/unique_store.hpp index b2c4d4e8d7e..a26db11ff31 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store.hpp +++ b/vespalib/src/vespa/vespalib/datastore/unique_store.hpp @@ -28,11 +28,6 @@ using DefaultUniqueStoreDictionary = UniqueStoreDictionary<DefaultDictionary>; } template <typename EntryT, typename RefT, typename Comparator, typename Allocator> -UniqueStore<EntryT, RefT, Comparator, Allocator>::UniqueStore(std::shared_ptr<alloc::MemoryAllocator> memory_allocator) - : UniqueStore(std::move(memory_allocator), [](const auto& data_store) { return ComparatorType(data_store);}) -{} - -template <typename EntryT, typename RefT, typename Comparator, typename Allocator> UniqueStore<EntryT, RefT, Comparator, Allocator>::UniqueStore(std::shared_ptr<alloc::MemoryAllocator> memory_allocator, const std::function<ComparatorType(const DataStoreType&)>& comparator_factory) : _allocator(std::move(memory_allocator)), _store(_allocator.get_data_store()), diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_allocator.h b/vespalib/src/vespa/vespalib/datastore/unique_store_allocator.h index 962084f3a4b..d3b3696f042 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store_allocator.h +++ b/vespalib/src/vespa/vespalib/datastore/unique_store_allocator.h @@ -31,7 +31,7 @@ private: UniqueStoreBufferType<WrappedEntryType> _typeHandler; public: - explicit UniqueStoreAllocator(std::shared_ptr<alloc::MemoryAllocator> memory_allocator); + UniqueStoreAllocator(std::shared_ptr<alloc::MemoryAllocator> memory_allocator); ~UniqueStoreAllocator() override; EntryRef allocate(const EntryType& value); void hold(EntryRef ref); diff --git a/vespalib/src/vespa/vespalib/portal/portal.cpp b/vespalib/src/vespa/vespalib/portal/portal.cpp index 8e91e2b5caf..9d9a9dc1557 100644 --- a/vespalib/src/vespa/vespalib/portal/portal.cpp +++ b/vespalib/src/vespa/vespalib/portal/portal.cpp @@ -200,7 +200,7 @@ Portal::Portal(CryptoEngine::SP crypto, int port) handle_accept(std::move(guard), std::move(socket)); } }); - _my_host = make_string("%s:%d", HostName::get().c_str(), listen_port()); + _my_host = vespalib::make_string("%s:%d", HostName::get().c_str(), listen_port()); } Portal::~Portal() diff --git a/vespalib/src/vespa/vespalib/util/rusage.cpp b/vespalib/src/vespa/vespalib/util/rusage.cpp index b0245a4e814..f582dddad97 100644 --- a/vespalib/src/vespa/vespalib/util/rusage.cpp +++ b/vespalib/src/vespa/vespalib/util/rusage.cpp @@ -48,7 +48,7 @@ RUsage::createSelf(vespalib::steady_time since) RUsage r; r._time = vespalib::steady_clock::now() - since; if (getrusage(RUSAGE_SELF, &r) != 0) { - throw std::runtime_error(make_string("getrusage failed with errno = %d", errno).c_str()); + throw std::runtime_error(vespalib::make_string("getrusage failed with errno = %d", errno).c_str()); } return r; } @@ -59,7 +59,7 @@ RUsage::createChildren(vespalib::steady_time since) RUsage r; r._time = vespalib::steady_clock::now() - since; if (getrusage(RUSAGE_CHILDREN, &r) != 0) { - throw std::runtime_error(make_string("getrusage failed with errno = %d", errno).c_str()); + throw std::runtime_error(vespalib::make_string("getrusage failed with errno = %d", errno).c_str()); } return r; } |