diff options
Diffstat (limited to 'searchlib/src/tests/queryeval')
61 files changed, 237 insertions, 200 deletions
diff --git a/searchlib/src/tests/queryeval/CMakeLists.txt b/searchlib/src/tests/queryeval/CMakeLists.txt index c24a661de22..55207e5705d 100644 --- a/searchlib/src/tests/queryeval/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_queryeval_test_app TEST SOURCES queryeval_test.cpp diff --git a/searchlib/src/tests/queryeval/blueprint/CMakeLists.txt b/searchlib/src/tests/queryeval/blueprint/CMakeLists.txt index bbaf7fc6490..e46ad1085e3 100644 --- a/searchlib/src/tests/queryeval/blueprint/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/blueprint/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_blueprint_test_app TEST SOURCES blueprint_test.cpp diff --git a/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp b/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp index b0d3edc984a..1d908bed568 100644 --- a/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp +++ b/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "mysearch.h" #include <vespa/vespalib/testkit/testapp.h> #include <vespa/searchlib/queryeval/blueprint.h> diff --git a/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp b/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp index c617db871a7..7a8250a2e16 100644 --- a/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp +++ b/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "mysearch.h" #include <vespa/vespalib/testkit/testapp.h> diff --git a/searchlib/src/tests/queryeval/blueprint/leaf_blueprints_test.cpp b/searchlib/src/tests/queryeval/blueprint/leaf_blueprints_test.cpp index 81873ccae7e..44be9fb0fca 100644 --- a/searchlib/src/tests/queryeval/blueprint/leaf_blueprints_test.cpp +++ b/searchlib/src/tests/queryeval/blueprint/leaf_blueprints_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// 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/searchlib/queryeval/blueprint.h> diff --git a/searchlib/src/tests/queryeval/blueprint/mysearch.h b/searchlib/src/tests/queryeval/blueprint/mysearch.h index 4fa53443123..6cfc7a04368 100644 --- a/searchlib/src/tests/queryeval/blueprint/mysearch.h +++ b/searchlib/src/tests/queryeval/blueprint/mysearch.h @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/searchlib/queryeval/blueprint.h> #include <vespa/searchlib/queryeval/multisearch.h> #include <vespa/searchlib/fef/termfieldmatchdataarray.h> diff --git a/searchlib/src/tests/queryeval/dot_product/CMakeLists.txt b/searchlib/src/tests/queryeval/dot_product/CMakeLists.txt index 1b2e58b0c69..e8b4e6d387c 100644 --- a/searchlib/src/tests/queryeval/dot_product/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/dot_product/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_dot_product_test_app TEST SOURCES dot_product_test.cpp diff --git a/searchlib/src/tests/queryeval/dot_product/dot_product_test.cpp b/searchlib/src/tests/queryeval/dot_product/dot_product_test.cpp index b90f009e4b7..4305f7da116 100644 --- a/searchlib/src/tests/queryeval/dot_product/dot_product_test.cpp +++ b/searchlib/src/tests/queryeval/dot_product/dot_product_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// 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/searchlib/queryeval/dot_product_search.h> diff --git a/searchlib/src/tests/queryeval/equiv/CMakeLists.txt b/searchlib/src/tests/queryeval/equiv/CMakeLists.txt index 58db3504c50..a60ff8b7549 100644 --- a/searchlib/src/tests/queryeval/equiv/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/equiv/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_equiv_test_app TEST SOURCES equiv_test.cpp diff --git a/searchlib/src/tests/queryeval/equiv/equiv_test.cpp b/searchlib/src/tests/queryeval/equiv/equiv_test.cpp index bc927e233db..9b74f8a650f 100644 --- a/searchlib/src/tests/queryeval/equiv/equiv_test.cpp +++ b/searchlib/src/tests/queryeval/equiv/equiv_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/log/log.h> LOG_SETUP("equiv_test"); #include <vespa/searchlib/queryeval/leaf_blueprints.h> diff --git a/searchlib/src/tests/queryeval/fake_searchable/CMakeLists.txt b/searchlib/src/tests/queryeval/fake_searchable/CMakeLists.txt index d762213f824..fa51c91262d 100644 --- a/searchlib/src/tests/queryeval/fake_searchable/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/fake_searchable/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_fake_searchable_test_app TEST SOURCES fake_searchable_test.cpp diff --git a/searchlib/src/tests/queryeval/fake_searchable/fake_searchable_test.cpp b/searchlib/src/tests/queryeval/fake_searchable/fake_searchable_test.cpp index e9c4bdb26a5..3bfdcd21ce6 100644 --- a/searchlib/src/tests/queryeval/fake_searchable/fake_searchable_test.cpp +++ b/searchlib/src/tests/queryeval/fake_searchable/fake_searchable_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// 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> diff --git a/searchlib/src/tests/queryeval/filter_search/CMakeLists.txt b/searchlib/src/tests/queryeval/filter_search/CMakeLists.txt index ad2da1f6eed..1d42766b5b4 100644 --- a/searchlib/src/tests/queryeval/filter_search/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/filter_search/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_filter_search_test_app TEST SOURCES filter_search_test.cpp diff --git a/searchlib/src/tests/queryeval/filter_search/filter_search_test.cpp b/searchlib/src/tests/queryeval/filter_search/filter_search_test.cpp index e468560f4ec..71033ed7d06 100644 --- a/searchlib/src/tests/queryeval/filter_search/filter_search_test.cpp +++ b/searchlib/src/tests/queryeval/filter_search/filter_search_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/searchlib/queryeval/simpleresult.h> #include <vespa/searchlib/queryeval/emptysearch.h> diff --git a/searchlib/src/tests/queryeval/getnodeweight/CMakeLists.txt b/searchlib/src/tests/queryeval/getnodeweight/CMakeLists.txt index 38f072d6df9..7720e0637cf 100644 --- a/searchlib/src/tests/queryeval/getnodeweight/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/getnodeweight/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_getnodeweight_test_app TEST SOURCES getnodeweight_test.cpp diff --git a/searchlib/src/tests/queryeval/getnodeweight/getnodeweight_test.cpp b/searchlib/src/tests/queryeval/getnodeweight/getnodeweight_test.cpp index a76620420a3..d9b7d5b3192 100644 --- a/searchlib/src/tests/queryeval/getnodeweight/getnodeweight_test.cpp +++ b/searchlib/src/tests/queryeval/getnodeweight/getnodeweight_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// 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> diff --git a/searchlib/src/tests/queryeval/global_filter/CMakeLists.txt b/searchlib/src/tests/queryeval/global_filter/CMakeLists.txt index 2f768bf9d88..3763fb81afa 100644 --- a/searchlib/src/tests/queryeval/global_filter/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/global_filter/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_queryeval_global_filter_test_app TEST SOURCES global_filter_test.cpp diff --git a/searchlib/src/tests/queryeval/global_filter/global_filter_test.cpp b/searchlib/src/tests/queryeval/global_filter/global_filter_test.cpp index 49d579b6d3d..ac486577aca 100644 --- a/searchlib/src/tests/queryeval/global_filter/global_filter_test.cpp +++ b/searchlib/src/tests/queryeval/global_filter/global_filter_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// 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/vespalib/util/require.h> diff --git a/searchlib/src/tests/queryeval/matching_elements_search/CMakeLists.txt b/searchlib/src/tests/queryeval/matching_elements_search/CMakeLists.txt index d2470083d40..d4ec1b83887 100644 --- a/searchlib/src/tests/queryeval/matching_elements_search/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/matching_elements_search/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_matching_elements_search_test_app TEST SOURCES diff --git a/searchlib/src/tests/queryeval/matching_elements_search/matching_elements_search_test.cpp b/searchlib/src/tests/queryeval/matching_elements_search/matching_elements_search_test.cpp index 5e5d9a9a282..b1ff582f3ff 100644 --- a/searchlib/src/tests/queryeval/matching_elements_search/matching_elements_search_test.cpp +++ b/searchlib/src/tests/queryeval/matching_elements_search/matching_elements_search_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/searchcommon/attribute/attributecontent.h> #include <vespa/searchlib/attribute/attributefactory.h> diff --git a/searchlib/src/tests/queryeval/monitoring_search_iterator/CMakeLists.txt b/searchlib/src/tests/queryeval/monitoring_search_iterator/CMakeLists.txt index cd6ad397299..bf2af32abc6 100644 --- a/searchlib/src/tests/queryeval/monitoring_search_iterator/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/monitoring_search_iterator/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_monitoring_search_iterator_test_app TEST SOURCES monitoring_search_iterator_test.cpp diff --git a/searchlib/src/tests/queryeval/monitoring_search_iterator/monitoring_search_iterator_test.cpp b/searchlib/src/tests/queryeval/monitoring_search_iterator/monitoring_search_iterator_test.cpp index ec31a18830e..f5b90fd862c 100644 --- a/searchlib/src/tests/queryeval/monitoring_search_iterator/monitoring_search_iterator_test.cpp +++ b/searchlib/src/tests/queryeval/monitoring_search_iterator/monitoring_search_iterator_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/searchlib/queryeval/andsearch.h> #include <vespa/searchlib/queryeval/monitoring_search_iterator.h> diff --git a/searchlib/src/tests/queryeval/multibitvectoriterator/CMakeLists.txt b/searchlib/src/tests/queryeval/multibitvectoriterator/CMakeLists.txt index 911cb968d63..dff8ea2ef0c 100644 --- a/searchlib/src/tests/queryeval/multibitvectoriterator/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/multibitvectoriterator/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_multibitvectoriterator_test_app TEST SOURCES multibitvectoriterator_test.cpp diff --git a/searchlib/src/tests/queryeval/multibitvectoriterator/multibitvectoriterator_bench.cpp b/searchlib/src/tests/queryeval/multibitvectoriterator/multibitvectoriterator_bench.cpp index 397014f498f..95e80cd08b8 100644 --- a/searchlib/src/tests/queryeval/multibitvectoriterator/multibitvectoriterator_bench.cpp +++ b/searchlib/src/tests/queryeval/multibitvectoriterator/multibitvectoriterator_bench.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// 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/searchlib/queryeval/multibitvectoriterator.h> diff --git a/searchlib/src/tests/queryeval/multibitvectoriterator/multibitvectoriterator_test.cpp b/searchlib/src/tests/queryeval/multibitvectoriterator/multibitvectoriterator_test.cpp index d0ccbaeb180..901d8371bc9 100644 --- a/searchlib/src/tests/queryeval/multibitvectoriterator/multibitvectoriterator_test.cpp +++ b/searchlib/src/tests/queryeval/multibitvectoriterator/multibitvectoriterator_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// 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/searchlib/queryeval/multibitvectoriterator.h> #include <vespa/searchlib/queryeval/emptysearch.h> @@ -20,35 +20,20 @@ using namespace search::fef; using namespace search; using vespalib::Trinary; -//----------------------------------------------------------------------------- - -class Test : public vespalib::TestApp -{ -public: - Test(); - ~Test(); - void testAndNot(); - void testAnd(); - void testBug7163266(); - void testOr(); +struct Fixture { + Fixture(); void testAndWith(bool invert); void testEndGuard(bool invert); - void testIteratorConformance(); - void testUnpackOfOr(); - template<typename T> - void testThatOptimizePreservesUnpack(); + void verifyUnpackOfOr(const UnpackInfo & unpackInfo); template <typename T> void testOptimizeCommon(bool isAnd, bool invert); template <typename T> - void testOptimizeAndOr(bool invert); - template <typename T> void testSearch(bool strict, bool invert); - int Main() override; -private: - void verifyUnpackOfOr(const UnpackInfo & unpackInfo); - void verifySelectiveUnpack(SearchIterator & s, const TermFieldMatchData * tfmd); - void searchAndCompare(SearchIterator::UP s, uint32_t docIdLimit); - void setup(); + template <typename T> + void testOptimizeAndOr(bool invert); + template<typename T> + void testThatOptimizePreservesUnpack(); + SearchIterator::UP createIter(size_t index, bool inverted, TermFieldMatchData & tfmd, bool strict) { return BitVectorIterator::create(getBV(index, inverted), tfmd, strict, inverted); } @@ -69,10 +54,9 @@ private: std::vector< BitVector::UP > _bvs_inverted; }; -Test::Test() = default; -Test::~Test() = default; - -void Test::setup() +Fixture::Fixture() + : _bvs(), + _bvs_inverted() { std::minstd_rand rnd(341); for(size_t i(0); i < 3; i++) { @@ -120,7 +104,7 @@ seek(SearchIterator & s, uint32_t docIdLimit) } void -Test::testAndWith(bool invert) +Fixture::testAndWith(bool invert) { TermFieldMatchData tfmd; { @@ -156,54 +140,55 @@ Test::testAndWith(bool invert) } } -void -Test::testAndNot() +TEST_F("testAndNot", Fixture) { for (bool invert : {false, true}) { - testOptimizeCommon<AndNotSearch>(false, invert); - testSearch<AndNotSearch>(false, invert); - testSearch<AndNotSearch>(true, invert); + f.template testOptimizeCommon<AndNotSearch>(false, invert); + f.template testSearch<AndNotSearch>(false, invert); + f.template testSearch<AndNotSearch>(true, invert); } } -void -Test::testAnd() +TEST_F("testAnd", Fixture) { for (bool invert : {false, true}) { - testOptimizeCommon<AndSearch>(true, invert); - testOptimizeAndOr<AndSearch>(invert); - testSearch<AndSearch>(false, invert); - testSearch<AndSearch>(true, invert); + f.template testOptimizeCommon<AndSearch>(true, invert); + f.template testOptimizeAndOr<AndSearch>(invert); + f.template testSearch<AndSearch>(false, invert); + f.template testSearch<AndSearch>(true, invert); } } -void -Test::testOr() +TEST_F("testOr", Fixture) { for (bool invert : {false, true}) { - testOptimizeCommon< OrSearch >(false, invert); - testOptimizeAndOr< OrSearch >(invert); - testSearch<OrSearch>(false, invert); - testSearch<OrSearch>(true, invert); + f.template testOptimizeCommon< OrSearch >(false, invert); + f.template testOptimizeAndOr< OrSearch >(invert); + f.template testSearch<OrSearch>(false, invert); + f.template testSearch<OrSearch>(true, invert); } } -void -Test::testBug7163266() +TEST_F("testAndWith", Fixture) { + f.testAndWith(false); + f.testAndWith(true); +} + +TEST_F("testBug7163266", Fixture) { TermFieldMatchData tfmd[30]; - _bvs[0]->setBit(1); - _bvs[1]->setBit(1); + f._bvs[0]->setBit(1); + f._bvs[1]->setBit(1); MultiSearch::Children children; UnpackInfo unpackInfo; for (size_t i(0); i < 28; i++) { children.emplace_back(new TrueSearch(tfmd[2])); unpackInfo.add(i); } - children.push_back(createIter(0, false, tfmd[0], false)); - children.push_back(createIter(1, false, tfmd[1], false)); + children.push_back(f.createIter(0, false, tfmd[0], false)); + children.push_back(f.createIter(1, false, tfmd[1], false)); SearchIterator::UP s = AndSearch::create(std::move(children), false, unpackInfo); - const MultiSearch * ms = dynamic_cast<const MultiSearch *>(s.get()); + const auto * ms = dynamic_cast<const MultiSearch *>(s.get()); EXPECT_TRUE(ms != nullptr); EXPECT_EQUAL(30u, ms->getChildren().size()); EXPECT_EQUAL("search::queryeval::AndSearchNoStrict<search::queryeval::(anonymous namespace)::SelectiveUnpack>", s->getClassName()); @@ -221,12 +206,26 @@ Test::testBug7163266() EXPECT_TRUE(ms->needUnpack(i)); } EXPECT_TRUE(ms->needUnpack(28)); // NB: force unpack all - fixup_bitvectors(); +} + +void +verifySelectiveUnpack(SearchIterator & s, const TermFieldMatchData * tfmd) +{ + s.seek(1); + EXPECT_EQUAL(0u, tfmd[0].getDocId()); + EXPECT_EQUAL(0u, tfmd[1].getDocId()); + EXPECT_EQUAL(0u, tfmd[2].getDocId()); + EXPECT_EQUAL(0u, tfmd[3].getDocId()); + s.unpack(1); + EXPECT_EQUAL(0u, tfmd[0].getDocId()); + EXPECT_EQUAL(1u, tfmd[1].getDocId()); + EXPECT_EQUAL(1u, tfmd[2].getDocId()); + EXPECT_EQUAL(0u, tfmd[3].getDocId()); } template<typename T> void -Test::testThatOptimizePreservesUnpack() +Fixture::testThatOptimizePreservesUnpack() { TermFieldMatchData tfmd[4]; _bvs[0]->setBit(1); @@ -242,7 +241,7 @@ Test::testThatOptimizePreservesUnpack() unpackInfo.add(2); SearchIterator::UP s = T::create(std::move(children), false, unpackInfo); s->initFullRange(); - const MultiSearch * ms = dynamic_cast<const MultiSearch *>(s.get()); + const auto * ms = dynamic_cast<const MultiSearch *>(s.get()); EXPECT_TRUE(ms != nullptr); EXPECT_EQUAL(4u, ms->getChildren().size()); verifySelectiveUnpack(*s, tfmd); @@ -269,25 +268,22 @@ void verifyOrUnpack(SearchIterator & s, TermFieldMatchData tfmd[3]) { EXPECT_EQUAL(0u, tfmd[2].getDocId()); } -void -Test::testUnpackOfOr() { - _bvs[0]->clearBit(1); - _bvs[1]->setBit(1); - _bvs[2]->clearBit(1); +TEST_F("testUnpackOfOr", Fixture) { + f._bvs[0]->clearBit(1); + f._bvs[1]->setBit(1); + f._bvs[2]->clearBit(1); UnpackInfo all; all.forceAll(); - verifyUnpackOfOr(all); + f.verifyUnpackOfOr(all); UnpackInfo unpackInfo; unpackInfo.add(1); unpackInfo.add(2); - verifyUnpackOfOr(unpackInfo); - - fixup_bitvectors(); + f.verifyUnpackOfOr(unpackInfo); } void -Test::verifyUnpackOfOr(const UnpackInfo &unpackInfo) +Fixture::verifyUnpackOfOr(const UnpackInfo &unpackInfo) { TermFieldMatchData tfmdA[3]; MultiSearch::Children children; @@ -301,7 +297,7 @@ Test::verifyUnpackOfOr(const UnpackInfo &unpackInfo) tfmd.resetOnlyDocId(0); } - const MultiSearch * ms = dynamic_cast<const MultiSearch *>(s.get()); + const auto * ms = dynamic_cast<const MultiSearch *>(s.get()); EXPECT_TRUE(ms != nullptr); EXPECT_EQUAL(3u, ms->getChildren().size()); @@ -315,22 +311,7 @@ Test::verifyUnpackOfOr(const UnpackInfo &unpackInfo) } void -Test::verifySelectiveUnpack(SearchIterator & s, const TermFieldMatchData * tfmd) -{ - s.seek(1); - EXPECT_EQUAL(0u, tfmd[0].getDocId()); - EXPECT_EQUAL(0u, tfmd[1].getDocId()); - EXPECT_EQUAL(0u, tfmd[2].getDocId()); - EXPECT_EQUAL(0u, tfmd[3].getDocId()); - s.unpack(1); - EXPECT_EQUAL(0u, tfmd[0].getDocId()); - EXPECT_EQUAL(1u, tfmd[1].getDocId()); - EXPECT_EQUAL(1u, tfmd[2].getDocId()); - EXPECT_EQUAL(0u, tfmd[3].getDocId()); -} - -void -Test::searchAndCompare(SearchIterator::UP s, uint32_t docIdLimit) +searchAndCompare(SearchIterator::UP s, uint32_t docIdLimit) { H a = seek(*s, docIdLimit); SearchIterator * p = s.get(); @@ -347,7 +328,7 @@ Test::searchAndCompare(SearchIterator::UP s, uint32_t docIdLimit) template <typename T> void -Test::testSearch(bool strict, bool invert) +Fixture::testSearch(bool strict, bool invert) { TermFieldMatchData tfmd; uint32_t docIdLimit(_bvs[0]->size()); @@ -376,7 +357,7 @@ Test::testSearch(bool strict, bool invert) template <typename T> void -Test::testOptimizeCommon(bool isAnd, bool invert) +Fixture::testOptimizeCommon(bool isAnd, bool invert) { TermFieldMatchData tfmd; @@ -387,7 +368,7 @@ Test::testOptimizeCommon(bool isAnd, bool invert) SearchIterator::UP s = T::create(std::move(children), false); s = MultiBitVectorIteratorBase::optimize(std::move(s)); EXPECT_TRUE(dynamic_cast<const T *>(s.get()) != nullptr); - const MultiSearch & m(dynamic_cast<const MultiSearch &>(*s)); + const auto & m(dynamic_cast<const MultiSearch &>(*s)); EXPECT_EQUAL(1u, m.getChildren().size()); EXPECT_TRUE(dynamic_cast<const BitVectorIterator *>(m.getChildren()[0].get()) != nullptr); } @@ -399,7 +380,7 @@ Test::testOptimizeCommon(bool isAnd, bool invert) SearchIterator::UP s = T::create(std::move(children), false); s = MultiBitVectorIteratorBase::optimize(std::move(s)); EXPECT_TRUE(dynamic_cast<const T *>(s.get()) != nullptr); - const MultiSearch & m(dynamic_cast<const MultiSearch &>(*s)); + const auto & m(dynamic_cast<const MultiSearch &>(*s)); EXPECT_EQUAL(2u, m.getChildren().size()); EXPECT_TRUE(dynamic_cast<const BitVectorIterator *>(m.getChildren()[0].get()) != nullptr); EXPECT_TRUE(dynamic_cast<const EmptySearch *>(m.getChildren()[1].get()) != nullptr); @@ -412,7 +393,7 @@ Test::testOptimizeCommon(bool isAnd, bool invert) SearchIterator::UP s = T::create(std::move(children), false); s = MultiBitVectorIteratorBase::optimize(std::move(s)); EXPECT_TRUE(dynamic_cast<const T *>(s.get()) != nullptr); - const MultiSearch & m(dynamic_cast<const MultiSearch &>(*s)); + const auto & m(dynamic_cast<const MultiSearch &>(*s)); EXPECT_EQUAL(2u, m.getChildren().size()); EXPECT_TRUE(dynamic_cast<const EmptySearch *>(m.getChildren()[0].get()) != nullptr); EXPECT_TRUE(dynamic_cast<const BitVectorIterator *>(m.getChildren()[1].get()) != nullptr); @@ -427,7 +408,7 @@ Test::testOptimizeCommon(bool isAnd, bool invert) s = MultiBitVectorIteratorBase::optimize(std::move(s)); EXPECT_TRUE(s); EXPECT_TRUE(dynamic_cast<const T *>(s.get()) != nullptr); - const MultiSearch & m(dynamic_cast<const MultiSearch &>(*s)); + const auto & m(dynamic_cast<const MultiSearch &>(*s)); EXPECT_EQUAL(2u, m.getChildren().size()); EXPECT_TRUE(dynamic_cast<const EmptySearch *>(m.getChildren()[0].get()) != nullptr); EXPECT_TRUE(dynamic_cast<const MultiBitVectorIteratorBase *>(m.getChildren()[1].get()) != nullptr); @@ -443,7 +424,7 @@ Test::testOptimizeCommon(bool isAnd, bool invert) s = MultiBitVectorIteratorBase::optimize(std::move(s)); EXPECT_TRUE(s); EXPECT_TRUE(dynamic_cast<const T *>(s.get()) != nullptr); - const MultiSearch & m(dynamic_cast<const MultiSearch &>(*s)); + const auto & m(dynamic_cast<const MultiSearch &>(*s)); EXPECT_EQUAL(2u, m.getChildren().size()); EXPECT_TRUE(dynamic_cast<const EmptySearch *>(m.getChildren()[0].get()) != nullptr); EXPECT_TRUE(dynamic_cast<const MultiBitVectorIteratorBase *>(m.getChildren()[1].get()) != nullptr); @@ -481,7 +462,7 @@ Test::testOptimizeCommon(bool isAnd, bool invert) template <typename T> void -Test::testOptimizeAndOr(bool invert) +Fixture::testOptimizeAndOr(bool invert) { TermFieldMatchData tfmd; @@ -506,7 +487,7 @@ Test::testOptimizeAndOr(bool invert) s = MultiBitVectorIteratorBase::optimize(std::move(s)); EXPECT_TRUE(s); EXPECT_TRUE(dynamic_cast<const T *>(s.get()) != nullptr); - const MultiSearch & m(dynamic_cast<const MultiSearch &>(*s)); + const auto & m(dynamic_cast<const MultiSearch &>(*s)); EXPECT_EQUAL(2u, m.getChildren().size()); EXPECT_TRUE(dynamic_cast<const MultiBitVectorIteratorBase *>(m.getChildren()[0].get()) != nullptr); EXPECT_TRUE(Trinary::False == m.getChildren()[0]->is_strict()); @@ -522,7 +503,7 @@ Test::testOptimizeAndOr(bool invert) s = MultiBitVectorIteratorBase::optimize(std::move(s)); EXPECT_TRUE(s); EXPECT_TRUE(dynamic_cast<const T *>(s.get()) != nullptr); - const MultiSearch & m(dynamic_cast<const MultiSearch &>(*s)); + const auto & m(dynamic_cast<const MultiSearch &>(*s)); EXPECT_EQUAL(2u, m.getChildren().size()); EXPECT_TRUE(dynamic_cast<const MultiBitVectorIteratorBase *>(m.getChildren()[0].get()) != nullptr); EXPECT_TRUE(Trinary::False == m.getChildren()[0]->is_strict()); @@ -538,7 +519,7 @@ Test::testOptimizeAndOr(bool invert) s = MultiBitVectorIteratorBase::optimize(std::move(s)); EXPECT_TRUE(s); EXPECT_TRUE(dynamic_cast<const T *>(s.get()) != nullptr); - const MultiSearch & m(dynamic_cast<const MultiSearch &>(*s)); + const auto & m(dynamic_cast<const MultiSearch &>(*s)); EXPECT_EQUAL(2u, m.getChildren().size()); EXPECT_TRUE(dynamic_cast<const MultiBitVectorIteratorBase *>(m.getChildren()[0].get()) != nullptr); EXPECT_TRUE(Trinary::True == m.getChildren()[0]->is_strict()); @@ -554,7 +535,7 @@ Test::testOptimizeAndOr(bool invert) s = MultiBitVectorIteratorBase::optimize(std::move(s)); EXPECT_TRUE(s); EXPECT_TRUE(dynamic_cast<const T *>(s.get()) != nullptr); - const MultiSearch & m(dynamic_cast<const MultiSearch &>(*s)); + const auto & m(dynamic_cast<const MultiSearch &>(*s)); EXPECT_EQUAL(2u, m.getChildren().size()); EXPECT_TRUE(dynamic_cast<const MultiBitVectorIteratorBase *>(m.getChildren()[0].get()) != nullptr); EXPECT_TRUE(Trinary::True == m.getChildren()[0]->is_strict()); @@ -563,7 +544,7 @@ Test::testOptimizeAndOr(bool invert) } void -Test::testEndGuard(bool invert) +Fixture::testEndGuard(bool invert) { using T = AndSearch; TermFieldMatchData tfmd; @@ -576,16 +557,72 @@ Test::testEndGuard(bool invert) s->initFullRange(); EXPECT_TRUE(s); EXPECT_TRUE(dynamic_cast<const MultiBitVectorIteratorBase *>(s.get()) != nullptr); - MultiSearch & m(dynamic_cast<MultiSearch &>(*s)); + auto & m(dynamic_cast<MultiSearch &>(*s)); EXPECT_TRUE(m.seek(0) || !m.seek(0)); EXPECT_TRUE(m.seek(3) || !m.seek(3)); EXPECT_FALSE(m.seek(_bvs[0]->size()+987)); } +TEST_F("testEndGuard", Fixture) { + f.testEndGuard(false); + f.testEndGuard(true); +} + +TEST_F("testThatOptimizePreservesUnpack", Fixture) { + f.template testThatOptimizePreservesUnpack<OrSearch>(); + f.template testThatOptimizePreservesUnpack<AndSearch>(); +} + +SearchIterator::UP +createDual(Fixture & f, TermFieldMatchData & tfmd, int32_t docIdLimit) { + MultiSearch::Children children; + children.push_back(f.createIter(0, false, tfmd, true)); + children.push_back(f.createIter(1, false, tfmd, true)); + SearchIterator::UP s = AndSearch::create(std::move(children), true); + s = MultiBitVectorIteratorBase::optimize(std::move(s)); + EXPECT_TRUE(s); + if (docIdLimit < 0) { + s->initFullRange(); + } else { + s->initRange(1, docIdLimit); + } + return s; +} + +void +countUntilEnd(SearchIterator & s) { + uint32_t seekCount = 0; + for (uint32_t docId = s.seekFirst(1); !s.isAtEnd(); docId = s.seekNext(docId+1)) { + seekCount++; + } + EXPECT_EQUAL(2459u, seekCount); +} + +void +countUntilDocId(SearchIterator & s) { + uint32_t seekCount = 0; + for (uint32_t docId = s.seekFirst(1), endId = s.getEndId(); docId < endId; docId = s.seekNext(docId+1)) { + seekCount++; + } + EXPECT_EQUAL(2459u, seekCount); +} + +TEST_F("test that short vectors don't spin at end", Fixture) { + TermFieldMatchData tfmd; + countUntilEnd(*createDual(f, tfmd, f._bvs[0]->size())); + countUntilDocId(*createDual(f, tfmd, f._bvs[0]->size())); + + countUntilDocId(*createDual(f, tfmd, f._bvs[0]->size() + 1)); + countUntilEnd(*createDual(f, tfmd, f._bvs[0]->size() + 1)); + + countUntilDocId(*createDual(f, tfmd, -1)); + countUntilEnd(*createDual(f, tfmd, -1)); +} + class Verifier : public search::test::SearchIteratorVerifier { public: Verifier(size_t numBv, bool is_and); - ~Verifier(); + ~Verifier() override; SearchIterator::UP create(bool strict) const override; @@ -627,7 +664,7 @@ Verifier::create(bool strict) const { return mbvit; } -void Test::testIteratorConformance() { +TEST("testIteratorConformance") { for (bool is_and : {false, true}) { for (size_t i(1); i < 6; i++) { Verifier searchIteratorVerifier(i, is_and); @@ -636,32 +673,4 @@ void Test::testIteratorConformance() { } } -int -Test::Main() -{ - TEST_INIT("multibitvectoriterator_test"); - setup(); - testBug7163266(); - testThatOptimizePreservesUnpack<OrSearch>(); - testThatOptimizePreservesUnpack<AndSearch>(); - TEST_FLUSH(); - testUnpackOfOr(); - TEST_FLUSH(); - testEndGuard(false); - testEndGuard(true); - TEST_FLUSH(); - testAndNot(); - TEST_FLUSH(); - testAnd(); - TEST_FLUSH(); - testOr(); - TEST_FLUSH(); - testAndWith(false); - testAndWith(true); - TEST_FLUSH(); - testIteratorConformance(); - TEST_FLUSH(); - TEST_DONE(); -} - -TEST_APPHOOK(Test); +TEST_MAIN() { TEST_RUN_ALL(); } diff --git a/searchlib/src/tests/queryeval/nearest_neighbor/CMakeLists.txt b/searchlib/src/tests/queryeval/nearest_neighbor/CMakeLists.txt index e543a847498..b68f7f93c18 100644 --- a/searchlib/src/tests/queryeval/nearest_neighbor/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/nearest_neighbor/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_nearest_neighbor_test_app TEST SOURCES diff --git a/searchlib/src/tests/queryeval/nearest_neighbor/nearest_neighbor_test.cpp b/searchlib/src/tests/queryeval/nearest_neighbor/nearest_neighbor_test.cpp index f3545499231..e4a8be121f5 100644 --- a/searchlib/src/tests/queryeval/nearest_neighbor/nearest_neighbor_test.cpp +++ b/searchlib/src/tests/queryeval/nearest_neighbor/nearest_neighbor_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/eval/eval/simple_value.h> #include <vespa/eval/eval/tensor_spec.h> diff --git a/searchlib/src/tests/queryeval/parallel_weak_and/CMakeLists.txt b/searchlib/src/tests/queryeval/parallel_weak_and/CMakeLists.txt index 6a0c574591c..533e610b32a 100644 --- a/searchlib/src/tests/queryeval/parallel_weak_and/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/parallel_weak_and/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_parallel_weak_and_test_app TEST SOURCES parallel_weak_and_test.cpp diff --git a/searchlib/src/tests/queryeval/parallel_weak_and/parallel_weak_and_test.cpp b/searchlib/src/tests/queryeval/parallel_weak_and/parallel_weak_and_test.cpp index 3c08b263a7b..6d7d8b42dbb 100644 --- a/searchlib/src/tests/queryeval/parallel_weak_and/parallel_weak_and_test.cpp +++ b/searchlib/src/tests/queryeval/parallel_weak_and/parallel_weak_and_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/searchlib/query/tree/simplequery.h> #include <vespa/searchlib/queryeval/fake_searchable.h> diff --git a/searchlib/src/tests/queryeval/predicate/CMakeLists.txt b/searchlib/src/tests/queryeval/predicate/CMakeLists.txt index 342eb7443ef..17aac2a9391 100644 --- a/searchlib/src/tests/queryeval/predicate/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/predicate/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_predicate_blueprint_test_app TEST SOURCES predicate_blueprint_test.cpp diff --git a/searchlib/src/tests/queryeval/predicate/predicate_blueprint_test.cpp b/searchlib/src/tests/queryeval/predicate/predicate_blueprint_test.cpp index 56e745afa50..ed349480ff4 100644 --- a/searchlib/src/tests/queryeval/predicate/predicate_blueprint_test.cpp +++ b/searchlib/src/tests/queryeval/predicate/predicate_blueprint_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. // Unit tests for predicate_blueprint. #include <vespa/searchlib/attribute/predicate_attribute.h> diff --git a/searchlib/src/tests/queryeval/predicate/predicate_search_test.cpp b/searchlib/src/tests/queryeval/predicate/predicate_search_test.cpp index d15175ba5d1..a69b4c7a45d 100644 --- a/searchlib/src/tests/queryeval/predicate/predicate_search_test.cpp +++ b/searchlib/src/tests/queryeval/predicate/predicate_search_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. // Unit tests for predicate_search. #include <vespa/log/log.h> diff --git a/searchlib/src/tests/queryeval/profiled_iterator/CMakeLists.txt b/searchlib/src/tests/queryeval/profiled_iterator/CMakeLists.txt index b4c36e7e00c..77fd0a1898b 100644 --- a/searchlib/src/tests/queryeval/profiled_iterator/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/profiled_iterator/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_queryeval_profiled_iterator_test_app TEST SOURCES profiled_iterator_test.cpp diff --git a/searchlib/src/tests/queryeval/profiled_iterator/profiled_iterator_test.cpp b/searchlib/src/tests/queryeval/profiled_iterator/profiled_iterator_test.cpp index 010e72428e2..aa096552da3 100644 --- a/searchlib/src/tests/queryeval/profiled_iterator/profiled_iterator_test.cpp +++ b/searchlib/src/tests/queryeval/profiled_iterator/profiled_iterator_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// 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/vespalib/util/execution_profiler.h> diff --git a/searchlib/src/tests/queryeval/queryeval_test.cpp b/searchlib/src/tests/queryeval/queryeval_test.cpp index 698bf7c08d5..a403f7a7c23 100644 --- a/searchlib/src/tests/queryeval/queryeval_test.cpp +++ b/searchlib/src/tests/queryeval/queryeval_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/regex/regex.h> diff --git a/searchlib/src/tests/queryeval/same_element/CMakeLists.txt b/searchlib/src/tests/queryeval/same_element/CMakeLists.txt index 95cd82bbcbb..615a7fcac9f 100644 --- a/searchlib/src/tests/queryeval/same_element/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/same_element/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_same_element_test_app TEST SOURCES same_element_test.cpp diff --git a/searchlib/src/tests/queryeval/same_element/same_element_test.cpp b/searchlib/src/tests/queryeval/same_element/same_element_test.cpp index fba8d5d7899..7c5a4648925 100644 --- a/searchlib/src/tests/queryeval/same_element/same_element_test.cpp +++ b/searchlib/src/tests/queryeval/same_element/same_element_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/util/stringfmt.h> diff --git a/searchlib/src/tests/queryeval/simple_phrase/CMakeLists.txt b/searchlib/src/tests/queryeval/simple_phrase/CMakeLists.txt index 10b547d01bd..e01af073639 100644 --- a/searchlib/src/tests/queryeval/simple_phrase/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/simple_phrase/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_simple_phrase_test_app TEST SOURCES simple_phrase_test.cpp diff --git a/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp b/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp index 0e238a1b878..29d4dd2c457 100644 --- a/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp +++ b/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/searchlib/queryeval/fake_result.h> #include <vespa/searchlib/queryeval/fake_searchable.h> diff --git a/searchlib/src/tests/queryeval/sourceblender/CMakeLists.txt b/searchlib/src/tests/queryeval/sourceblender/CMakeLists.txt index 266e26c1651..fb574a4ed4b 100644 --- a/searchlib/src/tests/queryeval/sourceblender/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/sourceblender/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_sourceblender_test_app TEST SOURCES sourceblender_test.cpp diff --git a/searchlib/src/tests/queryeval/sourceblender/sourceblender_test.cpp b/searchlib/src/tests/queryeval/sourceblender/sourceblender_test.cpp index 15a277d51c6..77c9e1a8039 100644 --- a/searchlib/src/tests/queryeval/sourceblender/sourceblender_test.cpp +++ b/searchlib/src/tests/queryeval/sourceblender/sourceblender_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// 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/searchlib/queryeval/sourceblendersearch.h> diff --git a/searchlib/src/tests/queryeval/sparse_vector_benchmark/CMakeLists.txt b/searchlib/src/tests/queryeval/sparse_vector_benchmark/CMakeLists.txt index 17171d38551..8150cbfcc36 100644 --- a/searchlib/src/tests/queryeval/sparse_vector_benchmark/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/sparse_vector_benchmark/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_sparse_vector_benchmark_test_app SOURCES sparse_vector_benchmark_test.cpp diff --git a/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp b/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp index 07ff335092e..ae2c0cac76f 100644 --- a/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp +++ b/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/test_kit.h> #include "../weak_and/rise_wand.h" diff --git a/searchlib/src/tests/queryeval/termwise_eval/CMakeLists.txt b/searchlib/src/tests/queryeval/termwise_eval/CMakeLists.txt index 6e7e730743f..7e30265dc19 100644 --- a/searchlib/src/tests/queryeval/termwise_eval/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/termwise_eval/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_termwise_eval_test_app TEST SOURCES termwise_eval_test.cpp diff --git a/searchlib/src/tests/queryeval/termwise_eval/termwise_eval_test.cpp b/searchlib/src/tests/queryeval/termwise_eval/termwise_eval_test.cpp index 763701b00a3..3ca35221c50 100644 --- a/searchlib/src/tests/queryeval/termwise_eval/termwise_eval_test.cpp +++ b/searchlib/src/tests/queryeval/termwise_eval/termwise_eval_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/searchlib/queryeval/searchiterator.h> diff --git a/searchlib/src/tests/queryeval/weak_and/CMakeLists.txt b/searchlib/src/tests/queryeval/weak_and/CMakeLists.txt index 8fac61609f1..dfedbbdabb6 100644 --- a/searchlib/src/tests/queryeval/weak_and/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/weak_and/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_weak_and_test_app TEST SOURCES weak_and_test.cpp diff --git a/searchlib/src/tests/queryeval/weak_and/parallel_weak_and_bench.cpp b/searchlib/src/tests/queryeval/weak_and/parallel_weak_and_bench.cpp index f8306a1a7e6..8df65815894 100644 --- a/searchlib/src/tests/queryeval/weak_and/parallel_weak_and_bench.cpp +++ b/searchlib/src/tests/queryeval/weak_and/parallel_weak_and_bench.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "wand_bench_setup.hpp" TEST_FF("benchmark", VespaParallelWandFactory(1000), WandSetup(f1, 10, 10000000)) { f2.benchmark(); } diff --git a/searchlib/src/tests/queryeval/weak_and/rise_wand.h b/searchlib/src/tests/queryeval/weak_and/rise_wand.h index 250993bf139..d4e66ec1907 100644 --- a/searchlib/src/tests/queryeval/weak_and/rise_wand.h +++ b/searchlib/src/tests/queryeval/weak_and/rise_wand.h @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once diff --git a/searchlib/src/tests/queryeval/weak_and/rise_wand.hpp b/searchlib/src/tests/queryeval/weak_and/rise_wand.hpp index 2be88984e86..32e17014f98 100644 --- a/searchlib/src/tests/queryeval/weak_and/rise_wand.hpp +++ b/searchlib/src/tests/queryeval/weak_and/rise_wand.hpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once diff --git a/searchlib/src/tests/queryeval/weak_and/wand_bench_setup.hpp b/searchlib/src/tests/queryeval/weak_and/wand_bench_setup.hpp index 0cd31cd491a..5e056eb6c0e 100644 --- a/searchlib/src/tests/queryeval/weak_and/wand_bench_setup.hpp +++ b/searchlib/src/tests/queryeval/weak_and/wand_bench_setup.hpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/searchlib/queryeval/andsearch.h> #include <vespa/searchlib/queryeval/andnotsearch.h> diff --git a/searchlib/src/tests/queryeval/weak_and/weak_and_bench.cpp b/searchlib/src/tests/queryeval/weak_and/weak_and_bench.cpp index 8d884883786..e536e3a098a 100644 --- a/searchlib/src/tests/queryeval/weak_and/weak_and_bench.cpp +++ b/searchlib/src/tests/queryeval/weak_and/weak_and_bench.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "wand_bench_setup.hpp" TEST_FF("benchmark", VespaWandFactory(1000), WandSetup(f1, 10, 10000000)) { f2.benchmark(); } diff --git a/searchlib/src/tests/queryeval/weak_and/weak_and_test.cpp b/searchlib/src/tests/queryeval/weak_and/weak_and_test.cpp index e1593f7ad1d..1054980e4ec 100644 --- a/searchlib/src/tests/queryeval/weak_and/weak_and_test.cpp +++ b/searchlib/src/tests/queryeval/weak_and/weak_and_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/searchlib/queryeval/fake_search.h> #include <vespa/searchlib/queryeval/wand/weak_and_search.h> diff --git a/searchlib/src/tests/queryeval/weak_and/weak_and_test_expensive.cpp b/searchlib/src/tests/queryeval/weak_and/weak_and_test_expensive.cpp index b778a3ac7e3..54bf1e92037 100644 --- a/searchlib/src/tests/queryeval/weak_and/weak_and_test_expensive.cpp +++ b/searchlib/src/tests/queryeval/weak_and/weak_and_test_expensive.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "wand_bench_setup.hpp" using namespace rise; diff --git a/searchlib/src/tests/queryeval/weak_and_heap/CMakeLists.txt b/searchlib/src/tests/queryeval/weak_and_heap/CMakeLists.txt index ab5b65a74b4..1dc51921788 100644 --- a/searchlib/src/tests/queryeval/weak_and_heap/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/weak_and_heap/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_weak_and_heap_test_app TEST SOURCES weak_and_heap_test.cpp diff --git a/searchlib/src/tests/queryeval/weak_and_heap/weak_and_heap_test.cpp b/searchlib/src/tests/queryeval/weak_and_heap/weak_and_heap_test.cpp index 1304168b179..08b21e0b96b 100644 --- a/searchlib/src/tests/queryeval/weak_and_heap/weak_and_heap_test.cpp +++ b/searchlib/src/tests/queryeval/weak_and_heap/weak_and_heap_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/searchlib/queryeval/wand/weak_and_heap.h> diff --git a/searchlib/src/tests/queryeval/weak_and_scorers/CMakeLists.txt b/searchlib/src/tests/queryeval/weak_and_scorers/CMakeLists.txt index 4fcce5b145e..0a21b2c0148 100644 --- a/searchlib/src/tests/queryeval/weak_and_scorers/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/weak_and_scorers/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_weak_and_scorers_test_app TEST SOURCES weak_and_scorers_test.cpp diff --git a/searchlib/src/tests/queryeval/weak_and_scorers/weak_and_scorers_test.cpp b/searchlib/src/tests/queryeval/weak_and_scorers/weak_and_scorers_test.cpp index c5c0ea9a528..528e117f976 100644 --- a/searchlib/src/tests/queryeval/weak_and_scorers/weak_and_scorers_test.cpp +++ b/searchlib/src/tests/queryeval/weak_and_scorers/weak_and_scorers_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/searchlib/fef/termfieldmatchdata.h> #include <vespa/searchlib/queryeval/searchiterator.h> diff --git a/searchlib/src/tests/queryeval/weighted_set_term/CMakeLists.txt b/searchlib/src/tests/queryeval/weighted_set_term/CMakeLists.txt index 9b9f0e588cc..6f7d18df9c4 100644 --- a/searchlib/src/tests/queryeval/weighted_set_term/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/weighted_set_term/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_weighted_set_term_test_app TEST SOURCES weighted_set_term_test.cpp diff --git a/searchlib/src/tests/queryeval/weighted_set_term/weighted_set_term_test.cpp b/searchlib/src/tests/queryeval/weighted_set_term/weighted_set_term_test.cpp index de5fc1a0c05..2f3f0eb7392 100644 --- a/searchlib/src/tests/queryeval/weighted_set_term/weighted_set_term_test.cpp +++ b/searchlib/src/tests/queryeval/weighted_set_term/weighted_set_term_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// 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/searchlib/queryeval/weighted_set_term_search.h> @@ -147,23 +147,31 @@ struct MockFixture { } // namespace <unnamed> -void run_simple(bool field_is_filter, bool term_is_not_needed) +void run_simple(bool field_is_filter, bool term_is_not_needed, bool singleTerm) { FakeSearchable index; setupFakeSearchable(index); FakeResult expect; if (field_is_filter || term_is_not_needed) { - expect.doc(3) - .doc(5) - .doc(7); + expect.doc(3); + if ( ! singleTerm) { + expect.doc(5) + .doc(7); + } } else { - expect.doc(3).elem(0).weight(30).pos(0) - .doc(5).elem(0).weight(50).pos(0) - .doc(7).elem(0).weight(70).pos(0); + expect.doc(3).elem(0).weight(30).pos(0); + if (!singleTerm) { + expect.doc(5).elem(0).weight(50).pos(0) + .doc(7).elem(0).weight(70).pos(0); + } } WS ws; - ws.add("7", 70).add("5", 50).add("3", 30).add("100", 1000) - .set_field_is_filter(field_is_filter) + if (singleTerm) { + ws.add("3", 30); + } else { + ws.add("7", 70).add("5", 50).add("3", 30).add("100", 1000); + } + ws.set_field_is_filter(field_is_filter) .set_term_is_not_needed(term_is_not_needed); EXPECT_TRUE(ws.isGenericSearch(index, "field", true)); @@ -178,15 +186,35 @@ void run_simple(bool field_is_filter, bool term_is_not_needed) } TEST("testSimple") { - TEST_DO(run_simple(false, false)); + TEST_DO(run_simple(false, false, false)); } TEST("testSimple filter field") { - TEST_DO(run_simple(true, false)); + TEST_DO(run_simple(true, false, false)); } TEST("testSimple unranked") { - TEST_DO(run_simple(false, true)); + TEST_DO(run_simple(false, true, false)); +} + +TEST("testSimple unranked filter filed") { + TEST_DO(run_simple(true, true, false)); +} + +TEST("testSimple single") { + TEST_DO(run_simple(false, false, true)); +} + +TEST("testSimple single filter field") { + TEST_DO(run_simple(true, false, true)); +} + +TEST("testSimple single unranked") { + TEST_DO(run_simple(false, true, true)); +} + +TEST("testSimple single unranked filter field") { + TEST_DO(run_simple(true, true, true)); } void run_multi(bool field_is_filter, bool term_is_not_needed) diff --git a/searchlib/src/tests/queryeval/wrappers/CMakeLists.txt b/searchlib/src/tests/queryeval/wrappers/CMakeLists.txt index cfc385c1998..58c50098371 100644 --- a/searchlib/src/tests/queryeval/wrappers/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/wrappers/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_executable(searchlib_wrappers_test_app TEST SOURCES diff --git a/searchlib/src/tests/queryeval/wrappers/wrappers_test.cpp b/searchlib/src/tests/queryeval/wrappers/wrappers_test.cpp index aaa9cb50f41..15b8773421a 100644 --- a/searchlib/src/tests/queryeval/wrappers/wrappers_test.cpp +++ b/searchlib/src/tests/queryeval/wrappers/wrappers_test.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/searchlib/queryeval/filter_wrapper.h> #include <vespa/searchlib/queryeval/booleanmatchiteratorwrapper.h> |