@mailwoman/resolver-wof-sqlite 5.4.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -48,6 +48,15 @@ export declare function discoverAdminDataRoots(reposRoot: string): string[];
|
|
|
48
48
|
* Insert missing ancestor rows for only-self places by reading `wof:hierarchy` from their source geojson under
|
|
49
49
|
* `geojsonRoots` (see {@link discoverAdminDataRoots}). Runs inside a single transaction; caller owns connection
|
|
50
50
|
* lifecycle (open, WAL checkpoint, close).
|
|
51
|
+
*
|
|
52
|
+
* `opts.maxId` bounds the candidate scan to ids BELOW it — pass the synthetic-id base (`OVERTURE_ID_BASE`, 8e12) so the
|
|
53
|
+
* backfill considers only real WOF places. Overture/GeoNames rows carry synthetic ids and have NO `wof:hierarchy`
|
|
54
|
+
* geojson, so probing them is pure waste: on a wide-coverage DB the only-self set is millions of Overture/GeoNames leaf
|
|
55
|
+
* localities, and the per-candidate geojson probe across every repo root turns a seconds-long WOF-only pass into a
|
|
56
|
+
* ~40-minute one (their ancestry comes from the parent_id closure, not this backfill). Correctness-preserving — the
|
|
57
|
+
* skipped rows would have `noGeojson`-skipped anyway. Omit `maxId` (default) for the legacy WOF-only DBs.
|
|
51
58
|
*/
|
|
52
|
-
export declare function backfillAncestorsFromHierarchy(db: DatabaseSync, geojsonRoots: readonly string[]
|
|
59
|
+
export declare function backfillAncestorsFromHierarchy(db: DatabaseSync, geojsonRoots: readonly string[], opts?: {
|
|
60
|
+
maxId?: number;
|
|
61
|
+
}): AncestryBackfillResult;
|
|
53
62
|
//# sourceMappingURL=ancestry-backfill.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ancestry-backfill.d.ts","sourceRoot":"","sources":["../ancestry-backfill.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAK/C,MAAM,WAAW,sBAAsB;IACtC,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAA;IACnB,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAA;IACjB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAA;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CA8BlE;AAmCD
|
|
1
|
+
{"version":3,"file":"ancestry-backfill.d.ts","sourceRoot":"","sources":["../ancestry-backfill.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAK/C,MAAM,WAAW,sBAAsB;IACtC,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAA;IACnB,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAA;IACjB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAA;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CA8BlE;AAmCD;;;;;;;;;;;GAWG;AACH,wBAAgB,8BAA8B,CAC7C,EAAE,EAAE,YAAY,EAChB,YAAY,EAAE,SAAS,MAAM,EAAE,EAC/B,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC3B,sBAAsB,CAgExB"}
|
package/out/ancestry-backfill.js
CHANGED
|
@@ -95,12 +95,21 @@ function placetypeFromKey(key) {
|
|
|
95
95
|
* Insert missing ancestor rows for only-self places by reading `wof:hierarchy` from their source geojson under
|
|
96
96
|
* `geojsonRoots` (see {@link discoverAdminDataRoots}). Runs inside a single transaction; caller owns connection
|
|
97
97
|
* lifecycle (open, WAL checkpoint, close).
|
|
98
|
+
*
|
|
99
|
+
* `opts.maxId` bounds the candidate scan to ids BELOW it — pass the synthetic-id base (`OVERTURE_ID_BASE`, 8e12) so the
|
|
100
|
+
* backfill considers only real WOF places. Overture/GeoNames rows carry synthetic ids and have NO `wof:hierarchy`
|
|
101
|
+
* geojson, so probing them is pure waste: on a wide-coverage DB the only-self set is millions of Overture/GeoNames leaf
|
|
102
|
+
* localities, and the per-candidate geojson probe across every repo root turns a seconds-long WOF-only pass into a
|
|
103
|
+
* ~40-minute one (their ancestry comes from the parent_id closure, not this backfill). Correctness-preserving — the
|
|
104
|
+
* skipped rows would have `noGeojson`-skipped anyway. Omit `maxId` (default) for the legacy WOF-only DBs.
|
|
98
105
|
*/
|
|
99
|
-
export function backfillAncestorsFromHierarchy(db, geojsonRoots) {
|
|
106
|
+
export function backfillAncestorsFromHierarchy(db, geojsonRoots, opts = {}) {
|
|
107
|
+
const maxId = opts.maxId ?? Number.MAX_SAFE_INTEGER;
|
|
108
|
+
// `s.id < ?` first lets SQLite prune by the PK index before the correlated only-self subquery runs at all.
|
|
100
109
|
const candidates = db
|
|
101
110
|
.prepare(`SELECT s.id AS id, s.placetype AS placetype FROM spr s
|
|
102
|
-
WHERE (SELECT count(*) FROM ancestors a WHERE a.id = s.id) <= 1`)
|
|
103
|
-
.all();
|
|
111
|
+
WHERE s.id < ? AND (SELECT count(*) FROM ancestors a WHERE a.id = s.id) <= 1`)
|
|
112
|
+
.all(maxId);
|
|
104
113
|
const insert = db.prepare("INSERT INTO ancestors (id, ancestor_id, ancestor_placetype, lastmodified) VALUES (?, ?, ?, 0)");
|
|
105
114
|
const hasRow = db.prepare("SELECT 1 FROM ancestors WHERE id = ? AND ancestor_id = ? LIMIT 1");
|
|
106
115
|
let placesFixed = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ancestry-backfill.js","sourceRoot":"","sources":["../ancestry-backfill.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC/D,OAAO,EAAE,IAAI,EA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IAAI,CAAC,EAAE;oBAAE,SAAQ;gBACjB,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;gBAEvB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,KAAK,EAAE;oBAAE,SAAQ;gBAE7D,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;oBAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;YACtC,CAAC;QACF,CAAC;QAED,IAAI,KAAK,GAAG,CAAC,CAAA;QAEb,KAAK,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;YAC9B,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC;gBAAE,SAAQ;YACjC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAA;YACvB,KAAK,EAAE,CAAA;QACR,CAAC;QAED,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;YACf,WAAW,EAAE,CAAA;YACb,SAAS,IAAI,KAAK,CAAA;QACnB,CAAC;IACF,CAAC;IAED,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAEjB,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,CAAA;AAC7C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailwoman/resolver-wof-sqlite",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0",
|
|
4
4
|
"description": "Who's On First SQLite resolver — FTS5-backed PlaceLookup that resolves text queries to WOF place IDs + coordinates. Optional dependency for callers who want geocoding.",
|
|
5
5
|
"license": "AGPL-3.0-only OR LicenseRef-Commercial",
|
|
6
6
|
"repository": {
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@mailwoman/codex": "5.
|
|
55
|
-
"@mailwoman/core": "5.
|
|
56
|
-
"@mailwoman/resolver": "5.
|
|
57
|
-
"@mailwoman/spatial": "5.
|
|
54
|
+
"@mailwoman/codex": "5.6.0",
|
|
55
|
+
"@mailwoman/core": "5.6.0",
|
|
56
|
+
"@mailwoman/resolver": "5.6.0",
|
|
57
|
+
"@mailwoman/spatial": "5.6.0",
|
|
58
58
|
"kysely": "^0.29.2"
|
|
59
59
|
}
|
|
60
60
|
}
|