MCPcopy Create free account
hub / github.com/MariaDB/server / GetSortIndex

Method GetSortIndex

storage/connect/array.cpp:792–823  ·  view source on GitHub ↗

/ 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. */ /

Source from the content-addressed store, hash-verified

790/* Returns Index.Memp if Ok or NULL in case of error. */
791/***********************************************************************/
792void *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. */

Callers 2

UpdateSortedRowsMethod · 0.80
DeleteSortedRowsMethod · 0.80

Calls 3

PlgDBallocFunction · 0.85
PlgDBfreeFunction · 0.85
FreeMethod · 0.80

Tested by

no test coverage detected