]>
Commit | Line | Data |
---|---|---|
1ae2b8cd HWN |
1 | /* |
2 | Copyright 2020 Google LLC | |
3 | ||
4 | Use of this source code is governed by a BSD-style | |
5 | license that can be found in the LICENSE file or at | |
6 | https://developers.google.com/open-source/licenses/bsd | |
7 | */ | |
8 | ||
9 | #ifndef REFTABLE_MERGED_H | |
10 | #define REFTABLE_MERGED_H | |
11 | ||
12 | #include "reftable-iterator.h" | |
13 | ||
14 | /* | |
15 | * Merged tables | |
16 | * | |
17 | * A ref database kept in a sequence of table files. The merged_table presents a | |
18 | * unified view to reading (seeking, iterating) a sequence of immutable tables. | |
19 | * | |
20 | * The merged tables are on purpose kept disconnected from their actual storage | |
21 | * (eg. files on disk), because it is useful to merge tables aren't files. For | |
22 | * example, the per-workspace and global ref namespace can be implemented as a | |
23 | * merged table of two stacks of file-backed reftables. | |
24 | */ | |
25 | ||
26 | /* A merged table is implements seeking/iterating over a stack of tables. */ | |
27 | struct reftable_merged_table; | |
28 | ||
29 | /* A generic reftable; see below. */ | |
30 | struct reftable_table; | |
31 | ||
32 | /* reftable_new_merged_table creates a new merged table. It takes ownership of | |
33 | the stack array. | |
34 | */ | |
35 | int reftable_new_merged_table(struct reftable_merged_table **dest, | |
36 | struct reftable_table *stack, int n, | |
37 | uint32_t hash_id); | |
38 | ||
39 | /* returns an iterator positioned just before 'name' */ | |
40 | int reftable_merged_table_seek_ref(struct reftable_merged_table *mt, | |
41 | struct reftable_iterator *it, | |
42 | const char *name); | |
43 | ||
44 | /* returns an iterator for log entry, at given update_index */ | |
45 | int reftable_merged_table_seek_log_at(struct reftable_merged_table *mt, | |
46 | struct reftable_iterator *it, | |
47 | const char *name, uint64_t update_index); | |
48 | ||
49 | /* like reftable_merged_table_seek_log_at but look for the newest entry. */ | |
50 | int reftable_merged_table_seek_log(struct reftable_merged_table *mt, | |
51 | struct reftable_iterator *it, | |
52 | const char *name); | |
53 | ||
54 | /* returns the max update_index covered by this merged table. */ | |
55 | uint64_t | |
56 | reftable_merged_table_max_update_index(struct reftable_merged_table *mt); | |
57 | ||
58 | /* returns the min update_index covered by this merged table. */ | |
59 | uint64_t | |
60 | reftable_merged_table_min_update_index(struct reftable_merged_table *mt); | |
61 | ||
62 | /* releases memory for the merged_table */ | |
63 | void reftable_merged_table_free(struct reftable_merged_table *m); | |
64 | ||
65 | /* return the hash ID of the merged table. */ | |
66 | uint32_t reftable_merged_table_hash_id(struct reftable_merged_table *m); | |
67 | ||
68 | /* create a generic table from reftable_merged_table */ | |
69 | void reftable_table_from_merged_table(struct reftable_table *tab, | |
70 | struct reftable_merged_table *table); | |
71 | ||
72 | #endif |