reftable/table: add `reftable_table` to the public interface

The `reftable_table` interface is an internal implementation detail that callers have no access to. Having direct access to this structure is important though for a subsequent patch series that will implement consistency checks for the reftable backend. Move the structure into "reftable-table.h" so that it part of the public interface. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Apr 7, 2025 at 15:16 UTC c8cbe85a233c7f38cb644c2e6a676871c90c9dcd
2 files changed +31 -34
reftable/reftable-table.h
+31 -1
@@ -20,8 +20,38 @@
20 * reftable_merged_table and struct reftable_stack.
21 */
22
23 +/* Metadata for a block type. */
24 +struct reftable_table_offsets {
25 + int is_present;
26 + uint64_t offset;
27 + uint64_t index_offset;
28 +};
29 +
30 /* The table struct is a handle to an open reftable file. */
24 -struct reftable_table;
31 +struct reftable_table {
32 + /* for convenience, associate a name with the instance. */
33 + char *name;
34 + struct reftable_block_source source;
35 +
36 + /* Size of the file, excluding the footer. */
37 + uint64_t size;
38 +
39 + /* The hash function used for ref records. */
40 + enum reftable_hash hash_id;
41 +
42 + uint32_t block_size;
43 + uint64_t min_update_index;
44 + uint64_t max_update_index;
45 + /* Length of the OID keys in the 'o' section */
46 + int object_id_len;
47 + int version;
48 +
49 + struct reftable_table_offsets ref_offsets;
50 + struct reftable_table_offsets obj_offsets;
51 + struct reftable_table_offsets log_offsets;
52 +
53 + uint64_t refcount;
54 +};
55
56 /* reftable_table_new opens a reftable for reading. If successful,
57 * returns 0 code and sets pp. The name is used for creating a
reftable/table.h
-33
@@ -14,39 +14,6 @@
14 #include "reftable-iterator.h"
15 #include "reftable-table.h"
16
17 -/* metadata for a block type */
18 -struct reftable_table_offsets {
19 - int is_present;
20 - uint64_t offset;
21 - uint64_t index_offset;
22 -};
23 -
24 -/* The state for reading a reftable file. */
25 -struct reftable_table {
26 - /* for convenience, associate a name with the instance. */
27 - char *name;
28 - struct reftable_block_source source;
29 -
30 - /* Size of the file, excluding the footer. */
31 - uint64_t size;
32 -
33 - /* The hash function used for ref records. */
34 - enum reftable_hash hash_id;
35 -
36 - uint32_t block_size;
37 - uint64_t min_update_index;
38 - uint64_t max_update_index;
39 - /* Length of the OID keys in the 'o' section */
40 - int object_id_len;
41 - int version;
42 -
43 - struct reftable_table_offsets ref_offsets;
44 - struct reftable_table_offsets obj_offsets;
45 - struct reftable_table_offsets log_offsets;
46 -
47 - uint64_t refcount;
48 -};
49 -
17 const char *reftable_table_name(struct reftable_table *t);
18
19 int table_init_iter(struct reftable_table *t,