// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include "readable_attribute_vector.h" #include #include namespace vespalib { class MemoryUsage; } namespace search::attribute { class BitVectorSearchCache; class ReadableAttributeVector; class ReferenceAttribute; /** * Attribute vector which does not store values of its own, but rather serves as a * convenient indirection wrapper towards a target vector, usually in another * document type altogether. Imported attributes are meant to be used in conjunction * with a reference attribute, which specifies a dynamic mapping from a local LID to * a target LID (via an intermediate GID). * * Any accessor on the imported attribute for a local LID yields the same result as * if the same accessor were invoked with the target LID on the target attribute vector. */ class ImportedAttributeVector : public ReadableAttributeVector { public: using SP = std::shared_ptr; using MetaStoreReadGuard = search::IDocumentMetaStoreContext::IReadGuard; ImportedAttributeVector(vespalib::stringref name, std::shared_ptr reference_attribute, std::shared_ptr document_meta_store, std::shared_ptr target_attribute, std::shared_ptr target_document_meta_store, bool use_search_cache); ImportedAttributeVector(vespalib::stringref name, std::shared_ptr reference_attribute, std::shared_ptr document_meta_store, std::shared_ptr target_attribute, std::shared_ptr target_document_meta_store, std::shared_ptr search_cache); ~ImportedAttributeVector() override; const std::shared_ptr& getReferenceAttribute() const noexcept { return _reference_attribute; } const std::shared_ptr &getDocumentMetaStore() const { return _document_meta_store; } const std::shared_ptr& getTargetAttribute() const noexcept { return _target_attribute; } const std::shared_ptr &getTargetDocumentMetaStore() const { return _target_document_meta_store; } const std::shared_ptr &getSearchCache() const { return _search_cache; } void clearSearchCache(); const vespalib::string &getName() const { return _name; } std::unique_ptr makeReadGuard(bool stableEnumGuard) const override; virtual std::unique_ptr makeReadGuard(std::shared_ptr targetMetaStoreReadGuard, bool stableEnumGuard) const; vespalib::MemoryUsage get_memory_usage() const; protected: vespalib::string _name; std::shared_ptr _reference_attribute; std::shared_ptr _document_meta_store; std::shared_ptr _target_attribute; std::shared_ptr _target_document_meta_store; std::shared_ptr _search_cache; }; }