MCPcopy Create free account
hub / github.com/apache/cloudberry / cube_a_f8

Function cube_a_f8

contrib/cube/cube.c:204–239  ·  view source on GitHub ↗

** Allows the construction of a zero-volume cube from a float[] */

Source from the content-addressed store, hash-verified

202** Allows the construction of a zero-volume cube from a float[]
203*/
204Datum
205cube_a_f8(PG_FUNCTION_ARGS)
206{
207 ArrayType *ur = PG_GETARG_ARRAYTYPE_P(0);
208 NDBOX *result;
209 int i;
210 int dim;
211 int size;
212 double *dur;
213
214 if (array_contains_nulls(ur))
215 ereport(ERROR,
216 (errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
217 errmsg("cannot work with arrays containing NULLs")));
218
219 dim = ARRNELEMS(ur);
220 if (dim > CUBE_MAX_DIM)
221 ereport(ERROR,
222 (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
223 errmsg("array is too long"),
224 errdetail("A cube cannot have more than %d dimensions.",
225 CUBE_MAX_DIM)));
226
227 dur = ARRPTR(ur);
228
229 size = POINT_SIZE(dim);
230 result = (NDBOX *) palloc0(size);
231 SET_VARSIZE(result, size);
232 SET_DIM(result, dim);
233 SET_POINT_BIT(result);
234
235 for (i = 0; i < dim; i++)
236 result->x[i] = dur[i];
237
238 PG_RETURN_NDBOX_P(result);
239}
240
241Datum
242cube_subset(PG_FUNCTION_ARGS)

Callers

nothing calls this directly

Calls 5

array_contains_nullsFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50
errdetailFunction · 0.50
palloc0Function · 0.50

Tested by

no test coverage detected