// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include #include namespace search::attribute { /** * Multi value read view adapter for imported atributes vectors. * Performs lid mapping. * @tparam MultiValueType The multi-value type of the data to access. */ template class ImportedMultiValueReadView : public IMultiValueReadView { using AtomicTargetLid = vespalib::datastore::AtomicValueWrapper; using TargetLids = vespalib::ConstArrayRef; TargetLids _target_lids; const IMultiValueReadView* _target_read_view; uint32_t get_target_lid(uint32_t lid) const { // Check range to avoid reading memory beyond end of mapping array return lid < _target_lids.size() ? _target_lids[lid].load_acquire() : 0u; } public: ImportedMultiValueReadView(TargetLids target_lids, const IMultiValueReadView* target_read_view); ~ImportedMultiValueReadView() override; vespalib::ConstArrayRef get_values(uint32_t docid) const override; }; }