]> git.ipfire.org Git - thirdparty/git.git/blob - reftable/iter.h
Sync with 'maint'
[thirdparty/git.git] / reftable / iter.h
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 ITER_H
10 #define ITER_H
11
12 #include "system.h"
13 #include "block.h"
14 #include "record.h"
15
16 #include "reftable-iterator.h"
17 #include "reftable-generic.h"
18
19 /* iterator that produces only ref records that point to `oid` */
20 struct filtering_ref_iterator {
21 int double_check;
22 struct reftable_table tab;
23 struct strbuf oid;
24 struct reftable_iterator it;
25 };
26 #define FILTERING_REF_ITERATOR_INIT \
27 { \
28 .oid = STRBUF_INIT \
29 }
30
31 void iterator_from_filtering_ref_iterator(struct reftable_iterator *,
32 struct filtering_ref_iterator *);
33
34 /* iterator that produces only ref records that point to `oid`,
35 * but using the object index.
36 */
37 struct indexed_table_ref_iter {
38 struct reftable_reader *r;
39 struct strbuf oid;
40
41 /* mutable */
42 uint64_t *offsets;
43
44 /* Points to the next offset to read. */
45 int offset_idx;
46 int offset_len;
47 struct block_reader block_reader;
48 struct block_iter cur;
49 int is_finished;
50 };
51
52 #define INDEXED_TABLE_REF_ITER_INIT { \
53 .cur = BLOCK_ITER_INIT, \
54 .oid = STRBUF_INIT, \
55 }
56
57 void iterator_from_indexed_table_ref_iter(struct reftable_iterator *it,
58 struct indexed_table_ref_iter *itr);
59
60 /* Takes ownership of `offsets` */
61 int new_indexed_table_ref_iter(struct indexed_table_ref_iter **dest,
62 struct reftable_reader *r, uint8_t *oid,
63 int oid_len, uint64_t *offsets, int offset_len);
64
65 #endif