feat(std): snappy and lz4 blocks in std/compression #433
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/432-snappy-lz4"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #432
Step 1 of #121. Adds
Bytes.snappyCompressed,snappyDecompressed,lz4BlockCompressedandlz4BlockDecompressed(maximumSize)tostd/compression, in TorbScript over a shared greedy hash-table matcher (lz77.trb).Fail(CompressionError)with an offset: truncated stream, copy before start, LZ4 offset 0, Snappy length mismatch, LZ4 output overmaximumSize, and a Snappy preamble declaring 4 GiB over a tiny input, which is refused before anything is allocated.tests/blocks.test.trb): round trips for empty, 1, 15, 16 bytes, a one-byte run, 70000 bytes of text and 100000 pseudo-random bytes; at least 3 spec vectors per codec plus one reference-implementation stream per codec (produced with libsnappy and liblz4, cross-checked in both directions); 64 KiB of repetitive text compresses to under half with each codec.docs/standard-library/compression.md, index, regeneratedskills/, anddocs/design/FIRST-PARTY.mdgap 26 marked partly done (frames, checksums and zstd stay open).Local checks:
torb format --checkclean,torb testof the compression package in the VM green (27 passed),torb docs sourceclean,torb docs skill --checkup to date.torb docs checklocally only reports the twostd/clioption<T>findings, which come from the older release toolchain I used and are not in files this PR touches. No bootstrap, gates or LTO locally; those run in CI.The new tests take about 8-10 s in the VM (old suite about 3 s); the 70k and 100k inputs are mandated by the issue.
Approved at
9c7a33c.blocks.test.trbcovers hand-written spec vectors, a libsnappy and a liblz4 reference stream per codec, pinned deterministic output, round trips (empty, 1, 15, 16 bytes, run, 70k text, 100k random, >64 KiB far repeat), all error paths with reason and offset, and every-prefix refusal. CI green on this head (gates, tier A, bootstrap linux-x64, pdisc).docs/standard-library/compression.md, index, regeneratedskills/and FIRST-PARTY gap 26 updated; pdisc green.lz77.trb.Non-blocking:
lz4DecompresscallsBuffer.withCapacity(smaller(maximumSize, total * 4)); a negativemaximumSizereacheswithCapacitywith a negative value. Clamp it to 0 or document the behavior, and add a test for it.compression.mdthat introduces the block formats is a single long line; re-wrap it at the file's usual width.