blob: 82476bed7aff44f25b5416f7b2a4f6a31c51c73d (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "single_raw_attribute_saver.h"
#include "raw_buffer_store.h"
#include "raw_buffer_store_writer.h"
#include <vespa/searchlib/attribute/iattributesavetarget.h>
#include <vespa/searchlib/util/bufferwriter.h>
namespace search::attribute {
SingleRawAttributeSaver::SingleRawAttributeSaver(vespalib::GenerationHandler::Guard &&guard,
const attribute::AttributeHeader &header,
EntryRefVector&& ref_vector,
const RawBufferStore& raw_store)
: AttributeSaver(std::move(guard), header),
_ref_vector(std::move(ref_vector)),
_raw_store(raw_store)
{
}
SingleRawAttributeSaver::~SingleRawAttributeSaver() = default;
void
SingleRawAttributeSaver::save_raw_store(BufferWriter& writer) const
{
RawBufferStoreWriter raw_writer(_raw_store, writer);
for (auto ref : _ref_vector) {
raw_writer.write(ref);
}
writer.flush();
}
bool
SingleRawAttributeSaver::onSave(IAttributeSaveTarget &saveTarget)
{
std::unique_ptr<search::BufferWriter> writer(saveTarget.datWriter().allocBufferWriter());
assert(!saveTarget.getEnumerated());
save_raw_store(*writer);
return true;
}
}
|