diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-04-19 20:21:25 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-04-19 20:33:15 +0000 |
commit | 13d80ba9eb4706b22d9ac11b8e015eacc71aff43 (patch) | |
tree | f934bc858b24c259aef8f86bdba75be069978c82 /searchlib | |
parent | 739eb8295cd1c7010c23ceca01239b72106133ba (diff) |
- Make all use of comparator const.
- Less explicit temporaries.
Diffstat (limited to 'searchlib')
8 files changed, 29 insertions, 41 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp index 0890605f265..80209c99c4d 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp +++ b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp @@ -188,16 +188,14 @@ template <typename EntryT> void EnumStoreT<EntryT>::free_unused_values() { - auto cmp = make_comparator(); - _dict->free_unused_values(cmp); + _dict->free_unused_values(make_comparator()); } template <typename EntryT> void EnumStoreT<EntryT>::free_unused_values(const IndexSet& to_remove) { - auto cmp = make_comparator(); - _dict->free_unused_values(to_remove, cmp); + _dict->free_unused_values(to_remove, make_comparator()); } template <typename EntryT> diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp index 697fa33a060..2097d1683c1 100644 --- a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp @@ -27,11 +27,10 @@ MultiValueNumericPostingAttribute<B, M>::applyValueChanges(const DocIndices& doc EnumStoreBatchUpdater& updater) { using PostingChangeComputer = PostingChangeComputerT<WeightedIndex, PostingMap>; - EnumStore & enumStore = this->getEnumStore(); - auto comp = enumStore.make_comparator(); EnumIndexMapper mapper; - PostingMap changePost(PostingChangeComputer::compute(this->getMultiValueMapping(), docIndices, comp, mapper)); + PostingMap changePost(PostingChangeComputer::compute(this->getMultiValueMapping(), docIndices, + this->getEnumStore().make_comparator(), mapper)); this->updatePostings(changePost); MultiValueNumericEnumAttribute<B, M>::applyValueChanges(docIndices, updater); } diff --git a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp index d427df69903..bae20b08fc9 100644 --- a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp @@ -31,7 +31,7 @@ class StringEnumIndexMapper : public EnumIndexMapper public: StringEnumIndexMapper(IEnumStoreDictionary & dictionary) : _dictionary(dictionary) { } IEnumStore::Index map(IEnumStore::Index original) const override; - virtual bool hasFold() const override { return true; } + bool hasFold() const override { return true; } private: IEnumStoreDictionary& _dictionary; }; @@ -44,10 +44,10 @@ applyValueChanges(const DocIndices& docIndices, EnumStoreBatchUpdater &updater) using PostingChangeComputer = PostingChangeComputerT<WeightedIndex, PostingMap>; EnumStore &enumStore(this->getEnumStore()); IEnumStoreDictionary& dictionary(enumStore.get_dictionary()); - auto compare = enumStore.make_folded_comparator(); StringEnumIndexMapper mapper(dictionary); - PostingMap changePost(PostingChangeComputer::compute(this->getMultiValueMapping(), docIndices, compare, mapper)); + PostingMap changePost(PostingChangeComputer::compute(this->getMultiValueMapping(), docIndices, + enumStore.make_folded_comparator(), mapper)); this->updatePostings(changePost); MultiValueStringAttributeT<B, T>::applyValueChanges(docIndices, updater); } diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp index 3cf51f43613..9eaa33355e9 100644 --- a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp @@ -102,7 +102,7 @@ PostingListAttributeBase<P>::handle_load_posting_lists_and_update_enum_store(enu template <typename P> void PostingListAttributeBase<P>::updatePostings(PostingMap &changePost, - vespalib::datastore::EntryComparator &cmp) + const vespalib::datastore::EntryComparator &cmp) { for (auto& elem : changePost) { EnumIndex idx = elem.first.getEnumIdx(); @@ -145,7 +145,7 @@ PostingListAttributeBase<P>:: clearPostings(attribute::IAttributeVector::EnumHandle eidx, uint32_t fromLid, uint32_t toLid, - vespalib::datastore::EntryComparator &cmp) + const vespalib::datastore::EntryComparator &cmp) { PostingChange<P> postings; @@ -267,8 +267,7 @@ void PostingListAttributeSubBase<P, LoadedVector, LoadedValueType, EnumStoreType>:: updatePostings(PostingMap &changePost) { - auto cmp = _es.make_folded_comparator(); - updatePostings(changePost, cmp); + updatePostings(changePost, _es.make_folded_comparator()); } @@ -276,11 +275,9 @@ template <typename P, typename LoadedVector, typename LoadedValueType, typename EnumStoreType> void PostingListAttributeSubBase<P, LoadedVector, LoadedValueType, EnumStoreType>:: -clearPostings(attribute::IAttributeVector::EnumHandle eidx, - uint32_t fromLid, uint32_t toLid) +clearPostings(attribute::IAttributeVector::EnumHandle eidx, uint32_t fromLid, uint32_t toLid) { - auto cmp = _es.make_folded_comparator(); - clearPostings(eidx, fromLid, toLid, cmp); + clearPostings(eidx, fromLid, toLid, _es.make_folded_comparator()); } diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.h b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.h index 03348f08486..8fb6d74319e 100644 --- a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.h @@ -52,11 +52,11 @@ protected: IEnumStoreDictionary& _dictionary; PostingListAttributeBase(AttributeVector &attr, IEnumStore &enumStore); - virtual ~PostingListAttributeBase(); + ~PostingListAttributeBase() override; virtual void updatePostings(PostingMap & changePost) = 0; - void updatePostings(PostingMap &changePost, vespalib::datastore::EntryComparator &cmp); + void updatePostings(PostingMap &changePost, const vespalib::datastore::EntryComparator &cmp); void clearAllPostings(); void disableFreeLists() { _postingList.disableFreeLists(); } void disableElemHoldList() { _postingList.disableElemHoldList(); } @@ -64,10 +64,10 @@ protected: bool forwardedOnAddDoc(DocId doc, size_t wantSize, size_t wantCapacity); void clearPostings(attribute::IAttributeVector::EnumHandle eidx, uint32_t fromLid, - uint32_t toLid, vespalib::datastore::EntryComparator &cmp); + uint32_t toLid, const vespalib::datastore::EntryComparator &cmp); void forwardedShrinkLidSpace(uint32_t newSize) override; - virtual vespalib::MemoryUsage getMemoryUsage() const override; + vespalib::MemoryUsage getMemoryUsage() const override; public: const PostingList & getPostingList() const { return _postingList; } @@ -102,7 +102,7 @@ private: public: PostingListAttributeSubBase(AttributeVector &attr, EnumStore &enumStore); - virtual ~PostingListAttributeSubBase(); + ~PostingListAttributeSubBase() override; void handle_load_posting_lists(LoadedVector &loaded); void updatePostings(PostingMap &changePost) override; diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp index 325874091ef..a45197dba9c 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp @@ -95,8 +95,7 @@ SingleValueNumericPostingAttribute<B>::applyValueChanges(EnumStoreBatchUpdater& } if (change._type == ChangeBase::UPDATE) { - applyUpdateValueChange(change, enumStore, - currEnumIndices); + applyUpdateValueChange(change, enumStore, currEnumIndices); } else if (change._type >= ChangeBase::ADD && change._type <= ChangeBase::DIV) { if (oldIdx.valid()) { T oldValue = enumStore.get_value(oldIdx); @@ -107,8 +106,7 @@ SingleValueNumericPostingAttribute<B>::applyValueChanges(EnumStoreBatchUpdater& } } else if(change._type == ChangeBase::CLEARDOC) { this->_defaultValue._doc = change._doc; - applyUpdateValueChange(this->_defaultValue, enumStore, - currEnumIndices); + applyUpdateValueChange(this->_defaultValue, enumStore, currEnumIndices); } } diff --git a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h index 397fad60be3..748d5bc4567 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h @@ -65,11 +65,10 @@ private: EnumStore & enumStore, std::map<DocId, EnumIndex> &currEnumIndices); - void - makePostingChange(const vespalib::datastore::EntryComparator *cmp, - IEnumStoreDictionary& dictionary, - const std::map<DocId, EnumIndex> &currEnumIndices, - PostingMap &changePost); + void makePostingChange(const vespalib::datastore::EntryComparator &cmp, + IEnumStoreDictionary& dictionary, + const std::map<DocId, EnumIndex> &currEnumIndices, + PostingMap &changePost); void applyValueChanges(EnumStoreBatchUpdater& updater) override; public: diff --git a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp index 50ed621b13e..5bdc6613756 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp @@ -52,7 +52,7 @@ SingleValueStringPostingAttributeT<B>::applyUpdateValueChange(const Change & c, template <typename B> void SingleValueStringPostingAttributeT<B>:: -makePostingChange(const vespalib::datastore::EntryComparator *cmpa, +makePostingChange(const vespalib::datastore::EntryComparator &cmpa, IEnumStoreDictionary& dictionary, const std::map<DocId, EnumIndex> &currEnumIndices, PostingMap &changePost) @@ -64,12 +64,12 @@ makePostingChange(const vespalib::datastore::EntryComparator *cmpa, // add new posting auto remapped_new_idx = dictionary.remap_index(newIdx); - changePost[EnumPostingPair(remapped_new_idx, cmpa)].add(docId, 1); + changePost[EnumPostingPair(remapped_new_idx, &cmpa)].add(docId, 1); // remove old posting if ( oldIdx.valid()) { auto remapped_old_idx = dictionary.remap_index(oldIdx); - changePost[EnumPostingPair(remapped_old_idx, cmpa)].remove(docId); + changePost[EnumPostingPair(remapped_old_idx, &cmpa)].remove(docId); } } } @@ -80,7 +80,6 @@ SingleValueStringPostingAttributeT<B>::applyValueChanges(EnumStoreBatchUpdater& { EnumStore & enumStore = this->getEnumStore(); IEnumStoreDictionary& dictionary = enumStore.get_dictionary(); - auto cmp = enumStore.make_folded_comparator(); PostingMap changePost; // used to make sure several arithmetic operations on the same document in a single commit works @@ -95,16 +94,14 @@ SingleValueStringPostingAttributeT<B>::applyValueChanges(EnumStoreBatchUpdater& oldIdx = this->_enumIndices[change._doc]; } if (change._type == ChangeBase::UPDATE) { - applyUpdateValueChange(change, enumStore, - currEnumIndices); + applyUpdateValueChange(change, enumStore, currEnumIndices); } else if (change._type == ChangeBase::CLEARDOC) { this->_defaultValue._doc = change._doc; - applyUpdateValueChange(this->_defaultValue, enumStore, - currEnumIndices); + applyUpdateValueChange(this->_defaultValue, enumStore, currEnumIndices); } } - makePostingChange(&cmp, dictionary, currEnumIndices, changePost); + makePostingChange(enumStore.make_folded_comparator(), dictionary, currEnumIndices, changePost); this->updatePostings(changePost); |