The twelfth batch
[alt-git.git] / reftable / reader.h
blob010fbfe85118c3f2e608b826aaef289dd3a7e23c
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 READER_H
10 #define READER_H
12 #include "block.h"
13 #include "record.h"
14 #include "reftable-iterator.h"
15 #include "reftable-reader.h"
17 uint64_t block_source_size(struct reftable_block_source *source);
19 int block_source_read_block(struct reftable_block_source *source,
20 struct reftable_block *dest, uint64_t off,
21 uint32_t size);
22 void block_source_close(struct reftable_block_source *source);
24 /* metadata for a block type */
25 struct reftable_reader_offsets {
26 int is_present;
27 uint64_t offset;
28 uint64_t index_offset;
31 /* The state for reading a reftable file. */
32 struct reftable_reader {
33 /* for convenience, associate a name with the instance. */
34 char *name;
35 struct reftable_block_source source;
37 /* Size of the file, excluding the footer. */
38 uint64_t size;
40 /* 'sha1' for SHA1, 's256' for SHA-256 */
41 uint32_t hash_id;
43 uint32_t block_size;
44 uint64_t min_update_index;
45 uint64_t max_update_index;
46 /* Length of the OID keys in the 'o' section */
47 int object_id_len;
48 int version;
50 struct reftable_reader_offsets ref_offsets;
51 struct reftable_reader_offsets obj_offsets;
52 struct reftable_reader_offsets log_offsets;
54 uint64_t refcount;
57 const char *reader_name(struct reftable_reader *r);
59 int reader_init_iter(struct reftable_reader *r,
60 struct reftable_iterator *it,
61 uint8_t typ);
63 /* initialize a block reader to read from `r` */
64 int reader_init_block_reader(struct reftable_reader *r, struct block_reader *br,
65 uint64_t next_off, uint8_t want_typ);
67 #endif