blosc2.schunk.SChunk.get_chunk#

SChunk.get_chunk(nchunk: int) bytes#

Return the compressed chunk that is in the SChunk.

Parameters:

nchunk (int) – The index of the chunk that will be returned.

Returns:

out – The compressed chunk.

Return type:

bytes object

Raises:

RunTimeError – If a problem is detected.

Examples

>>> import blosc2
>>> import numpy as np
>>> # Create an SChunk with 3 chunks
>>> nchunks = 3
>>> data = np.arange(200 * 1000 * nchunks, dtype=np.int32)
>>> cparams = blosc2.CParams(typesize=4)
>>> schunk = blosc2.SChunk(data=data, cparams=cparams)
>>> # Retrieve the first chunk (index 0)
>>> chunk = schunk.get_chunk(0)
>>> # Check the type and length of the compressed chunk
>>> type(chunk)
<class 'bytes'>
>>> len(chunk)
10552