STEPPED( index, fields [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] )
index | The INDEX to sort. This can be filtered or the result of a PROJECT on an INDEX. |
fields | A comma-delimited list of fields by which to sort the result, typically trailing elements in the key. |
UNORDERED | Optional. Specifies the output record order is not significant. |
ORDERED | Specifies the significance of the output record order. |
bool | When False, specifies the output record order is not significant. When True, specifies the default output record order. |
STABLE | Optional. Specifies the input record order is significant. |
UNSTABLE | Optional. Specifies the input record order is not significant. |
PARALLEL | Optional. Try to evaluate this activity in parallel. |
numthreads | Optional. Try to evaluate this activity using numthreads threads. |
ALGORITHM | Optional. Override the algorithm used for this activity. |
name | The algorithm to use for this activity. Must be from the list of supported algorithms for the SORT function's STABLE and UNSTABLE options. |
The STEPPED function sorts the index by the specified fields. This function is used in those cases where the SORTED(index) function will not suffice.
There are some restrictions in its use:
The key fields before ordered fields should be reasonably well filtered, otherwise the sorting could become very memory intensive.
Roxie only supports sorting by trailing components on indexes that are read locally (single part indexes or superkeys containing single part indexes), or NOROOT indexes read within ALLNODES.
Thor does not support STEPPED.
Example:
DataFile := '~RTTEST::TestStepped';
KeyFile := '~RTTEST::TestSteppedKey';
Rec := RECORD
STRING2 state;
STRING20 city;
STRING25 lname;
STRING15 fname;
END;
ds := DATASET(DataFile,s
{Rec,UNSIGNED8 RecPos {VIRTUAL(fileposition)}},
THOR);
IDX := INDEX(ds,{state,city,lname,fname,RecPos},KeyFile);
OUTPUT(IDX(state IN ['FL','PA']));
/* where this OUTPUT produces this result:
FL BOCA RATON WIK PICHA
FL DELAND WIKER OKE
FL GAINESVILLE WIK MACHOUSTON
PA NEW STANTON WIKER DESSIE */
OUTPUT(STEPPED(IDX(state IN ['FL','PA']),fname));
/* this STEPPED OUTPUT produces this result:
PA NEW STANTON WIKER DESSIE
FL GAINESVILLE WIK MACHOUSTON
FL DELAND WIKER OKE
FL BOCA RATON WIK PICHA */