reftable/stack: provide convenience functions to create iterators

There exist a bunch of call sites in the reftable backend that want to
create iterators for a reftable stack. This is rather convoluted right
now, where you always have to go via the merged table. And it is about
to become even more convoluted when we split up iterator initialization
and seeking in the next commit.

Introduce convenience functions that allow the caller to create an
iterator from a reftable stack directly without going through the merged
table. Adapt callers accordingly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2024-05-13 10:47:56 +02:00
committed by Junio C Hamano
parent 0e7be2b3ea
commit 08efe69212
5 changed files with 63 additions and 30 deletions

View File

@ -10,6 +10,7 @@ https://developers.google.com/open-source/licenses/bsd
#include "../write-or-die.h"
#include "system.h"
#include "constants.h"
#include "merged.h"
#include "reader.h"
#include "reftable-error.h"
@ -130,6 +131,20 @@ int read_lines(const char *filename, char ***namesp)
return err;
}
void reftable_stack_init_ref_iterator(struct reftable_stack *st,
struct reftable_iterator *it)
{
merged_table_init_iter(reftable_stack_merged_table(st),
it, BLOCK_TYPE_REF);
}
void reftable_stack_init_log_iterator(struct reftable_stack *st,
struct reftable_iterator *it)
{
merged_table_init_iter(reftable_stack_merged_table(st),
it, BLOCK_TYPE_LOG);
}
struct reftable_merged_table *
reftable_stack_merged_table(struct reftable_stack *st)
{