aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2024-01-22 23:32:02 +0100
committerGitHub <noreply@github.com>2024-01-22 23:32:02 +0100
commit48abccf6ee4dd5be89430c406e03519934205d90 (patch)
treeefc4a236bdd696a71a2e8d12a9cc6384a19fc701
parent8ed109fb98d442645f6308c93193831a7f87d70c (diff)
Revert "Support IDocidWithWeightPostingStore for more attribute data types."
-rw-r--r--searchlib/src/tests/attribute/bitvector/bitvector_test.cpp3
-rw-r--r--searchlib/src/tests/attribute/direct_posting_store/direct_posting_store_test.cpp8
-rw-r--r--searchlib/src/vespa/searchcommon/attribute/basictype.cpp9
-rw-r--r--searchlib/src/vespa/searchcommon/attribute/basictype.h1
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp65
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp3
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp13
8 files changed, 53 insertions, 51 deletions
diff --git a/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp b/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp
index 6e479e1d9db..f612bdda87f 100644
--- a/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp
+++ b/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp
@@ -430,8 +430,7 @@ BitVectorTest::test(BasicType bt, CollectionType ct, const vespalib::string &pre
sc = getSearch<VectorType>(tv, filter);
checkSearch(v, std::move(sc), 2, 1022, 205, !filter, true);
const auto* dww = v->as_docid_with_weight_posting_store();
- if ((dww != nullptr) && (bt == BasicType::STRING)) {
- // This way of doing lookup is only supported by string attributes.
+ if (dww != nullptr) {
auto lres = dww->lookup(getSearchStr<VectorType>(), dww->get_dictionary_snapshot());
using DWSI = search::queryeval::DocidWithWeightSearchIterator;
TermFieldMatchData md;
diff --git a/searchlib/src/tests/attribute/direct_posting_store/direct_posting_store_test.cpp b/searchlib/src/tests/attribute/direct_posting_store/direct_posting_store_test.cpp
index 2ddd211bd12..c1e12580559 100644
--- a/searchlib/src/tests/attribute/direct_posting_store/direct_posting_store_test.cpp
+++ b/searchlib/src/tests/attribute/direct_posting_store/direct_posting_store_test.cpp
@@ -142,11 +142,7 @@ TEST(DirectPostingStoreApiTest, attributes_do_not_support_IDocidPostingStore_int
TEST(DirectPostingStoreApiTest, attributes_support_IDocidWithWeightPostingStore_interface) {
expect_docid_with_weight_posting_store(BasicType::INT64, CollectionType::WSET, true);
- expect_docid_with_weight_posting_store(BasicType::INT32, CollectionType::WSET, true);
expect_docid_with_weight_posting_store(BasicType::STRING, CollectionType::WSET, true);
- expect_docid_with_weight_posting_store(BasicType::INT64, CollectionType::ARRAY, true);
- expect_docid_with_weight_posting_store(BasicType::INT32, CollectionType::ARRAY, true);
- expect_docid_with_weight_posting_store(BasicType::STRING, CollectionType::ARRAY, true);
}
TEST(DirectPostingStoreApiTest, attributes_do_not_support_IDocidWithWeightPostingStore_interface) {
@@ -154,11 +150,13 @@ TEST(DirectPostingStoreApiTest, attributes_do_not_support_IDocidWithWeightPostin
expect_not_docid_with_weight_posting_store(BasicType::INT64, CollectionType::ARRAY, false);
expect_not_docid_with_weight_posting_store(BasicType::INT64, CollectionType::WSET, false);
expect_not_docid_with_weight_posting_store(BasicType::INT64, CollectionType::SINGLE, true);
+ expect_not_docid_with_weight_posting_store(BasicType::INT64, CollectionType::ARRAY, true);
expect_not_docid_with_weight_posting_store(BasicType::STRING, CollectionType::SINGLE, false);
expect_not_docid_with_weight_posting_store(BasicType::STRING, CollectionType::ARRAY, false);
expect_not_docid_with_weight_posting_store(BasicType::STRING, CollectionType::WSET, false);
expect_not_docid_with_weight_posting_store(BasicType::STRING, CollectionType::SINGLE, true);
- expect_not_docid_with_weight_posting_store(BasicType::DOUBLE, CollectionType::ARRAY, true);
+ expect_not_docid_with_weight_posting_store(BasicType::STRING, CollectionType::ARRAY, true);
+ expect_not_docid_with_weight_posting_store(BasicType::INT32, CollectionType::WSET, true);
expect_not_docid_with_weight_posting_store(BasicType::DOUBLE, CollectionType::WSET, true);
}
diff --git a/searchlib/src/vespa/searchcommon/attribute/basictype.cpp b/searchlib/src/vespa/searchcommon/attribute/basictype.cpp
index 0312154690c..c63d07ca130 100644
--- a/searchlib/src/vespa/searchcommon/attribute/basictype.cpp
+++ b/searchlib/src/vespa/searchcommon/attribute/basictype.cpp
@@ -35,13 +35,4 @@ BasicType::asType(const vespalib::string &t)
return NONE;
}
-bool
-BasicType::is_integer_type() const noexcept
-{
- return (_type == INT8) ||
- (_type == INT16) ||
- (_type == INT32) ||
- (_type == INT64);
-}
-
}
diff --git a/searchlib/src/vespa/searchcommon/attribute/basictype.h b/searchlib/src/vespa/searchcommon/attribute/basictype.h
index 4bdee5ecfd9..35200b3f62d 100644
--- a/searchlib/src/vespa/searchcommon/attribute/basictype.h
+++ b/searchlib/src/vespa/searchcommon/attribute/basictype.h
@@ -36,7 +36,6 @@ class BasicType
Type type() const noexcept { return _type; }
const char * asString() const noexcept { return asString(_type); }
size_t fixedSize() const noexcept { return fixedSize(_type); }
- bool is_integer_type() const noexcept;
static BasicType fromType(bool) noexcept { return BOOL; }
static BasicType fromType(int8_t) noexcept { return INT8; }
static BasicType fromType(int16_t) noexcept { return INT16; }
diff --git a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp
index 5f00c1ccf2f..5d689f5bd81 100644
--- a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp
@@ -579,7 +579,8 @@ private:
const IDocidWithWeightPostingStore *_dwwps;
vespalib::string _scratchPad;
- bool has_always_btree_iterators_with_docid_and_weight() const {
+ bool use_docid_with_weight_posting_store() const {
+ // TODO: Relax requirement on always having weight iterator for query operators where that makes sense.
return (_dwwps != nullptr) && (_dwwps->has_always_btree_iterator());
}
@@ -598,7 +599,7 @@ public:
template <class TermNode>
void visitSimpleTerm(TermNode &n) {
- if (has_always_btree_iterators_with_docid_and_weight() && !_field.isFilter() && n.isRanked() && !Term::isPossibleRangeTerm(n.getTerm())) {
+ if (use_docid_with_weight_posting_store() && !_field.isFilter() && n.isRanked() && !Term::isPossibleRangeTerm(n.getTerm())) {
NodeAsKey key(n, _scratchPad);
setResult(std::make_unique<DirectAttributeBlueprint>(_field, _attr, *_dwwps, key));
} else {
@@ -679,41 +680,32 @@ public:
return std::make_unique<QueryTermUCS4>(term, QueryTermSimple::Type::WORD);
}
- template <typename TermType, typename SearchType>
- void visit_wset_or_in_term(TermType& n) {
- if (_dps != nullptr) {
- auto* bp = new attribute::DirectMultiTermBlueprint<IDocidPostingStore, SearchType>
- (_field, _attr, *_dps, n.getNumTerms());
- createDirectMultiTerm(bp, n);
- } else if (_dwwps != nullptr) {
- auto* bp = new attribute::DirectMultiTermBlueprint<IDocidWithWeightPostingStore, SearchType>
- (_field, _attr, *_dwwps, n.getNumTerms());
- createDirectMultiTerm(bp, n);
+ void visit(query::WeightedSetTerm &n) override {
+ bool isSingleValue = !_attr.hasMultiValue();
+ bool isString = (_attr.isStringType() && _attr.hasEnum());
+ bool isInteger = _attr.isIntegerType();
+ if (isSingleValue && (isString || isInteger)) {
+ auto ws = std::make_unique<AttributeWeightedSetBlueprint>(_field, _attr);
+ SearchContextParams scParams = createContextParams();
+ for (size_t i = 0; i < n.getNumTerms(); ++i) {
+ auto term = n.getAsString(i);
+ ws->addToken(_attr.createSearchContext(extractTerm(term.first, isInteger), scParams), term.second.percent());
+ }
+ setResult(std::move(ws));
} else {
- bool isSingleValue = !_attr.hasMultiValue();
- bool isString = (_attr.isStringType() && _attr.hasEnum());
- bool isInteger = _attr.isIntegerType();
- if (isSingleValue && (isString || isInteger)) {
- auto ws = std::make_unique<AttributeWeightedSetBlueprint>(_field, _attr);
- SearchContextParams scParams = createContextParams();
- for (size_t i = 0; i < n.getNumTerms(); ++i) {
- auto term = n.getAsString(i);
- ws->addToken(_attr.createSearchContext(extractTerm(term.first, isInteger), scParams), term.second.percent());
- }
- setResult(std::move(ws));
+ if (use_docid_with_weight_posting_store()) {
+ auto *bp = new attribute::DirectMultiTermBlueprint<IDocidWithWeightPostingStore, queryeval::WeightedSetTermSearch>
+ (_field, _attr, *_dwwps, n.getNumTerms());
+ createDirectMultiTerm(bp, n);
} else {
- auto* bp = new WeightedSetTermBlueprint(_field);
+ auto *bp = new WeightedSetTermBlueprint(_field);
createShallowWeightedSet(bp, n, _field, _attr.isIntegerType());
}
}
}
- void visit(query::WeightedSetTerm &n) override {
- visit_wset_or_in_term<query::WeightedSetTerm, queryeval::WeightedSetTermSearch>(n);
- }
-
void visit(query::DotProduct &n) override {
- if (has_always_btree_iterators_with_docid_and_weight()) {
+ if (use_docid_with_weight_posting_store()) {
auto *bp = new attribute::DirectMultiTermBlueprint<IDocidWithWeightPostingStore, queryeval::DotProductSearch>
(_field, _attr, *_dwwps, n.getNumTerms());
createDirectMultiTerm(bp, n);
@@ -724,7 +716,7 @@ public:
}
void visit(query::WandTerm &n) override {
- if (has_always_btree_iterators_with_docid_and_weight()) {
+ if (use_docid_with_weight_posting_store()) {
auto *bp = new DirectWandBlueprint(_field, *_dwwps,
n.getTargetNumHits(), n.getScoreThreshold(), n.getThresholdBoostFactor(),
n.getNumTerms());
@@ -739,7 +731,18 @@ public:
}
void visit(query::InTerm &n) override {
- visit_wset_or_in_term<query::InTerm, attribute::InTermSearch>(n);
+ if (_dps != nullptr) {
+ auto* bp = new attribute::DirectMultiTermBlueprint<IDocidPostingStore, attribute::InTermSearch>
+ (_field, _attr, *_dps, n.getNumTerms());
+ createDirectMultiTerm(bp, n);
+ } else if (_dwwps != nullptr) {
+ auto* bp = new attribute::DirectMultiTermBlueprint<IDocidWithWeightPostingStore, attribute::InTermSearch>
+ (_field, _attr, *_dwwps, n.getNumTerms());
+ createDirectMultiTerm(bp, n);
+ } else {
+ auto* bp = new WeightedSetTermBlueprint(_field);
+ createShallowWeightedSet(bp, n, _field, _attr.isIntegerType());
+ }
}
void fail_nearest_neighbor_term(query::NearestNeighborTerm&n, const vespalib::string& error_msg) {
diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp
index 9328857c919..ea1058d88fb 100644
--- a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp
@@ -89,7 +89,7 @@ template <typename B, typename M>
const IDocidWithWeightPostingStore*
MultiValueNumericPostingAttribute<B, M>::as_docid_with_weight_posting_store() const
{
- if (this->getConfig().basicType().is_integer_type()) {
+ if (this->hasWeightedSetType() && (this->getBasicType() == AttributeVector::BasicType::INT64)) {
return &_posting_store_adapter;
}
return nullptr;
diff --git a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp
index 371b8d920f9..b6e9b69a81d 100644
--- a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp
@@ -108,7 +108,8 @@ template <typename B, typename T>
const IDocidWithWeightPostingStore*
MultiValueStringPostingAttributeT<B, T>::as_docid_with_weight_posting_store() const
{
- if (this->isStringType()) {
+ // TODO: Add support for handling bit vectors too, and lift restriction on isFilter.
+ if (this->hasWeightedSetType() && this->isStringType()) {
return &_posting_store_adapter;
}
return nullptr;
diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp
index c74e25fbf5a..c57742ca4b6 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp
@@ -150,11 +150,22 @@ SingleValueNumericPostingAttribute<B>::getSearch(QueryTermSimple::UP qTerm,
return std::make_unique<SC>(std::move(base_sc), params, *this);
}
+namespace {
+
+bool is_integer_type(attribute::BasicType type) {
+ return (type == attribute::BasicType::INT8) ||
+ (type == attribute::BasicType::INT16) ||
+ (type == attribute::BasicType::INT32) ||
+ (type == attribute::BasicType::INT64);
+}
+
+}
+
template <typename B>
const IDocidPostingStore*
SingleValueNumericPostingAttribute<B>::as_docid_posting_store() const
{
- if (this->getConfig().basicType().is_integer_type()) {
+ if (is_integer_type(this->getBasicType())) {
return &_posting_store_adapter;
}
return nullptr;