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
9 #ifndef REFTABLE_MERGED_H
10 #define REFTABLE_MERGED_H
12 #include "reftable-iterator.h"
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 struct reftable_reader
;
32 * reftable_merged_table_new creates a new merged table. The readers must be
33 * kept alive as long as the merged table is still in use.
35 int reftable_merged_table_new(struct reftable_merged_table
**dest
,
36 struct reftable_reader
**readers
, size_t n
,
39 /* Initialize a merged table iterator for reading refs. */
40 int reftable_merged_table_init_ref_iterator(struct reftable_merged_table
*mt
,
41 struct reftable_iterator
*it
);
43 /* Initialize a merged table iterator for reading logs. */
44 int reftable_merged_table_init_log_iterator(struct reftable_merged_table
*mt
,
45 struct reftable_iterator
*it
);
47 /* returns the max update_index covered by this merged table. */
49 reftable_merged_table_max_update_index(struct reftable_merged_table
*mt
);
51 /* returns the min update_index covered by this merged table. */
53 reftable_merged_table_min_update_index(struct reftable_merged_table
*mt
);
55 /* releases memory for the merged_table */
56 void reftable_merged_table_free(struct reftable_merged_table
*m
);
58 /* return the hash ID of the merged table. */
59 uint32_t reftable_merged_table_hash_id(struct reftable_merged_table
*m
);