* 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 */
| 649 | * an array containing the aggregated histogram bounds |
| 650 | */ |
| 651 | static Datum * |
| 652 | buildHistogramEntryForStats(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 | /* |
no test coverage detected