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

Function ArrayGetOffset

src/backend/utils/adt/arrayutils.c:31–44  ·  view source on GitHub ↗

* Convert subscript list into linear element number (from 0) * * We assume caller has already range-checked the dimensions and subscripts, * so no overflow is possible. */

Source from the content-addressed store, hash-verified

29 * so no overflow is possible.
30 */
31int
32ArrayGetOffset(int n, const int *dim, const int *lb, const int *indx)
33{
34 int i,
35 scale = 1,
36 offset = 0;
37
38 for (i = n - 1; i >= 0; i--)
39 {
40 offset += (indx[i] - lb[i]) * scale;
41 scale *= dim[i];
42 }
43 return offset;
44}
45
46/*
47 * Same, but subscripts are assumed 0-based, and use a scale array

Callers 7

array_get_elementFunction · 0.85
array_set_elementFunction · 0.85
array_slice_sizeFunction · 0.85
array_extract_sliceFunction · 0.85
array_insert_sliceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected