summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2021-03-30 21:46:54 +0200
committerTor Egge <Tor.Egge@broadpark.no>2021-03-30 21:46:54 +0200
commita012301f78c9761fa943b9eb8b4239b0f93f5edd (patch)
tree56d52653f6543245a0f54a943c1618630fe2f4f8 /searchlib
parent1e5e5325e02f79a9875b83fb1e8edd9919844f3a (diff)
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());
}