DeflateCompressor#

class numpy::DeflateCompressor#

numpy C++ class.

Example#

#include <numpy/np_ndarray.h>
using namespace numpy;

// Use DeflateCompressor
DeflateCompressor obj;
// ... operations ...

Indexing / Selection#

Signature

Return Type

Location

Example

static std::vector<uint8_t> compress(const void\* data, size_t size, int level = 6)

static std::vector<uint8_t>

np_npz_utils.h:148

View

Other Methods#

Signature

Return Type

Location

Example

static std::vector<uint8_t> decompress(const void\* data, size_t compressed_size, size_t uncompressed_size)

static std::vector<uint8_t>

np_npz_utils.h:176

deflateEnd(&zs)

np_npz_utils.h:166

inflateEnd(&zs)

np_npz_utils.h:191

Code Examples#

The following examples are extracted from the test suite.

compress (np_test_5_all.cpp:71)
61        void np_test_zlib_basic_compression() {
62            std::cout << "========= basic compression/decompression =======================";
63
64            const char* original = "Hello, zlib! This is a test string for compression.";
65            size_t original_len = std::strlen(original) + 1;
66
67            // Compress
68            uLongf compressed_len = compressBound(static_cast<uLong>(original_len));
69            std::vector<Bytef> compressed(compressed_len);
70
71            int result = compress(compressed.data(), &compressed_len,
72                                  (const Bytef*)original, static_cast<uLong>(original_len));
73
74            if (result != Z_OK) {
75                std::cout << "  [FAIL] : in np_test_zlib_basic_compression() : Compression failed";
76                throw std::runtime_error("np_test_zlib_basic_compression failed: Compression failed");
77            }
78
79            // Decompress
80            uLongf decompressed_len = static_cast<uLongf>(original_len);
81            std::vector<Bytef> decompressed(decompressed_len);