Merge branch 'rs/parse-options-with-keep-unknown-abbrev-fix' into maint-2.43
[git.git] / reftable / iter.h
blob47d67d84df679c522ce50d1d7aade2d1be683b5a
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 ITER_H
10 #define ITER_H
12 #include "system.h"
13 #include "block.h"
14 #include "record.h"
16 #include "reftable-iterator.h"
17 #include "reftable-generic.h"
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);
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;
30 #define FILTERING_REF_ITERATOR_INIT \
31 { \
32 .oid = STRBUF_INIT \
35 void iterator_from_filtering_ref_iterator(struct reftable_iterator *,
36 struct filtering_ref_iterator *);
38 /* iterator that produces only ref records that point to `oid`,
39 * but using the object index.
41 struct indexed_table_ref_iter {
42 struct reftable_reader *r;
43 struct strbuf oid;
45 /* mutable */
46 uint64_t *offsets;
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;
56 #define INDEXED_TABLE_REF_ITER_INIT { \
57 .cur = BLOCK_ITER_INIT, \
58 .oid = STRBUF_INIT, \
61 void iterator_from_indexed_table_ref_iter(struct reftable_iterator *it,
62 struct indexed_table_ref_iter *itr);
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);
69 #endif