23 #define SIGLEN_DEFAULT (sizeof(int32) * 4)
24 #define SIGLEN_MAX GISTMaxIndexKeySize
25 #define SIGLENBIT(siglen) ((siglen) * BITBYTE)
26 #define GET_SIGLEN() (PG_HAS_OPCLASS_OPTIONS() ? \
27 ((GistHstoreOptions *) PG_GET_OPCLASS_OPTIONS())->siglen : \
33 #define LOOPBYTE(siglen) \
34 for (i = 0; i < (siglen); i++)
36 #define LOOPBIT(siglen) \
37 for (i = 0; i < SIGLENBIT(siglen); i++)
40 #define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
41 #define GETBITBYTE(x,i) ( (*((char*)(x)) >> (i)) & 0x01 )
42 #define CLRBIT(x,i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) )
43 #define SETBIT(x,i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITBYTE ) )
44 #define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 )
45 #define HASHVAL(val, siglen) (((unsigned int)(val)) % SIGLENBIT(siglen))
46 #define HASH(sign, val, siglen) SETBIT((sign), HASHVAL(val, siglen))
55 #define ALLISTRUE 0x04
57 #define ISALLTRUE(x) ( ((GISTTYPE*)x)->flag & ALLISTRUE )
59 #define GTHDRSIZE (VARHDRSZ + sizeof(int32))
60 #define CALCGTSIZE(flag, siglen) ( GTHDRSIZE+(((flag) & ALLISTRUE) ? 0 : (siglen)) )
62 #define GETSIGN(x) ( (BITVECP)( (char*)x+GTHDRSIZE ) )
64 #define SUMBIT(val) ( \
65 GETBITBYTE((val),0) + \
66 GETBITBYTE((val),1) + \
67 GETBITBYTE((val),2) + \
68 GETBITBYTE((val),3) + \
69 GETBITBYTE((val),4) + \
70 GETBITBYTE((val),5) + \
71 GETBITBYTE((val),6) + \
75 #define GETENTRY(vec,pos) ((GISTTYPE *) DatumGetPointer((vec)->vector[(pos)].key))
77 #define WISH_F(a,b,c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) )
101 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
102 errmsg(
"cannot accept a value of type %s",
"ghstore")));
111 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
112 errmsg(
"cannot display a value of type %s",
"ghstore")));
163 for (
i = 0;
i < count; ++
i)
192 if ((
sign[
i] & 0xff) != 0xff)
404 if (size_waste > waste)
418 if (seed_1 == 0 || seed_2 == 0)
435 costvector[
j - 1].
pos =
j;
437 size_alpha =
hemdist(datum_l, _j, siglen);
438 size_beta =
hemdist(datum_r, _j, siglen);
439 costvector[
j - 1].
cost = abs(size_alpha - size_beta);
446 for (k = 0; k < maxoff; k++)
448 j = costvector[k].
pos;
455 else if (
j == seed_2)
462 size_alpha =
hemdist(datum_l, _j, siglen);
463 size_beta =
hemdist(datum_r, _j, siglen);
470 memset(union_l, 0xff, siglen);
476 union_l[
i] |= ptr[
i];
486 memset(union_r, 0xff, siglen);
492 union_r[
i] |= ptr[
i];
537 for (
i = 0;
res &&
i < count; ++
i)
573 for (
i = 0;
res &&
i < key_count; ++
i)
596 for (
i = 0; !
res &&
i < key_count; ++
i)
608 elog(
ERROR,
"Unsupported strategy number: %d", strategy);
620 "signature length in bytes",
#define PG_GETARG_ARRAYTYPE_P(n)
void deconstruct_array_builtin(ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
#define FLEXIBLE_ARRAY_MEMBER
static void PGresult * res
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define PG_GETARG_TEXT_PP(n)
#define PG_GETARG_POINTER(n)
#define PG_GETARG_UINT16(n)
#define PG_RETURN_POINTER(x)
#define PG_RETURN_BOOL(x)
#define gistentryinit(e, k, r, pg, o, l)
#define HStoreExistsAllStrategyNumber
#define HStoreExistsStrategyNumber
#define DatumGetHStoreP(d)
#define HSTORE_KEY(arr_, str_, i_)
#define PG_GETARG_HSTORE_P(x)
#define HStoreOldContainsStrategyNumber
#define HStoreExistsAnyStrategyNumber
#define HStoreContainsStrategyNumber
#define HSTORE_VALISNULL(arr_, i_)
#define HSTORE_VALLEN(arr_, i_)
#define HSTORE_KEYLEN(arr_, i_)
#define HSTORE_VAL(arr_, str_, i_)
#define HASHVAL(val, siglen)
Datum ghstore_options(PG_FUNCTION_ARGS)
Datum ghstore_union(PG_FUNCTION_ARGS)
Datum ghstore_picksplit(PG_FUNCTION_ARGS)
static int hemdist(GISTTYPE *a, GISTTYPE *b, int siglen)
PG_FUNCTION_INFO_V1(ghstore_in)
static int32 sizebitvec(BITVECP sign, int siglen)
static int hemdistsign(BITVECP a, BITVECP b, int siglen)
Datum ghstore_compress(PG_FUNCTION_ARGS)
Datum ghstore_out(PG_FUNCTION_ARGS)
#define CALCGTSIZE(flag, siglen)
#define GETENTRY(vec, pos)
Datum ghstore_consistent(PG_FUNCTION_ARGS)
static int32 unionkey(BITVECP sbase, GISTTYPE *add, int siglen)
static GISTTYPE * ghstore_alloc(bool allistrue, int siglen, BITVECP sign)
static pg_crc32 crc32_sz(const char *buf, int size)
Datum ghstore_penalty(PG_FUNCTION_ARGS)
#define SIGLENBIT(siglen)
Datum ghstore_decompress(PG_FUNCTION_ARGS)
Datum ghstore_in(PG_FUNCTION_ARGS)
Datum ghstore_same(PG_FUNCTION_ARGS)
#define HASH(sign, val, siglen)
static int comparecost(const void *a, const void *b)
static int pg_cmp_s32(int32 a, int32 b)
#define OffsetNumberNext(offsetNumber)
#define FirstOffsetNumber
#define FIN_TRADITIONAL_CRC32(crc)
#define INIT_TRADITIONAL_CRC32(crc)
#define COMP_TRADITIONAL_CRC32(crc, data, len)
#define qsort(a, b, c, d)
static Datum PointerGetDatum(const void *X)
static Pointer DatumGetPointer(Datum X)
void init_local_reloptions(local_relopts *relopts, Size relopt_struct_size)
void add_local_int_reloption(local_relopts *relopts, const char *name, const char *desc, int default_val, int min_val, int max_val, int offset)
static pg_noinline void Size size
#define SET_VARSIZE(PTR, len)
#define VARSIZE_ANY_EXHDR(PTR)