Class: RLZ4::BlockCodec
- Inherits:
-
Object
- Object
- RLZ4::BlockCodec
- Defined in:
- lib/rlz4/block_codec.rb
Class Method Summary collapse
-
.new(dict: nil) ⇒ Object
Block-format LZ4 compression with a reusable scratch hash table.
Instance Method Summary collapse
Class Method Details
.new(dict: nil) ⇒ Object
Block-format LZ4 compression with a reusable scratch hash table.
Dict is passed once at construction time and baked into the codec: the dict is hashed into a pristine table exactly once in ‘.new`, and every subsequent `#compress` call restores that pristine state via a 16 KiB memcpy before running the block compressor. This amortises dict initialisation across the codec’s lifetime rather than paying ~3-5 µs per call to re-hash the dict.
‘#compress` mutates the scratch table; `#decompress` does not. Both live on the same class so callers hold one object per worker.
A BlockCodec must not cross Ractor boundaries. Per-Ractor codecs are the natural unit.
26 27 28 |
# File 'lib/rlz4/block_codec.rb', line 26 def self.new(dict: nil) _native_new(Dictionary === dict ? dict.bytes : dict) end |
Instance Method Details
#decompress(bytes, decompressed_size:) ⇒ Object
31 32 33 |
# File 'lib/rlz4/block_codec.rb', line 31 def decompress(bytes, decompressed_size:) _decompress(bytes, decompressed_size) end |