summaryrefslogtreecommitdiffstats
path: root/memfilepersistence/src/tests/spi/options_builder.h
blob: 7f04a02086cf3706ec6535b8a5b4d5f46573a705 (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
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vespa/memfilepersistence/common/environment.h>
#include <vespa/vespalib/stllike/string.h>
#include <memory>

namespace storage {
namespace memfile {

class OptionsBuilder
{
    Options _newOptions;
public:
    OptionsBuilder(const Options& opts)
        : _newOptions(opts)
    {
    }

    OptionsBuilder& maximumReadThroughGap(uint32_t readThroughGap) {
        _newOptions._maximumGapToReadThrough = readThroughGap;
        return *this;
    }

    OptionsBuilder& initialIndexRead(uint32_t bytesToRead) {
        _newOptions._initialIndexRead = bytesToRead;
        return *this;
    }

    OptionsBuilder& revertTimePeriod(framework::MicroSecTime revertTime) {
        _newOptions._revertTimePeriod = revertTime;
        return *this;
    }

    OptionsBuilder& defaultRemoveDocType(vespalib::stringref typeName) {
        _newOptions._defaultRemoveDocType = typeName;
        return *this;
    }

    OptionsBuilder& maxDocumentVersions(uint32_t maxVersions) {
        _newOptions._maxDocumentVersions = maxVersions;
        return *this;
    }

    std::unique_ptr<Options> build() const {
        return std::unique_ptr<Options>(new Options(_newOptions));
    }
};

} // memfile
} // storage