blob: 52ccb4c91b1d5fdbd8d8db58c9ebad5b8503e7a5 (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "serialized_fast_value_attribute.h"
#include <vespa/eval/eval/value.h>
#include <vespa/searchcommon/attribute/config.h>
#include <vespa/log/log.h>
LOG_SETUP(".searchlib.tensor.serialized_fast_value_attribute");
using namespace vespalib;
using namespace vespalib::eval;
namespace search::tensor {
SerializedFastValueAttribute::SerializedFastValueAttribute(stringref name, const Config &cfg)
: TensorAttribute(name, cfg, _tensorBufferStore),
_tensor_type(cfg.tensorType()),
_tensorBufferStore(_tensor_type, get_memory_allocator(), 1000u)
{
}
SerializedFastValueAttribute::~SerializedFastValueAttribute()
{
getGenerationHolder().clearHoldLists();
_tensorStore.clearHoldLists();
}
void
SerializedFastValueAttribute::setTensor(DocId docId, const vespalib::eval::Value &tensor)
{
checkTensorType(tensor);
EntryRef ref = _tensorBufferStore.store_tensor(tensor);
assert(ref.valid());
setTensorRef(docId, ref);
}
std::unique_ptr<Value>
SerializedFastValueAttribute::getTensor(DocId docId) const
{
EntryRef ref;
if (docId < getCommittedDocIdLimit()) {
ref = acquire_entry_ref(docId);
}
return _tensorBufferStore.get_tensor(ref);
}
}
|