aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/attribute
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-07-06 15:10:49 +0200
committerGitHub <noreply@github.com>2023-07-06 15:10:49 +0200
commit38348a148848c6111c1e2461451cb0c1aef1a95d (patch)
tree609814329e84d178481c3e50f97e7313267b8bdb /searchlib/src/tests/attribute
parent1320294132ab2dc5d9e0ab03f30130fce9ad2291 (diff)
Revert "Enable DirectWeightedAttribute optmization also for arrays."
Diffstat (limited to 'searchlib/src/tests/attribute')
-rw-r--r--searchlib/src/tests/attribute/document_weight_iterator/document_weight_iterator_test.cpp62
1 files changed, 14 insertions, 48 deletions
diff --git a/searchlib/src/tests/attribute/document_weight_iterator/document_weight_iterator_test.cpp b/searchlib/src/tests/attribute/document_weight_iterator/document_weight_iterator_test.cpp
index c864877aec2..98e70fd6c1f 100644
--- a/searchlib/src/tests/attribute/document_weight_iterator/document_weight_iterator_test.cpp
+++ b/searchlib/src/tests/attribute/document_weight_iterator/document_weight_iterator_test.cpp
@@ -38,13 +38,7 @@ void add_docs(AttributeVector::SP attr_ptr, size_t limit = 1000) {
template <typename ATTR, typename KEY>
void set_doc(ATTR *attr, uint32_t docid, KEY key, int32_t weight) {
attr->clearDoc(docid);
- if (attr->hasWeightedSetType()) {
- attr->append(docid, key, weight);
- } else {
- for (int32_t i(0); i < weight; i++) {
- attr->append(docid, key, 1);
- }
- }
+ attr->append(docid, key, weight);
attr->commit();
}
@@ -62,13 +56,11 @@ void populate_string(AttributeVector::SP attr_ptr) {
set_doc(attr, 7, "foo", 10);
}
-template<CollectionType::Type CT>
struct LongFixture {
AttributeVector::SP attr;
const IDocumentWeightAttribute *api;
- LongFixture()
- : attr(make_attribute(BasicType::INT64, CollectionType::WSET, true)),
- api(attr->asDocumentWeightAttribute())
+ LongFixture() : attr(make_attribute(BasicType::INT64, CollectionType::WSET, true)),
+ api(attr->asDocumentWeightAttribute())
{
ASSERT_TRUE(api != nullptr);
add_docs(attr);
@@ -76,16 +68,11 @@ struct LongFixture {
}
};
-using LongWsetFixture = LongFixture<CollectionType::WSET>;
-using LongArrayFixture = LongFixture<CollectionType::ARRAY>;
-
-template<CollectionType::Type CT>
struct StringFixture {
AttributeVector::SP attr;
const IDocumentWeightAttribute *api;
- StringFixture()
- : attr(make_attribute(BasicType::STRING, CT, true)),
- api(attr->asDocumentWeightAttribute())
+ StringFixture() : attr(make_attribute(BasicType::STRING, CollectionType::WSET, true)),
+ api(attr->asDocumentWeightAttribute())
{
ASSERT_TRUE(api != nullptr);
add_docs(attr);
@@ -93,15 +80,10 @@ struct StringFixture {
}
};
-using StringWsetFixture = StringFixture<CollectionType::WSET>;
-using StringArrayFixture = StringFixture<CollectionType::ARRAY>;
-
TEST("require that appropriate attributes support the document weight attribute interface") {
EXPECT_TRUE(make_attribute(BasicType::INT32, CollectionType::WSET, true)->asDocumentWeightAttribute() != nullptr);
EXPECT_TRUE(make_attribute(BasicType::INT64, CollectionType::WSET, true)->asDocumentWeightAttribute() != nullptr);
EXPECT_TRUE(make_attribute(BasicType::STRING, CollectionType::WSET, true)->asDocumentWeightAttribute() != nullptr);
- EXPECT_TRUE(make_attribute(BasicType::INT64, CollectionType::ARRAY, true)->asDocumentWeightAttribute() != nullptr);
- EXPECT_TRUE(make_attribute(BasicType::STRING, CollectionType::ARRAY, true)->asDocumentWeightAttribute() != nullptr);
}
TEST("require that inappropriate attributes do not support the document weight attribute interface") {
@@ -109,10 +91,12 @@ TEST("require that inappropriate attributes do not support the document weight a
EXPECT_TRUE(make_attribute(BasicType::INT64, CollectionType::ARRAY, false)->asDocumentWeightAttribute() == nullptr);
EXPECT_TRUE(make_attribute(BasicType::INT64, CollectionType::WSET, false)->asDocumentWeightAttribute() == nullptr);
EXPECT_TRUE(make_attribute(BasicType::INT64, CollectionType::SINGLE, true)->asDocumentWeightAttribute() == nullptr);
+ EXPECT_TRUE(make_attribute(BasicType::INT64, CollectionType::ARRAY, true)->asDocumentWeightAttribute() == nullptr);
EXPECT_TRUE(make_attribute(BasicType::STRING, CollectionType::SINGLE, false)->asDocumentWeightAttribute() == nullptr);
EXPECT_TRUE(make_attribute(BasicType::STRING, CollectionType::ARRAY, false)->asDocumentWeightAttribute() == nullptr);
EXPECT_TRUE(make_attribute(BasicType::STRING, CollectionType::WSET, false)->asDocumentWeightAttribute() == nullptr);
EXPECT_TRUE(make_attribute(BasicType::STRING, CollectionType::SINGLE, true)->asDocumentWeightAttribute() == nullptr);
+ EXPECT_TRUE(make_attribute(BasicType::STRING, CollectionType::ARRAY, true)->asDocumentWeightAttribute() == nullptr);
EXPECT_TRUE(make_attribute(BasicType::FLOAT, CollectionType::WSET, true)->asDocumentWeightAttribute() == nullptr);
EXPECT_TRUE(make_attribute(BasicType::DOUBLE, CollectionType::WSET, true)->asDocumentWeightAttribute() == nullptr);
}
@@ -131,22 +115,12 @@ void verify_invalid_lookup(IDocumentWeightAttribute::LookupResult result) {
EXPECT_EQUAL(0, result.max_weight);
}
-TEST_F("require that integer wset lookup works correctly", LongWsetFixture) {
+TEST_F("require that integer lookup works correctly", LongFixture) {
verify_valid_lookup(f1.api->lookup("111", f1.api->get_dictionary_snapshot()));
verify_invalid_lookup(f1.api->lookup("222", f1.api->get_dictionary_snapshot()));
}
-TEST_F("require that integer array lookup works correctly", LongArrayFixture) {
- verify_valid_lookup(f1.api->lookup("111", f1.api->get_dictionary_snapshot()));
- verify_invalid_lookup(f1.api->lookup("222", f1.api->get_dictionary_snapshot()));
-}
-
-TEST_F("require string wset lookup works correctly", StringWsetFixture) {
- verify_valid_lookup(f1.api->lookup("foo", f1.api->get_dictionary_snapshot()));
- verify_invalid_lookup(f1.api->lookup("bar", f1.api->get_dictionary_snapshot()));
-}
-
-TEST_F("require string array lookup works correctly", StringArrayFixture) {
+TEST_F("require string lookup works correctly", StringFixture) {
verify_valid_lookup(f1.api->lookup("foo", f1.api->get_dictionary_snapshot()));
verify_invalid_lookup(f1.api->lookup("bar", f1.api->get_dictionary_snapshot()));
}
@@ -178,23 +152,15 @@ void verify_posting(const IDocumentWeightAttribute &api, const char *term) {
}
}
-TEST_F("require that integer wset iterators are created correctly", LongWsetFixture) {
+TEST_F("require that integer iterators are created correctly", LongFixture) {
verify_posting(*f1.api, "111");
}
-TEST_F("require that integer array iterators are created correctly", LongArrayFixture) {
- verify_posting(*f1.api, "111");
-}
-
-TEST_F("require that string wset iterators are created correctly", StringWsetFixture) {
- verify_posting(*f1.api, "foo");
-}
-
-TEST_F("require that string array iterators are created correctly", StringArrayFixture) {
+TEST_F("require that string iterators are created correctly", StringFixture) {
verify_posting(*f1.api, "foo");
}
-TEST_F("require that collect_folded works for string", StringWsetFixture)
+TEST_F("require that collect_folded works for string", StringFixture)
{
StringAttribute *attr = static_cast<StringAttribute *>(f1.attr.get());
set_doc(attr, 2, "bar", 30);
@@ -210,7 +176,7 @@ TEST_F("require that collect_folded works for string", StringWsetFixture)
EXPECT_EQUAL(expected_folded, folded);
}
-TEST_F("require that collect_folded works for integers", LongWsetFixture)
+TEST_F("require that collect_folded works for integers", LongFixture)
{
IntegerAttributeTemplate<int64_t> *attr = dynamic_cast<IntegerAttributeTemplate<int64_t> *>(f1.attr.get());
set_doc(attr, 2, int64_t(112), 30);
@@ -251,7 +217,7 @@ Verifier::Verifier()
set_doc(int_attr, docid, int64_t(123), 1);
}
}
-Verifier::~Verifier() = default;
+Verifier::~Verifier() {}
TEST("verify document weight search iterator") {
Verifier verifier;