summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2023-09-20 16:17:15 +0200
committerTor Egge <Tor.Egge@online.no>2023-09-20 16:17:15 +0200
commitd3c2bfcdf1069a8c45a38ddb7c07cfcac16db2ea (patch)
tree4fad3a8c90735831e341d008ad6b7606dea3980c /searchlib
parent6943e28f0a442f0f3d1bb0dfa273ffba477df6ee (diff)
Posting list search contexts:
Rename useThis() to use_dictionary_entry() and step iterator one or more steps when not using dictionary entry.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h34
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp15
2 files changed, 34 insertions, 15 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h
index 107abd24069..05ccedb39ec 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h
@@ -57,7 +57,7 @@ protected:
void lookupTerm(const vespalib::datastore::EntryComparator &comp);
void lookupRange(const vespalib::datastore::EntryComparator &low, const vespalib::datastore::EntryComparator &high);
void lookupSingle();
- virtual bool useThis(const DictionaryConstIterator & it) const {
+ virtual bool use_dictionary_entry(DictionaryConstIterator& it) const {
(void) it;
return true;
}
@@ -182,7 +182,12 @@ private:
using Parent = PostingSearchContext<BaseSC, PostingListFoldedSearchContextT<DataT>, AttrT>;
using RegexpUtil = vespalib::RegexpUtil;
using Parent::_enumStore;
- bool useThis(const PostingListSearchContext::DictionaryConstIterator & it) const override;
+ // Note: steps iterator one ore more steps when not using dictionary entry
+ bool use_dictionary_entry(PostingListSearchContext::DictionaryConstIterator& it) const override;
+ // Note: Uses copy of dictionary iterator to avoid stepping original.
+ bool use_single_dictionary_entry(PostingListSearchContext::DictionaryConstIterator it) const {
+ return use_dictionary_entry(it);
+ }
public:
StringPostingSearchContext(BaseSC&& base_sc, bool useBitVector, const AttrT &toBeSearched);
};
@@ -289,7 +294,7 @@ StringPostingSearchContext(BaseSC&& base_sc, bool useBitVector, const AttrT &toB
* A single dictionary entry from lookupRange() might not be
* a match if this is a regex search or a fuzzy search.
*/
- if (!this->_lowerDictItr.valid() || useThis(this->_lowerDictItr)) {
+ if (!this->_lowerDictItr.valid() || use_single_dictionary_entry(this->_lowerDictItr)) {
this->lookupSingle();
} else {
this->_uniqueValues = 0;
@@ -300,15 +305,26 @@ StringPostingSearchContext(BaseSC&& base_sc, bool useBitVector, const AttrT &toB
template <typename BaseSC, typename AttrT, typename DataT>
bool
-StringPostingSearchContext<BaseSC, AttrT, DataT>::useThis(const PostingListSearchContext::DictionaryConstIterator & it) const {
+StringPostingSearchContext<BaseSC, AttrT, DataT>::use_dictionary_entry(PostingListSearchContext::DictionaryConstIterator& it) const {
if ( this->isRegex() ) {
- return this->getRegex().valid()
- ? this->getRegex().partial_match(_enumStore.get_value(it.getKey().load_acquire()))
- : false;
+ if (this->getRegex().valid() &&
+ this->getRegex().partial_match(_enumStore.get_value(it.getKey().load_acquire()))) {
+ return true;
+ }
+ ++it;
+ return false;
} else if ( this->isCased() ) {
- return this->match(_enumStore.get_value(it.getKey().load_acquire()));
+ if (this->match(_enumStore.get_value(it.getKey().load_acquire()))) {
+ return true;
+ }
+ ++it;
+ return false;
} else if (this->isFuzzy()) {
- return this->getFuzzyMatcher().isMatch(_enumStore.get_value(it.getKey().load_acquire()));
+ if (this->getFuzzyMatcher().isMatch(_enumStore.get_value(it.getKey().load_acquire()))) {
+ return true;
+ }
+ ++it;
+ return false;
}
return true;
}
diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp
index 725491c4702..bd1cc1191a7 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp
@@ -64,9 +64,10 @@ size_t
PostingListSearchContextT<DataT>::countHits() const
{
size_t sum(0);
- for (auto it(_lowerDictItr); it != _upperDictItr; ++it) {
- if (useThis(it)) {
+ for (auto it(_lowerDictItr); it != _upperDictItr;) {
+ if (use_dictionary_entry(it)) {
sum += _postingList.frozenSize(it.getData().load_acquire());
+ ++it;
}
}
return sum;
@@ -77,10 +78,11 @@ template <typename DataT>
void
PostingListSearchContextT<DataT>::fillArray()
{
- for (auto it(_lowerDictItr); it != _upperDictItr; ++it) {
- if (useThis(it)) {
+ for (auto it(_lowerDictItr); it != _upperDictItr;) {
+ if (use_dictionary_entry(it)) {
_merger.addToArray(PostingListTraverser<PostingList>(_postingList,
it.getData().load_acquire()));
+ ++it;
}
}
_merger.merge();
@@ -91,10 +93,11 @@ template <typename DataT>
void
PostingListSearchContextT<DataT>::fillBitVector()
{
- for (auto it(_lowerDictItr); it != _upperDictItr; ++it) {
- if (useThis(it)) {
+ for (auto it(_lowerDictItr); it != _upperDictItr;) {
+ if (use_dictionary_entry(it)) {
_merger.addToBitVector(PostingListTraverser<PostingList>(_postingList,
it.getData().load_acquire()));
+ ++it;
}
}
}