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.
Referenced by gtsvector_alloc(), gtsvector_compress(), gtsvector_picksplit(), and gtsvector_union().
#define ARRKEY 0x01 |
Definition at line 69 of file tsgistidx.c.
Referenced by gtsvector_compress().
Definition at line 83 of file tsgistidx.c.
Referenced by gtsvector_consistent(), gtsvector_same(), gtsvectorout(), makesign(), and unionkey().
#define ARROUTSTR "%d unique words" |
Definition at line 97 of file tsgistidx.c.
Referenced by gtsvectorout().
#define CALCGTSIZE | ( | flag, | |
len | |||
) | ( GTHDRSIZE + ( ( (flag) & ARRKEY ) ? ((len)*sizeof(int32)) : (((flag) & ALLISTRUE) ? 0 : (len)) ) ) |
Definition at line 78 of file tsgistidx.c.
Referenced by gtsvector_alloc(), gtsvector_compress(), and gtsvector_union().
Definition at line 49 of file tsgistidx.c.
#define EXTRALEN ( 2*13 ) |
Definition at line 98 of file tsgistidx.c.
Referenced by gtsvectorout().
#define GET_SIGLEN | ( | ) |
Definition at line 36 of file tsgistidx.c.
Referenced by gtsvector_compress(), gtsvector_penalty(), gtsvector_picksplit(), gtsvector_same(), and gtsvector_union().
Definition at line 82 of file tsgistidx.c.
Referenced by gtsvector_compress(), gtsvector_consistent(), gtsvector_same(), makesign(), and unionkey().
#define GETBIT | ( | x, | |
i | |||
) | ( (GETBYTE(x,i) >> ( (i) % BITS_PER_BYTE )) & 0x01 ) |
Definition at line 51 of file tsgistidx.c.
Referenced by checkcondition_bit().
Definition at line 48 of file tsgistidx.c.
#define GETBYTE | ( | x, | |
i | |||
) | ( *( (BITVECP)(x) + (int)( (i) / BITS_PER_BYTE ) ) ) |
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.
Referenced by gtsvector_picksplit(), and gtsvector_union().
Definition at line 81 of file tsgistidx.c.
Referenced by checkcondition_bit(), gtsvector_same(), gtsvectorout(), hemdist(), and unionkey().
Definition at line 80 of file tsgistidx.c.
Referenced by checkcondition_bit(), fillcache(), gtsvector_alloc(), gtsvector_compress(), gtsvector_penalty(), gtsvector_picksplit(), gtsvector_same(), gtsvector_union(), gtsvectorout(), hemdist(), and unionkey().
Definition at line 77 of file tsgistidx.c.
Definition at line 54 of file tsgistidx.c.
Referenced by makesign(), and unionkey().
Definition at line 53 of file tsgistidx.c.
Referenced by checkcondition_bit().
#define ISALLTRUE | ( | x | ) | ( ((SignTSVector*)(x))->flag & ALLISTRUE ) |
Definition at line 75 of file tsgistidx.c.
Referenced by fillcache(), gtsvector_compress(), gtsvector_consistent(), gtsvector_penalty(), gtsvector_picksplit(), gtsvector_same(), gtsvectorout(), hemdist(), and unionkey().
#define ISARRKEY | ( | x | ) | ( ((SignTSVector*)(x))->flag & ARRKEY ) |
Definition at line 73 of file tsgistidx.c.
Referenced by fillcache(), gtsvector_penalty(), and gtsvectorout().
#define ISSIGNKEY | ( | x | ) | ( ((SignTSVector*)(x))->flag & SIGNKEY ) |
Definition at line 74 of file tsgistidx.c.
Referenced by gtsvector_compress(), gtsvector_consistent(), gtsvector_same(), and unionkey().
Definition at line 44 of file tsgistidx.c.
Referenced by gtsvector_compress(), gtsvector_picksplit(), gtsvector_same(), hemdistsign(), and unionkey().
Definition at line 50 of file tsgistidx.c.
#define SIGLEN_DEFAULT (31 * 4) |
Definition at line 34 of file tsgistidx.c.
Referenced by gtsvector_options().
#define SIGLEN_MAX GISTMaxIndexKeySize |
Definition at line 35 of file tsgistidx.c.
Referenced by gtsvector_options().
#define SIGLENBIT | ( | siglen | ) | ((siglen) * BITS_PER_BYTE) |
Definition at line 40 of file tsgistidx.c.
Referenced by gtsvector_penalty(), gtsvector_picksplit(), gtsvectorout(), hemdist(), and hemdistcache().
#define SIGNKEY 0x02 |
Definition at line 70 of file tsgistidx.c.
Referenced by gtsvector_alloc(), gtsvector_compress(), gtsvector_picksplit(), and gtsvector_union().
Definition at line 96 of file tsgistidx.c.
Referenced by gtsvectorout().
Definition at line 581 of file tsgistidx.c.
Referenced by gtsvector_picksplit().
typedef char* BITVECP |
Definition at line 42 of file tsgistidx.c.
|
static |
Definition at line 279 of file tsgistidx.c.
References QueryOperand::prefix, TS_MAYBE, TS_NO, and QueryOperand::valcrc.
Referenced by gtsvector_consistent().
|
static |
Definition at line 311 of file tsgistidx.c.
References GETBIT, GETSIGLEN, GETSIGN, HASHVAL, sort-test::key, QueryOperand::prefix, TS_MAYBE, TS_NO, and QueryOperand::valcrc.
Referenced by gtsvector_consistent().
|
static |
Definition at line 589 of file tsgistidx.c.
References SPLITCOST::cost.
Referenced by gtsvector_picksplit().
|
static |
Definition at line 127 of file tsgistidx.c.
Referenced by gtsvector_compress().
|
static |
Definition at line 570 of file tsgistidx.c.
References CACHESIGN::allistrue, GETSIGN, ISALLTRUE, ISARRKEY, makesign(), and CACHESIGN::sign.
Referenced by gtsvector_picksplit().
|
static |
Definition at line 150 of file tsgistidx.c.
References ALLISTRUE, CALCGTSIZE, flag(), SignTSVector::flag, GETSIGN, palloc(), SET_VARSIZE, and SIGNKEY.
Referenced by gtsvector_compress(), gtsvector_picksplit(), and gtsvector_union().
Datum gtsvector_compress | ( | PG_FUNCTION_ARGS | ) |
Definition at line 166 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, LOOPBYTE, makesign(), GISTENTRY::offset, GISTENTRY::page, palloc(), PG_GETARG_POINTER, PG_RETURN_POINTER, PointerGetDatum, WordEntry::pos, qsort, qunique(), GISTENTRY::rel, repalloc(), SET_VARSIZE, sign, SIGNKEY, TSVectorData::size, STRPTR, TOAST_INDEX_TARGET, val, and VARSIZE.
Datum gtsvector_consistent | ( | PG_FUNCTION_ARGS | ) |
Definition at line 328 of file tsgistidx.c.
References CHKVAL::arrb, CHKVAL::arre, ARRNELEM, checkcondition_arr(), checkcondition_bit(), DatumGetPointer, GETARR, GETQUERY, ISALLTRUE, ISSIGNKEY, sort-test::key, GISTENTRY::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 246 of file tsgistidx.c.
References DatumGetPointer, gistentryinit, sort-test::key, GISTENTRY::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 806 of file tsgistidx.c.
References add_local_int_reloption(), init_local_reloptions(), offsetof, PG_GETARG_POINTER, PG_RETURN_VOID, SIGLEN_DEFAULT, and SIGLEN_MAX.
Datum gtsvector_penalty | ( | PG_FUNCTION_ARGS | ) |
Definition at line 527 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 618 of file tsgistidx.c.
References Abs, ALLISTRUE, comparecost(), SPLITCOST::cost, fillcache(), FirstOffsetNumber, GET_SIGLEN, GETENTRY, GETSIGN, gtsvector_alloc(), hemdistcache(), hemdistsign(), i, ISALLTRUE, LOOPBYTE, MemSet, GistEntryVector::n, OffsetNumberNext, palloc(), PG_GETARG_POINTER, PG_RETURN_POINTER, PointerGetDatum, SPLITCOST::pos, qsort, SIGLENBIT, sign, CACHESIGN::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 423 of file tsgistidx.c.
References ARRNELEM, Assert, 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 396 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_DATUM.
Datum gtsvectorout | ( | PG_FUNCTION_ARGS | ) |
Definition at line 103 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_POINTER, PG_RETURN_POINTER, SIGLENBIT, SINGOUTSTR, sizebitvec(), and sprintf.
|
static |
Definition at line 506 of file tsgistidx.c.
References Assert, GETSIGLEN, GETSIGN, hemdistsign(), ISALLTRUE, SIGLENBIT, and sizebitvec().
Referenced by gtsvector_penalty().
Definition at line 602 of file tsgistidx.c.
References CACHESIGN::allistrue, hemdistsign(), SIGLENBIT, CACHESIGN::sign, and sizebitvec().
Referenced by gtsvector_picksplit().
Definition at line 490 of file tsgistidx.c.
References i, LOOPBYTE, and pg_number_of_ones.
Referenced by gtsvector_penalty(), gtsvector_picksplit(), hemdist(), and hemdistcache().
|
static |
Definition at line 138 of file tsgistidx.c.
References ARRNELEM, GETARR, HASH, and MemSet.
Referenced by fillcache(), gtsvector_compress(), and gtsvector_penalty().
Definition at line 484 of file tsgistidx.c.
References pg_popcount().
Referenced by gtsvector_penalty(), gtsvector_picksplit(), gtsvectorout(), hemdist(), and hemdistcache().
|
static |
|
static |
Definition at line 100 of file tsgistidx.c.
Referenced by gtsvectorout().