11 #define G_INT_NUMRANGES_DEFAULT 100
12 #define G_INT_NUMRANGES_MAX ((GISTMaxIndexKeySize - VARHDRSZ) / \
14 #define G_INT_GET_NUMRANGES() (PG_HAS_OPCLASS_OPTIONS() ? \
15 ((GISTIntArrayOptions *) PG_GET_OPCLASS_OPTIONS())->num_ranges : \
16 G_INT_NUMRANGES_DEFAULT)
26 #define ARRPTR(x) ( (int32 *) ARR_DATA_PTR(x) )
27 #define ARRNELEMS(x) ArrayGetNItems(ARR_NDIM(x), ARR_DIMS(x))
30 #define CHECKARRVALID(x) \
32 if (ARR_HASNULL(x) && array_contains_nulls(x)) \
34 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), \
35 errmsg("array must not contain nulls"))); \
38 #define ARRISEMPTY(x) (ARRNELEMS(x) == 0)
43 int _nelems_ = ARRNELEMS(x); \
45 isort(ARRPTR(x), _nelems_); \
49 #define PREPAREARR(x) \
51 int _nelems_ = ARRNELEMS(x); \
53 if (isort(ARRPTR(x), _nelems_)) \
54 (x) = _int_unique(x); \
58 #define WISH_F(a,b,c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) )
62 #define SIGLEN_DEFAULT (63 * 4)
63 #define SIGLEN_MAX GISTMaxIndexKeySize
64 #define SIGLENBIT(siglen) ((siglen) * BITS_PER_BYTE)
65 #define GET_SIGLEN() (PG_HAS_OPCLASS_OPTIONS() ? \
66 ((GISTIntArrayBigOptions *) PG_GET_OPCLASS_OPTIONS())->siglen : \
71 #define LOOPBYTE(siglen) \
72 for (i = 0; i < siglen; i++)
75 #define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITS_PER_BYTE ) ) )
76 #define GETBITBYTE(x,i) ( (*((char*)(x)) >> (i)) & 0x01 )
77 #define CLRBIT(x,i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITS_PER_BYTE ) )
78 #define SETBIT(x,i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITS_PER_BYTE ) )
79 #define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITS_PER_BYTE )) & 0x01 )
80 #define HASHVAL(val, siglen) (((unsigned int)(val)) % SIGLENBIT(siglen))
81 #define HASH(sign, val, siglen) SETBIT((sign), HASHVAL(val, siglen))
100 #define ALLISTRUE 0x04
102 #define ISALLTRUE(x) ( ((GISTTYPE*)x)->flag & ALLISTRUE )
104 #define GTHDRSIZE (VARHDRSZ + sizeof(int32))
105 #define CALCGTSIZE(flag, siglen) ( GTHDRSIZE+(((flag) & ALLISTRUE) ? 0 : (siglen)) )
107 #define GETSIGN(x) ( (BITVECP)( (char*)x+GTHDRSIZE ) )
134 #define BooleanSearchStrategy 20
154 #define HDRSIZEQT offsetof(QUERYTYPE, items)
155 #define COMPUTESIZE(size) ( HDRSIZEQT + (size) * sizeof(ITEM) )
156 #define QUERYTYPEMAXITEMS ((MaxAllocSize - HDRSIZEQT) / sizeof(ITEM))
157 #define GETQUERY(x) ( (x)->items )
168 #define DatumGetQueryTypeP(X) ((QUERYTYPE *) PG_DETOAST_DATUM(X))
169 #define DatumGetQueryTypePCopy(X) ((QUERYTYPE *) PG_DETOAST_DATUM_COPY(X))
170 #define PG_GETARG_QUERYTYPE_P(n) DatumGetQueryTypeP(PG_GETARG_DATUM(n))
171 #define PG_GETARG_QUERYTYPE_P_COPY(n) DatumGetQueryTypePCopy(PG_GETARG_DATUM(n))
179 int compASC(
const void *
a,
const void *
b);
183 #define QSORT(a, direction) \
185 int _nelems_ = ARRNELEMS(a); \
187 qsort((void*) ARRPTR(a), _nelems_, sizeof(int32), \
188 (direction) ? compASC : compDESC ); \
ArrayType * inner_int_union(ArrayType *a, ArrayType *b)
bool inner_int_overlap(ArrayType *a, ArrayType *b)
ArrayType * inner_int_inter(ArrayType *a, ArrayType *b)
bool isort(int32 *a, int len)
bool inner_int_contains(ArrayType *a, ArrayType *b)
int32 intarray_match_first(ArrayType *a, int32 elem)
int internal_size(int *a, int len)
ArrayType * copy_intArrayType(ArrayType *a)
bool signconsistent(QUERYTYPE *query, BITVECP sign, int siglen, bool calcnot)
void rt__int_size(ArrayType *a, float *size)
struct QUERYTYPE QUERYTYPE
ArrayType * _int_unique(ArrayType *r)
bool query_has_required_values(QUERYTYPE *query)
int compASC(const void *a, const void *b)
void gensign(BITVECP sign, int *a, int len, int siglen)
ArrayType * int_to_intset(int32 elem)
ArrayType * new_intArrayType(int num)
ArrayType * intarray_add_elem(ArrayType *a, int32 elem)
bool execconsistent(QUERYTYPE *query, ArrayType *array, bool calcnot)
ArrayType * intarray_concat_arrays(ArrayType *a, ArrayType *b)
int compDESC(const void *a, const void *b)
ArrayType * resize_intArrayType(ArrayType *a, int num)
bool gin_bool_consistent(QUERYTYPE *query, bool *check)
#define FLEXIBLE_ARRAY_MEMBER
static pg_noinline void Size size
ITEM items[FLEXIBLE_ARRAY_MEMBER]