16 #define SIGLEN ( sizeof(int)*SIGLENINT )
17 #define SIGLENBIT (SIGLEN*BITBYTE)
22 #define SIGPTR(x) ( (BITVECP) ARR_DATA_PTR(x) )
29 for(i=0;i<SIGLENBIT;i++)
32 #define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
33 #define GETBITBYTE(x,i) ( (*((char*)(x)) >> (i)) & 0x01 )
34 #define CLRBIT(x,i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) )
35 #define SETBIT(x,i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITBYTE ) )
36 #define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 )
37 #define HASHVAL(val) (((unsigned int)(val)) % SIGLENBIT)
38 #define HASH(sign, val) SETBIT((sign), HASHVAL(val))
44 char data[FLEXIBLE_ARRAY_MEMBER];
47 #define ALLISTRUE 0x04
49 #define ISALLTRUE(x) ( ((GISTTYPE*)x)->flag & ALLISTRUE )
51 #define GTHDRSIZE (VARHDRSZ + sizeof(int32))
52 #define CALCGTSIZE(flag) ( GTHDRSIZE+(((flag) & ALLISTRUE) ? 0 : SIGLEN) )
54 #define GETSIGN(x) ( (BITVECP)( (char*)x+GTHDRSIZE ) )
56 #define SUMBIT(val) ( \
57 GETBITBYTE((val),0) + \
58 GETBITBYTE((val),1) + \
59 GETBITBYTE((val),2) + \
60 GETBITBYTE((val),3) + \
61 GETBITBYTE((val),4) + \
62 GETBITBYTE((val),5) + \
63 GETBITBYTE((val),6) + \
67 #define GETENTRY(vec,pos) ((GISTTYPE *) DatumGetPointer((vec)->vector[(pos)].key))
69 #define WISH_F(a,b,c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) )
128 for (i = 0; i < count; ++
i)
157 if ((sign[i] & 0xff) != 0xff)
226 sign = (
BITVECP) (((
char *) sign) + 1);
287 for (i = 0; i < len; i++)
301 memcpy((
void *)
GETSIGN(result), (
void *) base,
sizeof(
BITVEC));
316 *penalty =
hemdist(origval, newval);
372 if (size_waste > waste)
386 if (seed_1 == 0 || seed_2 == 0)
426 costvector[j - 1].
pos = j;
428 size_alpha =
hemdist(datum_l, _j);
429 size_beta =
hemdist(datum_r, _j);
430 costvector[j - 1].
cost = abs(size_alpha - size_beta);
437 for (k = 0; k < maxoff; k++)
439 j = costvector[k].
pos;
446 else if (j == seed_2)
453 size_alpha =
hemdist(datum_l, _j);
454 size_beta =
hemdist(datum_r, _j);
467 union_l[
i] |= ptr[
i];
483 union_r[
i] |= ptr[
i];
527 for (i = 0; res && i < count; ++
i)
563 &key_datums, &key_nulls, &key_count);
565 for (i = 0; res && i < key_count; ++
i)
586 &key_datums, &key_nulls, &key_count);
590 for (i = 0; !res && i < key_count; ++
i)
602 elog(
ERROR,
"Unsupported strategy number: %d", strategy);
#define PG_RETURN_POINTER(x)
static int hemdist(GISTTYPE *a, GISTTYPE *b)
#define DatumGetHStoreP(d)
#define HStoreContainsStrategyNumber
#define PointerGetDatum(X)
#define HSTORE_KEYLEN(arr_, i_)
static int32 sizebitvec(BITVECP sign)
#define MemSet(start, val, len)
#define HSTORE_VALLEN(arr_, i_)
#define PG_GETARG_POINTER(n)
Datum ghstore_union(PG_FUNCTION_ARGS)
#define PG_GETARG_TEXT_PP(n)
#define COMP_TRADITIONAL_CRC32(crc, data, len)
#define PG_GETARG_ARRAYTYPE_P(n)
#define HSTORE_VALISNULL(arr_, i_)
#define INIT_TRADITIONAL_CRC32(crc)
#define HStoreExistsStrategyNumber
#define HStoreExistsAllStrategyNumber
Datum ghstore_same(PG_FUNCTION_ARGS)
Datum ghstore_picksplit(PG_FUNCTION_ARGS)
#define FirstOffsetNumber
static int32 unionkey(BITVECP sbase, GISTTYPE *add)
#define FIN_TRADITIONAL_CRC32(crc)
#define HSTORE_KEY(arr_, str_, i_)
#define GETENTRY(vec, pos)
void * palloc0(Size size)
static pg_crc32 crc32_sz(char *buf, int size)
#define PG_RETURN_BOOL(x)
#define PG_RETURN_DATUM(x)
Datum ghstore_decompress(PG_FUNCTION_ARGS)
Datum ghstore_penalty(PG_FUNCTION_ARGS)
#define gistentryinit(e, k, r, pg, o, l)
Datum ghstore_out(PG_FUNCTION_ARGS)
static int comparecost(const void *a, const void *b)
#define OffsetNumberNext(offsetNumber)
PG_FUNCTION_INFO_V1(ghstore_in)
Datum ghstore_consistent(PG_FUNCTION_ARGS)
#define PG_GETARG_UINT16(n)
#define DatumGetPointer(X)
#define HSTORE_VAL(arr_, str_, i_)
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
#define VARSIZE_ANY_EXHDR(PTR)
Datum ghstore_compress(PG_FUNCTION_ARGS)
#define HStoreExistsAnyStrategyNumber
#define SET_VARSIZE(PTR, len)
#define qsort(a, b, c, d)
Datum ghstore_in(PG_FUNCTION_ARGS)
#define HStoreOldContainsStrategyNumber
static int hemdistsign(BITVECP a, BITVECP b)