diff options
Diffstat (limited to 'searchcore')
5 files changed, 15 insertions, 26 deletions
diff --git a/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp b/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp index 6a5932d2b3a..0bbbdabd0aa 100644 --- a/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp @@ -35,6 +35,7 @@ LOG_SETUP("attribute_manager_test"); #include <vespa/searchlib/predicate/predicate_index.h> #include <vespa/searchlib/predicate/predicate_tree_annotator.h> #include <vespa/searchlib/test/directory_handler.h> +#include <vespa/searchlib/test/mock_gid_to_lid_mapping.h> #include <vespa/searchlib/util/filekit.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/threadstackexecutor.h> @@ -58,6 +59,7 @@ using search::attribute::IAttributeContext; using search::attribute::IAttributeVector; using search::attribute::ImportedAttributeVector; using search::attribute::ReferenceAttribute; +using search::attribute::test::MockGidToLidMapperFactory; using search::index::DummyFileHeaderContext; using search::predicate::PredicateIndex; using search::predicate::PredicateTreeAnnotations; @@ -132,6 +134,7 @@ struct ImportedAttributesRepoBuilder { ImportedAttributesRepoBuilder() : _repo(std::make_unique<ImportedAttributesRepo>()) {} void add(const vespalib::string &name) { auto refAttr = std::make_shared<ReferenceAttribute>(name + "_ref", AVConfig(BasicType::REFERENCE)); + refAttr->setGidToLidMapperFactory(std::make_shared<MockGidToLidMapperFactory>()); auto targetAttr = search::AttributeFactory::createAttribute(name + "_target", INT32_SINGLE); auto documentMetaStore = std::shared_ptr<search::IDocumentMetaStoreContext>(); auto importedAttr = std::make_shared<ImportedAttributeVector>(name, refAttr, targetAttr, documentMetaStore, false); diff --git a/searchcore/src/tests/proton/attribute/imported_attributes_context/imported_attributes_context_test.cpp b/searchcore/src/tests/proton/attribute/imported_attributes_context/imported_attributes_context_test.cpp index f221b2140c1..aac74e1583d 100644 --- a/searchcore/src/tests/proton/attribute/imported_attributes_context/imported_attributes_context_test.cpp +++ b/searchcore/src/tests/proton/attribute/imported_attributes_context/imported_attributes_context_test.cpp @@ -8,6 +8,7 @@ LOG_SETUP("imported_attributes_context_test"); #include <vespa/searchlib/attribute/attribute.h> #include <vespa/searchlib/attribute/attributefactory.h> #include <vespa/searchlib/attribute/imported_attribute_vector.h> +#include <vespa/searchlib/test/mock_gid_to_lid_mapping.h> #include <future> using namespace proton; @@ -17,12 +18,15 @@ using search::attribute::Config; using search::attribute::IAttributeVector; using search::attribute::ImportedAttributeVector; using search::attribute::ReferenceAttribute; +using search::attribute::test::MockGidToLidMapperFactory; using generation_t = AttributeVector::generation_t; ReferenceAttribute::SP createReferenceAttribute(const vespalib::string &name) { - return std::make_shared<ReferenceAttribute>(name, Config(BasicType::REFERENCE)); + auto refAttr = std::make_shared<ReferenceAttribute>(name, Config(BasicType::REFERENCE)); + refAttr->setGidToLidMapperFactory(std::make_shared<MockGidToLidMapperFactory>()); + return refAttr; } AttributeVector::SP diff --git a/searchcore/src/tests/proton/reference/gid_to_lid_mapper/gid_to_lid_mapper_test.cpp b/searchcore/src/tests/proton/reference/gid_to_lid_mapper/gid_to_lid_mapper_test.cpp index 5445ba9c585..cec51e18e3c 100644 --- a/searchcore/src/tests/proton/reference/gid_to_lid_mapper/gid_to_lid_mapper_test.cpp +++ b/searchcore/src/tests/proton/reference/gid_to_lid_mapper/gid_to_lid_mapper_test.cpp @@ -37,10 +37,6 @@ BucketId toBucketId(const GlobalId &gid) { return bucketId; } -void assertLid(const std::unique_ptr<search::IGidToLidMapper> &mapper, const vespalib::string &docId, uint32_t lid) { - EXPECT_EQUAL(lid, mapper->mapGidToLid(toGid(docId))); -} - using GidMap = std::map<GlobalId, uint32_t>; struct GidCollector : public search::IGidToLidMapperVisitor @@ -66,6 +62,13 @@ void assertGids(const GidMap &expGids, const GidMap &gids) EXPECT_EQUAL(expGids, gids); } +void assertLid(const std::unique_ptr<search::IGidToLidMapper> &mapper, const vespalib::string &docId, uint32_t lid) { + auto gids = collectGids(mapper); + auto itr = gids.find(toGid(docId)); + uint32_t foundLid = (itr != gids.end()) ? itr->second : 0u; + EXPECT_EQUAL(lid, foundLid); +} + } struct Fixture @@ -139,15 +142,6 @@ struct Fixture } }; -TEST_F("Test that we can use gid mapper to get lids", Fixture) -{ - auto factory = f.getGidToLidMapperFactory(); - auto mapper = factory->getMapper(); - TEST_DO(assertLid(mapper, doc1, 4)); - TEST_DO(assertLid(mapper, doc2, 7)); - TEST_DO(assertLid(mapper, doc3, 0)); -} - TEST_F("Test that mapper holds read guard", Fixture) { TEST_DO(f.assertGenerations(3, 3)); diff --git a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_mapper.cpp b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_mapper.cpp index db990dff3bc..20bc1d1a49d 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_mapper.cpp +++ b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_mapper.cpp @@ -16,17 +16,6 @@ GidToLidMapper::~GidToLidMapper() { } -uint32_t -GidToLidMapper::mapGidToLid(const document::GlobalId &gid) const -{ - uint32_t lid = 0; - if (_dms.getLid(gid, lid)) { - return lid; - } else { - return 0u; - } -} - void GidToLidMapper::foreach(const search::IGidToLidMapperVisitor &visitor) const { diff --git a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_mapper.h b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_mapper.h index ed6bf91dbd3..47bcf4257f8 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_mapper.h +++ b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_mapper.h @@ -21,7 +21,6 @@ public: GidToLidMapper(vespalib::GenerationHandler::Guard &&guard, const DocumentMetaStore &dms); virtual ~GidToLidMapper(); - virtual uint32_t mapGidToLid(const document::GlobalId &gid) const override; virtual void foreach(const search::IGidToLidMapperVisitor &visitor) const override; }; |