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

Function cmp_orderbyvals

src/backend/executor/nodeIndexscan.c:408–438  ·  view source on GitHub ↗

* Compare ORDER BY expression values. */

Source from the content-addressed store, hash-verified

406 * Compare ORDER BY expression values.
407 */
408static int
409cmp_orderbyvals(const Datum *adist, const bool *anulls,
410 const Datum *bdist, const bool *bnulls,
411 IndexScanState *node)
412{
413 int i;
414 int result;
415
416 for (i = 0; i < node->iss_NumOrderByKeys; i++)
417 {
418 SortSupport ssup = &node->iss_SortSupport[i];
419
420 /*
421 * Handle nulls. We only need to support NULLS LAST ordering, because
422 * match_pathkeys_to_index() doesn't consider indexorderby
423 * implementation otherwise.
424 */
425 if (anulls[i] && !bnulls[i])
426 return 1;
427 else if (!anulls[i] && bnulls[i])
428 return -1;
429 else if (anulls[i] && bnulls[i])
430 return 0;
431
432 result = ssup->comparator(adist[i], bdist[i], ssup);
433 if (result != 0)
434 return result;
435 }
436
437 return 0;
438}
439
440/*
441 * Pairing heap provides getting topmost (greatest) element while KNN provides

Callers 2

IndexNextWithReorderFunction · 0.85
reorderqueue_cmpFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected