transitio.index.read_index

Contents

transitio.index.read_index#

transitio.index.read_index(path, *, country=None)#

Read the index at path, or raise if it is unsupported or corrupt.

A schema-7 index is a directory of partitions: without country every partition is read and joined into the flat feeds, places and edges tables (the cross-border edges included, so nothing a flat index carried is lost), and the links table is kept beside them; with country the result holds that partition’s feeds, places and domestic edges, and the links whose place lies in it. country is refused for an older schema. A schema-8 index also carries its GTFS-RT companions in realtime (joined, or the country’s own). A schema-12 index keeps place boundaries and the edges’ evidence, selectors and curation in on-demand tables: only the core tables are read here, and a partition’s on-demand ones when first needed (Place.geometry, area(), an edge’s evidence or selector); check_index() reads them all.

pandas (and its pyarrow Parquet engine, a required dependency) reads feeds.parquet. The manifest is read first, so an incompatible snapshot is refused before the larger file is touched, and the Parquet’s bytes are checked against the feeds_sha256 the manifest records. That match proves the Parquet and manifest are the paired halves of one build — not that the build is authentic; refresh() additionally checks a downloaded archive against the digest its release manifest declares. Each file is read as a size-bounded regular file, so a symlinked or over-large one is refused rather than followed. The manifest’s snapshot_id and the Parquet’s columns are checked against the schema version, so a structurally wrong but correctly-hashed index is refused rather than misread downstream.