combine - ObjectVision/GeoDMS GitHub Wiki

Relational functions combine

syntax

  • combine(a, b, ... , n)

definition

combine(a, b, ... , n) results in a uint32 domain unit with the cartesian product of the domain units a, b, ..., n.

The number of elements of the new domain unit is the multiplication of the number of elements of a, b, ..., n.

description

The combine function generates subitems, relations to the individual original domains: first_rel, second_rel, third_rel and so on up to sixteenth_rel, one per argument. In the example first_rel for NHCity and second_rel for YearDomain. The elements are numbered with the last argument varying fastest: element ((a × #B) + b) × #C + c of combine(A, B, C) is the combination of the elements a, b and c.

These data items contain relations to the original domain unit and can be used in a lookup function to relate attributes to the new domain unit, see the example.

N.B. the subitems are attributes over the whole of the new domain unit, so when combining large domains, using them can explode memory usage, even to look up a few elements. It can therefore be useful to use the combine variant that doesn't create the subitems: combine_unit_uint8_16_32_64. Since GeoDMS 20.24.0, for a relation x_rel to the combined unit, use first_rel(x_rel), second_rel(x_rel) and on, or combine_rel(x_rel, position), instead of first_rel[x_rel]: they give the relation to a factor per element of x_rel, without data over the combined unit, and work for the variants without subitems too.

Since GeoDMS 20.24.0 the twelfth subitem is called twelfth_rel. Up to 20.23.1 it was spelled twelveth_rel; a configuration that refers to that name must be changed.

Use the combine_data function to combine values of data items, resulting in a data item with the unit resulting from the combine-function as values unit.

Use a combine_uint8_16_32_64 function to configure a domain unit for another value type.

applies to

  • unit a, b, ..., n with value type from group CanBeDomainUnit

conditions

The combine-functions combine a maximum of sixteen domain units. Use a combine in a combine if more domain units need to be combined.

performance

O(n₁ × n₂ × ... × nₖ) where nᵢ = cardinality of domain i. Creates the full Cartesian product. Warning: Combining large domains quickly explodes memory usage. For example, combining two domains of 10,000 elements each produces 100 million result elements.

example

unit<uint32> NHCityYear := combine(NHCity, YearDomain)
{ 
   attribute<string> NHCity_name := NHCity/name[first_rel];
   attribute<string> Year        := YearDomain/Year[second_rel];
}

see also

⚠️ **GitHub.com Fallback** ⚠️