blob: 75927112b89b135dafb095256acf3f22baeaebc8 (
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
50
51
52
53
54
55
56
57
58
59
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "serialized_fast_value_attribute.h"
#include "serialized_tensor_ref.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, const NearestNeighborIndexFactory& index_factory)
: TensorAttribute(name, cfg, _tensorBufferStore, index_factory),
_tensorBufferStore(cfg.tensorType(), get_memory_allocator(),
TensorBufferStore::array_store_max_type_id)
{
}
SerializedFastValueAttribute::~SerializedFastValueAttribute()
{
getGenerationHolder().reclaim_all();
_tensorStore.reclaim_all_memory();
}
SerializedTensorRef
SerializedFastValueAttribute::get_serialized_tensor_ref(uint32_t docid) const
{
EntryRef ref = acquire_entry_ref(docid);
return _tensorBufferStore.get_serialized_tensor_ref(ref);
}
bool
SerializedFastValueAttribute::supports_get_serialized_tensor_ref() const
{
return true;
}
vespalib::eval::TypedCells
SerializedFastValueAttribute::get_vector(uint32_t docid, uint32_t subspace) const
{
EntryRef ref = acquire_entry_ref(docid);
auto vectors = _tensorBufferStore.get_vectors(ref);
return (subspace < vectors.subspaces()) ? vectors.cells(subspace) : _tensorBufferStore.get_empty_subspace();
}
VectorBundle
SerializedFastValueAttribute::get_vectors(uint32_t docid) const
{
EntryRef ref = acquire_entry_ref(docid);
return _tensorBufferStore.get_vectors(ref);
}
}
|