136 nodeBuffer->
isTemp =
false;
137 nodeBuffer->
level = level;
149 (level + 1) *
sizeof(
List *));
304 memcpy(ptr, itup, itupsz);
326 memcpy(*itup, ptr, itupsz);
542 int splitPagesCount = 0;
585 relocationBuffersInfos =
593 foreach(lc, splitinfo)
602 relocationBuffersInfos[
i].
entry,
603 relocationBuffersInfos[
i].
isnull);
614 relocationBuffersInfos[
i].
nodeBuffer = newNodeBuffer;
646 best_penalty[0] = -1;
652 for (
i = 0;
i < splitPagesCount;
i++)
669 &entry[
j], isnull[
j]);
671 zero_penalty =
false;
673 if (best_penalty[
j] < 0 || usize < best_penalty[
j])
685 best_penalty[
j] = usize;
688 best_penalty[
j + 1] = -1;
690 else if (best_penalty[
j] == usize)
705 zero_penalty =
false;
720 targetBufferInfo = &relocationBuffersInfos[which];
732 targetBufferInfo->
entry,
733 targetBufferInfo->
isnull);
739 pfree(relocationBuffersInfos);
753 elog(
ERROR,
"could not seek to block %ld in temporary file", blknum);
761 elog(
ERROR,
"could not seek to block %ld in temporary file", blknum);
#define InvalidBlockNumber
int BufFileSeekBlock(BufFile *file, int64 blknum)
void BufFileReadExact(BufFile *file, void *ptr, size_t size)
BufFile * BufFileCreateTemp(bool interXact)
void BufFileWrite(BufFile *file, const void *ptr, size_t size)
void BufFileClose(BufFile *file)
BlockNumber BufferGetBlockNumber(Buffer buffer)
#define Assert(condition)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
#define PAGE_IS_EMPTY(nbp)
#define BUFFER_HALF_FILLED(nodeBuffer, gfbb)
#define PAGE_FREE_SPACE(nbp)
#define LEVEL_HAS_BUFFERS(nlevel, gfbb)
#define BUFFER_PAGE_DATA_OFFSET
#define PAGE_NO_SPACE(nbp, itup)
void gistPushItupToNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer, IndexTuple itup)
void gistRelocateBuildBuffersOnSplit(GISTBuildBuffers *gfbb, GISTSTATE *giststate, Relation r, int level, Buffer buffer, List *splitinfo)
static void gistBuffersReleaseBlock(GISTBuildBuffers *gfbb, long blocknum)
static void gistLoadNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer)
GISTBuildBuffers * gistInitBuildBuffers(int pagesPerBuffer, int levelStep, int maxLevel)
static void WriteTempFileBlock(BufFile *file, long blknum, const void *ptr)
static void gistAddLoadedBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer)
void gistFreeBuildBuffers(GISTBuildBuffers *gfbb)
static void gistPlaceItupToPage(GISTNodeBufferPage *pageBuffer, IndexTuple itup)
GISTNodeBuffer * gistGetNodeBuffer(GISTBuildBuffers *gfbb, GISTSTATE *giststate, BlockNumber nodeBlocknum, int level)
static GISTNodeBufferPage * gistAllocateNewPageBuffer(GISTBuildBuffers *gfbb)
static long gistBuffersGetFreeBlock(GISTBuildBuffers *gfbb)
static void gistUnloadNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer)
bool gistPopItupFromNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer, IndexTuple *itup)
static void ReadTempFileBlock(BufFile *file, long blknum, void *ptr)
static void gistGetItupFromPage(GISTNodeBufferPage *pageBuffer, IndexTuple *itup)
void gistUnloadNodeBuffers(GISTBuildBuffers *gfbb)
void gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p, OffsetNumber o, GISTENTRY *attdata, bool *isnull)
IndexTuple gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *giststate)
float gistpenalty(GISTSTATE *giststate, int attno, GISTENTRY *orig, bool isNullOrig, GISTENTRY *add, bool isNullAdd)
IndexTupleData * IndexTuple
#define IndexTupleSize(itup)
List * lcons(void *datum, List *list)
void pfree(void *pointer)
void * MemoryContextAllocZero(MemoryContext context, Size size)
MemoryContext CurrentMemoryContext
void * repalloc(void *pointer, Size size)
static int list_length(const List *l)
#define foreach_current_index(var_or_cell)
MemoryContextSwitchTo(old_ctx)
#define IndexRelationGetNumberOfKeyAttributes(relation)
GISTNodeBuffer ** loadedBuffers
List * bufferEmptyingQueue
GISTNodeBufferPage * pageBuffer
bool isnull[INDEX_MAX_KEYS]
GISTPageSplitInfo * splitinfo
GISTNodeBuffer * nodeBuffer
GISTENTRY entry[INDEX_MAX_KEYS]