summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/include/tiered.h
blob: 6cd9162e1c41e49718648712be14fcfafb62af16 (plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*-
 * Copyright (c) 2014-present MongoDB, Inc.
 * Copyright (c) 2008-2014 WiredTiger, Inc.
 *	All rights reserved.
 *
 * See the file LICENSE for redistribution information.
 */

/*
 * WT_TIERED_MANAGER --
 *	A structure that holds resources used to manage any tiered storage
 *	for the whole database.
 */
struct __wt_tiered_manager {
    uint64_t wait_usecs; /* Wait time period */
    uint32_t workers;    /* Current number of workers */
    uint32_t workers_max;
    uint32_t workers_min;

#define WT_TIERED_MAX_WORKERS 20
#define WT_TIERED_MIN_WORKERS 1

/* AUTOMATIC FLAG VALUE GENERATION START */
#define WT_TIERED_MANAGER_SHUTDOWN 0x1u /* Manager has shut down */
                                        /* AUTOMATIC FLAG VALUE GENERATION STOP */
    uint32_t flags;
};

/*
 * WT_CURSOR_TIERED --
 *	A tiered cursor.
 */
struct __wt_cursor_tiered {
    WT_CURSOR iface;

    WT_TIERED *tiered;

    WT_CURSOR **cursors;
    WT_CURSOR *current; /* The current cursor for iteration */
    WT_CURSOR *primary; /* The current primary */

/* AUTOMATIC FLAG VALUE GENERATION START */
#define WT_CURTIERED_ACTIVE 0x1u       /* Incremented the session count */
#define WT_CURTIERED_ITERATE_NEXT 0x2u /* Forward iteration */
#define WT_CURTIERED_ITERATE_PREV 0x4u /* Backward iteration */
#define WT_CURTIERED_MULTIPLE 0x8u     /* Multiple cursors have values */
                                       /* AUTOMATIC FLAG VALUE GENERATION STOP */
    uint32_t flags;
};

/*
 * Define the maximum number of tiers for convenience. We expect at most two initially. This can
 * change if more are needed. It is easier to have the array statically allocated initially than
 * worrying about the memory management. For now also assign types to slots. Local files in slot 0.
 * Shared tier top level in slot 1.
 */
#define WT_TIERED_INDEX_INVALID (uint32_t) - 1
#define WT_TIERED_INDEX_LOCAL 0
#define WT_TIERED_INDEX_SHARED 1

#define WT_TIERED_MAX_TIERS 4

/* Object name types */
/* AUTOMATIC FLAG VALUE GENERATION START */
#define WT_TIERED_NAME_LOCAL 0x1u
#define WT_TIERED_NAME_OBJECT 0x2u
#define WT_TIERED_NAME_PREFIX 0x4u
#define WT_TIERED_NAME_SHARED 0x8u
/* AUTOMATIC FLAG VALUE GENERATION STOP */

/*
 * WT_TIERED_TIERS --
 *	Information we need to keep about each tier such as its data handle and name.
 *	We define operations that each tier can accept. The local tier should be able to accept
 *	reads and writes. The shared tier can do reads and flushes. Other ideas for future tiers
 *	may include a merge tier that is read only or an archival tier that is flush only.
 */
struct __wt_tiered_tiers {
    WT_DATA_HANDLE *tier; /* Data handle for this tier */
    const char *name;     /* Tier's metadata name */
/* AUTOMATIC FLAG VALUE GENERATION START */
#define WT_TIERS_OP_FLUSH 0x1u
#define WT_TIERS_OP_READ 0x2u
#define WT_TIERS_OP_WRITE 0x4u
    /* AUTOMATIC FLAG VALUE GENERATION STOP */
    uint32_t flags; /* Flags including operations */
};

/*
 * WT_TIERED --
 *	Handle for a tiered data source. This data structure is used as the basis for metadata
 *	as the top level definition of a tiered table. This structure tells us where to find the
 *	parts of the tree and in what order we should look at the tiers. Prior to the first call
 *	to flush_tier after the creation of this table the only tier that exists will be the local
 *	disk represented by a file: URI. Then a second (or more) set of tiers will be where the
 *	tiered data lives. The non-local tier will point to a tier: URI and that is described by a
 *	WT_TIERED_TREE data structure that will encapsulate what the current state of the
 *	individual objects is.
 */
struct __wt_tiered {
    WT_DATA_HANDLE iface;

    const char *obj_config; /* Config to use for each object */
    const char *key_format, *value_format;

    WT_BUCKET_STORAGE *bstorage;

    WT_TIERED_TIERS tiers[WT_TIERED_MAX_TIERS]; /* Tiers array */

    uint64_t current_id; /* Current object id number */
    uint64_t next_id;    /* Next object number */

    WT_COLLATOR *collator; /* TODO: handle custom collation */
    /* TODO: What about compression, encryption, etc? Do we need to worry about that here? */

/* AUTOMATIC FLAG VALUE GENERATION START */
#define WT_TIERED_FLAG_UNUSED 0x1u
    /* AUTOMATIC FLAG VALUE GENERATION STOP */
    uint32_t flags;
};

/*
 * WT_TIERED_OBJECT --
 *     Definition of a tiered object. This is a single object in a tiered tree.
 *     This is the lowest level data structure and item that makes
 *     up a tiered table. This structure contains the information needed to construct the name of
 *     this object and how to access it.
 */
struct __wt_tiered_object {
    const char *uri;      /* Data source for this object */
    WT_TIERED_TREE *tree; /* Pointer to tree this object is part of */
    uint64_t count;       /* Approximate count of records */
    uint64_t size;        /* Final size of object */
    uint64_t switch_txn;  /* Largest txn that can write to this object */
    uint64_t switch_ts;   /* Timestamp for switching */
    uint32_t id;          /* This object's id */
    uint32_t generation;  /* Do we need this?? */
    uint32_t refcnt;      /* Number of references */

/* AUTOMATIC FLAG VALUE GENERATION START */
#define WT_TIERED_OBJ_LOCAL 0x1u /* Local resident also */
    /* AUTOMATIC FLAG VALUE GENERATION STOP */
    uint32_t flags;
};

/*
 * WT_TIERED_TREE --
 *     Definition of the shared tiered portion of a tree.
 */
struct __wt_tiered_tree {
    WT_DATA_HANDLE iface;
    const char *name, *config;
    const char *key_format, *value_format;

/* AUTOMATIC FLAG VALUE GENERATION START */
#define WT_TIERED_TREE_UNUSED 0x1u
    /* AUTOMATIC FLAG VALUE GENERATION STOP */
    uint32_t flags;
};