Index

relational-functions index

syntax

  • index(a)

definition

index(a) results in an index attribute based on the sort order of the values in attribute a.

If two values are identical in attribute a, the first occurring value receives the lowest index number.

applies to

  • attribute a with Numeric, Point, uint2, uint4, bool or string value-type

examples

1. defining the index

attribute<Region> indexTemp (Region) := index(Temperature);
Temperature indexTemp
12 2
11 5
null 1
11 3
14 0
null 4
14 6

domain Region, nr of rows = 7

2. using the index to sort an attribute:

attribute<degrees> Temperature_sorted (Region) := Temperature[indexTemp];
Temperature indexTemp Temperature_sorted
12 2 null
11 5 null
null 1 11
11 3 11
14 0 12
null 4 14
14 6 14

domain Region, nr of rows = 7

3. using index and unique to make a new sorted domain:

unit<uint32> Region: nrofrows = 7
{
   attribute<degrees> Temperature :[12,11,null,11,14,null,14];
   attribute<.>       indexTemp   := index(Temperature);
}

unit<uint32> Region_sorted := unique(Region/indexTemp)
{
   attribute<float32> Temperature := (Region/Temperature[Region/indexTemp])[values];
}
Values Temperature
0 null
1 null
2 11
3 11
4 12
5 14
9 14

domain Region_sorted, nr of rows = 7