blob: 9ccb6c9ef26a22a1c980bafc10e34bbb65d485a9 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "single_raw_attribute_loader.h"
#include "attributevector.h"
#include "blob_sequence_reader.h"
#include "raw_buffer_store.h"
#include "raw_buffer_store_reader.h"
using vespalib::datastore::EntryRef;
namespace search::attribute {
SingleRawAttributeLoader::SingleRawAttributeLoader(AttributeVector& attr, RefVector& ref_vector, RawBufferStore& raw_store)
: _attr(attr),
_ref_vector(ref_vector),
_raw_store(raw_store)
{
}
SingleRawAttributeLoader::~SingleRawAttributeLoader() = default;
void
SingleRawAttributeLoader::load_raw_store(BlobSequenceReader& reader, uint32_t docid_limit)
{
RawBufferStoreReader raw_reader(_raw_store, reader);
_raw_store.set_initializing(true);
for (uint32_t lid = 0; lid < docid_limit; ++lid) {
_ref_vector.push_back(AtomicEntryRef(raw_reader.read()));
}
_raw_store.set_initializing(false);
}
bool
SingleRawAttributeLoader::on_load(vespalib::Executor*)
{
BlobSequenceReader reader(_attr);
if (!reader.hasData()) {
return false;
}
_attr.setCreateSerialNum(reader.getCreateSerialNum());
uint32_t docid_limit(reader.getDocIdLimit());
_ref_vector.reset();
_ref_vector.unsafe_reserve(docid_limit);
load_raw_store(reader, docid_limit);
_attr.commit();
_attr.getStatus().setNumDocs(docid_limit);
_attr.setCommittedDocIdLimit(docid_limit);
return true;
}
}
|