// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include #include #include #include #include namespace search::attribute { /** * Class for mapping from document id to an array of values as reader. */ template > class MultiValueMappingReadView { using AtomicEntryRef = vespalib::datastore::AtomicEntryRef; using Indices = vespalib::ConstArrayRef; using ArrayStoreTypeMapper = vespalib::datastore::ArrayStoreDynamicTypeMapper; using ArrayStore = vespalib::datastore::ArrayStore; Indices _indices; const ArrayStore* _store; public: constexpr MultiValueMappingReadView() : _indices(), _store(nullptr) { } MultiValueMappingReadView(Indices indices, const ArrayStore* store) : _indices(indices), _store(store) { } vespalib::ConstArrayRef get(uint32_t doc_id) const { return _store->get(_indices[doc_id].load_acquire()); } bool valid() const noexcept { return _store != nullptr; } uint32_t get_committed_docid_limit() const noexcept { return _indices.size(); } }; }