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

Function array_seek

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

* Advance ptr over nitems array elements * * ptr: starting location in array * offset: 0-based linear element number of first element (the one at *ptr) * nullbitmap: start of array's null bitmap, or NULL if none * nitems: number of array elements to advance over (>= 0) * typlen, typbyval, typalign: storage parameters of array element datatype * * It is caller's responsibility to ensure tha

Source from the content-addressed store, hash-verified

4753 * It is caller's responsibility to ensure that nitems is within range
4754 */
4755static char *
4756array_seek(char *ptr, int offset, bits8 *nullbitmap, int nitems,
4757 int typlen, bool typbyval, char typalign)
4758{
4759 int bitmask;
4760 int i;
4761
4762 /* easy if fixed-size elements and no NULLs */
4763 if (typlen > 0 && !nullbitmap)
4764 return ptr + nitems * ((Size) att_align_nominal(typlen, typalign));
4765
4766 /* seems worth having separate loops for NULL and no-NULLs cases */
4767 if (nullbitmap)
4768 {
4769 nullbitmap += offset / 8;
4770 bitmask = 1 << (offset % 8);
4771
4772 for (i = 0; i < nitems; i++)
4773 {
4774 if (*nullbitmap & bitmask)
4775 {
4776 ptr = att_addlength_pointer(ptr, typlen, ptr);
4777 ptr = (char *) att_align_nominal(ptr, typalign);
4778 }
4779 bitmask <<= 1;
4780 if (bitmask == 0x100 /* (1<<8) */)
4781 {
4782 nullbitmap++;
4783 bitmask = 1;
4784 }
4785 }
4786 }
4787 else
4788 {
4789 for (i = 0; i < nitems; i++)
4790 {
4791 ptr = att_addlength_pointer(ptr, typlen, ptr);
4792 ptr = (char *) att_align_nominal(ptr, typalign);
4793 }
4794 }
4795 return ptr;
4796}
4797
4798/*
4799 * Compute total size of the nitems array elements starting at *ptr

Callers 6

array_get_elementFunction · 0.85
array_set_elementFunction · 0.85
array_nelems_sizeFunction · 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