Skip to content

subindex

Jip Claassens edited this page Aug 11, 2026 · 1 revision

Relational functions subindex

syntax

  • subindex(primary_index, primary_keys_in_index_order, secondary_values)

definition

subindex refines an index: within each run of an equal primary key it re-orders the elements by the secondary values. primary_index is an index attribute (e.g. index(grp)), primary_keys_in_index_order the primary keys looked up through that index (grp[primary_index]), and secondary_values the values to order by within each key run.

example

unit<uint32> D6: nrofrows = 6
{
    attribute<uint32> v   : [30,10,20,5,25,15];
    attribute<uint32> grp : [0,1,0,1,0,1];
}
attribute<uint32> idxg (D6) := index(D6/grp);
attribute<uint32> sub  (D6) := subindex(idxg, D6/grp[idxg], D6/v);

sub results in [2,4,0,3,1,5]: within group 0 the positions ordered by v (20,25,30), then within group 1 (5,10,15).

see also

Clone this wiki locally