Wrapped

class pcodec.wrapped.ChunkCompressor

Holds metadata about a chunk and supports compressing one page at a time.

n_per_page()
Returns:

a list containing the count of numbers in each page.

write_meta()
Returns:

a bytes object containing the encoded chunk metadata.

Raises:

TypeError, RuntimeError

write_page(page_idx)
Parameters:

page_idx – an int for which page you want to write.

Returns:

a bytes object containing the encoded page.

Raises:

TypeError, RuntimeError

class pcodec.wrapped.ChunkDecompressor

Holds metadata about a chunk and supports decompressing one page at a time.

read_page_into(src, page_n, dst)

Decompresses a page into the provided array. If dst is shorter than the numbers in compressed, fills dst and ignores the numbers that didn’t fit. If dst is longer, fills as much of dst as possible.

Parameters:
  • src – the compressed page

  • page_n – the total count of numbers in the page. It is expected that the wrapping format provides this information.

  • dst – a numpy array to fill with the decompressed values. Must be contiguous, and its length must either be >= page_n, or a multiple of 256.

Returns:

a tuple containing progress and the number of bytes read. Progress is an object with a count of elements written and whether the compressed data was finished.

Raises:

TypeError, RuntimeError

class pcodec.wrapped.FileCompressor

The top-level object for creating wrapped pcodec files. Has a default constructor.

chunk_compressor(src, config)

Create a chunk compressor, computing the chunk metadata necessary to compress the provided src.

This does the bulk of the work of compression.

Parameters:
  • src – numpy array to compress. This must be 1D, contiguous, and one of Pco’s supported data types, e.g. float16, uint64.

  • config – a ChunkConfig object containing compression level and other settings.

Returns:

a ChunkCompressor

Raises:

TypeError, RuntimeError

write_header()
Returns:

a bytes object containing the encoded header

Raises:

TypeError, RuntimeError

class pcodec.wrapped.FileDecompressor

The top-level object for decompressing wrapped pcodec files. Has a default constructor.

chunk_decompressor(src, dtype)

Creates a ChunkDecompressor by reading encoded chunk metadata.

Parameters:
  • src – a bytes object containing the encoded chunk metadata

  • dtype – a data type supported by pcodec; e.g. ‘f32’, ‘i64’

Returns:

a tuple containing a ChunkDecompressor and the number of bytes read

Raises:

TypeError, RuntimeError

static new(src)

Creates a FileDecompressor.

Parameters:

src – a bytes object containing the encoded header

Returns:

a tuple containing a FileDecompressor and the number of bytes read

Raises:

TypeError, RuntimeError