def test_multithreaded_unsupported(self): samples = [] for i in range(128): samples.append(b'foo' * 64) samples.append(b'bar' * 64) d = zstd.train_dictionary(8192, samples) cctx = zstd.ZstdCompressor(dict_data=d, threads=2) with self.assertRaisesRegexp( zstd.ZstdError, 'compress\(\) cannot be used with both dictionaries and multi-threaded compression' ): cctx.compress(b'foo') params = zstd.get_compression_parameters(3) cctx = zstd.ZstdCompressor(compression_params=params, threads=2) with self.assertRaisesRegexp( zstd.ZstdError, 'compress\(\) cannot be used with both compression parameters and multi-threaded compression' ): cctx.compress(b'foo')
def test_get_compression_parameters(self): p = zstd.get_compression_parameters(1) self.assertIsInstance(p, zstd.CompressionParameters) self.assertEqual(p.window_log, 19)
def multithreaded_chunk_size(level, source_size=0): params = zstd.get_compression_parameters(level, source_size) return 1 << (params.window_log + 2)
def test_compression_size(self): params = zstd.get_compression_parameters(3) size = zstd.estimate_compression_context_size(params) self.assertGreater(size, 100000)