class Zstd::Decompress::Context
- Zstd::Decompress::Context
- Zstd::Context
- Reference
- Object
Overview
Usage:
cctx = Zstd::Deompress::Context.new
dbuf = cctx.compress cbuf
When decompressing many times, it is recommended to allocate a context only once, and re-use it for each successive compression operation. This will make workload friendlier for system's memory. Use one context per thread for parallel execution.
Defined in:
zstd/decompress/context.crConstant Summary
-
CONTENT_SIZE_ERROR =
0_u64 &- 2
Constructors
Instance Method Summary
-
#decompress(src : Bytes, dst : Bytes | Nil = nil) : Bytes
Returns decompressed
Bytes
- #dict : Zstd::Dict?
-
#dict=(d : Zstd::Dict)
Reference a prepared dictionary, to be used to decompress next frames.
-
#frame_content_size(src : Bytes)
https://facebook.github.io/zstd/zstd_manual.html#Chapter6 Returns the frame content size if known.
-
#memsize
Give the current memory usage of zstd context.
Constructor Detail
Instance Method Detail
Returns decompressed Bytes
dst
is an optional output buffer that must be >= frame_content_size
Reference a prepared dictionary, to be used to decompress next frames. The dictionary remains active for decompression of future frames using same DCtx. Currently, only one dictionary can be managed.
Referencing a new dictionary effectively "discards" any previous one.
Referencing a nil Dict
means "return to no-dictionary mode".
https://facebook.github.io/zstd/zstd_manual.html#Chapter6 Returns the frame content size if known.
Notes:
- Always available when using single pass compression.
- Not available if compressed using streaming mode.
- decompressed size can be very large (64-bits value), potentially larger than what local system can handle as a single memory segment. In which case, it's necessary to use streaming mode to decompress data.
- If source is untrusted, decompressed size could be wrong or intentionally modified. Always ensure return value fits within application's authorized limits. Each application can set its own limits.
Give the current memory usage of zstd context.
Note that object memory usage can evolve (increase or decrease) over time.