summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-04-19 21:22:11 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2021-04-19 21:22:11 +0000
commit8ed4e70600e1c773f97a237c77697d61bbdcf409 (patch)
tree60c846e608fb527cc9bd0d6c891f795303643aff /searchlib
parent13d80ba9eb4706b22d9ac11b8e015eacc71aff43 (diff)
Avoid the need for 'prefix' for types where it does not make sense.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/attribute/enum_comparator/enum_comparator_test.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp11
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumcomparator.h9
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumstore.h9
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multistringattribute.hpp4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlestringattribute.hpp4
7 files changed, 28 insertions, 21 deletions
diff --git a/searchlib/src/tests/attribute/enum_comparator/enum_comparator_test.cpp b/searchlib/src/tests/attribute/enum_comparator/enum_comparator_test.cpp
index d999a6f37a2..a9efc22dc5a 100644
--- a/searchlib/src/tests/attribute/enum_comparator/enum_comparator_test.cpp
+++ b/searchlib/src/tests/attribute/enum_comparator/enum_comparator_test.cpp
@@ -162,8 +162,8 @@ TEST("requireThatFoldedLessIsWorking")
EXPECT_FALSE(cmp1.less(e2, e1)); // similar folded
EXPECT_TRUE(cmp1.less(e2, e3)); // folded compare
EXPECT_FALSE(cmp1.less(e3, e2)); // folded compare
- auto cmp2 = es.make_folded_comparator("fol", false);
- auto cmp3 = es.make_folded_comparator("fol", true);
+ auto cmp2 = es.make_folded_comparator("fol");
+ auto cmp3 = es.make_folded_comparator_prefix("fol");
EXPECT_TRUE(cmp2.less(EnumIndex(), e4));
EXPECT_FALSE(cmp2.less(e4, EnumIndex()));
EXPECT_FALSE(cmp3.less(EnumIndex(), e4)); // similar when prefix
@@ -183,8 +183,8 @@ TEST("requireThatFoldedEqualIsWorking")
EXPECT_TRUE(cmp1.equal(e2, e1));
EXPECT_FALSE(cmp1.equal(e2, e3)); // folded compare
EXPECT_FALSE(cmp1.equal(e3, e2)); // folded compare
- auto cmp2 = es.make_folded_comparator("fol", false);
- auto cmp3 = es.make_folded_comparator("fol", true);
+ auto cmp2 = es.make_folded_comparator("fol");
+ auto cmp3 = es.make_folded_comparator_prefix("fol");
EXPECT_FALSE(cmp2.equal(EnumIndex(), e4));
EXPECT_FALSE(cmp2.equal(e4, EnumIndex()));
EXPECT_TRUE(cmp2.equal(EnumIndex(), EnumIndex()));
diff --git a/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp b/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp
index a428ac77d87..3e601e823c5 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp
@@ -12,10 +12,9 @@ FoldedStringCompare _strCmp;
}
template <typename EntryT>
-EnumStoreComparator<EntryT>::EnumStoreComparator(const DataStoreType& data_store, const EntryT& fallback_value, bool prefix)
+EnumStoreComparator<EntryT>::EnumStoreComparator(const DataStoreType& data_store, const EntryT& fallback_value)
: ParentType(data_store, fallback_value)
{
- (void) prefix;
}
template <typename EntryT>
@@ -41,9 +40,9 @@ EnumStoreStringComparator::EnumStoreStringComparator(const DataStoreType& data_s
{
}
-EnumStoreFoldedStringComparator::EnumStoreFoldedStringComparator(const DataStoreType& data_store, bool prefix)
+EnumStoreFoldedStringComparator::EnumStoreFoldedStringComparator(const DataStoreType& data_store)
: ParentType(data_store, nullptr),
- _prefix(prefix),
+ _prefix(false),
_prefix_len(0u)
{
}
@@ -72,9 +71,7 @@ EnumStoreFoldedStringComparator::compare_folded(const char* lhs, const char* rhs
}
int
-EnumStoreFoldedStringComparator::compare_folded_prefix(const char* lhs,
- const char* rhs,
- size_t prefix_len)
+EnumStoreFoldedStringComparator::compare_folded_prefix(const char* lhs, const char* rhs, size_t prefix_len)
{
return _strCmp.compareFoldedPrefix(lhs, rhs, prefix_len);
}
diff --git a/searchlib/src/vespa/searchlib/attribute/enumcomparator.h b/searchlib/src/vespa/searchlib/attribute/enumcomparator.h
index 0215053ba3a..1e1b28d3881 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, const EntryT& fallback_value, bool prefix = false);
+ EnumStoreComparator(const DataStoreType& data_store, const EntryT& fallback_value);
EnumStoreComparator(const DataStoreType& data_store);
static bool equal_helper(const EntryT& lhs, const EntryT& rhs);
@@ -83,7 +83,7 @@ public:
*
* @param prefix whether we should perform prefix compare.
*/
- EnumStoreFoldedStringComparator(const DataStoreType& data_store, bool prefix = false);
+ EnumStoreFoldedStringComparator(const DataStoreType& data_store);
/**
* Creates a comparator using the given low-level data store and that uses the
@@ -92,7 +92,10 @@ public:
* @param prefix whether we should perform prefix compare.
*/
EnumStoreFoldedStringComparator(const DataStoreType& data_store,
- const char* fallback_value, bool prefix = false);
+ const char* fallback_value, bool prefix);
+ EnumStoreFoldedStringComparator(const DataStoreType& data_store, const char* fallback_value)
+ : EnumStoreFoldedStringComparator(data_store, fallback_value, false)
+ {}
static bool equal(const char* lhs, const char* rhs) {
return compare_folded(lhs, rhs) == 0;
diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.h b/searchlib/src/vespa/searchlib/attribute/enumstore.h
index 01acee671bc..b95237fe176 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumstore.h
+++ b/searchlib/src/vespa/searchlib/attribute/enumstore.h
@@ -188,7 +188,14 @@ public:
return FoldedComparatorType(_store.get_data_store());
}
- FoldedComparatorType make_folded_comparator(const EntryType& fallback_value, bool prefix = false) const {
+ FoldedComparatorType
+ make_folded_comparator(const EntryType& fallback_value) const {
+ return FoldedComparatorType(_store.get_data_store(), fallback_value);
+ }
+
+ template<bool prefix=true>
+ FoldedComparatorType
+ make_folded_comparator_prefix(const EntryType& fallback_value) const {
return FoldedComparatorType(_store.get_data_store(), fallback_value, prefix);
}
diff --git a/searchlib/src/vespa/searchlib/attribute/multistringattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multistringattribute.hpp
index 003fb9fa6b7..f1508cfa631 100644
--- a/searchlib/src/vespa/searchlib/attribute/multistringattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multistringattribute.hpp
@@ -120,11 +120,11 @@ StringTemplSearchContext(QueryTermSimpleUP qTerm, const AttrType & toBeSearched)
this->_plsc = static_cast<attribute::IPostingListSearchContext *>(this);
if (this->valid()) {
if (this->isPrefix()) {
- auto comp = enumStore.make_folded_comparator(queryTerm()->getTerm(), true);
+ auto comp = enumStore.make_folded_comparator_prefix(queryTerm()->getTerm());
lookupRange(comp, comp);
} else if (this->isRegex()) {
vespalib::string prefix(vespalib::RegexpUtil::get_prefix(this->queryTerm()->getTerm()));
- auto comp = enumStore.make_folded_comparator(prefix.c_str(), true);
+ auto comp = enumStore.make_folded_comparator_prefix(prefix.c_str());
lookupRange(comp, comp);
} else {
auto comp = enumStore.make_folded_comparator(queryTerm()->getTerm());
diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h
index 22e9987aa9e..dac3a1f7453 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h
@@ -284,11 +284,11 @@ StringPostingSearchContext(QueryTermSimpleUP qTerm, bool useBitVector, const Att
if (this->valid()) {
if (this->isPrefix()) {
- auto comp = _enumStore.make_folded_comparator(this->queryTerm()->getTerm(), true);
+ auto comp = _enumStore.make_folded_comparator_prefix(this->queryTerm()->getTerm());
this->lookupRange(comp, comp);
} else if (this->isRegex()) {
vespalib::string prefix(RegexpUtil::get_prefix(this->queryTerm()->getTerm()));
- auto comp = _enumStore.make_folded_comparator(prefix.c_str(), true);
+ auto comp = _enumStore.make_folded_comparator_prefix(prefix.c_str());
this->lookupRange(comp, comp);
} else {
auto comp = _enumStore.make_folded_comparator(this->queryTerm()->getTerm());
diff --git a/searchlib/src/vespa/searchlib/attribute/singlestringattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlestringattribute.hpp
index e362ecff6cd..532b83ea03c 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlestringattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlestringattribute.hpp
@@ -56,11 +56,11 @@ SingleValueStringAttributeT<B>::StringTemplSearchContext::StringTemplSearchConte
this->_plsc = static_cast<attribute::IPostingListSearchContext *>(this);
if (this->valid()) {
if (this->isPrefix()) {
- auto comp = enumStore.make_folded_comparator(queryTerm()->getTerm(), true);
+ auto comp = enumStore.make_folded_comparator_prefix(queryTerm()->getTerm());
lookupRange(comp, comp);
} else if (this->isRegex()) {
vespalib::string prefix(vespalib::RegexpUtil::get_prefix(this->queryTerm()->getTerm()));
- auto comp = enumStore.make_folded_comparator(prefix.c_str(), true);
+ auto comp = enumStore.make_folded_comparator_prefix(prefix.c_str());
lookupRange(comp, comp);
} else {
auto comp = enumStore.make_folded_comparator(queryTerm()->getTerm());