blob: df0e14d5eda34f60f18d09d8a51b1f5da90fa120 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "iattributefilewriter.h"
#include <vespa/searchlib/util/bufferwriter.h>
namespace search {
/*
* BufferWriter implementation that passes full buffers on to
* IAttributeFileWriter.
*/
class AttributeFileBufferWriter : public BufferWriter
{
protected:
using BufferBuf = IAttributeFileWriter::BufferBuf;
using Buffer = IAttributeFileWriter::Buffer;
Buffer _buf;
size_t _bytesWritten;
uint32_t _incompleteBuffers;
IAttributeFileWriter &_fileWriter;
virtual void onFlush(size_t nowLen) = 0;
public:
static constexpr size_t BUFFER_SIZE = 4 * 1024 * 1024;
AttributeFileBufferWriter(IAttributeFileWriter &fileWriter);
~AttributeFileBufferWriter() override;
void flush() override;
size_t getBytesWritten() const { return _bytesWritten; }
};
} // namespace search
|