diff options
author | Tor Egge <Tor.Egge@online.no> | 2024-03-14 18:15:12 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2024-03-14 18:15:12 +0100 |
commit | c3026e157c35c8f488766bf43d8633f48cafd9fa (patch) | |
tree | 3082a66a57ad664e496e81bd0ac3340486fb421e /searchlib | |
parent | 1502728a967ab7b70c78f2ef54f5f14d16428697 (diff) |
Move normalize_class_name to vespalib.
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/tests/attribute/searchable/attribute_weighted_set_blueprint_test.cpp | 25 | ||||
-rw-r--r-- | searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp | 12 |
2 files changed, 9 insertions, 28 deletions
diff --git a/searchlib/src/tests/attribute/searchable/attribute_weighted_set_blueprint_test.cpp b/searchlib/src/tests/attribute/searchable/attribute_weighted_set_blueprint_test.cpp index 16597b8b615..a8630ea569e 100644 --- a/searchlib/src/tests/attribute/searchable/attribute_weighted_set_blueprint_test.cpp +++ b/searchlib/src/tests/attribute/searchable/attribute_weighted_set_blueprint_test.cpp @@ -15,6 +15,7 @@ #include <vespa/searchlib/test/mock_attribute_manager.h> #include <vespa/searchlib/attribute/enumstore.hpp> #include <vespa/searchcommon/attribute/config.h> +#include <vespa/vespalib/util/normalize_class_name.h> #include <vespa/log/log.h> LOG_SETUP("attribute_weighted_set_blueprint_test"); @@ -25,6 +26,7 @@ using namespace search::fef; using namespace search::queryeval; using namespace search::attribute; using namespace search::attribute::test; +using vespalib::normalize_class_name; namespace { @@ -182,29 +184,6 @@ TEST("attribute_weighted_set_test") { test_tokens(false, {3}); } -namespace { - -void -normalize_class_name_helper(vespalib::string& class_name, const vespalib::string& old, const vespalib::string& replacement) -{ - for (;;) { - auto pos = class_name.find(old); - if (pos == vespalib::string::npos) { - break; - } - class_name.replace(pos, old.size(), replacement); - } -} - -vespalib::string normalize_class_name(vespalib::string class_name) -{ - normalize_class_name_helper(class_name, "long long", "long"); - normalize_class_name_helper(class_name, ">>", "> >"); - return class_name; -} - -} - TEST("attribute_weighted_set_single_token_filter_lifted_out") { MockAttributeManager manager; setupAttributeManager(manager, true); diff --git a/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp b/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp index d2df4a8c24f..6b3c068cd4d 100644 --- a/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp +++ b/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp @@ -20,6 +20,7 @@ #include <vespa/vespalib/data/simple_buffer.h> #include <vespa/vespalib/data/slime/slime.h> #include <vespa/vespalib/data/slime/inserter.h> +#include <vespa/vespalib/util/normalize_class_name.h> #include <filesystem> #include <vespa/log/log.h> @@ -34,6 +35,7 @@ using vespalib::Slime; using vespalib::slime::Inspector; using vespalib::slime::SlimeInserter; using vespalib::make_string_short::fmt; +using vespalib::normalize_class_name; using Path = std::vector<std::variant<size_t,vespalib::stringref>>; vespalib::string strict_equiv_name = "search::queryeval::EquivImpl<true, search::queryeval::StrictHeapOrSearch<search::queryeval::NoUnpack, vespalib::LeftArrayHeap, unsigned char> >"; @@ -1143,7 +1145,7 @@ TEST("require that children does not optimize when parents refuse them to") { MatchData::UP md = MatchData::makeTestInstance(100, 10); top_up->fetchPostings(ExecuteInfo::FALSE); SearchIterator::UP search = top_up->createSearch(*md, true); - EXPECT_EQUAL(strict_equiv_name, search->getClassName()); + EXPECT_EQUAL(strict_equiv_name, normalize_class_name(search->getClassName())); { const auto & e = dynamic_cast<const MultiSearch &>(*search); EXPECT_EQUAL("search::BitVectorIteratorStrictT<false>", e.getChildren()[0]->getClassName()); @@ -1153,7 +1155,7 @@ TEST("require that children does not optimize when parents refuse them to") { md->resolveTermField(12)->tagAsNotNeeded(); search = top_up->createSearch(*md, true); - EXPECT_EQUAL(strict_equiv_name, search->getClassName()); + EXPECT_EQUAL(strict_equiv_name, normalize_class_name(search->getClassName())); { const auto & e = dynamic_cast<const MultiSearch &>(*search); EXPECT_EQUAL("search::BitVectorIteratorStrictT<false>", e.getChildren()[0]->getClassName()); @@ -1181,7 +1183,7 @@ TEST("require_that_unpack_optimization_is_not_overruled_by_equiv") { MatchData::UP md = MatchData::makeTestInstance(100, 10); top_up->fetchPostings(ExecuteInfo::FALSE); SearchIterator::UP search = top_up->createSearch(*md, true); - EXPECT_EQUAL(strict_equiv_name, search->getClassName()); + EXPECT_EQUAL(strict_equiv_name, normalize_class_name(search->getClassName())); { const auto & e = dynamic_cast<const MultiSearch &>(*search); EXPECT_EQUAL("search::queryeval::StrictHeapOrSearch<search::queryeval::(anonymous namespace)::FullUnpack, vespalib::LeftArrayHeap, unsigned char>", @@ -1190,7 +1192,7 @@ TEST("require_that_unpack_optimization_is_not_overruled_by_equiv") { md->resolveTermField(2)->tagAsNotNeeded(); search = top_up->createSearch(*md, true); - EXPECT_EQUAL(strict_equiv_name, search->getClassName()); + EXPECT_EQUAL(strict_equiv_name, normalize_class_name(search->getClassName())); { const auto & e = dynamic_cast<const MultiSearch &>(*search); EXPECT_EQUAL("search::queryeval::StrictHeapOrSearch<search::queryeval::(anonymous namespace)::SelectiveUnpack, vespalib::LeftArrayHeap, unsigned char>", @@ -1200,7 +1202,7 @@ TEST("require_that_unpack_optimization_is_not_overruled_by_equiv") { md->resolveTermField(1)->tagAsNotNeeded(); md->resolveTermField(3)->tagAsNotNeeded(); search = top_up->createSearch(*md, true); - EXPECT_EQUAL(strict_equiv_name, search->getClassName()); + EXPECT_EQUAL(strict_equiv_name, normalize_class_name(search->getClassName())); { const auto & e = dynamic_cast<const MultiSearch &>(*search); EXPECT_EQUAL("search::queryeval::StrictHeapOrSearch<search::queryeval::NoUnpack, vespalib::LeftArrayHeap, unsigned char>", |