PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/gist.h"
#include "access/heaptoast.h"
#include "access/reloptions.h"
#include "lib/qunique.h"
#include "port/pg_bitutils.h"
#include "tsearch/ts_utils.h"
#include "utils/builtins.h"
#include "utils/pg_crc.h"
Go to the source code of this file.
Data Structures | |
struct | GistTsVectorOptions |
struct | SignTSVector |
struct | CHKVAL |
struct | CACHESIGN |
struct | SPLITCOST |
Macros | |
#define | SIGLEN_DEFAULT (31 * 4) |
#define | SIGLEN_MAX GISTMaxIndexKeySize |
#define | GET_SIGLEN() |
#define | SIGLENBIT(siglen) ((siglen) * BITS_PER_BYTE) |
#define | LOOPBYTE(siglen) for (i = 0; i < siglen; i++) |
#define | GETBYTE(x, i) ( *( (BITVECP)(x) + (int)( (i) / BITS_PER_BYTE ) ) ) |
#define | GETBITBYTE(x, i) ( ((char)(x)) >> (i) & 0x01 ) |
#define | CLRBIT(x, i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITS_PER_BYTE ) ) |
#define | SETBIT(x, i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITS_PER_BYTE ) ) |
#define | GETBIT(x, i) ( (GETBYTE(x,i) >> ( (i) % BITS_PER_BYTE )) & 0x01 ) |
#define | HASHVAL(val, siglen) (((unsigned int)(val)) % SIGLENBIT(siglen)) |
#define | HASH(sign, val, siglen) SETBIT((sign), HASHVAL(val, siglen)) |
#define | GETENTRY(vec, pos) ((SignTSVector *) DatumGetPointer((vec)->vector[(pos)].key)) |
#define | ARRKEY 0x01 |
#define | SIGNKEY 0x02 |
#define | ALLISTRUE 0x04 |
#define | ISARRKEY(x) ( ((SignTSVector*)(x))->flag & ARRKEY ) |
#define | ISSIGNKEY(x) ( ((SignTSVector*)(x))->flag & SIGNKEY ) |
#define | ISALLTRUE(x) ( ((SignTSVector*)(x))->flag & ALLISTRUE ) |
#define | GTHDRSIZE ( VARHDRSZ + sizeof(int32) ) |
#define | CALCGTSIZE(flag, len) ( GTHDRSIZE + ( ( (flag) & ARRKEY ) ? ((len)*sizeof(int32)) : (((flag) & ALLISTRUE) ? 0 : (len)) ) ) |
#define | GETSIGN(x) ( (BITVECP)( (char*)(x)+GTHDRSIZE ) ) |
#define | GETSIGLEN(x) ( VARSIZE(x) - GTHDRSIZE ) |
#define | GETARR(x) ( (int32*)( (char*)(x)+GTHDRSIZE ) ) |
#define | ARRNELEM(x) ( ( VARSIZE(x) - GTHDRSIZE )/sizeof(int32) ) |
#define | SINGOUTSTR "%d true bits, %d false bits" |
#define | ARROUTSTR "%d unique words" |
#define | EXTRALEN ( 2*13 ) |
#define | WISH_F(a, b, c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) ) |
Typedefs | |
typedef char * | BITVECP |
Variables | |
static int | outbuf_maxlen = 0 |
#define ALLISTRUE 0x04 |
Definition at line 71 of file tsgistidx.c.
#define ARRKEY 0x01 |
Definition at line 69 of file tsgistidx.c.
Definition at line 83 of file tsgistidx.c.
#define ARROUTSTR "%d unique words" |
Definition at line 99 of file tsgistidx.c.
#define CALCGTSIZE | ( | flag, | |
len | |||
) | ( GTHDRSIZE + ( ( (flag) & ARRKEY ) ? ((len)*sizeof(int32)) : (((flag) & ALLISTRUE) ? 0 : (len)) ) ) |
Definition at line 78 of file tsgistidx.c.
Definition at line 49 of file tsgistidx.c.
#define EXTRALEN ( 2*13 ) |
Definition at line 100 of file tsgistidx.c.
#define GET_SIGLEN | ( | ) |
Definition at line 36 of file tsgistidx.c.
Definition at line 51 of file tsgistidx.c.
Definition at line 48 of file tsgistidx.c.
Definition at line 47 of file tsgistidx.c.
#define GETENTRY | ( | vec, | |
pos | |||
) | ((SignTSVector *) DatumGetPointer((vec)->vector[(pos)].key)) |
Definition at line 56 of file tsgistidx.c.
Definition at line 80 of file tsgistidx.c.
Definition at line 77 of file tsgistidx.c.
Definition at line 54 of file tsgistidx.c.
Definition at line 53 of file tsgistidx.c.
#define ISALLTRUE | ( | x | ) | ( ((SignTSVector*)(x))->flag & ALLISTRUE ) |
Definition at line 75 of file tsgistidx.c.
#define ISARRKEY | ( | x | ) | ( ((SignTSVector*)(x))->flag & ARRKEY ) |
Definition at line 73 of file tsgistidx.c.
#define ISSIGNKEY | ( | x | ) | ( ((SignTSVector*)(x))->flag & SIGNKEY ) |
Definition at line 74 of file tsgistidx.c.
Definition at line 44 of file tsgistidx.c.
Definition at line 50 of file tsgistidx.c.
#define SIGLEN_DEFAULT (31 * 4) |
Definition at line 34 of file tsgistidx.c.
#define SIGLEN_MAX GISTMaxIndexKeySize |
Definition at line 35 of file tsgistidx.c.
#define SIGLENBIT | ( | siglen | ) | ((siglen) * BITS_PER_BYTE) |
Definition at line 40 of file tsgistidx.c.
#define SIGNKEY 0x02 |
Definition at line 70 of file tsgistidx.c.
Definition at line 98 of file tsgistidx.c.
Definition at line 588 of file tsgistidx.c.
typedef char* BITVECP |
Definition at line 42 of file tsgistidx.c.
|
static |
Definition at line 286 of file tsgistidx.c.
References TS_MAYBE, TS_NO, and val.
Referenced by gtsvector_consistent().
|
static |
Definition at line 318 of file tsgistidx.c.
References GETBIT, GETSIGLEN, GETSIGN, HASHVAL, sort-test::key, TS_MAYBE, TS_NO, and val.
Referenced by gtsvector_consistent().
|
static |
Definition at line 596 of file tsgistidx.c.
Referenced by gtsvector_picksplit().
|
static |
|
static |
Definition at line 577 of file tsgistidx.c.
References CACHESIGN::allistrue, GETSIGN, ISALLTRUE, ISARRKEY, sort-test::key, makesign(), and CACHESIGN::sign.
Referenced by gtsvector_picksplit().
|
static |
Definition at line 157 of file tsgistidx.c.
References ALLISTRUE, CALCGTSIZE, flag(), GETSIGN, len, palloc(), res, SET_VARSIZE, sign, and SIGNKEY.
Referenced by gtsvector_compress(), gtsvector_picksplit(), and gtsvector_union().
Datum gtsvector_compress | ( | PG_FUNCTION_ARGS | ) |
Definition at line 173 of file tsgistidx.c.
References ALLISTRUE, ARRKEY, ARRPTR, CALCGTSIZE, COMP_LEGACY_CRC32, compareint(), DatumGetPointer(), DatumGetTSVector(), FIN_LEGACY_CRC32, GET_SIGLEN, GETARR, GETSIGN, gistentryinit, gtsvector_alloc(), i, INIT_LEGACY_CRC32, ISALLTRUE, ISSIGNKEY, GISTENTRY::key, GISTENTRY::leafkey, WordEntry::len, len, LOOPBYTE, makesign(), GISTENTRY::offset, GISTENTRY::page, palloc(), PG_GETARG_POINTER, PG_RETURN_POINTER, PointerGetDatum(), WordEntry::pos, qsort, qunique(), GISTENTRY::rel, repalloc(), res, SET_VARSIZE, sign, SIGNKEY, STRPTR, TOAST_INDEX_TARGET, val, and VARSIZE.
Datum gtsvector_consistent | ( | PG_FUNCTION_ARGS | ) |
Definition at line 335 of file tsgistidx.c.
References CHKVAL::arrb, CHKVAL::arre, ARRNELEM, checkcondition_arr(), checkcondition_bit(), DatumGetPointer(), GETARR, GETQUERY, ISALLTRUE, ISSIGNKEY, GISTENTRY::key, sort-test::key, PG_GETARG_POINTER, PG_GETARG_TSQUERY, PG_RETURN_BOOL, TSQueryData::size, TS_EXEC_PHRASE_NO_POS, and TS_execute().
Referenced by gtsvector_consistent_oldsig().
Datum gtsvector_consistent_oldsig | ( | PG_FUNCTION_ARGS | ) |
Datum gtsvector_decompress | ( | PG_FUNCTION_ARGS | ) |
Definition at line 253 of file tsgistidx.c.
References DatumGetPointer(), gistentryinit, GISTENTRY::key, sort-test::key, GISTENTRY::offset, GISTENTRY::page, palloc(), PG_DETOAST_DATUM, PG_GETARG_POINTER, PG_RETURN_POINTER, PointerGetDatum(), and GISTENTRY::rel.
Datum gtsvector_options | ( | PG_FUNCTION_ARGS | ) |
Definition at line 813 of file tsgistidx.c.
References add_local_int_reloption(), init_local_reloptions(), PG_GETARG_POINTER, PG_RETURN_VOID, SIGLEN_DEFAULT, and SIGLEN_MAX.
Datum gtsvector_penalty | ( | PG_FUNCTION_ARGS | ) |
Definition at line 534 of file tsgistidx.c.
References DatumGetPointer(), GET_SIGLEN, GETSIGN, hemdist(), hemdistsign(), ISALLTRUE, ISARRKEY, GISTENTRY::key, makesign(), newval, palloc(), pfree(), PG_GETARG_POINTER, PG_RETURN_POINTER, SIGLENBIT, sign, and sizebitvec().
Datum gtsvector_picksplit | ( | PG_FUNCTION_ARGS | ) |
Definition at line 625 of file tsgistidx.c.
References ALLISTRUE, comparecost(), SPLITCOST::cost, fillcache(), FirstOffsetNumber, GET_SIGLEN, GETENTRY, GETSIGN, gtsvector_alloc(), hemdistcache(), hemdistsign(), i, ISALLTRUE, j, LOOPBYTE, GistEntryVector::n, OffsetNumberNext, palloc(), PG_GETARG_POINTER, PG_RETURN_POINTER, PointerGetDatum(), SPLITCOST::pos, qsort, SIGLENBIT, CACHESIGN::sign, sign, SIGNKEY, sizebitvec(), GIST_SPLITVEC::spl_ldatum, GIST_SPLITVEC::spl_left, GIST_SPLITVEC::spl_nleft, GIST_SPLITVEC::spl_nright, GIST_SPLITVEC::spl_rdatum, GIST_SPLITVEC::spl_right, and WISH_F.
Datum gtsvector_same | ( | PG_FUNCTION_ARGS | ) |
Definition at line 430 of file tsgistidx.c.
References a, ARRNELEM, Assert(), b, GET_SIGLEN, GETARR, GETSIGLEN, GETSIGN, i, ISALLTRUE, ISSIGNKEY, LOOPBYTE, PG_GETARG_POINTER, and PG_RETURN_POINTER.
Datum gtsvector_union | ( | PG_FUNCTION_ARGS | ) |
Definition at line 403 of file tsgistidx.c.
References ALLISTRUE, CALCGTSIZE, SignTSVector::flag, GET_SIGLEN, GETENTRY, GETSIGN, gtsvector_alloc(), i, GistEntryVector::n, PG_GETARG_POINTER, PG_RETURN_POINTER, SET_VARSIZE, SIGNKEY, unionkey(), and VARSIZE.
Datum gtsvectorin | ( | PG_FUNCTION_ARGS | ) |
Definition at line 88 of file tsgistidx.c.
References ereport, errcode(), errmsg(), ERROR, and PG_RETURN_VOID.
Datum gtsvectorout | ( | PG_FUNCTION_ARGS | ) |
Definition at line 105 of file tsgistidx.c.
References ARRNELEM, ARROUTSTR, EXTRALEN, GETSIGLEN, GETSIGN, ISALLTRUE, ISARRKEY, sort-test::key, Max, outbuf_maxlen, palloc(), PG_DETOAST_DATUM, PG_FREE_IF_COPY, PG_GETARG_DATUM, PG_RETURN_POINTER, SIGLENBIT, SINGOUTSTR, sizebitvec(), and sprintf.
|
static |
Definition at line 513 of file tsgistidx.c.
References a, Assert(), b, GETSIGLEN, GETSIGN, hemdistsign(), ISALLTRUE, SIGLENBIT, and sizebitvec().
Referenced by gtsvector_penalty().
Definition at line 609 of file tsgistidx.c.
References a, b, hemdistsign(), SIGLENBIT, and sizebitvec().
Referenced by gtsvector_picksplit().
Definition at line 497 of file tsgistidx.c.
References a, b, i, LOOPBYTE, and pg_number_of_ones.
Referenced by gtsvector_penalty(), gtsvector_picksplit(), hemdist(), and hemdistcache().
|
static |
Definition at line 145 of file tsgistidx.c.
References a, ARRNELEM, GETARR, HASH, len, MemSet, and sign.
Referenced by fillcache(), gtsvector_compress(), and gtsvector_penalty().
Definition at line 491 of file tsgistidx.c.
References pg_popcount(), and sign.
Referenced by gtsvector_penalty(), gtsvector_picksplit(), gtsvectorout(), hemdist(), and hemdistcache().
|
static |
|
static |
Definition at line 102 of file tsgistidx.c.
Referenced by gtsvectorout().