Expand description
Node coordinate store for OSM processing.
Four storage backends are selected based on available RAM and explicit configuration:
-
Dense (mmap): Planetiler’s “ARRAY” strategy — a flat file where node ID is the array index. Each slot stores latitude and longitude as two i32 fixed-point values (1e-7 precision ≈ 1cm), packed into 8 bytes. Used when the store fits in RAM (≤ 105% of physical memory).
-
BufferedFile: A sharded in-memory page cache that buffers writes in 4 KB pages (512 nodes each), flushing to disk viapwritewhen a shard exceeds its page budget. After pass 1 completes,NodeStore::prepare_for_readsflushes all remaining pages and switches to a dense mmap for O(1) reads. Used for planet builds where--node-storeis explicit and the store exceeds the mmap threshold (a planet store of about 100 GB on a machine with less RAM). -
File: Direct random-access I/O via
pread/pwrite— same flat file layout as Dense but without mapping the entire address space. Used when--node-storeis explicitly provided and the file exceeds the mmap threshold (e.g. planet builds on machines where a 97 GB mmap is rejected by the OS). The kernel’s file buffer cache handles paging transparently. -
Sparse (
HashMap): AHashMap<u64, u64>storing packed coordinates. Used for regional extracts where node IDs span a large range but only a small fraction exist. Avoids allocating a 97 GB file for a 200 MB PBF.
§Node Cache
A sidecar .meta.json file records the PBF file size, modification time,
and max node ID used. On subsequent runs, try_open_cached checks the
metadata: if the PBF hasn’t changed, the existing node store is reused.
This avoids re-scanning billions of nodes on re-runs with the same PBF.
Structs§
- Concurrent
Node Writer - A concurrent writer handle for the node store.
- Node
Cache Meta - Sidecar metadata for node cache validation.
- Node
Store - A node coordinate store with automatic backend selection.
Enums§
- Cache
Scope - What a node store was built from.
Functions§
- meta_
path - Derive the sidecar metadata path from a node store path.
- try_
open_ cached - Try to open a cached node store, validating against the current PBF file.
- write_
cache_ meta - Write cache metadata alongside the node store.