The ninteenth batch
[git.git] / reftable / reftable-merged.h
blob14d5fc9f05c63d08280a9b2f6725c8c90bc5cca0
1 /*
2 Copyright 2020 Google LLC
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 */
9 #ifndef REFTABLE_MERGED_H
10 #define REFTABLE_MERGED_H
12 #include "reftable-iterator.h"
15 * Merged tables
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.
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.
26 /* A merged table is implements seeking/iterating over a stack of tables. */
27 struct reftable_merged_table;
29 /* A generic reftable; see below. */
30 struct reftable_table;
32 /* reftable_new_merged_table creates a new merged table. It takes ownership of
33 the stack array.
35 int reftable_new_merged_table(struct reftable_merged_table **dest,
36 struct reftable_table *stack, size_t n,
37 uint32_t hash_id);
39 /* returns the max update_index covered by this merged table. */
40 uint64_t
41 reftable_merged_table_max_update_index(struct reftable_merged_table *mt);
43 /* returns the min update_index covered by this merged table. */
44 uint64_t
45 reftable_merged_table_min_update_index(struct reftable_merged_table *mt);
47 /* releases memory for the merged_table */
48 void reftable_merged_table_free(struct reftable_merged_table *m);
50 /* return the hash ID of the merged table. */
51 uint32_t reftable_merged_table_hash_id(struct reftable_merged_table *m);
53 /* create a generic table from reftable_merged_table */
54 void reftable_table_from_merged_table(struct reftable_table *tab,
55 struct reftable_merged_table *table);
57 #endif