Julia
- Package
Cozipin the Asterisk registry, on Julia 1.10 or newer, with the native library for Linux x86-64 and aarch64, macOS and Windows x86-64.
using Pkg
Pkg.Registry.add(Pkg.RegistrySpec(url = "https://github.com/asterisk-labs/AsteriskRegistry"))
Pkg.add("Cozip")
Cozip uses libcozip for archive I/O and DuckDB to write and decode manifests. The native library is downloaded on first use. create, stage_metadata and stage_create are exported. Call Cozip.write and Cozip.read with the module name. The rules every binding shares are on the API overview.
Writing
create
Cozip.write(out_path, table; temp_dir = nothing) -> String
create(out_path, table; temp_dir = nothing) -> String
Writes a Flat archive from a table, as Write describes, and returns abspath(out_path).
| out_path | The destination archive. An existing file is replaced. |
|---|---|
| table | Any Tables.jl source with name, path and your columns, copied into a DataFrame. |
| temp_dir | Where the temporary manifest Parquet goes, created if missing. The default is tempdir(). |
using Cozip, DataFrames
tbl = DataFrame(
name = ["a.txt", "data/b.bin"],
path = ["a.txt", "b.bin"],
split = ["train", "val"],
)
Cozip.write("out.zip", tbl)
DuckDB writes the manifest with native scalar types: UInt64 as UBIGINT, Vector{UInt8} as BLOB, and missing as null. An element type it cannot store raises ArgumentError. Table-level metadata, a GeoParquet geo entry included, is kept.
stage_metadata
stage_metadata(table) -> (metadata = DataFrame, paths = Vector{Tuple{String,String}})
Plans the archive without writing anything, the first of the two stages. It returns the manifest as a DataFrame and the (name, path) tuples in the same order. table is as for create.
metadata, paths = stage_metadata(tbl)
metadata
2×4 DataFrame
Row │ name offset size split
│ String UInt64 UInt64 String
─────┼────────────────────────────────────
1 │ a.txt 127 96 train
2 │ data/b.bin 263 40960 val
stage_create
stage_create(out_path, paths, metadata_parquet; validate = true) -> String
Writes the archive around a manifest Parquet you wrote and returns abspath(out_path).
| out_path | The destination archive. |
|---|---|
| paths | An iterable of two-element Tuples (name, source_path), in the manifest's row order. Vectors of vectors are refused. |
| metadata_parquet | The Parquet file, stored byte for byte as __metadata__. |
| validate | A Bool. The first mismatch with a fresh plan raises ArgumentError. |
Reading
read
Cozip.read(source; columns = nothing, location = true) -> DataFrame
Reads the manifest of a Flat archive into a DataFrame, one row per file. The arguments are described under Read.
| source | A string, in one of the source forms. |
|---|---|
| columns | nothing, or a vector of names. With a vector, the columns are name, offset, size, cozip:location, then the listed ones. An unknown name throws an ArgumentError. |
| location | A Bool. |
url = "https://huggingface.co/datasets/asterisk-labs/cozip-api-fixtures/resolve/v0.1.0/data/cities.zip"
manifest = Cozip.read(url; columns = ["label", "continent"])
filter(:continent => ==("Europe"), manifest)[:, [:name, :offset, :size]]
2×3 DataFrame
Row │ name offset size
│ String UInt64 UInt64
─────┼──────────────────────────────────────
1 │ cities/paris.geojson 1092 172
2 │ cities/oslo.geojson 1313 171
DuckDB decodes the manifest through a locked connection. Column types follow the Parquet file, so a Cozip.write manifest returns UInt64 offsets and sizes.
On Windows, Cozip.read throws an ErrorException before it reads anything, because the native reader has not been verified there from Julia. Writing works on Windows. Read with Python there, or under WSL.
verify
Cozip.verify(source) -> Nothing
Checks an archive of any profile, as described under Verify. Returns nothing, or throws a Cozip.LibCozip.CozipError whose name is the broken rule. Like Cozip.read, it is not exported and throws on Windows.
Opening the files
ArchGDAL and other GDAL readers open cozip:location. A local archive also opens with a seek and a read of the byte range.
out = Cozip.write("out.zip", tbl)
m = Cozip.read(out; columns = ["split"])
bytes = open(out) do io
seek(io, m.offset[1])
read(io, m.size[1]) # the 96 bytes of a.txt
end
GeoParquet manifests
Write the manifest with GeoParquet.jl and pass it to stage_create with the paths from stage_metadata.
using GeoParquet
import GeoInterface as GI
md, paths = stage_metadata(tbl)
md.geometry = [GI.Point((-77.04, -12.05)), GI.Point((2.35, 48.86))]
GeoParquet.write("meta.parquet", md, (:geometry,))
stage_create("out.zip", paths, "meta.parquet")
GeoParquet.jl stores offset and size as unsigned 64-bit integers with a logical type and no converted type. pyarrow reads them as uint64, but DuckDB reads them as signed, so Cozip.read returns them as Int64 for this manifest.
Errors
A check made in Julia throws an ArgumentError, a missing file included, with a message that starts with cozip: and counts rows from one. A failure inside libcozip throws Cozip.LibCozip.CozipError, with the fields code, name and message, and counts entries from zero. The API overview lists the causes.
ArgumentError: cozip: row 1 ("a"): source not found: nope.txt
CozipError [INVALID_ARGUMENT] entry 0 ('e') has a zero-byte payload; FLAT user entries must be non-empty
CozipError [HASH_MISMATCH] cozip integrity hash mismatch: bad.zip
Native library
Cozip.LibCozip.cozip_version() returns the version of the loaded library, such as 2026.11.23. Set COZIP_LIB_PATH to an absolute path before using Cozip to load another build instead of the artifact, such as one made from core/ with CMake.