ores.geo.ip2country

Table of Contents

An IPv4 address range and the country code it resolves to, one row per range per tenant. The ranges are found by containment – ip_range @> address – so the range is the key and the index over it is a GiST index; a btree cannot answer a containment test.

The store holds no history. A publish truncates it and loads the ranges the dataset carries, because ip2country reissues its whole table rather than amending rows.

1. Flags

2. Columns

2.1. ip_range

The addresses this row covers, as the integers IPv4 addresses are counted in.

The range is half-open: it covers its lower bound and not its upper, so the publish function makes it from the first address and the last address plus one. Ranges that touch share a boundary rather than overlapping.

2.2. country_code

The ISO 3166-1 alpha-2 country the addresses in this range belong to.

3. Artefact columns

The dataset states a range by its first and last address rather than by the range itself, so the staging row carries the two ends and the publish function makes the range.

3.1. range_start

3.2. range_end

3.3. country_code

4. Artefact indexes

4.1. range

5. SQL

5.1. Flags

5.2. Indexes

The tenant index is declared here rather than left to the template: a current-state entity whose tenant is not in its key emits no tenant index of its own, and the lookup filters by tenant on every call.

name columns unique current_only where_extra using
range ip_range false false   gist
tenant tenant_id false false    

6. C++

6.1. Flags

ores.geo keeps its headers at its own include root, so there is no directory between the component and domain/ for this model to name. The flag is stated even though sql-only-store withdraws the C++ space, because it describes the component rather than the surface.

7. Notes

Bound to SQL-only store (alongside its shape profile): the only reader of this table is ores_geo_ip2country_lookup_fn, which answers in SQL, so the model generates the schema and no client surface. Its key is an int8range, which no C++ type maps, so a domain class could not be generated for it in any case.

The range index is one of the few indexes in the tree that is not a btree.

8. See also

Emacs 29.3 (Org mode 9.6.15)