14 #define GETENTRY(vec,pos) ((ArrayType *) DatumGetPointer((vec)->vector[(pos)].key))
24 #define MAXNUMELTS (Min((MaxAllocSize / sizeof(Datum)),((MaxAllocSize - ARR_OVERHEAD_NONULLS(1)) / sizeof(int)))/2)
132 for (
i = 0;
i < entryvec->
n;
i++)
143 for (
i = 0;
i < entryvec->
n;
i++)
185 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
186 errmsg(
"input array is too big (%d maximum allowed, %d current), use gist__intbig_ops opclass instead",
223 lenr =
len - num_ranges;
229 for (
j =
i =
len - 1;
i > 0 && lenr > 0;
i--,
j--)
234 while (
i > 0 && lenr > 0 && dr[
i - 1] == r_start - 1)
235 --r_start, --
i, --lenr;
237 dr[2 *
j + 1] = r_end;
240 for (;
i >= 0;
i--,
j--)
241 dr[2 *
j] = dr[2 *
j + 1] = dr[
i];
248 memmove(&dr[0], &dr[2 *
j], 2 * (
len -
j) *
sizeof(
int32));
256 while (
len > num_ranges * 2)
259 for (
i = 2;
i <
len;
i += 2)
265 memmove(&dr[cand - 1], &dr[cand + 1], (
len - cand - 1) *
sizeof(
int32));
275 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
276 errmsg(
"data is too sparse, recreate index using gist__intbig_ops opclass instead")));
320 if (lenin < 2 * num_ranges)
337 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
338 errmsg(
"compressed array is too big, recreate index using gist__intbig_ops opclass instead")));
343 for (
i = 0;
i < lenin;
i += 2)
347 if ((!
i) || *(dr - 1) !=
j)
377 *result = tmp1 - tmp2;
477 maxoff = entryvec->
n - 2;
497 size_waste = size_union - size_inter;
506 if (size_waste > waste || firsttime)
520 if (seed_1 == 0 || seed_2 == 0)
526 datum_alpha =
GETENTRY(entryvec, seed_1);
529 datum_beta =
GETENTRY(entryvec, seed_2);
541 costvector[
i - 1].
pos =
i;
549 costvector[
i - 1].
cost = fabsf((size_alpha - size_l) - (size_beta - size_r));
566 for (
j = 0;
j < maxoff;
j++)
568 i = costvector[
j].
pos;
582 else if (
i == seed_2)
632 "number of ranges for compression",
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 inner_int_contains(ArrayType *a, ArrayType *b)
#define G_INT_GET_NUMRANGES()
int internal_size(int *a, int len)
ArrayType * copy_intArrayType(ArrayType *a)
void rt__int_size(ArrayType *a, float *size)
#define QSORT(a, direction)
ArrayType * _int_unique(ArrayType *r)
#define BooleanSearchStrategy
ArrayType * new_intArrayType(int num)
bool execconsistent(QUERYTYPE *query, ArrayType *array, bool calcnot)
ArrayType * resize_intArrayType(ArrayType *a, int num)
#define G_INT_NUMRANGES_DEFAULT
#define G_INT_NUMRANGES_MAX
Datum g_int_penalty(PG_FUNCTION_ARGS)
Datum g_int_picksplit(PG_FUNCTION_ARGS)
#define GETENTRY(vec, pos)
Datum g_int_options(PG_FUNCTION_ARGS)
Datum g_int_same(PG_FUNCTION_ARGS)
Datum g_int_compress(PG_FUNCTION_ARGS)
Datum g_int_union(PG_FUNCTION_ARGS)
Datum g_int_decompress(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(g_int_consistent)
Datum g_int_consistent(PG_FUNCTION_ARGS)
static int comparecost(const void *a, const void *b)
#define DatumGetArrayTypePCopy(X)
#define PG_GETARG_ARRAYTYPE_P_COPY(n)
#define PG_GETARG_ARRAYTYPE_P(n)
#define DatumGetArrayTypeP(X)
static void PGresult * res
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define PG_GETARG_POINTER(n)
#define PG_GETARG_UINT16(n)
#define DirectFunctionCall3(func, arg1, arg2, arg3)
#define PG_RETURN_POINTER(x)
#define PG_RETURN_BOOL(x)
#define gistentryinit(e, k, r, pg, o, l)
void pfree(void *pointer)
#define OffsetNumberNext(offsetNumber)
#define FirstOffsetNumber
#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 RTOldContainsStrategyNumber
#define RTOverlapStrategyNumber
#define RTSameStrategyNumber
#define RTContainsStrategyNumber
#define RTOldContainedByStrategyNumber
#define RTContainedByStrategyNumber