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

Function ExecIndexAdvanceArrayKeys

src/backend/executor/nodeIndexscan.c:742–780  ·  view source on GitHub ↗

* ExecIndexAdvanceArrayKeys * Advance to the next set of array key values, if any. * * Returns true if there is another set of values to consider, false if not. * On true result, the scankeys are initialized with the next set of values. */

Source from the content-addressed store, hash-verified

740 * On true result, the scankeys are initialized with the next set of values.
741 */
742bool
743ExecIndexAdvanceArrayKeys(IndexArrayKeyInfo *arrayKeys, int numArrayKeys)
744{
745 bool found = false;
746 int j;
747
748 /*
749 * Note we advance the rightmost array key most quickly, since it will
750 * correspond to the lowest-order index column among the available
751 * qualifications. This is hypothesized to result in better locality of
752 * access in the index.
753 */
754 for (j = numArrayKeys - 1; j >= 0; j--)
755 {
756 ScanKey scan_key = arrayKeys[j].scan_key;
757 int next_elem = arrayKeys[j].next_elem;
758 int num_elems = arrayKeys[j].num_elems;
759 Datum *elem_values = arrayKeys[j].elem_values;
760 bool *elem_nulls = arrayKeys[j].elem_nulls;
761
762 if (next_elem >= num_elems)
763 {
764 next_elem = 0;
765 found = false; /* need to advance next array key */
766 }
767 else
768 found = true;
769 scan_key->sk_argument = elem_values[next_elem];
770 if (elem_nulls[next_elem])
771 scan_key->sk_flags |= SK_ISNULL;
772 else
773 scan_key->sk_flags &= ~SK_ISNULL;
774 arrayKeys[j].next_elem = next_elem + 1;
775 if (found)
776 break;
777 }
778
779 return found;
780}
781
782
783/* ----------------------------------------------------------------

Callers 1

MultiExecBitmapIndexScanFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected