]>
Commit | Line | Data |
---|---|---|
46bc0e73 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 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 | /* Returns true for a zeroed out iterator, such as the one returned from | |
20 | * iterator_destroy. */ | |
21 | int iterator_is_null(struct reftable_iterator *it); | |
22 | ||
23 | /* iterator that produces only ref records that point to `oid` */ | |
24 | struct filtering_ref_iterator { | |
25 | int double_check; | |
26 | struct reftable_table tab; | |
27 | struct strbuf oid; | |
28 | struct reftable_iterator it; | |
29 | }; | |
30 | #define FILTERING_REF_ITERATOR_INIT \ | |
31 | { \ | |
32 | .oid = STRBUF_INIT \ | |
33 | } | |
34 | ||
35 | void iterator_from_filtering_ref_iterator(struct reftable_iterator *, | |
36 | struct filtering_ref_iterator *); | |
37 | ||
38 | /* iterator that produces only ref records that point to `oid`, | |
39 | * but using the object index. | |
40 | */ | |
41 | struct indexed_table_ref_iter { | |
42 | struct reftable_reader *r; | |
43 | struct strbuf oid; | |
44 | ||
45 | /* mutable */ | |
46 | uint64_t *offsets; | |
47 | ||
48 | /* Points to the next offset to read. */ | |
49 | int offset_idx; | |
50 | int offset_len; | |
51 | struct block_reader block_reader; | |
52 | struct block_iter cur; | |
53 | int is_finished; | |
54 | }; | |
55 | ||
a8305bc6 PS |
56 | #define INDEXED_TABLE_REF_ITER_INIT { \ |
57 | .cur = BLOCK_ITER_INIT, \ | |
58 | .oid = STRBUF_INIT, \ | |
59 | } | |
46bc0e73 HWN |
60 | |
61 | void iterator_from_indexed_table_ref_iter(struct reftable_iterator *it, | |
62 | struct indexed_table_ref_iter *itr); | |
63 | ||
64 | /* Takes ownership of `offsets` */ | |
65 | int new_indexed_table_ref_iter(struct indexed_table_ref_iter **dest, | |
66 | struct reftable_reader *r, uint8_t *oid, | |
67 | int oid_len, uint64_t *offsets, int offset_len); | |
68 | ||
69 | #endif |