PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <math.h>
#include "access/genam.h"
#include "access/gist_private.h"
#include "access/tableam.h"
#include "access/xloginsert.h"
#include "miscadmin.h"
#include "nodes/execnodes.h"
#include "optimizer/optimizer.h"
#include "storage/bufmgr.h"
#include "storage/bulk_write.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/tuplesort.h"
Go to the source code of this file.
Data Structures | |
struct | GISTBuildState |
struct | GistSortedBuildLevelState |
struct | ParentMapEntry |
Macros | |
#define | BUFFERING_MODE_SWITCH_CHECK_STEP 256 |
#define | BUFFERING_MODE_TUPLE_SIZE_STATS_TARGET 4096 |
#define | GIST_SORTED_BUILD_PAGE_NUM 4 |
Typedefs | |
typedef struct GistSortedBuildLevelState | GistSortedBuildLevelState |
Enumerations | |
enum | GistBuildMode { GIST_SORTED_BUILD , GIST_BUFFERING_DISABLED , GIST_BUFFERING_AUTO , GIST_BUFFERING_STATS , GIST_BUFFERING_ACTIVE } |
#define BUFFERING_MODE_SWITCH_CHECK_STEP 256 |
Definition at line 52 of file gistbuild.c.
#define BUFFERING_MODE_TUPLE_SIZE_STATS_TARGET 4096 |
Definition at line 60 of file gistbuild.c.
#define GIST_SORTED_BUILD_PAGE_NUM 4 |
Definition at line 113 of file gistbuild.c.
typedef struct GistSortedBuildLevelState GistSortedBuildLevelState |
enum GistBuildMode |
Enumerator | |
---|---|
GIST_SORTED_BUILD | |
GIST_BUFFERING_DISABLED | |
GIST_BUFFERING_AUTO | |
GIST_BUFFERING_STATS | |
GIST_BUFFERING_ACTIVE |
Definition at line 67 of file gistbuild.c.
|
static |
Definition at line 787 of file gistbuild.c.
References GISTBuildState::freespace, GISTBuildState::indtuples, GISTBuildState::indtuplesSize, and SizeOfPageHeaderData.
Referenced by gistBuildCallback(), and gistInitBuffering().
|
static |
Definition at line 400 of file gistbuild.c.
References GistSortedBuildLevelState::current_page, F_LEAF, gist_indexsortbuild_levelstate_add(), gist_indexsortbuild_levelstate_flush(), GIST_ROOT_BLKNO, GIST_SORTED_BUILD_PAGE_NUM, GistBuildLSN, gistinitpage(), i, MAIN_FORKNUM, MemoryContextReset(), GistSortedBuildLevelState::pages, PageSetLSN(), palloc(), palloc0(), GistSortedBuildLevelState::parent, pfree(), smgr_bulk_finish(), smgr_bulk_get_buf(), smgr_bulk_start_rel(), smgr_bulk_write(), and tuplesort_getindextuple().
Referenced by gistbuild().
|
static |
Definition at line 461 of file gistbuild.c.
References GistSortedBuildLevelState::current_page, gist_indexsortbuild_levelstate_flush(), GIST_SORTED_BUILD_PAGE_NUM, gistfillbuffer(), gistinitpage(), GistPageGetOpaque, IndexTupleSize, InvalidOffsetNumber, PageGetFreeSpace(), GistSortedBuildLevelState::pages, and palloc0().
Referenced by gist_indexsortbuild(), and gist_indexsortbuild_levelstate_flush().
|
static |
Definition at line 493 of file gistbuild.c.
References SplitPageLayout::block, buf, CHECK_FOR_INTERRUPTS, GistSortedBuildLevelState::current_page, data, elog, ERROR, F_LEAF, FirstOffsetNumber, gist_indexsortbuild_levelstate_add(), GistBuildLSN, gistextractpage(), gistfillitupvec(), gistinitpage(), gistjoinvector(), GistPageGetOpaque, GistPageIsLeaf, gistSplit(), gistunion(), i, IndexTupleSize, InvalidOffsetNumber, ItemPointerSetBlockNumber(), SplitPageLayout::itup, GistSortedBuildLevelState::last_blkno, SplitPageLayout::lenlist, SplitPageLayout::list, MemoryContextSwitchTo(), SplitPageLayout::next, gistxlogPage::num, PageAddItem, GistSortedBuildLevelState::pages, PageSetLSN(), palloc(), palloc0(), GistSortedBuildLevelState::parent, pfree(), RelationGetRelationName, smgr_bulk_get_buf(), smgr_bulk_write(), and IndexTupleData::t_tid.
Referenced by gist_indexsortbuild(), and gist_indexsortbuild_levelstate_add().
|
static |
Definition at line 907 of file gistbuild.c.
References GISTBuildState::gfbb, gistProcessEmptyingQueue(), gistProcessItup(), and GISTBuildBuffers::rootlevel.
Referenced by gistBuildCallback().
|
static |
Definition at line 1223 of file gistbuild.c.
References BufferGetPage(), elog, ERROR, FirstOffsetNumber, GIST_EXCLUSIVE, gistcheckpage(), gistGetParent(), GISTBuildState::indexrel, InvalidBlockNumber, InvalidBuffer, InvalidOffsetNumber, ItemPointerGetBlockNumber(), LockBuffer(), OffsetNumberNext, PageGetItem(), PageGetItemId(), PageGetMaxOffsetNumber(), GistSortedBuildLevelState::parent, ReadBuffer(), and IndexTupleData::t_tid.
Referenced by gistbufferinginserttuples().
|
static |
Definition at line 1054 of file gistbuild.c.
References Assert, GISTPageSplitInfo::buf, BufferGetBlockNumber(), BufferGetPage(), DEBUG2, GISTPageSplitInfo::downlink, elog, FirstOffsetNumber, GISTBuildState::freespace, GISTBuildState::gfbb, GIST_ROOT_BLKNO, GIST_SHARE, gistBufferingFindCorrectParent(), gistMemorizeAllDownlinks(), gistMemorizeParent(), gistplacetopage(), gistRelocateBuildBuffersOnSplit(), GISTBuildState::giststate, GISTBuildState::heaprel, i, GISTBuildState::indexrel, InvalidBlockNumber, InvalidBuffer, InvalidOffsetNumber, ItemPointerGetBlockNumber(), lfirst, list_free_deep(), list_length(), LockBuffer(), PageGetItem(), PageGetItemId(), PageGetMaxOffsetNumber(), palloc(), ReadBuffer(), GISTBuildBuffers::rootlevel, IndexTupleData::t_tid, and UnlockReleaseBuffer().
Referenced by gistProcessItup().
IndexBuildResult* gistbuild | ( | Relation | heap, |
Relation | index, | ||
IndexInfo * | indexInfo | ||
) |
Definition at line 179 of file gistbuild.c.
References Assert, BufferGetBlockNumber(), BufferGetPage(), GISTBuildState::buildMode, createTempGistContext(), CurrentMemoryContext, DEBUG1, elog, END_CRIT_SECTION, ERROR, F_LEAF, fillfactor, freeGISTstate(), GISTBuildState::freespace, GISTBuildState::gfbb, GIST_BUFFERING_ACTIVE, GIST_BUFFERING_AUTO, GIST_BUFFERING_DISABLED, GIST_BUFFERING_STATS, GIST_DEFAULT_FILLFACTOR, gist_indexsortbuild(), GIST_OPTION_BUFFERING_OFF, GIST_OPTION_BUFFERING_ON, GIST_ROOT_BLKNO, GIST_SORTED_BUILD, GIST_SORTSUPPORT_PROC, gistBuildCallback(), GistBuildLSN, gistEmptyAllBuffers(), gistFreeBuildBuffers(), GISTInitBuffer(), gistNewBuffer(), gistSortedBuildCallback(), GISTBuildState::giststate, IndexBuildResult::heap_tuples, GISTBuildState::heaprel, i, if(), index_getprocid(), INDEX_MAX_KEYS, IndexBuildResult::index_tuples, GISTBuildState::indexrel, IndexRelationGetNumberOfKeyAttributes, GISTBuildState::indtuples, GISTBuildState::indtuplesSize, initGISTstate(), log_newpage_range(), MAIN_FORKNUM, maintenance_work_mem, MarkBufferDirty(), MemoryContextDelete(), MemoryContextSwitchTo(), OidIsValid, PageSetLSN(), palloc(), RelationGetNumberOfBlocks, RelationGetRelationName, RelationNeedsWAL, GISTBuildState::sortstate, START_CRIT_SECTION, table_index_build_scan(), GISTSTATE::tempCxt, tuplesort_begin_index_gist(), tuplesort_end(), TUPLESORT_NONE, tuplesort_performsort(), and UnlockReleaseBuffer().
Referenced by gisthandler().
|
static |
Definition at line 820 of file gistbuild.c.
References BUFFERING_MODE_SWITCH_CHECK_STEP, BUFFERING_MODE_TUPLE_SIZE_STATS_TARGET, GISTBuildState::buildMode, calculatePagesPerBuffer(), effective_cache_size, GISTBuildState::freespace, GISTBuildState::gfbb, GIST_BUFFERING_ACTIVE, GIST_BUFFERING_AUTO, GIST_BUFFERING_STATS, gistBufferingBuildInsert(), gistdoinsert(), gistFormTuple(), gistInitBuffering(), GISTBuildState::giststate, GISTBuildState::heaprel, IndexTupleSize, GISTBuildState::indtuples, GISTBuildState::indtuplesSize, GISTBuildBuffers::levelStep, MAIN_FORKNUM, MemoryContextReset(), MemoryContextSwitchTo(), GISTBuildBuffers::pagesPerBuffer, RelationGetSmgr(), smgrnblocks(), IndexTupleData::t_tid, GISTSTATE::tempCxt, and values.
Referenced by gistbuild().
|
static |
Definition at line 1370 of file gistbuild.c.
References GISTNodeBuffer::blocksCount, GISTBuildBuffers::bufferEmptyingQueue, GISTBuildBuffers::buffersOnLevels, GISTBuildBuffers::buffersOnLevelsLen, GISTBuildBuffers::context, DEBUG2, elog, GISTBuildState::gfbb, gistProcessEmptyingQueue(), GISTBuildState::giststate, i, lcons(), linitial, list_delete_first(), MemoryContextSwitchTo(), NIL, GISTNodeBuffer::queuedForEmptying, and GISTSTATE::tempCxt.
Referenced by gistbuild().
|
static |
Definition at line 1425 of file gistbuild.c.
References BufferGetPage(), FirstOffsetNumber, GIST_ROOT_BLKNO, GIST_SHARE, GistPageIsLeaf, ItemPointerGetBlockNumber(), LockBuffer(), PageGetItem(), PageGetItemId(), ReadBuffer(), IndexTupleData::t_tid, and UnlockReleaseBuffer().
Referenced by gistInitBuffering().
|
static |
Definition at line 1565 of file gistbuild.c.
References elog, ERROR, HASH_FIND, hash_search(), ParentMapEntry::parentblkno, and GISTBuildState::parentMap.
Referenced by gistBufferingFindCorrectParent().
|
static |
Definition at line 626 of file gistbuild.c.
References GISTBuildState::buildMode, calculatePagesPerBuffer(), DEBUG1, effective_cache_size, elog, GISTBuildState::freespace, GISTBuildState::gfbb, GIST_BUFFERING_ACTIVE, GIST_BUFFERING_DISABLED, gistGetMaxLevel(), gistInitBuildBuffers(), gistInitParentMap(), i, GISTBuildState::indexrel, GISTBuildState::indtuples, GISTBuildState::indtuplesSize, maintenance_work_mem, MAXALIGN, SizeOfPageHeaderData, TupleDescAttr, and VARHDRSZ.
Referenced by gistBuildCallback().
|
static |
Definition at line 1514 of file gistbuild.c.
References CurrentMemoryContext, HASHCTL::entrysize, HASH_BLOBS, HASH_CONTEXT, hash_create(), HASH_ELEM, HASHCTL::hcxt, HASHCTL::keysize, and GISTBuildState::parentMap.
Referenced by gistInitBuffering().
|
static |
Definition at line 1544 of file gistbuild.c.
References Assert, BufferGetBlockNumber(), BufferGetPage(), FirstOffsetNumber, gistMemorizeParent(), GistPageIsLeaf, ItemPointerGetBlockNumber(), PageGetItem(), PageGetItemId(), PageGetMaxOffsetNumber(), and IndexTupleData::t_tid.
Referenced by gistbufferinginserttuples().
|
static |
Definition at line 1528 of file gistbuild.c.
References HASH_ENTER, hash_search(), GistSortedBuildLevelState::parent, ParentMapEntry::parentblkno, and GISTBuildState::parentMap.
Referenced by gistbufferinginserttuples(), gistMemorizeAllDownlinks(), and gistProcessItup().
|
static |
Definition at line 1297 of file gistbuild.c.
References GISTBuildBuffers::bufferEmptyingQueue, GISTBuildState::gfbb, gistPopItupFromNodeBuffer(), gistProcessItup(), GISTBuildState::giststate, gistUnloadNodeBuffers(), GISTNodeBuffer::level, linitial, list_delete_first(), MemoryContextReset(), NIL, GISTNodeBuffer::nodeBlocknum, GISTNodeBuffer::queuedForEmptying, and GISTSTATE::tempCxt.
Referenced by gistBufferingBuildInsert(), and gistEmptyAllBuffers().
|
static |
Definition at line 923 of file gistbuild.c.
References Assert, BUFFER_OVERFLOWED, BufferGetPage(), CHECK_FOR_INTERRUPTS, GISTBuildState::gfbb, GIST_EXCLUSIVE, gistbufferinginserttuples(), gistchoose(), gistgetadjusted(), gistGetNodeBuffer(), gistMemorizeParent(), gistPushItupToNodeBuffer(), GISTBuildState::giststate, GISTBuildState::indexrel, InvalidBlockNumber, InvalidOffsetNumber, ItemPointerGetBlockNumber(), LEVEL_HAS_BUFFERS, LockBuffer(), PageGetItem(), PageGetItemId(), ReadBuffer(), IndexTupleData::t_tid, and UnlockReleaseBuffer().
Referenced by gistBufferingBuildInsert(), and gistProcessEmptyingQueue().
|
static |
Definition at line 366 of file gistbuild.c.
References gistCompressValues(), GISTBuildState::giststate, INDEX_MAX_KEYS, GISTBuildState::indexrel, GISTBuildState::indtuples, MemoryContextReset(), MemoryContextSwitchTo(), GISTBuildState::sortstate, GISTSTATE::tempCxt, tuplesort_putindextuplevalues(), and values.
Referenced by gistbuild().