typedefstruct SpGistOptions
{
int32 varlena_header_; /* varlena header (do not touch directly!) */ int fillfactor; /* page fill factor in percent (0..100) */
} SpGistOptions;
/* *ContentsofpagespecialspaceonSPGiSTindexpages
*/ typedefstruct SpGistPageOpaqueData
{
uint16 flags; /* see bit definitions below */
uint16 nRedirection; /* number of redirection tuples on page */
uint16 nPlaceholder; /* number of placeholder tuples on page */ /* note there's no count of either LIVE or DEAD tuples ... */
uint16 spgist_page_id; /* for identification of SP-GiST indexes */
} SpGistPageOpaqueData;
typedef SpGistPageOpaqueData *SpGistPageOpaque;
/* Flag bits in page special space */ #define SPGIST_META (1<<0) #define SPGIST_DELETED (1<<1) /* never set, but keep for backwards
* compatibility */ #define SPGIST_LEAF (1<<2) #define SPGIST_NULLS (1<<3)
/* Per-datatype info needed in SpGistState */ typedefstruct SpGistTypeDesc
{
Oid type;
int16 attlen; bool attbyval; char attalign; char attstorage;
} SpGistTypeDesc;
typedefstruct SpGistState
{
Relation index; /* index we're working with */
spgConfigOut config; /* filled in by opclass config method */
SpGistTypeDesc attType; /* type of values to be indexed/restored */
SpGistTypeDesc attLeafType; /* type of leaf-tuple values */
SpGistTypeDesc attPrefixType; /* type of inner-tuple prefix values */
SpGistTypeDesc attLabelType; /* type of node label values */
/* leafTupDesc typically points to index's tupdesc, but not always */
TupleDesc leafTupDesc; /* descriptor for leaf-level tuples */
char *deadTupleStorage; /* workspace for spgFormDeadTuple */
TransactionId redirectXid; /* XID to use when creating a redirect tuple */ bool isBuild; /* true if doing index build */
} SpGistState;
/* Item to be re-examined later during a search */ typedefstruct SpGistSearchItem
{
pairingheap_node phNode; /* pairing heap node */
Datum value; /* value reconstructed from parent, or
* leafValue if isLeaf */
SpGistLeafTuple leafTuple; /* whole leaf tuple, if needed */ void *traversalValue; /* opclass-specific traverse value */ int level; /* level of items on this page */
ItemPointerData heapPtr; /* heap info, if heap tuple */ bool isNull; /* SearchItem is NULL item */ bool isLeaf; /* SearchItem is heap item */ bool recheck; /* qual recheck is needed */ bool recheckDistances; /* distance recheck is needed */
/* array with numberOfOrderBys entries */ double distances[FLEXIBLE_ARRAY_MEMBER];
} SpGistSearchItem;
/* Index quals to be passed to opclass (null-related quals removed) */ int numberOfKeys; /* number of index qualifier conditions */
ScanKey keyData; /* array of index qualifier descriptors */ int numberOfOrderBys; /* number of ordering operators */ int numberOfNonNullOrderBys; /* number of ordering operators
* with non-NULL arguments */
ScanKey orderByData; /* array of ordering op descriptors */
Oid *orderByTypes; /* array of ordering op return types */ int *nonNullOrderByOffsets; /* array of offset of non-NULL
* ordering keys in the original array */
Oid indexCollation; /* collation of index column */
/* Opclass defined functions: */
FmgrInfo innerConsistentFn;
FmgrInfo leafConsistentFn;
/* These fields are only used in amgetbitmap scans: */
TIDBitmap *tbm; /* bitmap being filled */
int64 ntids; /* number of TIDs passed to bitmap */
/* These fields are only used in amgettuple scans: */ bool want_itup; /* are we reconstructing tuples? */
TupleDesc reconTupDesc; /* if so, descriptor for reconstructed tuples */ int nPtrs; /* number of TIDs found on current page */ int iPtr; /* index for scanning through same */
ItemPointerData heapPtrs[MaxIndexTuplesPerPage]; /* TIDs from cur page */ bool recheck[MaxIndexTuplesPerPage]; /* their recheck flags */ bool recheckDistances[MaxIndexTuplesPerPage]; /* distance recheck
* flags */
HeapTuple reconTups[MaxIndexTuplesPerPage]; /* reconstructed tuples */
/* *Thisstructiswhatweactuallykeepinindex->rd_amcache.Itincludes *staticconfigurationinformationaswellasthelastUsedPagescache.
*/ typedefstruct SpGistCache
{
spgConfigOut config; /* filled in by opclass config method */
SpGistTypeDesc attType; /* type of values to be indexed/restored */
SpGistTypeDesc attLeafType; /* type of leaf-tuple values */
SpGistTypeDesc attPrefixType; /* type of inner-tuple prefix values */
SpGistTypeDesc attLabelType; /* type of node label values */
SpGistLUPCache lastUsedPages; /* local storage of last-used info */
} SpGistCache;
/* values of tupstate (see README for more info) */ #define SPGIST_LIVE 0/* normal live tuple (either inner or leaf) */ #define SPGIST_REDIRECT 1/* temporary redirection placeholder */ #define SPGIST_DEAD 2/* dead, cannot be removed because of links */ #define SPGIST_PLACEHOLDER 3/* placeholder, used to preserve offsets */
/* *SPGiSTinnertuple:listof"nodes"thatsubdivideasetoftuples * *Innertuplelayout: *header/optionalprefix/arrayofnodes,whichareSpGistNodeTuples * *sizeandprefixSizemustbemultiplesofMAXALIGN * *Iftheprefixdatumisofapass-by-valuetype,itisstoredinits *Datumrepresentation,thatisitson-diskrepresentationisoflength *sizeof(Datum).Thisisafairlyunfortunatechoice,becauseinnoother *placedoesPostgresuseDatumasanon-diskrepresentation;itcreates *anunnecessaryincompatibilitybetween32-bitand64-bitbuilds.Butthe *compatibilitylossismostlytheoreticalsinceMAXIMUM_ALIGNOFtypically *differsbetweensuchbuilds,too.Anywaywe'restuckwithitnow.
*/ typedefstruct SpGistInnerTupleData
{ unsignedint tupstate:2, /* LIVE/REDIRECT/DEAD/PLACEHOLDER */
allTheSame:1, /* all nodes in tuple are equivalent */
nNodes:13, /* number of nodes within inner tuple */
prefixSize:16; /* size of prefix, or 0 if none */
uint16 size; /* total size of inner tuple */ /* On most machines there will be a couple of wasted bytes here */ /* prefix datum follows, then nodes */
} SpGistInnerTupleData;
typedef SpGistInnerTupleData *SpGistInnerTuple;
/* these must match largest values that fit in bit fields declared above */ #define SGITMAXNNODES 0x1FFF #define SGITMAXPREFIXSIZE 0xFFFF #define SGITMAXSIZE 0xFFFF
/* *SPGiSTleaftuple:carriesaleafdatumandaheaptupleTID, *andoptionallysome"included"columns. * *Inthesimplestcase,theleafdatumisthesameastheindexedvalue; *butitcouldalsobeasuffixorsomeothersortofdeltathatpermits *reconstructiongivenknowledgeoftheprefixpathtraversedtogethere. *Anyincludedcolumnsarestoredwithoutmodification. * *AnullsbitmapispresentifthereareincludedcolumnsANDanyofthe *datumsareNULL.Wedonotneedanullsbitmapforthecaseofanull *leafdatumwithoutincludedcolumns,aswecaninferwhethertheleaf *datumisnullfromwhetherthetupleisstoredonanullspage.(This *provisionismostlyforbackwardscompatibility,butitdoessavespace *on32-bitmachines.)AswithotherPGindextupledesigns,ifthenulls *bitmapexiststhenit'sofsizeINDEX_MAX_KEYSbitsregardlessofthe *actualnumberofattributes.FortheusualchoiceofINDEX_MAX_KEYS, *thiscostsnothingbecauseofalignmentconsiderations. * *Thesizefieldiswiderthancouldpossiblybeneededforanon-diskleaf *tuple,butthisallowsustoformleaftuplesevenwhenthedatumistoo *widetobestoredimmediately,anditcostsnothingbecauseofalignment *considerations. * *t_infoholdsthenextOffsetfield(14bitswide,enoughforsupported *pagesizes)plusthehas-nulls-bitmapflagbit;anotherflagbitisfree. * *Normally,nextOffsetlinkstothenexttuplebelongingtothesameparent *node(whichmustbeonthesamepage),orit's0ifthereisnonexttuple. *Butwhentherootpageisaleafpage,wedon'tchainitstuples, *sonextOffsetisalways0ontheroot. * *sizemustbeamultipleofMAXALIGN;also,itmustbeatleastSGDTSIZE *sothatthetuplecanbeconvertedtoREDIRECTstatuslater.(This *restrictiononlyaddsbytesforaNULLleafdatumstoredona32-bit *machine;otherwisealignmentrestrictionsforceitanyway.)
*/ typedefstruct SpGistLeafTupleData
{ unsignedint tupstate:2, /* LIVE/REDIRECT/DEAD/PLACEHOLDER */
size:30; /* large enough for any palloc'able value */
uint16 t_info; /* nextOffset, which links to the next tuple
* in chain, plus two flag bits */
ItemPointerData heapPtr; /* TID of represented heap tuple */ /* nulls bitmap follows if the flag bit for it is set */ /* leaf datum, then any included datums, follows on a MAXALIGN boundary */
} SpGistLeafTupleData;
/* Page capacity after allowing for fixed header and special space */ #define SPGIST_PAGE_CAPACITY \
MAXALIGN_DOWN(BLCKSZ - \
SizeOfPageHeaderData - \
MAXALIGN(sizeof(SpGistPageOpaqueData)))
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.