Пример #1
0
    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')
Пример #2
0
    def test_get_compression_parameters(self):
        p = zstd.get_compression_parameters(1)
        self.assertIsInstance(p, zstd.CompressionParameters)

        self.assertEqual(p.window_log, 19)
Пример #3
0
 def test_compression_size(self):
     params = zstd.get_compression_parameters(3)
     size = zstd.estimate_compression_context_size(params)
     self.assertGreater(size, 100000)
Пример #4
0
def multithreaded_chunk_size(level, source_size=0):
    params = zstd.get_compression_parameters(level, source_size)

    return 1 << (params.window_log + 2)