diff options
author | Geir Storli <geirst@yahooinc.com> | 2023-11-23 14:39:13 +0000 |
---|---|---|
committer | Geir Storli <geirst@yahooinc.com> | 2023-11-23 14:39:13 +0000 |
commit | 2c92cf12501eecf4c12d67515b93fb095ceda21b (patch) | |
tree | 275cf19e245ede167c7b1e7232a831941451a1d5 /searchlib/src/tests/attribute | |
parent | 09e766e260bf77cb2d7157d080468790c391618e (diff) |
Rename IDocumentWeightAttribute to IDocidWithWeightPostingStore.
Also introduce a baseline interface IDirectPostingStore.
This prepares for the introduction of IDocidPostingStore
that will be implemented by single-value attributes with fast-search.
Diffstat (limited to 'searchlib/src/tests/attribute')
5 files changed, 44 insertions, 46 deletions
diff --git a/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp b/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp index dfea4901180..181c0fdf110 100644 --- a/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp +++ b/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp @@ -1,23 +1,21 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/vespalib/testkit/testapp.h> - +#include <vespa/searchcommon/attribute/config.h> #include <vespa/searchlib/attribute/attribute.h> #include <vespa/searchlib/attribute/attributefactory.h> -#include <vespa/searchlib/util/randomgenerator.h> -#include <vespa/vespalib/util/compress.h> +#include <vespa/searchlib/attribute/i_docid_with_weight_posting_store.h> +#include <vespa/searchlib/common/bitvectoriterator.h> #include <vespa/searchlib/fef/termfieldmatchdata.h> -#include <vespa/searchlib/attribute/i_document_weight_attribute.h> +#include <vespa/searchlib/parsequery/parse.h> #include <vespa/searchlib/queryeval/document_weight_search_iterator.h> -#include <vespa/searchlib/test/searchiteratorverifier.h> -#include <vespa/searchlib/common/bitvectoriterator.h> #include <vespa/searchlib/queryeval/executeinfo.h> -#include <vespa/searchlib/parsequery/parse.h> -#include <vespa/searchcommon/attribute/config.h> +#include <vespa/searchlib/test/searchiteratorverifier.h> +#include <vespa/searchlib/util/randomgenerator.h> #include <vespa/vespalib/stllike/asciistream.h> +#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/util/compress.h> #include <vespa/log/log.h> - LOG_SETUP("bitvector_test"); using search::AttributeFactory; @@ -431,12 +429,12 @@ BitVectorTest::test(BasicType bt, CollectionType ct, const vespalib::string &pre checkSearch(v, std::move(sc), 2, 1022, 205, !fastSearch && !filter, true); sc = getSearch<VectorType>(tv, filter); checkSearch(v, std::move(sc), 2, 1022, 205, !filter, true); - const search::IDocumentWeightAttribute *dwa = v->asDocumentWeightAttribute(); - if (dwa != nullptr) { - auto lres = dwa->lookup(getSearchStr<VectorType>(), dwa->get_dictionary_snapshot()); + const auto* dww = v->as_docid_with_weight_posting_store(); + if (dww != nullptr) { + auto lres = dww->lookup(getSearchStr<VectorType>(), dww->get_dictionary_snapshot()); using DWSI = search::queryeval::DocumentWeightSearchIterator; TermFieldMatchData md; - auto dwsi = std::make_unique<DWSI>(md, *dwa, lres); + auto dwsi = std::make_unique<DWSI>(md, *dww, lres); if (!filter) { TEST_DO(checkSearch(v, std::move(dwsi), md, 2, 1022, 205, !filter, true)); } else { 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 6b0ddbc6e35..e2864773c96 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 @@ -1,18 +1,18 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <vespa/searchcommon/attribute/config.h> #include <vespa/searchlib/attribute/attribute.h> +#include <vespa/searchlib/attribute/attribute_read_guard.h> #include <vespa/searchlib/attribute/attributefactory.h> #include <vespa/searchlib/attribute/attributeguard.h> -#include <vespa/searchlib/attribute/attribute_read_guard.h> #include <vespa/searchlib/attribute/attributememorysavetarget.h> -#include <vespa/searchlib/attribute/i_document_weight_attribute.h> +#include <vespa/searchlib/attribute/i_docid_with_weight_posting_store.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchlib/queryeval/document_weight_search_iterator.h> #include <vespa/searchlib/test/searchiteratorverifier.h> #include <vespa/searchlib/util/randomgenerator.h> -#include <vespa/searchcommon/attribute/config.h> -#include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/test/insertion_operators.h> +#include <vespa/vespalib/testkit/test_kit.h> #include <vespa/log/log.h> LOG_SETUP("document_weight_iterator_test"); @@ -58,9 +58,9 @@ void populate_string(AttributeVector::SP attr_ptr) { struct LongFixture { AttributeVector::SP attr; - const IDocumentWeightAttribute *api; + const IDocidWithWeightPostingStore *api; LongFixture() : attr(make_attribute(BasicType::INT64, CollectionType::WSET, true)), - api(attr->asDocumentWeightAttribute()) + api(attr->as_docid_with_weight_posting_store()) { ASSERT_TRUE(api != nullptr); add_docs(attr); @@ -70,9 +70,9 @@ struct LongFixture { struct StringFixture { AttributeVector::SP attr; - const IDocumentWeightAttribute *api; + const IDocidWithWeightPostingStore *api; StringFixture() : attr(make_attribute(BasicType::STRING, CollectionType::WSET, true)), - api(attr->asDocumentWeightAttribute()) + api(attr->as_docid_with_weight_posting_store()) { ASSERT_TRUE(api != nullptr); add_docs(attr); @@ -81,33 +81,33 @@ struct StringFixture { }; TEST("require that appropriate attributes support the document weight attribute interface") { - 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::WSET, true)->as_docid_with_weight_posting_store() != nullptr); + EXPECT_TRUE(make_attribute(BasicType::STRING, CollectionType::WSET, true)->as_docid_with_weight_posting_store() != nullptr); } TEST("require that inappropriate attributes do not support the document weight attribute interface") { - EXPECT_TRUE(make_attribute(BasicType::INT64, CollectionType::SINGLE, false)->asDocumentWeightAttribute() == nullptr); - 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::INT32, CollectionType::WSET, true)->asDocumentWeightAttribute() == nullptr); - EXPECT_TRUE(make_attribute(BasicType::DOUBLE, CollectionType::WSET, true)->asDocumentWeightAttribute() == nullptr); -} - -void verify_valid_lookup(IDocumentWeightAttribute::LookupResult result) { + EXPECT_TRUE(make_attribute(BasicType::INT64, CollectionType::SINGLE, false)->as_docid_with_weight_posting_store() == nullptr); + EXPECT_TRUE(make_attribute(BasicType::INT64, CollectionType::ARRAY, false)->as_docid_with_weight_posting_store() == nullptr); + EXPECT_TRUE(make_attribute(BasicType::INT64, CollectionType::WSET, false)->as_docid_with_weight_posting_store() == nullptr); + EXPECT_TRUE(make_attribute(BasicType::INT64, CollectionType::SINGLE, true)->as_docid_with_weight_posting_store() == nullptr); + EXPECT_TRUE(make_attribute(BasicType::INT64, CollectionType::ARRAY, true)->as_docid_with_weight_posting_store() == nullptr); + EXPECT_TRUE(make_attribute(BasicType::STRING, CollectionType::SINGLE, false)->as_docid_with_weight_posting_store() == nullptr); + EXPECT_TRUE(make_attribute(BasicType::STRING, CollectionType::ARRAY, false)->as_docid_with_weight_posting_store() == nullptr); + EXPECT_TRUE(make_attribute(BasicType::STRING, CollectionType::WSET, false)->as_docid_with_weight_posting_store() == nullptr); + EXPECT_TRUE(make_attribute(BasicType::STRING, CollectionType::SINGLE, true)->as_docid_with_weight_posting_store() == nullptr); + EXPECT_TRUE(make_attribute(BasicType::STRING, CollectionType::ARRAY, true)->as_docid_with_weight_posting_store() == nullptr); + EXPECT_TRUE(make_attribute(BasicType::INT32, CollectionType::WSET, true)->as_docid_with_weight_posting_store() == nullptr); + EXPECT_TRUE(make_attribute(BasicType::DOUBLE, CollectionType::WSET, true)->as_docid_with_weight_posting_store() == nullptr); +} + +void verify_valid_lookup(IDirectPostingStore::LookupResult result) { EXPECT_TRUE(result.posting_idx.valid()); EXPECT_EQUAL(3u, result.posting_size); EXPECT_EQUAL(5, result.min_weight); EXPECT_EQUAL(20, result.max_weight); } -void verify_invalid_lookup(IDocumentWeightAttribute::LookupResult result) { +void verify_invalid_lookup(IDirectPostingStore::LookupResult result) { EXPECT_FALSE(result.posting_idx.valid()); EXPECT_EQUAL(0u, result.posting_size); EXPECT_EQUAL(0, result.min_weight); @@ -124,7 +124,7 @@ TEST_F("require string lookup works correctly", StringFixture) { verify_invalid_lookup(f1.api->lookup("bar", f1.api->get_dictionary_snapshot())); } -void verify_posting(const IDocumentWeightAttribute &api, const char *term) { +void verify_posting(const IDocidWithWeightPostingStore &api, const char *term) { auto result = api.lookup(term, api.get_dictionary_snapshot()); ASSERT_TRUE(result.posting_idx.valid()); std::vector<DocumentWeightIterator> itr_store; @@ -195,7 +195,7 @@ public: ~Verifier(); SearchIterator::UP create(bool strict) const override { (void) strict; - const IDocumentWeightAttribute *api(_attr->asDocumentWeightAttribute()); + const auto* api = _attr->as_docid_with_weight_posting_store(); ASSERT_TRUE(api != nullptr); auto dict_entry = api->lookup("123", api->get_dictionary_snapshot()); ASSERT_TRUE(dict_entry.posting_idx.valid()); diff --git a/searchlib/src/tests/attribute/document_weight_or_filter_search/document_weight_or_filter_search_test.cpp b/searchlib/src/tests/attribute/document_weight_or_filter_search/document_weight_or_filter_search_test.cpp index 804e2fdfbd9..ae4812b5437 100644 --- a/searchlib/src/tests/attribute/document_weight_or_filter_search/document_weight_or_filter_search_test.cpp +++ b/searchlib/src/tests/attribute/document_weight_or_filter_search/document_weight_or_filter_search_test.cpp @@ -1,7 +1,7 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/gtest/gtest.h> -#include <vespa/searchlib/attribute/i_document_weight_attribute.h> +#include <vespa/searchlib/attribute/i_direct_posting_store.h> #include <vespa/searchlib/attribute/document_weight_or_filter_search.h> #include <vespa/searchlib/queryeval/searchiterator.h> #include <vespa/searchlib/common/bitvector.h> diff --git a/searchlib/src/tests/attribute/imported_attribute_vector/imported_attribute_vector_test.cpp b/searchlib/src/tests/attribute/imported_attribute_vector/imported_attribute_vector_test.cpp index eafbbfff103..53fe3c4046a 100644 --- a/searchlib/src/tests/attribute/imported_attribute_vector/imported_attribute_vector_test.cpp +++ b/searchlib/src/tests/attribute/imported_attribute_vector/imported_attribute_vector_test.cpp @@ -140,8 +140,8 @@ TEST_F("getFixedWidth() is inherited from target attribute vector", Fixture) { f.get_imported_attr()->getFixedWidth()); } -TEST_F("asDocumentWeightAttribute() returns nullptr", Fixture) { - EXPECT_TRUE(f.get_imported_attr()->asDocumentWeightAttribute() == nullptr); +TEST_F("as_docid_with_weight_posting_store() returns nullptr", Fixture) { + EXPECT_TRUE(f.get_imported_attr()->as_docid_with_weight_posting_store() == nullptr); } TEST_F("asTensorAttribute() returns nullptr", Fixture) { diff --git a/searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp b/searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp index e618b091a7e..39869340cea 100644 --- a/searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp +++ b/searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp @@ -315,7 +315,7 @@ public: return result; } void expect_document_weight_attribute() { - EXPECT_TRUE(attr->asDocumentWeightAttribute() != nullptr); + EXPECT_TRUE(attr->as_docid_with_weight_posting_store() != nullptr); } void expect_filter_search(const SimpleResult& upper_and_lower, const Node& term) { expect_filter_search(upper_and_lower, upper_and_lower, term); |