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

Function mda_next_tuple

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

* Generates the tuple that is lexicographically one greater than the current * n-tuple in "curr", with the restriction that the i-th element of "curr" is * less than the i-th element of "span". * * Returns -1 if no next tuple exists, else the subscript position (0..n-1) * corresponding to the dimension to advance along. * * We assume caller has validated dimensions, so overflow is impossibl

Source from the content-addressed store, hash-verified

197 * We assume caller has validated dimensions, so overflow is impossible
198 */
199int
200mda_next_tuple(int n, int *curr, const int *span)
201{
202 int i;
203
204 if (n <= 0)
205 return -1;
206
207 curr[n - 1] = (curr[n - 1] + 1) % span[n - 1];
208 for (i = n - 1; i && curr[i] == 0; i--)
209 curr[i - 1] = (curr[i - 1] + 1) % span[i - 1];
210
211 if (i)
212 return i;
213 if (curr[0])
214 return 0;
215
216 return -1;
217}
218
219/*
220 * ArrayGetIntegerTypmods: verify that argument is a 1-D cstring array,

Callers 3

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