mirror of
https://github.com/postgres/postgres.git
synced 2025-10-19 15:49:24 +03:00
Add TIDStore, to store sets of TIDs (ItemPointerData) efficiently.
TIDStore is a data structure designed to efficiently store large sets of TIDs. For TID storage, it employs a radix tree, where the key is a block number, and the value is a bitmap representing offset numbers. The TIDStore can be created on a DSA area and used by multiple backend processes simultaneously. There are potential future users such as tidbitmap.c, though it's very likely the interface will need to evolve as we come to understand the needs of different kinds of users. For example, we can support updating the offset bitmap of existing values. Currently, the TIDStore is not used for anything yet, aside from the test code. But an upcoming patch will use it. This includes a unit test module, in src/test/modules/test_tidstore. Co-authored-by: John Naylor Discussion: https://postgr.es/m/CAD21AoAfOZvmfR0j8VmZorZjL7RhTiQdVttNuC4W-Shdc2a-AA%40mail.gmail.com
This commit is contained in:
49
src/include/access/tidstore.h
Normal file
49
src/include/access/tidstore.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* tidstore.h
|
||||
* TidStore interface.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/access/tidstore.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef TIDSTORE_H
|
||||
#define TIDSTORE_H
|
||||
|
||||
#include "storage/itemptr.h"
|
||||
#include "utils/dsa.h"
|
||||
|
||||
typedef struct TidStore TidStore;
|
||||
typedef struct TidStoreIter TidStoreIter;
|
||||
|
||||
/* Result struct for TidStoreIterateNext */
|
||||
typedef struct TidStoreIterResult
|
||||
{
|
||||
BlockNumber blkno;
|
||||
int max_offset;
|
||||
int num_offsets;
|
||||
OffsetNumber *offsets;
|
||||
} TidStoreIterResult;
|
||||
|
||||
extern TidStore *TidStoreCreate(size_t max_bytes, dsa_area *dsa,
|
||||
int tranche_id);
|
||||
extern TidStore *TidStoreAttach(dsa_area *dsa, dsa_pointer rt_dp);
|
||||
extern void TidStoreDetach(TidStore *ts);
|
||||
extern void TidStoreLockExclusive(TidStore *ts);
|
||||
extern void TidStoreLockShare(TidStore *ts);
|
||||
extern void TidStoreUnlock(TidStore *ts);
|
||||
extern void TidStoreDestroy(TidStore *ts);
|
||||
extern void TidStoreSetBlockOffsets(TidStore *ts, BlockNumber blkno, OffsetNumber *offsets,
|
||||
int num_offsets);
|
||||
extern bool TidStoreIsMember(TidStore *ts, ItemPointer tid);
|
||||
extern TidStoreIter *TidStoreBeginIterate(TidStore *ts);
|
||||
extern TidStoreIterResult *TidStoreIterateNext(TidStoreIter *iter);
|
||||
extern void TidStoreEndIterate(TidStoreIter *iter);
|
||||
extern size_t TidStoreMemoryUsage(TidStore *ts);
|
||||
extern dsa_pointer TidStoreGetHandle(TidStore *ts);
|
||||
|
||||
#endif /* TIDSTORE_H */
|
Reference in New Issue
Block a user