aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/attribute/extendable_string_array_multi_value_read_view.h
blob: d83398b5568d78d6fcf74546c52e5314fb00bf19 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/searchcommon/attribute/i_multi_value_read_view.h>
#include <vespa/vespalib/stllike/allocator.h>

namespace search::attribute {

/**
 * Read view for the data stored in an extendable multi-value string
 * array attribute vector (used by streaming visitor) that handles
 * optional addition of weight.
 * @tparam MultiValueType The multi-value type of the data to access.
 */
template <typename MultiValueType>
class ExtendableStringArrayMultiValueReadView : public attribute::IMultiValueReadView<MultiValueType>
{
    using Offsets = std::vector<uint32_t, vespalib::allocator_large<uint32_t>>;
    const std::vector<char>&            _buffer;
    const Offsets                     & _offsets;
    const std::vector<uint32_t>&        _idx;
    mutable std::vector<MultiValueType> _copy;
public:
    ExtendableStringArrayMultiValueReadView(const std::vector<char>& buffer, const Offsets & offsets, const std::vector<uint32_t>& idx);
    ~ExtendableStringArrayMultiValueReadView() override;
    vespalib::ConstArrayRef<MultiValueType> get_values(uint32_t doc_id) const override;
};

}