id()
id() : string
The stable identifier recorded in a frame header.
Returns
string —A short lowercase token such as "zstd", "gzip" or "none".
Zstandard through the `zstd` binary, for hosts without `ext-zstd`.
This exists because the extension is absent on many hosts and gzip costs 76% more stored bytes.
It is explicitly NOT a per-frame codec: a process spawn dominates the work at frame sizes, and
1,000 separate zstd invocations were measured at 5.88 seconds - roughly 5.9 ms each against
the sub-millisecond compression itself. PipeCodec carries that split and the process handling.
Frames it writes carry the same id and the same bytes as ZstdCodec's, so a bucket written on a host with the extension reads on a host with only the binary and the other way round.
levels() : array{min: int, max: int, default: int, fast: int, dense: int}
The compression levels this codec accepts.
The usable range, the default, the level to use on the flush path where throughput matters, and the level to use during compaction where ratio matters.
__construct(string|null $binaryPath = null, string|null $scratchDirectory = null) : mixed
Constructs the codec.
| string|null | $binaryPath | An explicit path to the binary, or NULL to search PATH and the common directories. |
| string|null | $scratchDirectory | Directory for batch scratch files, or NULL for the system temporary directory. |
compress(string $data, ?int $level = null, ?string $dictionary = null) : string
Compresses a buffer.
| string | $data | The bytes to compress. An empty string compresses to an empty string, so that an absent payload never becomes a non-empty frame. |
| ?int | $level | A level within CompressionCodecInterface::levels(), or NULL for the default. |
| ?string | $dictionary | Raw dictionary bytes, or NULL. Ignored by codecs that report no dictionary support, so a caller never has to branch on it. |
The compressed bytes.
compressBatch(list$buffers, int|null $level = null, string|null $dictionary = null) : list<string>
Compresses many buffers in one process.
| list |
$buffers | The buffers to compress, in order. |
| int|null | $level | A level within PipeCodec::levels(), or NULL for the default. |
| string|null | $dictionary | Raw dictionary bytes, or NULL. |
When the codec is unavailable, or the binary fails.
The compressed buffers, in the same order.
decompressBatch(list$buffers, string|null $dictionary = null) : list<string>
Decompresses many buffers in one process.
| list |
$buffers | The buffers to decompress, in order. |
| string|null | $dictionary | The same dictionary bytes used to compress, or NULL. |
When the codec is unavailable, or the binary fails.
The original buffers, in the same order.
arguments(bool $compressing, int $level, string|null $dictionaryPath) : list<string>
The flags one invocation runs with, before the input paths.
| bool | $compressing | TRUE to compress, FALSE to decompress. |
| int | $level | A level already brought into range by PipeCodec::clamp(). |
| string|null | $dictionaryPath | Where the dictionary was written, or NULL when there is none. |
The arguments, without the binary itself.