// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "extendable_string_array_multi_value_read_view.h" namespace search::attribute { template ExtendableStringArrayMultiValueReadView::ExtendableStringArrayMultiValueReadView(const std::vector& buffer, const Offsets & offsets, const std::vector& idx) : attribute::IMultiValueReadView(), _buffer(buffer), _offsets(offsets), _idx(idx), _copy() { } template ExtendableStringArrayMultiValueReadView::~ExtendableStringArrayMultiValueReadView() = default; template vespalib::ConstArrayRef ExtendableStringArrayMultiValueReadView::get_values(uint32_t doc_id) const { auto offset = _idx[doc_id]; auto next_offset = _idx[doc_id + 1]; vespalib::ConstArrayRef raw(&_offsets[offset], next_offset - offset); if (_copy.size() < raw.size()) { _copy.resize(raw.size()); } auto dst = _copy.data(); for (auto &src : raw) { *dst = multivalue::ValueBuilder::build(_buffer.data() + src, 1); ++dst; } return vespalib::ConstArrayRef(_copy.data(), raw.size()); } template class ExtendableStringArrayMultiValueReadView; template class ExtendableStringArrayMultiValueReadView>; }