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

Function buildHistogramEntryForStats

src/backend/commands/analyzeutils.c:651–682  ·  view source on GitHub ↗

* Preparing the output array of histogram bounds, removing any duplicates * Input: * ldatum - list of pointers to the aggregated bounds, may contain duplicates * typInfo - type information * Output: * an array containing the aggregated histogram bounds */

Source from the content-addressed store, hash-verified

649 * an array containing the aggregated histogram bounds
650 */
651static Datum *
652buildHistogramEntryForStats(List *ldatum, TypInfo *typInfo, int *num_hist)
653{
654 Assert(ldatum);
655 Assert(typInfo);
656
657 Datum *histArray = (Datum *) palloc(sizeof(Datum) * list_length(ldatum));
658
659 ListCell *lc;
660 Datum *prevDatum = (Datum *) linitial(ldatum);
661 int idx = 0;
662
663 *num_hist = 0;
664
665 foreach_with_count(lc, ldatum, idx)
666 {
667 Datum *pdatum = (Datum *) lfirst(lc);
668
669 /* remove duplicate datum in the list, starting from the second datum */
670 if (OidFunctionCall2Coll(typInfo->eqFuncOp, typInfo->collid,
671 *pdatum, *prevDatum) && idx > 0)
672 {
673 continue;
674 }
675
676 histArray[*num_hist] = *pdatum;
677 *num_hist = *num_hist + 1;
678 *prevDatum = *pdatum;
679 }
680
681 return histArray;
682}
683
684
685/*

Callers 1

Calls 4

list_lengthFunction · 0.85
foreach_with_countFunction · 0.85
OidFunctionCall2CollFunction · 0.85
pallocFunction · 0.50

Tested by

no test coverage detected