aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/features/mutable_dense_value_view.h
blob: 4794de23b4a40b9624a77779c836cbd16f6b611b (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
31
32
33
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/eval/eval/value.h>
#include <cassert>

namespace search::features::mutable_value {

using namespace vespalib::eval;

/**
 * A dense tensor with a cells reference that can be modified.
 */
class MutableDenseValueView : public Value {
private:
    const ValueType _type;
    TypedCells _cells;
public:
    MutableDenseValueView(const ValueType &type_in);
    void setCells(TypedCells cells_in) {
        assert(cells_in.type == _type.cell_type());
        _cells = cells_in;
    }
    const ValueType &type() const final override { return _type; }
    TypedCells cells() const final override { return _cells; }
    const Index &index() const final override { return TrivialIndex::get(); }
    vespalib::MemoryUsage get_memory_usage() const final override {
        return self_memory_usage<MutableDenseValueView>();
    }
};

}