79 memset(&hashCtl, 0,
sizeof(hashCtl));
126 (
const void *) &nodeBlocknum,
141 nodeBuffer->
isTemp =
false;
142 nodeBuffer->
level = level;
154 (level + 1) *
sizeof(
List *));
309 memcpy(ptr, itup, itupsz);
331 memcpy(*itup, ptr, itupsz);
547 int splitPagesCount = 0,
591 relocationBuffersInfos =
600 foreach(lc, splitinfo)
608 relocationBuffersInfos[
i].
entry,
609 relocationBuffersInfos[i].
isnull);
620 relocationBuffersInfos[
i].
nodeBuffer = newNodeBuffer;
654 best_penalty[0] = -1;
660 for (i = 0; i < splitPagesCount; i++)
675 &splitPageInfo->
entry[j],
677 &entry[j], isnull[j]);
679 zero_penalty =
false;
681 if (best_penalty[j] < 0 || usize < best_penalty[j])
693 best_penalty[j] = usize;
695 if (j < r->rd_att->natts - 1)
696 best_penalty[j + 1] = -1;
698 else if (best_penalty[j] == usize)
713 zero_penalty =
false;
728 targetBufferInfo = &relocationBuffersInfos[which];
740 targetBufferInfo->
entry,
741 targetBufferInfo->
isnull);
747 pfree(relocationBuffersInfos);
761 elog(
ERROR,
"could not seek temporary file: %m");
763 elog(
ERROR,
"could not read temporary file: %m");
770 elog(
ERROR,
"could not seek temporary file: %m");
779 errmsg(
"could not write block %ld of temporary file: %m",
#define PAGE_FREE_SPACE(nbp)
void gistRelocateBuildBuffersOnSplit(GISTBuildBuffers *gfbb, GISTSTATE *giststate, Relation r, int level, Buffer buffer, List *splitinfo)
GISTPageSplitInfo * splitinfo
bool isnull[INDEX_MAX_KEYS]
static void gistPlaceItupToPage(GISTNodeBufferPage *pageBuffer, IndexTuple item)
static GISTNodeBufferPage * gistAllocateNewPageBuffer(GISTBuildBuffers *gfbb)
void gistPushItupToNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer, IndexTuple itup)
void gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p, OffsetNumber o, GISTENTRY *attdata, bool *isnull)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
#define BUFFER_HALF_FILLED(nodeBuffer, gfbb)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
IndexTuple gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *giststate)
void BufFileClose(BufFile *file)
#define LEVEL_HAS_BUFFERS(nlevel, gfbb)
GISTENTRY entry[INDEX_MAX_KEYS]
static void gistBuffersReleaseBlock(GISTBuildBuffers *gfbb, long blocknum)
static void gistLoadNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer)
GISTNodeBufferPage * pageBuffer
void pfree(void *pointer)
float gistpenalty(GISTSTATE *giststate, int attno, GISTENTRY *orig, bool isNullOrig, GISTENTRY *add, bool isNullAdd)
#define BUFFER_PAGE_DATA_OFFSET
static long gistBuffersGetFreeBlock(GISTBuildBuffers *gfbb)
static void gistUnloadNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer)
BufFile * BufFileCreateTemp(bool interXact)
List * bufferEmptyingQueue
GISTBuildBuffers * gistInitBuildBuffers(int pagesPerBuffer, int levelStep, int maxLevel)
IndexTupleData * IndexTuple
int errcode_for_file_access(void)
#define PAGE_NO_SPACE(nbp, itup)
GISTNodeBuffer * gistGetNodeBuffer(GISTBuildBuffers *gfbb, GISTSTATE *giststate, BlockNumber nodeBlocknum, int level)
MemoryContext CurrentMemoryContext
static void gistGetItupFromPage(GISTNodeBufferPage *pageBuffer, IndexTuple *item)
#define ereport(elevel, rest)
HTAB * hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
int BufFileSeekBlock(BufFile *file, long blknum)
void * MemoryContextAllocZero(MemoryContext context, Size size)
void gistUnloadNodeBuffers(GISTBuildBuffers *gfbb)
static void WriteTempFileBlock(BufFile *file, long blknum, void *ptr)
List * lcons(void *datum, List *list)
#define Assert(condition)
#define InvalidBlockNumber
static int list_length(const List *l)
#define PAGE_IS_EMPTY(nbp)
void * repalloc(void *pointer, Size size)
static void gistAddLoadedBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer)
GISTNodeBuffer ** loadedBuffers
BlockNumber BufferGetBlockNumber(Buffer buffer)
void gistFreeBuildBuffers(GISTBuildBuffers *gfbb)
int errmsg(const char *fmt,...)
static void ReadTempFileBlock(BufFile *file, long blknum, void *ptr)
GISTNodeBuffer * nodeBuffer
size_t BufFileRead(BufFile *file, void *ptr, size_t size)
size_t BufFileWrite(BufFile *file, void *ptr, size_t size)
bool gistPopItupFromNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer, IndexTuple *itup)
#define offsetof(type, field)
#define IndexTupleSize(itup)