builtin/bundle: have unbundle check for repo before opening its bundle
[git/gitster.git] / reftable / iter.h
blob537431baba075ad72614b1c68eff1fd28fa51288
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 /* 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;
26 #define FILTERING_REF_ITERATOR_INIT \
27 { \
28 .oid = STRBUF_INIT \
31 void iterator_from_filtering_ref_iterator(struct reftable_iterator *,
32 struct filtering_ref_iterator *);
34 /* iterator that produces only ref records that point to `oid`,
35 * but using the object index.
37 struct indexed_table_ref_iter {
38 struct reftable_reader *r;
39 struct strbuf oid;
41 /* mutable */
42 uint64_t *offsets;
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;
52 #define INDEXED_TABLE_REF_ITER_INIT { \
53 .cur = BLOCK_ITER_INIT, \
54 .oid = STRBUF_INIT, \
57 void iterator_from_indexed_table_ref_iter(struct reftable_iterator *it,
58 struct indexed_table_ref_iter *itr);
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);
65 #endif