25 #define ARRPTR(x) ( (double *) ARR_DATA_PTR(x) )
26 #define ARRNELEMS(x) ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x))
153 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
154 errmsg(
"cannot work with arrays containing NULLs")));
159 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
160 errmsg(
"can't extend cube"),
161 errdetail(
"A cube cannot have more than %d dimensions.",
166 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
167 errmsg(
"UR and LL arrays must be of same length")));
174 for (
i = 0;
i < dim;
i++)
176 if (dur[
i] != dll[
i])
188 for (
i = 0;
i < dim;
i++)
189 result->
x[
i] = dur[
i];
193 for (
i = 0;
i < dim;
i++)
194 result->
x[
i + dim] = dll[
i];
217 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
218 errmsg(
"cannot work with arrays containing NULLs")));
223 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
224 errmsg(
"array is too long"),
225 errdetail(
"A cube cannot have more than %d dimensions.",
236 for (
i = 0;
i < dim;
i++)
237 result->
x[
i] = dur[
i];
255 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
256 errmsg(
"cannot work with arrays containing NULLs")));
263 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
264 errmsg(
"array is too long"),
265 errdetail(
"A cube cannot have more than %d dimensions.",
276 for (
i = 0;
i < dim;
i++)
278 if ((dx[
i] <= 0) || (dx[
i] >
DIM(
c)))
280 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
281 errmsg(
"Index out of bounds")));
282 result->
x[
i] =
c->x[dx[
i] - 1];
284 result->
x[
i + dim] =
c->x[dx[
i] +
DIM(
c) - 1];
302 for (
i = 0;
i < dim;
i++)
313 for (
i = 0;
i < dim;
i++)
364 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
365 errmsg(
"cube dimension is too large"),
366 errdetail(
"A cube cannot have more than %d dimensions.",
440 for (
i = 1;
i < entryvec->
n;
i++)
499 *result = (float) (tmp1 - tmp2);
541 maxoff = entryvec->
n - 2;
564 size_waste = size_union - size_inter;
570 if (size_waste > waste || firsttime)
619 else if (
i == seed_2)
634 if (size_alpha - size_l < size_beta - size_r)
785 result->
x[
i] =
Min(0,
788 result->
x[
i + dim] =
Max(0,
828 bool swapped =
false;
860 result->
x[
i] =
Max(0,
945 for (
i = 0;
i < dim;
i++)
954 for (
i = 0;
i < dim;
i++)
1128 if ((
a == NULL) || (
b == NULL))
1198 if ((
a == NULL) || (
b == NULL))
1257 bool swapped =
false;
1306 bool swapped =
false;
1350 bool swapped =
false;
1413 bool inverse =
false;
1418 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
1419 errmsg(
"zero cube index is not defined")));
1428 if (coord <= 2 *
DIM(cube))
1431 int index = (coord - 1) / 2;
1434 bool upper = ((coord - 1) % 2 == 1);
1494 elog(
ERROR,
"unrecognized cube strategy number: %d", strategy);
1506 if ((
a1 <= b1) && (
a2 <= b1) && (
a1 <= b2) && (
a2 <= b2))
1510 if ((
a1 > b1) && (
a2 > b1) && (
a1 > b2) && (
a2 > b2))
1544 for (
i = 0;
i <
DIM(cube);
i++)
1571 if (
DIM(
c) >= n && n > 0)
1588 if (
DIM(
c) >= n && n > 0)
1608 if (coord <= 0 || coord > 2 *
DIM(cube))
1610 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
1611 errmsg(
"cube index %d is out of bounds", coord)));
1648 bool inverse =
false;
1654 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
1655 errmsg(
"zero cube index is not defined")));
1664 if (coord <= 2 *
DIM(cube))
1667 int index = (coord - 1) / 2;
1670 bool upper = ((coord - 1) % 2 == 1);
1726 for (
i = 0,
j = dim;
i <
DIM(
a);
i++,
j++)
1738 if (result->
x[
i] > result->
x[
j])
1740 result->
x[
i] = (result->
x[
i] + result->
x[
j]) / 2;
1741 result->
x[
j] = result->
x[
i];
1745 for (;
i < dim;
i++,
j++)
1828 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1829 errmsg(
"can't extend cube"),
1830 errdetail(
"A cube cannot have more than %d dimensions.",
1840 for (
i = 0;
i <
DIM(cube);
i++)
1841 result->
x[
i] = cube->
x[
i];
1842 result->
x[
DIM(result) - 1] =
x;
1850 for (
i = 0;
i <
DIM(cube);
i++)
1852 result->
x[
i] = cube->
x[
i];
1853 result->
x[
DIM(result) +
i] = cube->
x[
DIM(cube) +
i];
1855 result->
x[
DIM(result) - 1] =
x;
1856 result->
x[2 *
DIM(result) - 1] =
x;
1876 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1877 errmsg(
"can't extend cube"),
1878 errdetail(
"A cube cannot have more than %d dimensions.",
1888 for (
i = 0;
i <
DIM(cube);
i++)
1889 result->
x[
i] = cube->
x[
i];
1890 result->
x[
DIM(result) - 1] = x1;
1898 for (
i = 0;
i <
DIM(cube);
i++)
1903 result->
x[
DIM(result) - 1] = x1;
1904 result->
x[2 *
DIM(result) - 1] = x2;
Datum idx(PG_FUNCTION_ARGS)
#define PG_GETARG_ARRAYTYPE_P(n)
bool array_contains_nulls(ArrayType *array)
Datum cube_gt(PG_FUNCTION_ARGS)
Datum cube_eq(PG_FUNCTION_ARGS)
Datum cube_le(PG_FUNCTION_ARGS)
Datum cube_coord(PG_FUNCTION_ARGS)
Datum distance_taxicab(PG_FUNCTION_ARGS)
Datum cube_ll_coord(PG_FUNCTION_ARGS)
Datum cube_subset(PG_FUNCTION_ARGS)
Datum cube_distance(PG_FUNCTION_ARGS)
static bool cube_is_point_internal(NDBOX *cube)
bool cube_overlap_v0(NDBOX *a, NDBOX *b)
bool g_cube_leaf_consistent(NDBOX *key, NDBOX *query, StrategyNumber strategy)
bool cube_contains_v0(NDBOX *a, NDBOX *b)
Datum distance_chebyshev(PG_FUNCTION_ARGS)
Datum g_cube_picksplit(PG_FUNCTION_ARGS)
int32 cube_cmp_v0(NDBOX *a, NDBOX *b)
Datum cube_dim(PG_FUNCTION_ARGS)
Datum g_cube_union(PG_FUNCTION_ARGS)
Datum cube_in(PG_FUNCTION_ARGS)
Datum cube_enlarge(PG_FUNCTION_ARGS)
Datum cube_c_f8(PG_FUNCTION_ARGS)
Datum g_cube_same(PG_FUNCTION_ARGS)
Datum cube_ur_coord(PG_FUNCTION_ARGS)
Datum g_cube_distance(PG_FUNCTION_ARGS)
Datum cube_contained(PG_FUNCTION_ARGS)
Datum cube_cmp(PG_FUNCTION_ARGS)
Datum cube_a_f8_f8(PG_FUNCTION_ARGS)
Datum g_cube_consistent(PG_FUNCTION_ARGS)
NDBOX * cube_union_v0(NDBOX *a, NDBOX *b)
static double distance_1D(double a1, double a2, double b1, double b2)
Datum cube_size(PG_FUNCTION_ARGS)
Datum cube_recv(PG_FUNCTION_ARGS)
void rt_cube_size(NDBOX *a, double *size)
Datum cube_lt(PG_FUNCTION_ARGS)
Datum cube_contains(PG_FUNCTION_ARGS)
Datum cube_union(PG_FUNCTION_ARGS)
Datum cube_f8_f8(PG_FUNCTION_ARGS)
Datum g_cube_decompress(PG_FUNCTION_ARGS)
Datum cube_f8(PG_FUNCTION_ARGS)
Datum cube_a_f8(PG_FUNCTION_ARGS)
Datum cube_c_f8_f8(PG_FUNCTION_ARGS)
Datum cube_coord_llur(PG_FUNCTION_ARGS)
Datum cube_inter(PG_FUNCTION_ARGS)
Datum g_cube_compress(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(cube_in)
Datum cube_is_point(PG_FUNCTION_ARGS)
bool g_cube_internal_consistent(NDBOX *key, NDBOX *query, StrategyNumber strategy)
NDBOX * g_cube_binary_union(NDBOX *r1, NDBOX *r2, int *sizep)
Datum cube_send(PG_FUNCTION_ARGS)
Datum cube_overlap(PG_FUNCTION_ARGS)
Datum cube_ge(PG_FUNCTION_ARGS)
Datum cube_out(PG_FUNCTION_ARGS)
Datum g_cube_penalty(PG_FUNCTION_ARGS)
Datum cube_ne(PG_FUNCTION_ARGS)
#define SET_DIM(cube, _dim)
void cube_scanner_finish(void)
#define DatumGetNDBOXP(x)
#define LL_COORD(cube, i)
int cube_yyparse(NDBOX **result, Size scanbuflen, struct Node *escontext)
#define CubeKNNDistanceCoord
#define CubeKNNDistanceEuclid
#define PG_RETURN_NDBOX_P(x)
void cube_scanner_init(const char *str, Size *scanbuflen)
#define CubeKNNDistanceTaxicab
#define SET_POINT_BIT(cube)
#define CubeKNNDistanceChebyshev
#define PG_GETARG_NDBOX_P(x)
#define UR_COORD(cube, i)
static void PGresult * res
int errdetail(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
char * float8out_internal(double num)
#define PG_FREE_IF_COPY(ptr, n)
#define PG_RETURN_BYTEA_P(x)
#define DirectFunctionCall2(func, arg1, arg2)
#define PG_GETARG_FLOAT8(n)
#define PG_RETURN_FLOAT8(x)
#define PG_GETARG_POINTER(n)
#define PG_RETURN_CSTRING(x)
#define PG_GETARG_DATUM(n)
#define PG_GETARG_CSTRING(n)
#define PG_GETARG_UINT16(n)
#define PG_RETURN_INT32(x)
#define PG_GETARG_INT32(n)
#define PG_RETURN_DATUM(x)
#define PG_RETURN_POINTER(x)
#define PG_RETURN_BOOL(x)
#define GistPageIsLeaf(page)
#define gistentryinit(e, k, r, pg, o, l)
static const FormData_pg_attribute a1
static const FormData_pg_attribute a2
if(TABLE==NULL||TABLE_index==NULL)
void * palloc0(Size size)
void * repalloc(void *pointer, Size size)
#define OffsetNumberNext(offsetNumber)
#define FirstOffsetNumber
Datum upper(PG_FUNCTION_ARGS)
static Datum PointerGetDatum(const void *X)
static float8 DatumGetFloat8(Datum X)
static pg_noinline void Size size
#define RTOldContainsStrategyNumber
#define RTOverlapStrategyNumber
#define RTSameStrategyNumber
#define RTContainsStrategyNumber
#define RTOldContainedByStrategyNumber
#define RTContainedByStrategyNumber
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
StringInfoData * StringInfo
GISTENTRY vector[FLEXIBLE_ARRAY_MEMBER]
double x[FLEXIBLE_ARRAY_MEMBER]
#define SET_VARSIZE(PTR, len)