summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-11-03 13:43:54 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-11-04 14:31:47 +0000
commitb2cc73a0a85d185ff3697fe568498b91cf24bb78 (patch)
treee203d02f047412de4398c5ad7f3efca805d2ca10
parent7afa9dde3c0b86d1b4ded4b4bc583189ba45a17d (diff)
Simplify and avoid default arguments.
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumcomparator.h15
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumstore.h9
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumstore.hpp4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp3
-rw-r--r--searchlib/src/vespa/searchlib/attribute/reference_attribute.h11
-rw-r--r--vespalib/src/vespa/vespalib/datastore/unique_store.h3
-rw-r--r--vespalib/src/vespa/vespalib/datastore/unique_store.hpp5
-rw-r--r--vespalib/src/vespa/vespalib/datastore/unique_store_allocator.h2
9 files changed, 31 insertions, 23 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp b/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp
index 1a1e18a6eae..6cb805d701b 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(const vespalib::datastore::EntryRef lhs, const vespalib::datastore::EntryRef rhs) const {
+EnumStoreStringComparator::less(vespalib::datastore::EntryRef lhs, 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 cfff8d286a5..59dbb3a8cc3 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;
- EnumStoreComparator(const DataStoreType& data_store)
+ explicit 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 EnumStoreComparator<EntryT>(this->_store, lookup_value);
+ return {this->_store, lookup_value};
}
};
@@ -76,6 +76,9 @@ 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)
{}
@@ -91,15 +94,15 @@ private:
EnumStoreStringComparator(const DataStoreType& data_store, CompareStrategy compare_strategy, const char* lookup_value, bool prefix);
public:
- bool less(const vespalib::datastore::EntryRef lhs, const vespalib::datastore::EntryRef rhs) const override;
+ bool less(vespalib::datastore::EntryRef lhs, vespalib::datastore::EntryRef rhs) const override;
EnumStoreStringComparator make_folded() const {
- return EnumStoreStringComparator(_store, _compare_strategy == CompareStrategy::UNCASED_THEN_CASED ? CompareStrategy::UNCASED : _compare_strategy);
+ return {_store, _compare_strategy == CompareStrategy::UNCASED_THEN_CASED ? CompareStrategy::UNCASED : _compare_strategy};
}
EnumStoreStringComparator make_for_lookup(const char* lookup_value) const {
- return EnumStoreStringComparator(_store, _compare_strategy, lookup_value);
+ return {_store, _compare_strategy, lookup_value};
}
EnumStoreStringComparator make_for_prefix_lookup(const char* lookup_value) const {
- return EnumStoreStringComparator(_store, _compare_strategy, lookup_value, true);
+ return {_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 d63274c95fe..3489afdd3f8 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 : public IEnumStore {
+class EnumStoreT final : public IEnumStore {
public:
using EntryType = EntryT;
static constexpr bool has_string_type = std::is_same_v<EntryType, const char *>;
@@ -61,9 +61,6 @@ 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 {
@@ -76,6 +73,8 @@ 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;
@@ -159,7 +158,7 @@ public:
IndexList _possibly_unused;
public:
- BatchUpdater(EnumStoreType& store)
+ explicit 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 3f15f64d191..210d0e4e052 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<EntryT>(has_postings, dict_cfg, {}, attribute::getUndefined<EntryType>())
+ : EnumStoreT(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 std::unique_ptr<IEnumStore::EnumIndexRemapper>();
+ return {};
}
template <typename EntryT>
diff --git a/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp b/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp
index 57513586908..cb196e9a54e 100644
--- a/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp
@@ -234,9 +234,8 @@ ReferenceAttribute::onLoad(vespalib::Executor *)
setCreateSerialNum(attrReader.getCreateSerialNum());
assert(attrReader.getEnumerated());
assert(!attrReader.hasIdx());
- size_t numDocs(0);
uint64_t numValues = attrReader.getEnumCount();
- numDocs = numValues;
+ size_t 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 e2c2db319d0..7b36f975c7e 100644
--- a/searchlib/src/vespa/searchlib/attribute/reference_attribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/reference_attribute.h
@@ -33,11 +33,12 @@ 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/vespalib/src/vespa/vespalib/datastore/unique_store.h b/vespalib/src/vespa/vespalib/datastore/unique_store.h
index 71346719932..04bcc3fc10d 100644
--- a/vespalib/src/vespa/vespalib/datastore/unique_store.h
+++ b/vespalib/src/vespa/vespalib/datastore/unique_store.h
@@ -51,7 +51,8 @@ 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 = [](const auto& data_store) { return ComparatorType(data_store);});
+ 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();
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 a26db11ff31..b2c4d4e8d7e 100644
--- a/vespalib/src/vespa/vespalib/datastore/unique_store.hpp
+++ b/vespalib/src/vespa/vespalib/datastore/unique_store.hpp
@@ -28,6 +28,11 @@ 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 d3b3696f042..962084f3a4b 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:
- UniqueStoreAllocator(std::shared_ptr<alloc::MemoryAllocator> memory_allocator);
+ explicit UniqueStoreAllocator(std::shared_ptr<alloc::MemoryAllocator> memory_allocator);
~UniqueStoreAllocator() override;
EntryRef allocate(const EntryType& value);
void hold(EntryRef ref);