28#define ARRPTR(x) ( (double *) ARR_DATA_PTR(x) )
29#define ARRNELEMS(x) ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x))
130 cube_yyparse(&result, scanbuflen, fcinfo->context, scanner);
157 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
158 errmsg(
"cannot work with arrays containing NULLs")));
163 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
164 errmsg(
"can't extend cube"),
165 errdetail(
"A cube cannot have more than %d dimensions.",
170 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
171 errmsg(
"UR and LL arrays must be of same length")));
178 for (
i = 0;
i < dim;
i++)
180 if (dur[
i] != dll[
i])
192 for (
i = 0;
i < dim;
i++)
193 result->
x[
i] = dur[
i];
197 for (
i = 0;
i < dim;
i++)
198 result->
x[
i + dim] = dll[
i];
221 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
222 errmsg(
"cannot work with arrays containing NULLs")));
227 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
228 errmsg(
"array is too long"),
229 errdetail(
"A cube cannot have more than %d dimensions.",
240 for (
i = 0;
i < dim;
i++)
241 result->
x[
i] = dur[
i];
259 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
260 errmsg(
"cannot work with arrays containing NULLs")));
267 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
268 errmsg(
"array is too long"),
269 errdetail(
"A cube cannot have more than %d dimensions.",
280 for (
i = 0;
i < dim;
i++)
282 if ((dx[
i] <= 0) || (dx[
i] >
DIM(
c)))
284 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
285 errmsg(
"Index out of bounds")));
286 result->
x[
i] =
c->x[dx[
i] - 1];
288 result->
x[
i + dim] =
c->x[dx[
i] +
DIM(
c) - 1];
306 for (
i = 0;
i < dim;
i++)
317 for (
i = 0;
i < dim;
i++)
368 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
369 errmsg(
"cube dimension is too large"),
370 errdetail(
"A cube cannot have more than %d dimensions.",
444 for (
i = 1;
i < entryvec->
n;
i++)
503 *result = (float) (tmp1 - tmp2);
545 maxoff = entryvec->
n - 2;
568 size_waste = size_union - size_inter;
574 if (size_waste > waste || firsttime)
623 else if (
i == seed_2)
638 if (size_alpha - size_l < size_beta - size_r)
789 result->
x[
i] =
Min(0,
792 result->
x[
i + dim] =
Max(0,
832 bool swapped =
false;
864 result->
x[
i] =
Max(0,
949 for (
i = 0;
i < dim;
i++)
958 for (
i = 0;
i < dim;
i++)
1001 for (
i = dim;
i <
DIM(
b);
i++)
1132 if ((
a == NULL) || (
b == NULL))
1202 if ((
a == NULL) || (
b == NULL))
1261 bool swapped =
false;
1310 bool swapped =
false;
1354 bool swapped =
false;
1417 bool inverse =
false;
1422 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
1423 errmsg(
"zero cube index is not defined")));
1432 if (coord <= 2 *
DIM(cube))
1435 int index = (coord - 1) / 2;
1438 bool upper = ((coord - 1) % 2 == 1);
1498 elog(
ERROR,
"unrecognized cube strategy number: %d", strategy);
1510 if ((
a1 <= b1) && (
a2 <= b1) && (
a1 <= b2) && (
a2 <= b2))
1514 if ((
a1 > b1) && (
a2 > b1) && (
a1 > b2) && (
a2 > b2))
1548 for (
i = 0;
i <
DIM(cube);
i++)
1575 if (
DIM(
c) >= n && n > 0)
1592 if (
DIM(
c) >= n && n > 0)
1612 if (coord <= 0 || coord > 2 *
DIM(cube))
1614 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
1615 errmsg(
"cube index %d is out of bounds", coord)));
1652 bool inverse =
false;
1658 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
1659 errmsg(
"zero cube index is not defined")));
1668 if (coord <= 2 *
DIM(cube))
1671 int index = (coord - 1) / 2;
1674 bool upper = ((coord - 1) % 2 == 1);
1730 for (
i = 0,
j = dim;
i <
DIM(
a);
i++,
j++)
1742 if (result->
x[
i] > result->
x[
j])
1744 result->
x[
i] = (result->
x[
i] + result->
x[
j]) / 2;
1745 result->
x[
j] = result->
x[
i];
1749 for (;
i < dim;
i++,
j++)
1832 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1833 errmsg(
"can't extend cube"),
1834 errdetail(
"A cube cannot have more than %d dimensions.",
1844 for (
i = 0;
i <
DIM(cube);
i++)
1845 result->
x[
i] = cube->
x[
i];
1846 result->
x[
DIM(result) - 1] =
x;
1854 for (
i = 0;
i <
DIM(cube);
i++)
1856 result->
x[
i] = cube->
x[
i];
1857 result->
x[
DIM(result) +
i] = cube->
x[
DIM(cube) +
i];
1859 result->
x[
DIM(result) - 1] =
x;
1860 result->
x[2 *
DIM(result) - 1] =
x;
1880 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1881 errmsg(
"can't extend cube"),
1882 errdetail(
"A cube cannot have more than %d dimensions.",
1892 for (
i = 0;
i <
DIM(cube);
i++)
1893 result->
x[
i] = cube->
x[
i];
1894 result->
x[
DIM(result) - 1] = x1;
1902 for (
i = 0;
i <
DIM(cube);
i++)
1907 result->
x[
DIM(result) - 1] = x1;
1908 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)
PG_MODULE_MAGIC_EXT(.name="cube",.version=PG_VERSION)
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)
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)
#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)