31 #define WORDNUM(x) ((x) / BITS_PER_BITMAPWORD)
32 #define BITNUM(x) ((x) % BITS_PER_BITMAPWORD)
35 #define WORDS_PER_PAGE(n) ((n) / BITS_PER_BITMAPWORD + 1)
38 #define NUM_FULL_OFFSETS ((sizeof(uintptr_t) - sizeof(uint8) - sizeof(int8)) / sizeof(OffsetNumber))
48 #ifndef WORDS_BIGENDIAN
65 #ifdef WORDS_BIGENDIAN
84 #define MAX_OFFSET_IN_BITMAP Min(BITS_PER_BITMAPWORD * PG_INT8_MAX - 1, MaxOffsetNumber)
86 #define MaxBlocktableEntrySize \
87 offsetof(BlocktableEntry, words) + \
88 (sizeof(bitmapword) * WORDS_PER_PAGE(MAX_OFFSET_IN_BITMAP))
90 #define RT_PREFIX local_ts
91 #define RT_SCOPE static
94 #define RT_VALUE_TYPE BlocktableEntry
95 #define RT_VARLEN_VALUE_SIZE(page) \
96 (offsetof(BlocktableEntry, words) + \
97 sizeof(bitmapword) * (page)->header.nwords)
98 #define RT_RUNTIME_EMBEDDABLE_VALUE
101 #define RT_PREFIX shared_ts
103 #define RT_SCOPE static
106 #define RT_VALUE_TYPE BlocktableEntry
107 #define RT_VARLEN_VALUE_SIZE(page) \
108 (offsetof(BlocktableEntry, words) + \
109 sizeof(bitmapword) * (page)->header.nwords)
110 #define RT_RUNTIME_EMBEDDABLE_VALUE
132 #define TidStoreIsShared(ts) ((ts)->area != NULL)
173 while (16 * maxBlockSize > max_bytes)
221 "TID storage meta data",
228 while (8 * dsa_max_size > max_bytes)
234 if (dsa_init_size > dsa_max_size)
235 dsa_init_size = dsa_max_size;
266 ts->
tree.
shared = shared_ts_attach(area, handle);
364 int next_word_threshold;
370 for (
int i = 1;
i < num_offsets;
i++)
371 Assert(offsets[
i] > offsets[
i - 1]);
377 for (
int i = 0;
i < num_offsets;
i++)
383 elog(
ERROR,
"tuple offset out of range: %u", off);
393 wordnum <=
WORDNUM(offsets[num_offsets - 1]);
398 while (
idx < num_offsets)
404 elog(
ERROR,
"tuple offset out of range: %u", off);
406 if (off >= next_word_threshold)
424 local_ts_set(ts->
tree.
local, blkno, page);
440 page = local_ts_find(ts->
tree.
local, blk);
543 return shared_ts_memory_usage(ts->
tree.
shared);
545 return local_ts_memory_usage(ts->
tree.
local);
589 if (num_offsets < max_offsets)
597 for (wordnum = 0; wordnum < page->
header.
nwords; wordnum++)
606 if (num_offsets < max_offsets)
Datum idx(PG_FUNCTION_ARGS)
#define BITS_PER_BITMAPWORD
MemoryContext BumpContextCreate(MemoryContext parent, const char *name, Size minContextSize, Size initBlockSize, Size maxBlockSize)
#define Assert(condition)
#define FLEXIBLE_ARRAY_MEMBER
dsa_area * dsa_attach(dsa_handle handle)
void dsa_detach(dsa_area *area)
dsa_area * dsa_create_ext(int tranche_id, size_t init_segment_size, size_t max_segment_size)
#define DSA_MIN_SEGMENT_SIZE
#define DSA_DEFAULT_INIT_SEGMENT_SIZE
#define DSA_HANDLE_INVALID
#define DsaPointerIsValid(x)
#define DSA_MAX_SEGMENT_SIZE
static OffsetNumber ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_MAXSIZE
#define ALLOCSET_DEFAULT_MINSIZE
#define ALLOCSET_SMALL_SIZES
#define ALLOCSET_DEFAULT_INITSIZE
#define InvalidOffsetNumber
static void word(struct vars *v, int dir, struct state *lp, struct state *rp)
bitmapword words[FLEXIBLE_ARRAY_MEMBER]
struct BlocktableEntry::@12 header
OffsetNumber full_offsets[NUM_FULL_OFFSETS]
TidStoreIterResult output
union TidStoreIter::@14 tree_iter
shared_ts_radix_tree * shared
local_ts_radix_tree * local
TidStore * TidStoreAttach(dsa_handle area_handle, dsa_pointer handle)
void TidStoreEndIterate(TidStoreIter *iter)
void TidStoreDetach(TidStore *ts)
TidStoreIterResult * TidStoreIterateNext(TidStoreIter *iter)
void TidStoreLockShare(TidStore *ts)
TidStore * TidStoreCreateShared(size_t max_bytes, int tranche_id)
void TidStoreDestroy(TidStore *ts)
dsa_area * TidStoreGetDSA(TidStore *ts)
void TidStoreUnlock(TidStore *ts)
TidStore * TidStoreCreateLocal(size_t max_bytes, bool insert_only)
#define TidStoreIsShared(ts)
#define WORDS_PER_PAGE(n)
bool TidStoreIsMember(TidStore *ts, ItemPointer tid)
int TidStoreGetBlockOffsets(TidStoreIterResult *result, OffsetNumber *offsets, int max_offsets)
TidStoreIter * TidStoreBeginIterate(TidStore *ts)
struct BlocktableEntry BlocktableEntry
#define MAX_OFFSET_IN_BITMAP
void TidStoreLockExclusive(TidStore *ts)
dsa_pointer TidStoreGetHandle(TidStore *ts)
#define MaxBlocktableEntrySize
void TidStoreSetBlockOffsets(TidStore *ts, BlockNumber blkno, OffsetNumber *offsets, int num_offsets)
size_t TidStoreMemoryUsage(TidStore *ts)