25#define ARRPTR(x) ( (double *) ARR_DATA_PTR(x) )
26#define ARRNELEMS(x) ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x))
127 cube_yyparse(&result, scanbuflen, fcinfo->context, scanner);
154 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
155 errmsg(
"cannot work with arrays containing NULLs")));
160 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
161 errmsg(
"can't extend cube"),
162 errdetail(
"A cube cannot have more than %d dimensions.",
167 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
168 errmsg(
"UR and LL arrays must be of same length")));
175 for (
i = 0;
i < dim;
i++)
177 if (dur[
i] != dll[
i])
189 for (
i = 0;
i < dim;
i++)
190 result->
x[
i] = dur[
i];
194 for (
i = 0;
i < dim;
i++)
195 result->
x[
i + dim] = dll[
i];
218 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
219 errmsg(
"cannot work with arrays containing NULLs")));
224 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
225 errmsg(
"array is too long"),
226 errdetail(
"A cube cannot have more than %d dimensions.",
237 for (
i = 0;
i < dim;
i++)
238 result->
x[
i] = dur[
i];
256 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
257 errmsg(
"cannot work with arrays containing NULLs")));
264 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
265 errmsg(
"array is too long"),
266 errdetail(
"A cube cannot have more than %d dimensions.",
277 for (
i = 0;
i < dim;
i++)
279 if ((dx[
i] <= 0) || (dx[
i] >
DIM(
c)))
281 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
282 errmsg(
"Index out of bounds")));
283 result->
x[
i] =
c->x[dx[
i] - 1];
285 result->
x[
i + dim] =
c->x[dx[
i] +
DIM(
c) - 1];
303 for (
i = 0;
i < dim;
i++)
314 for (
i = 0;
i < dim;
i++)
365 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
366 errmsg(
"cube dimension is too large"),
367 errdetail(
"A cube cannot have more than %d dimensions.",
441 for (
i = 1;
i < entryvec->
n;
i++)
500 *result = (float) (tmp1 - tmp2);
542 maxoff = entryvec->
n - 2;
565 size_waste = size_union - size_inter;
571 if (size_waste > waste || firsttime)
620 else if (
i == seed_2)
635 if (size_alpha - size_l < size_beta - size_r)
786 result->
x[
i] =
Min(0,
789 result->
x[
i + dim] =
Max(0,
829 bool swapped =
false;
861 result->
x[
i] =
Max(0,
946 for (
i = 0;
i < dim;
i++)
955 for (
i = 0;
i < dim;
i++)
1129 if ((
a == NULL) || (
b == NULL))
1199 if ((
a == NULL) || (
b == NULL))
1258 bool swapped =
false;
1307 bool swapped =
false;
1351 bool swapped =
false;
1414 bool inverse =
false;
1419 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
1420 errmsg(
"zero cube index is not defined")));
1429 if (coord <= 2 *
DIM(cube))
1432 int index = (coord - 1) / 2;
1435 bool upper = ((coord - 1) % 2 == 1);
1495 elog(
ERROR,
"unrecognized cube strategy number: %d", strategy);
1507 if ((
a1 <= b1) && (
a2 <= b1) && (
a1 <= b2) && (
a2 <= b2))
1511 if ((
a1 > b1) && (
a2 > b1) && (
a1 > b2) && (
a2 > b2))
1545 for (
i = 0;
i <
DIM(cube);
i++)
1572 if (
DIM(
c) >= n && n > 0)
1589 if (
DIM(
c) >= n && n > 0)
1609 if (coord <= 0 || coord > 2 *
DIM(cube))
1611 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
1612 errmsg(
"cube index %d is out of bounds", coord)));
1649 bool inverse =
false;
1655 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
1656 errmsg(
"zero cube index is not defined")));
1665 if (coord <= 2 *
DIM(cube))
1668 int index = (coord - 1) / 2;
1671 bool upper = ((coord - 1) % 2 == 1);
1727 for (
i = 0,
j = dim;
i <
DIM(
a);
i++,
j++)
1739 if (result->
x[
i] > result->
x[
j])
1741 result->
x[
i] = (result->
x[
i] + result->
x[
j]) / 2;
1742 result->
x[
j] = result->
x[
i];
1746 for (;
i < dim;
i++,
j++)
1829 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1830 errmsg(
"can't extend cube"),
1831 errdetail(
"A cube cannot have more than %d dimensions.",
1841 for (
i = 0;
i <
DIM(cube);
i++)
1842 result->
x[
i] = cube->
x[
i];
1843 result->
x[
DIM(result) - 1] =
x;
1851 for (
i = 0;
i <
DIM(cube);
i++)
1853 result->
x[
i] = cube->
x[
i];
1854 result->
x[
DIM(result) +
i] = cube->
x[
DIM(cube) +
i];
1856 result->
x[
DIM(result) - 1] =
x;
1857 result->
x[2 *
DIM(result) - 1] =
x;
1877 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1878 errmsg(
"can't extend cube"),
1879 errdetail(
"A cube cannot have more than %d dimensions.",
1889 for (
i = 0;
i <
DIM(cube);
i++)
1890 result->
x[
i] = cube->
x[
i];
1891 result->
x[
DIM(result) - 1] = x1;
1899 for (
i = 0;
i <
DIM(cube);
i++)
1904 result->
x[
DIM(result) - 1] = x1;
1905 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)
int cube_yyparse(NDBOX **result, Size scanbuflen, struct Node *escontext, yyscan_t yyscanner)
#define SET_DIM(cube, _dim)
void cube_scanner_init(const char *str, Size *scanbuflen, yyscan_t *yyscannerp)
#define DatumGetNDBOXP(x)
#define LL_COORD(cube, i)
#define CubeKNNDistanceCoord
void cube_scanner_finish(yyscan_t yyscanner)
#define CubeKNNDistanceEuclid
#define PG_RETURN_NDBOX_P(x)
#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 * repalloc(void *pointer, Size size)
void * palloc0(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)