/ Sort and return the sort index. */ Note: This is meant if the array contains unique values. */ Returns Index.Memp if Ok or NULL in case of error. */ /
| 790 | /* Returns Index.Memp if Ok or NULL in case of error. */ |
| 791 | /***********************************************************************/ |
| 792 | void *ARRAY::GetSortIndex(PGLOBAL g) |
| 793 | { |
| 794 | // Prepare non conservative sort with offet values |
| 795 | Index.Size = Nval * sizeof(int); |
| 796 | |
| 797 | if (!PlgDBalloc(g, NULL, Index)) |
| 798 | goto error; |
| 799 | |
| 800 | Offset.Size = (Nval + 1) * sizeof(int); |
| 801 | |
| 802 | if (!PlgDBalloc(g, NULL, Offset)) |
| 803 | goto error; |
| 804 | |
| 805 | // Call the sort program, it returns the number of distinct values |
| 806 | Ndif = Qsort(g, Nval); |
| 807 | |
| 808 | if (Ndif < 0) |
| 809 | goto error; |
| 810 | |
| 811 | if (Ndif < Nval) |
| 812 | goto error; |
| 813 | |
| 814 | PlgDBfree(Offset); |
| 815 | return Index.Memp; |
| 816 | |
| 817 | error: |
| 818 | Nval = Ndif = 0; |
| 819 | Valblk->Free(); |
| 820 | PlgDBfree(Index); |
| 821 | PlgDBfree(Offset); |
| 822 | return NULL; |
| 823 | } // end of GetSortIndex |
| 824 | |
| 825 | /***********************************************************************/ |
| 826 | /* Block filter testing for IN operator on Column/Array operands. */ |
no test coverage detected