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

Function initArrayResultWithSize

src/backend/utils/adt/arrayfuncs.c:5200–5229  ·  view source on GitHub ↗

* initArrayResultWithSize * As initArrayResult, but allow the initial size of the allocated arrays * to be specified. */

Source from the content-addressed store, hash-verified

5198 * to be specified.
5199 */
5200ArrayBuildState *
5201initArrayResultWithSize(Oid element_type, MemoryContext rcontext, bool subcontext, int initsize)
5202{
5203 ArrayBuildState *astate;
5204 MemoryContext arr_context = rcontext;
5205
5206 /* Make a temporary context to hold all the junk */
5207 if (subcontext)
5208 arr_context = AllocSetContextCreate(rcontext,
5209 "accumArrayResult",
5210 ALLOCSET_DEFAULT_SIZES);
5211
5212 astate = (ArrayBuildState *)
5213 MemoryContextAlloc(arr_context, sizeof(ArrayBuildState));
5214 astate->mcontext = arr_context;
5215 astate->private_cxt = subcontext;
5216 astate->alen = initsize;
5217 astate->dvalues = (Datum *)
5218 MemoryContextAlloc(arr_context, astate->alen * sizeof(Datum));
5219 astate->dnulls = (bool *)
5220 MemoryContextAlloc(arr_context, astate->alen * sizeof(bool));
5221 astate->nelems = 0;
5222 astate->element_type = element_type;
5223 get_typlenbyvalalign(element_type,
5224 &astate->typlen,
5225 &astate->typbyval,
5226 &astate->typalign);
5227
5228 return astate;
5229}
5230
5231/*
5232 * accumArrayResult - accumulate one (more) Datum for an array result

Callers 3

initArrayResultFunction · 0.85
array_agg_combineFunction · 0.85
array_agg_deserializeFunction · 0.85

Calls 2

MemoryContextAllocFunction · 0.85
get_typlenbyvalalignFunction · 0.85

Tested by

no test coverage detected