Repository navigation
Tags
Tags
Format v1.3.1: document all types, enforce size and layer limits (#20) Updates FORMAT.md to v1.3.1, and makes the code enforce the limits the document describes. ### FORMAT.md - Adds a version history and documents Type 4 (chunked) and the Layered Index format. - Gives all size limits in MiB: an 8MiB zstd window, and 128MiB for each serialized file index (Type 1-4), both before and after decompression. - The 128MiB limit applies to each layer's `FilesData`. There is no limit on the size of the whole layered index. - A layered index has at most 100,000 layers. - If a layer has several entries with the same name, the one with the highest offset is used. - Documents that delete layers remove directories left empty, and that readers must not assume files in a layer are sorted by name. - Fixes the Type 3 entry limit, the uncompressed size formula and the CRC byte order. The uncompressed limit includes exactly 128MiB, which is what the decoder accepts. ### Code - `Serialize` now returns `ErrMaxSizeExceeded` instead of writing an index that `DeserializeFiles` would reject. For Type 2/3 that is a payload or compressed output over 128MiB; for Type 4 it is a total size over 128MiB. - Adds `MaxLayers` (100,000) and `ErrTooManyLayers`. `AddLayer`, `AddDeleteLayer` and `DeserializeLayered` enforce the limit. `DeserializeLayered` no longer reserves memory for an unchecked layer count from its input. - `Find` and `FindInLayer` return the same entry as `Files()` when a layer has duplicate names. Before this, they returned whichever match the binary search hit first. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Layered indexes now support up to 100,000 layers. Attempts to add or read indexes exceeding this limit return an error. * **Bug Fixes** * Serialization now returns an error when uncompressed data or the final serialized output exceeds 128 MiB, including for chunked output. * **Documentation** * Expanded the format guide with Type 4 and Layered Index specifications, including chunk layout, ordering, size limits, independent decompression, and layer override and deletion behavior. * Updated Type 1 and 2 limits to document an 8 MiB Zstandard window, a 100-entry cap, and the uncompressed-size limit. * Updated Type 3 documentation to allow up to 1 billion files, retain the 128 MiB uncompressed-data limit, and clarify size reconstruction. * Clarified CRC byte order. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Add layered zip indexes (#17) * Add layered zip indexes - Add LayeredIndex[T] for combining multiple zip indexes with generic references - Implement file override semantics: newer layers override older ones - Add delete layers to remove files from previous layers - Automatic empty directory cleanup when files are deleted - Binary search optimization: files sorted by name on layer addition - Find operations use O(log n) binary search instead of O(n) linear search - Concurrent serialization/deserialization with user-provided RefSerializer[T] - Manual msgpack format: version + layers with ref data as binary arrays - Comprehensive test suite with 15+ test scenarios and benchmarks - Iterator support for Go 1.23 range syntax - Complete API: layer management, file access, conversion, serialization - Updated README with usage examples and API documentation * Upgrade Go versions and dependencies. * Upgrade ci-lint
Add chunked encoding of large directories (#16) When warm, it provides a nice speedup: ``` BEFORE: BenchmarkFindSerialized/100-32 84632 14027 ns/op 24.28 b/file 84632 files/s 5062 B/op 4 allocs/op BenchmarkFindSerialized/1000-32 13371 88087 ns/op 23.32 b/file 13371 files/s 49398 B/op 4 allocs/op BenchmarkFindSerialized/10000-32 1491 769408 ns/op 20.66 b/file 1491 files/s 451106 B/op 4 allocs/op BenchmarkFindSerialized/100000-32 163 7350855 ns/op 20.25 b/file 163.0 files/s 4499216 B/op 5 allocs/op BenchmarkFindSerialized/1000000-32 15 175437187 ns/op 20.16 b/file 7.500 files/s 44978624 B/op 6 allocs/op AFTER: BenchmarkFindSerialized/100-32 89673 13144 ns/op 24.28 b/file 89673 files/s 216 B/op 4 allocs/op BenchmarkFindSerialized/1000-32 15356 78862 ns/op 23.32 b/file 15356 files/s 220 B/op 4 allocs/op BenchmarkFindSerialized/10000-32 1663 719424 ns/op 20.66 b/file 1663 files/s 228 B/op 4 allocs/op BenchmarkFindSerialized/100000-32 170 6894286 ns/op 20.25 b/file 170.0 files/s 26760 B/op 4 allocs/op BenchmarkFindSerialized/1000000-32 16 67916169 ns/op 20.16 b/file 16.00 files/s 2812044 B/op 4 allocs/op ``` * Add new chunked format for faster FindSerialized. It kicks in at 25000 dir entries. Ensures that performance will be somewhat linear. Bumps index limit to 1B. ``` BenchmarkFindSerialized/100-32 88186 13926 ns/op 24.28 b/file 88186 files/s 216 B/op 4 allocs/op BenchmarkFindSerialized/1000-32 14157 82875 ns/op 23.32 b/file 14157 files/s 220 B/op 4 allocs/op BenchmarkFindSerialized/10000-32 1562 757547 ns/op 20.66 b/file 1562 files/s 225 B/op 4 allocs/op BenchmarkFindSerialized/100000-32 567 2101872 ns/op 21.66 b/file 567.0 files/s 1164419 B/op 10 allocs/op BenchmarkFindSerialized/1000000-32 583 2035905 ns/op 21.73 b/file 583.0 files/s 1181472 B/op 47 allocs/op ```
Sync upstream changes (#15) Notably includes golang/go#66869 and `RemoveInsecurePaths()` for golang/go#55356