/** * @file Reads the WOF adapters' records from the WOF record store, in WOF-id order, with each record's * ancestors resolved by primary-key lookup. * * The adapters used to hold every record of the input in one map so that any record's ancestors could * be found. That map peaked at 14,883 MiB for `wof-admin` and `wof-postalcode` together. A record and its * ancestors are now read from the store as they are needed. The ancestors that recur, the counties, * regions and countries, stay in a bounded cache. */ import { type WOFRepoRefresh } from "@mailwoman/gazetteer/whosonfirst/record-store"; import type { WOFRecordEntry } from "#adapters/wof/json-rows"; import type { AdapterOptions } from "#types"; import { type WOFRecord } from "#utils/wof-json"; /** * Options for {@linkcode openStoredRecordEntries}. */ export interface StoredRecordEntriesOptions { /** * Whether a parsed record belongs to the reader's index: a record it renders, * or one an ancestor walk may reach. * * The adapter's `--country` filter applies on top. */ keep: (record: WOFRecord) => boolean; /** * Whether a kept record is rendered. * * A record that's only an ancestor, such as an admin record read by `wof-postalcode`, * is kept and not rendered. */ render?: (record: WOFRecord) => boolean; /** * The ancestors a rendered record's variants read, from a lookup that returns kept records only. */ resolve: (record: WOFRecord, lookup: (id: number) => WOFRecord | undefined) => A; onRepo?: (refresh: WOFRepoRefresh) => void; } /** * Opened entries over the store, and the handle that closes it. */ export interface StoredRecordEntries extends Disposable { entries: Iterable>; /** * Every kept record of the given placetypes in ascending WOF-id order, with the stored feature's * properties, read in a pass of its own before or after {@linkcode StoredRecordEntries.entries}. * * The properties hold what a record omits, such as the point, bounding box and population. */ scan: (placetypes: readonly string[]) => Iterable<{ record: WOFRecord; properties: Record; }>; } /** * Refreshes the store for `opts.inputPath`, then returns the rendered records in ascending WOF-id order. * * A record is kept, rendered and resolved exactly as the in-memory index read it: * parsed by {@linkcode recordFromFeature}, filtered by `keep` and the country, * with ancestors found among kept records of the same repositories. */ export declare function openStoredRecordEntries(opts: AdapterOptions, reader: StoredRecordEntriesOptions): Promise>; //# sourceMappingURL=stored-records.d.ts.map