cozip
Cloud-Optimized ZIP
cozip is one layer of the Asterisk stack for AI
An ordinary ZIP lists its files at the end
A reader starts at the end of the archive. The last 98 bytes say where the directory starts.
Then it reads the whole directory, one record per file with its name, size and offset. For a million files that is 56 MB.
Only then does it know where the file is. Three reads in a row before the first byte of data.
Measured on a million files of 1,000 bytes. That many entries need the ZIP64 end records, 98 bytes in all.
cozip reads the manifest, not the directory
The reader asks for the first 64 KiB. At byte 51 the index says where the manifest is.
Then it reads the manifest, one row per file with its offset, size and your columns. Here that is 11.7 MB with six metadata columns, a fifth of the directory.
The row gives the exact bytes, so the next read is the file. The Central Directory is never parsed.
The same million files. The manifest holds name, offset, size and six metadata columns in 11.7 MB of Parquet.
The manifest is a table
| required | yours, any metadata | |||||
|---|---|---|---|---|---|---|
| name | offset | size | split | date | cloud_cover | landcover |
| 000000.tif | 132 | 1,000 | train | 2024-01-01 | 22.6 | water |
| 000001.tif | 1,172 | 1,000 | train | 2024-01-02 | 19.9 | urban |
| 000002.tif | 2,212 | 1,000 | train | 2024-01-03 | 36.3 | forest |
| 000003.tif | 3,252 | 1,000 | train | 2024-01-04 | 17.9 | bare |
| 000004.tif | 4,292 | 1,000 | train | 2024-01-05 | 34.6 | bare |
| 000005.tif | 5,332 | 1,000 | train | 2024-01-06 | 94.8 | forest |
| 000006.tif | 6,372 | 1,000 | train | 2024-01-07 | 57.3 | crop |
| 000007.tif | 7,412 | 1,000 | train | 2024-01-08 | 34.0 | bare |
| 000008.tif | 8,452 | 1,000 | val | 2024-01-09 | 27.2 | bare |
| ... 999,991 more rows | ||||||
Every manifest has name, offset and size. Any other column is yours: here a split, a date, cloud cover and a land cover class.
Query it like any table. cloud_cover < 25 keeps three of these rows, and on all million rows DuckDB filters split, cloud cover, date and area in 35 ms.
With all six columns the manifest is a fifth of the directory: 11.7 MB against 56 MB. With only name, offset and size it is 0.5 MB.
The reference archive: a million files of 1,000 bytes. Its manifest also has lon and lat. Timings on a laptop, from local disk.
It is still a ZIP
$ unzip -l tiles.zip Archive: tiles.zip Length Date Time Name --------- ---------- ----- ---- 41 11-22-2026 23:30 __cozip__ 1000 11-22-2026 23:30 000000.tif 1000 11-22-2026 23:30 000001.tif 1000 11-22-2026 23:30 000002.tif 999,996 more lines 1000 11-22-2026 23:30 999999.tif 11742751 11-22-2026 23:30 __metadata__ --------- ------- 1011742792 1000002 files
Any ZIP tool lists it. cozip adds an index and a manifest.
- __cozip__
- the index, always the first entry
- __metadata__
- the manifest, 11.7 MB of Parquet here
- __cozip_padding__
- only in an archive under 32,819 bytes, so not in this one; readers ignore it
Direct ranges work because files keep their bytes.
- Stored, never compressed
- a file is its original bytes, at an offset with a size
- No encryption, no data descriptors
- nothing to decode between the offsets
- One segment, no comment
- the end record is always the last 22 bytes
- Unique ASCII names
- with / as the separator and no folder entries
- ZIP64 when needed
- above 4 GiB, or from 65,535 entries
Five languages, one format
cozip_write_flat("tiles.zip", entries, n, capacity, "manifest.parquet", &err);
cozip_read_flat_metadata("s3://bucket/tiles.zip", &parquet, &size, &message);cozip.write("tiles.zip", table)
manifest = cozip.read("s3://bucket/tiles.zip")cozip::write("tiles.zip", table)
manifest <- cozip::read("s3://bucket/tiles.zip")Cozip.write("tiles.zip", table)
manifest = Cozip.read("s3://bucket/tiles.zip")import { read } from "@asterisk-labs/cozip";
const manifest = await read("https://example.com/tiles.zip");