summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-03-30 22:44:49 +0200
committerGitHub <noreply@github.com>2021-03-30 22:44:49 +0200
commitb875c9c53cf33f888345d8fe6f28374d90daef31 (patch)
tree4084b7d32e527f30b926bea152523fbc146c2fb4 /searchlib
parent262607d6fcb6a5bdbdb96c8da0e5988c39b2c546 (diff)
parenta012301f78c9761fa943b9eb8b4239b0f93f5edd (diff)
Merge pull request #17244 from vespa-engine/toregge/enable-limited-range-search-with-hash-dictionary
Enable limited range search with hash dictionary (i.e. fallback to filtering).
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h10
2 files changed, 13 insertions, 1 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp
index 576506aeea9..b7517094b19 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp
@@ -57,6 +57,10 @@ void
PostingListSearchContext::lookupRange(const vespalib::datastore::EntryComparator &low,
const vespalib::datastore::EntryComparator &high)
{
+ if (!_dictionary.get_has_btree_dictionary()) {
+ _uniqueValues = 2; // Avoid zero and single value optimizations, use filtering
+ return;
+ }
_lowerDictItr.lower_bound(_frozenDictionary.getRoot(), EnumIndex(), low);
_upperDictItr = _lowerDictItr;
if (_upperDictItr.valid() && !high.less(EnumIndex(), _upperDictItr.getKey())) {
diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h
index 3777f3cf4ea..22e9987aa9e 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h
@@ -80,6 +80,9 @@ protected:
}
virtual bool fallbackToFiltering() const {
+ if (_uniqueValues >= 2 && !_dictionary.get_has_btree_dictionary()) {
+ return true; // force filtering for range search
+ }
uint32_t numHits = calculateApproxNumHits();
// numHits > 1000: make sure that posting lists are unit tested.
return (numHits > 1000) &&
@@ -216,7 +219,7 @@ private:
bool fallbackToFiltering() const override {
return (this->getRangeLimit() != 0)
- ? false
+ ? (this->_uniqueValues >= 2 && !this->_dictionary.get_has_btree_dictionary())
: Parent::fallbackToFiltering();
}
unsigned int approximateHits() const override {
@@ -339,6 +342,11 @@ getIterators(bool shouldApplyRangeLimit)
auto compHigh = _enumStore.make_comparator(capped.upper());
this->lookupRange(compLow, compHigh);
+ if (!this->_dictionary.get_has_btree_dictionary()) {
+ _low = capped.lower();
+ _high = capped.upper();
+ return;
+ }
if (shouldApplyRangeLimit) {
this->applyRangeLimit(this->getRangeLimit());
}