]> git.ipfire.org Git - thirdparty/git.git/blame - reftable/iter.h
Merge branch 'rs/parse-options-with-keep-unknown-abbrev-fix'
[thirdparty/git.git] / reftable / iter.h
CommitLineData
46bc0e73
HWN
1/*
2Copyright 2020 Google LLC
3
4Use of this source code is governed by a BSD-style
5license that can be found in the LICENSE file or at
6https://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. */
21int iterator_is_null(struct reftable_iterator *it);
22
23/* iterator that produces only ref records that point to `oid` */
24struct 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
35void 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 */
41struct 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
61void iterator_from_indexed_table_ref_iter(struct reftable_iterator *it,
62 struct indexed_table_ref_iter *itr);
63
64/* Takes ownership of `offsets` */
65int 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