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

Function array_insert_slice

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

* Insert a slice into an array. * * ndim/dim[]/lb[] are dimensions of the original array. A new array with * those same dimensions is to be constructed. destArray must already * have been allocated and its header initialized. * * st[]/endp[] identify the slice to be replaced. Elements within the slice * volume are taken from consecutive elements of the srcArray; elements * outside it ar

Source from the content-addressed store, hash-verified

5057 * We assume the caller has verified that the slice coordinates are valid.
5058 */
5059static void
5060array_insert_slice(ArrayType *destArray,
5061 ArrayType *origArray,
5062 ArrayType *srcArray,
5063 int ndim,
5064 int *dim,
5065 int *lb,
5066 int *st,
5067 int *endp,
5068 int typlen,
5069 bool typbyval,
5070 char typalign)
5071{
5072 char *destPtr = ARR_DATA_PTR(destArray);
5073 char *origPtr = ARR_DATA_PTR(origArray);
5074 char *srcPtr = ARR_DATA_PTR(srcArray);
5075 bits8 *destBitmap = ARR_NULLBITMAP(destArray);
5076 bits8 *origBitmap = ARR_NULLBITMAP(origArray);
5077 bits8 *srcBitmap = ARR_NULLBITMAP(srcArray);
5078 int orignitems = ArrayGetNItems(ARR_NDIM(origArray),
5079 ARR_DIMS(origArray));
5080 int dest_offset,
5081 orig_offset,
5082 src_offset,
5083 prod[MAXDIM],
5084 span[MAXDIM],
5085 dist[MAXDIM],
5086 indx[MAXDIM];
5087 int i,
5088 j,
5089 inc;
5090
5091 dest_offset = ArrayGetOffset(ndim, dim, lb, st);
5092 /* copy items before the slice start */
5093 inc = array_copy(destPtr, dest_offset,
5094 origPtr, 0, origBitmap,
5095 typlen, typbyval, typalign);
5096 destPtr += inc;
5097 origPtr += inc;
5098 if (destBitmap)
5099 array_bitmap_copy(destBitmap, 0, origBitmap, 0, dest_offset);
5100 orig_offset = dest_offset;
5101 mda_get_prod(ndim, dim, prod);
5102 mda_get_range(ndim, span, st, endp);
5103 mda_get_offset_values(ndim, dist, prod, span);
5104 for (i = 0; i < ndim; i++)
5105 indx[i] = 0;
5106 src_offset = 0;
5107 j = ndim - 1;
5108 do
5109 {
5110 /* Copy/advance over elements between here and next part of slice */
5111 if (dist[j])
5112 {
5113 inc = array_copy(destPtr, dist[j],
5114 origPtr, orig_offset, origBitmap,
5115 typlen, typbyval, typalign);
5116 destPtr += inc;

Callers 1

array_set_sliceFunction · 0.85

Calls 9

ArrayGetNItemsFunction · 0.85
ArrayGetOffsetFunction · 0.85
array_copyFunction · 0.85
array_bitmap_copyFunction · 0.85
mda_get_prodFunction · 0.85
mda_get_rangeFunction · 0.85
mda_get_offset_valuesFunction · 0.85
array_seekFunction · 0.85
mda_next_tupleFunction · 0.85

Tested by

no test coverage detected