···11+# snappy
22+33+**Status: FUNCTIONAL**
44+55+## Overview
66+A pure OCaml implementation of Google's Snappy compression format. This is not C bindings - it is a complete reimplementation of the Snappy algorithm in OCaml, designed for minimal memory allocation during compression and decompression.
77+88+## Current State
99+The implementation is feature-complete with both compression and decompression working:
1010+1111+- **Compression**: LZ77-style compression with hash table for match finding
1212+- **Decompression**: Full support for all Snappy tag types (literals, 1/2/4-byte offset copies)
1313+- **Varint encoding/decoding**: For length headers
1414+- **Overlap handling**: Proper byte-by-byte copy for RLE-style patterns
1515+- **Low-allocation API**: `compress_into`/`decompress_into` for writing to pre-allocated buffers
1616+- **Error handling**: Typed errors and exception variants
1717+1818+Performance optimizations included:
1919+- Unsafe byte access in verified hot paths (`Bytes.unsafe_get`/`unsafe_set`)
2020+- OCaml compiler optimization flags (`-O3 -unbox-closures`)
2121+- Hash table-based match finding with 32KB window
2222+2323+## Dependencies
2424+- ocaml (>= 4.14.0)
2525+- dune (>= 3.0)
2626+- alcotest (test only, >= 1.7.0)
2727+2828+## TODO
2929+- [ ] Streaming API for processing large data without full buffering
3030+- [ ] Framing format support (Snappy framing for arbitrary-length streams)
3131+- [ ] Benchmarks comparing to C snappy bindings
3232+- [ ] Update placeholder author/maintainer info in dune-project
3333+3434+## Build & Test
3535+```bash
3636+# Build
3737+dune build
3838+3939+# Run tests
4040+dune test
4141+4242+# Run only quick tests
4343+dune test --force
4444+4545+# Install
4646+dune install
4747+```
4848+4949+## Notes
5050+- Tests pass against standard Snappy test corpus (alice29.txt, html, urls, etc.)
5151+- Handles bad/malformed compressed data gracefully with proper error messages
5252+- Maximum copy offset is 32KB (standard Snappy limitation)
5353+- Compression ratio on repeated patterns is excellent (<10% for highly repetitive data)