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