reflog: clear leftovers in reflog_expiry_cleanup()
[git/debian.git] / reftable / reftable-merged.h
blob1a6d16915ab453b480f0ca657448034a11ddf6be
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, int n,
37 uint32_t hash_id);
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);
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);
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);
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);
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);
62 /* releases memory for the merged_table */
63 void reftable_merged_table_free(struct reftable_merged_table *m);
65 /* return the hash ID of the merged table. */
66 uint32_t reftable_merged_table_hash_id(struct reftable_merged_table *m);
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);
72 #endif