Commit 22e71c6
feat(mbtiles)!: split the cache schema into flat and normalized layouts
Mirror the flat vs normalized split of the regular schemas:
- `CacheSchema::Flat`: a single tile_cache table with the blob inline -
simple and fast when few tiles share content.
- `CacheSchema::Normalized` (previously the only layout): tile_cache
pointing into the xxh3-64-keyed, de-duplicated cache_data blob table -
the recommended default for web caches.
Both keep the tile_cache name for the coordinate/metadata table
(detection tells them apart by the sixth column: tile_data vs tile_id)
and both expose the spec-compatible tiles view.
- `MbtType::Cache { schema: CacheSchema }`, mirroring Normalized.
- CLI values `cache-flat` and `cache-normalized`; `cache` stays as an
alias for cache-normalized.
- Runtime API takes the schema like insert_tiles takes mbt_type;
`MbtilesCache` detects and stores the layout (`open` creates
normalized; `open_with_schema` chooses).
- Copies preserve expires/etag in any cache-to-cache direction,
including across layouts, via a shared canonical select; only
normalized needs the blob-insert + collision-check path.
- Flat purges skip the orphan-blob GC; per-tile validation of flat
caches has nothing to hash-check, like flat.
- Cache detection and reads use runtime SQL (the two layouts' tile_cache
columns cannot coexist in the sqlx-prepare database), dropping two
.sqlx entries.
- Tests parametrized over both layouts (unit, pool, copy round-trips,
2x2 cache-to-cache matrix, diff inputs); CLI golden tests cover both;
normalized golden outputs are byte-identical to before.
BREAKING CHANGE: `MbtType::Cache` gains a payload, `MbtTypeCli::Cache`
is replaced by `CacheFlat`/`CacheNormalized`, and the cache read/write
APIs take a `CacheSchema` parameter.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 2b96a28 commit 22e71c6
31 files changed
Lines changed: 1026 additions & 453 deletions
File tree
- docs/content
- files
- martin/src/bin
- mbtiles
- .sqlx
- sql
- src
- bin
- schemas
- tests
- snapshots
- tests
- expected/mbtiles
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
72 | 86 | | |
73 | | - | |
74 | | - | |
| 87 | + | |
75 | 88 | | |
76 | 89 | | |
77 | | - | |
| 90 | + | |
78 | 91 | | |
79 | 92 | | |
80 | 93 | | |
81 | 94 | | |
82 | | - | |
| 95 | + | |
83 | 96 | | |
84 | 97 | | |
85 | 98 | | |
86 | | - | |
87 | | - | |
| 99 | + | |
| 100 | + | |
88 | 101 | | |
89 | 102 | | |
90 | | - | |
| 103 | + | |
91 | 104 | | |
92 | | - | |
| 105 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
532 | 532 | | |
533 | 533 | | |
534 | 534 | | |
535 | | - | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
536 | 538 | | |
537 | 539 | | |
538 | 540 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
650 | 650 | | |
651 | 651 | | |
652 | 652 | | |
653 | | - | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
654 | 659 | | |
655 | 660 | | |
656 | 661 | | |
| |||
Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 0 additions & 19 deletions
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
File renamed without changes.
0 commit comments