aboutsummaryrefslogtreecommitdiffstats
path: root/persistence/src/vespa/persistence/spi/selection.h
blob: 6374887cda7ab86afc0dfde69bd888d3a592af49 (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
60
61
62
63
64
65
66
67
68
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
 * \class storage::spi::Selection
 * \ingroup spi
 *
 * \brief Use a matcher to find what documents one is interested in.
 */

#pragma once

#include "documentselection.h"
#include <vespa/persistence/spi/types.h>

namespace storage::spi {

class Selection {
public:
    using TimestampSubset = std::vector<Timestamp>;
private:
    DocumentSelection _documentSelection;
    Timestamp         _fromTimestamp;
    Timestamp         _toTimestamp;
    TimestampSubset   _timestampSubset;

public:
    Selection(const DocumentSelection& docSel);
    ~Selection();

    const DocumentSelection& getDocumentSelection() const {
        return _documentSelection;
    }

    /**
     * All the timestamp stuff will disappear when we rewrite selection.
     */
    /**
     * Specifies that only documents with a timestamp newer than or equal
     * to the given value shall be included in the result.
     */
    void setFromTimestamp(Timestamp fromTimestamp) {
        _fromTimestamp = fromTimestamp;
    }
    /**
     * Specifies that only documents with a timestamp older than or equal
     * to the given value shall be included in the result.
     */
    void setToTimestamp(Timestamp toTimestamp) {
        _toTimestamp = toTimestamp;
    }

    /**
     * Assign an explicit subset of timestamps to iterate over.
     * If non-empty, document selection, timestamp range and include removes
     * will be ignored; all specified entries are returned if they exist.
     * Timestamps MUST be in strictly increasing order.
     */
    void setTimestampSubset(const TimestampSubset& timestampSubset) {
        _timestampSubset = timestampSubset;
    }
    const TimestampSubset& getTimestampSubset() const {
        return _timestampSubset;
    }

    Timestamp getFromTimestamp() const { return _fromTimestamp; }
    Timestamp getToTimestamp() const { return _toTimestamp; }
};

}