summaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/tensor/direct_tensor_attribute.h
blob: ed48ea20e0f777ea49b5cebe858549c824bb91d0 (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
// 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;
    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; }

    // Implements DocVectorAccess
    vespalib::eval::TypedCells get_vector(uint32_t docid, uint32_t subspace) const override;
    VectorBundle get_vectors(uint32_t docid) const override;
};

}  // namespace search::tensor