aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Core/MySQL/MySQLGtid.h
blob: 45eeaf02fa2e99dee1f89cbcf699ebf891f82515 (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
#pragma once
#include <IO/ReadHelpers.h>
#include <IO/WriteHelpers.h>

namespace DB
{
class GTID
{
public:
    UUID uuid;
    Int64 seq_no;

    GTID() : seq_no(0) { }
};

class GTIDSet
{
public:
    struct Interval
    {
        Int64 start;
        Int64 end;
    };

    UUID uuid;
    std::vector<Interval> intervals;

    void tryMerge(size_t i);

    static void tryShrink(GTIDSet & set, unsigned int i, Interval & current);
};

class GTIDSets
{
public:
    std::vector<GTIDSet> sets;

    void parse(String gtid_format_);
    void update(const GTID & other);

    String toString() const;
    String toPayload() const;
};

}