1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

Refactor tidstore.c iterator buffering.

Previously, TidStoreIterateNext() would expand the set of offsets for
each block into an internal buffer that it overwrote each time.  In
order to be able to collect the offsets for multiple blocks before
working with them, change the contract.  Now, the offsets are obtained
by a separate call to TidStoreGetBlockOffsets(), which can be called at
a later time.  TidStoreIteratorResult objects are safe to copy and store
in a queue.

Reviewed-by: Noah Misch <noah@leadboat.com>
Discussion: https://postgr.es/m/CAAKRu_bbkmwAzSBgnezancgJeXrQZXy4G4kBTd+5=cr86H5yew@mail.gmail.com
This commit is contained in:
Thomas Munro
2024-07-24 17:24:59 +12:00
parent 1462aad2e4
commit f6bef362ca
4 changed files with 51 additions and 42 deletions

View File

@ -20,13 +20,14 @@
typedef struct TidStore TidStore;
typedef struct TidStoreIter TidStoreIter;
/* Result struct for TidStoreIterateNext */
/*
* Result struct for TidStoreIterateNext. This is copyable, but should be
* treated as opaque. Call TidStoreGetOffsets() to obtain the offsets.
*/
typedef struct TidStoreIterResult
{
BlockNumber blkno;
int max_offset;
int num_offsets;
OffsetNumber *offsets;
void *internal_page;
} TidStoreIterResult;
extern TidStore *TidStoreCreateLocal(size_t max_bytes, bool insert_only);
@ -42,6 +43,9 @@ extern void TidStoreSetBlockOffsets(TidStore *ts, BlockNumber blkno, OffsetNumbe
extern bool TidStoreIsMember(TidStore *ts, ItemPointer tid);
extern TidStoreIter *TidStoreBeginIterate(TidStore *ts);
extern TidStoreIterResult *TidStoreIterateNext(TidStoreIter *iter);
extern int TidStoreGetBlockOffsets(TidStoreIterResult *result,
OffsetNumber *offsets,
int max_offsets);
extern void TidStoreEndIterate(TidStoreIter *iter);
extern size_t TidStoreMemoryUsage(TidStore *ts);
extern dsa_pointer TidStoreGetHandle(TidStore *ts);