// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "imported_attribute_vector.h" #include "imported_attribute_vector_read_guard.h" #include "imported_search_context.h" #include namespace search::attribute { ImportedAttributeVector::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) : _name(name), _reference_attribute(std::move(reference_attribute)), _document_meta_store(std::move(document_meta_store)), _target_attribute(std::move(target_attribute)), _target_document_meta_store(std::move(target_document_meta_store)), _search_cache(use_search_cache ? std::make_shared() : std::shared_ptr()) { } ImportedAttributeVector::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) : _name(name), _reference_attribute(std::move(reference_attribute)), _document_meta_store(std::move(document_meta_store)), _target_attribute(std::move(target_attribute)), _target_document_meta_store(std::move(target_document_meta_store)), _search_cache(std::move(search_cache)) { } ImportedAttributeVector::~ImportedAttributeVector() = default; std::unique_ptr ImportedAttributeVector::makeReadGuard(bool stableEnumGuard) const { return makeReadGuard(_target_document_meta_store->getReadGuard(), stableEnumGuard); } std::unique_ptr ImportedAttributeVector::makeReadGuard(std::shared_ptr targetMetaStoreReadGuard, bool stableEnumGuard) const { return std::make_unique(std::move(targetMetaStoreReadGuard), *this, stableEnumGuard); } void ImportedAttributeVector::clearSearchCache() { if (_search_cache) { _search_cache->clear(); } } vespalib::MemoryUsage ImportedAttributeVector::get_memory_usage() const { constexpr auto self_memory_usage = sizeof(ImportedAttributeVector); vespalib::MemoryUsage result(self_memory_usage, self_memory_usage, 0, 0); if (_search_cache) { result.merge(_search_cache->get_memory_usage()); } return result; } }