summaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/tensor/direct_tensor_attribute.h
blob: 6466c6f753755ac152b55cf5b4c2b0eb24c3097e (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "tensor_attribute.h"
#include "direct_tensor_store.h"

namespace vespalib::eval { struct Value; }

namespace search::tensor {

class DirectTensorAttribute final : public TensorAttribute
{
    DirectTensorStore _direct_store;

public:
    DirectTensorAttribute(vespalib::stringref baseFileName, const Config &cfg);
    ~DirectTensorAttribute() override;
    void setTensor(DocId docId, const vespalib::eval::Value &tensor) override;
    void update_tensor(DocId docId,
                       const document::TensorUpdate &update,
                       bool create_empty_if_non_existing) override;
    std::unique_ptr<vespalib::eval::Value> getTensor(DocId docId) const override;
    void set_tensor(DocId docId, std::unique_ptr<vespalib::eval::Value> tensor);
    const vespalib::eval::Value &get_tensor_ref(DocId docId) const override;
    bool supports_get_tensor_ref() const override { return true; }
};

}  // namespace search::tensor