First - ObjectVision/GeoDMS GitHub Wiki
Aggregation functions first
- first(a)
- first(a, relation)
- first(a) results in a parameter with the first of the non null values of attribute a.
- first(a, relation) results in an attribute with the first of the non null values of attribute a, grouped by relation. The domain unit of the resulting attribute is the values unit of the relation.
- attribute a with Numeric, Point, string or bool value type
- relation with value type of the group CanBeDomainUnit
- The values unit of the resulting data item should match with regard to value type and metric with the values unit of attribute a.
- The domain of argument a and relation must match.
- Without relation: O(n) where n = number of elements in the domain of a. Scans until first non-null value is found.
- With relation: O(n) where n = number of elements in the domain of a. Tracks first non-null value per group during a single pass.
parameter<uint32> firstNrInh := first(City/NrInhabitants); result = 550
parameter<string> firstCityName := first(City/CityName); result = ‘Amsterdam’
parameter<bool> firstIsCap := first(City/IsCapital); result = True
attribute<uint32> firstNrInhRegion (Region) := first(City/NrInhabitants, City/Region_rel);
attribute<string> firstCityNameRegion (Region) := first(City/CityName, City/Region_rel);
attribute<bool> firstIsCapital (Region) := first(City/IsCapital, City/Region_rel);
| City/NrInhabitants | City/CityName | IsCapital | City/Region_rel |
|---|---|---|---|
| 550 | Amsterdam | True | 0 |
| 525 | Rotterdam | False | 1 |
| 300 | Utrecht | False | 2 |
| 500 | DenHaag | False | 1 |
| 200 | Eindhoven | False | 3 |
| 175 | Haarlem | False | null |
| null | null | False | 3 |
domain City, nr of rows = 7
| firstNrInhRegion | firstCityNameRegion | firstIsCapitalRegion |
|---|---|---|
| 550 | Amsterdam | True |
| 525 | Rotterdam | False |
| 300 | Utrecht | False |
| 200 | Eindhoven | False |
| null | null | False |
domain Region, nr of rows = 5