ZSTD_compressStream2 method
int
ZSTD_compressStream2(
- Pointer<
ZSTD_CCtx> cctx, - Pointer<
ZSTD_outBuffer> output, - Pointer<
ZSTD_inBuffer> input, - int endOp,
! ZSTD_compressStream2() : Requires v1.4.0+ Behaves about the same as ZSTD_compressStream, with additional control on end directive.
- Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*()
- Compression parameters cannot be changed once compression is started (save a list of exceptions in multi-threading mode)
- output->pos must be <= dstCapacity, input->pos must be <= srcSize
- output->pos and input->pos will be updated. They are guaranteed to remain below their respective limit.
- endOp must be a valid directive
- When nbWorkers==0 (default), function is blocking : it completes its job before returning to caller.
- When nbWorkers>=1, function is non-blocking : it copies a portion of input, distributes jobs to internal worker threads, flush to output whatever is available, and then immediately returns, just indicating that there is some data remaining to be flushed. The function nonetheless guarantees forward progress : it will return only after it reads or write at least 1+ byte.
- Exception : if the first call requests a ZSTD_e_end directive and provides enough dstCapacity, the function delegates to ZSTD_compress2() which is always blocking.
- @return provides a minimum amount of data remaining to be flushed from internal buffers or an error code, which can be tested using ZSTD_isError(). if @return != 0, flush is not fully completed, there is still some data left within internal buffers. This is useful for ZSTD_e_flush, since in this case more flushes are necessary to empty all buffers. For ZSTD_e_end, @return == 0 when internal buffers are fully flushed and frame is completed.
- after a ZSTD_e_end directive, if internal buffer is not fully flushed (@return != 0), only ZSTD_e_end or ZSTD_e_flush operations are allowed. Before starting a new compression job, or changing compression parameters, it is required to fully flush internal buffers.
- note: if an operation ends with an error, it may leave @cctx in an undefined state. Therefore, it's UB to invoke ZSTD_compressStream2() of ZSTD_compressStream() on such a state. In order to be re-employed after an error, a state must be reset, which can be done explicitly (ZSTD_CCtx_reset()), or is sometimes implied by methods starting a new compression job (ZSTD_initCStream(), ZSTD_compressCCtx())
Implementation
int ZSTD_compressStream2(
ffi.Pointer<ZSTD_CCtx> cctx,
ffi.Pointer<ZSTD_outBuffer> output,
ffi.Pointer<ZSTD_inBuffer> input,
int endOp,
) {
return _ZSTD_compressStream2(
cctx,
output,
input,
endOp,
);
}