def commit_ref_db_val_from_raw_val(commit_db_key_val_list): '''serialize and compress a list of db_key/db_value pairs for commit storage Parameters ---------- commit_db_key_val_list : iterable of 2-tuples Iterable collection binary encoded db_key/db_val pairs. Returns ------- bytes Serialized and compressed representation of the object. ''' serialized_db_list = msgpack.packb( tuple(commit_db_key_val_list), use_bin_type=True) zlibpacked = blosc.compress( serialized_db_list, cname='zlib', clevel=9, shuffle=blosc.SHUFFLE, typesize=1) print(blosc.get_cbuffer_sizes(zlibpacked)) return zlibpacked
def test_get_cbuffer_sizes(self): s = b'0123456789' * 100000 blosc.set_blocksize(2**16) c = blosc.compress(s, typesize=1) t = blosc.get_cbuffer_sizes(c) self.assertEqual(t[0], 1000000) # One cannot be sure of the exact compressed bytes, so round to KB self.assertEqual(t[1] // 2**10, 4354 // 2**10) self.assertEqual(t[2], 2**16)
def test_get_cbuffer_sizes(self): s = b'0123456789' * 100000 blosc.set_blocksize(2**16) c = blosc.compress(s, typesize=1) t = blosc.get_cbuffer_sizes(c) self.assertEqual(t[0], 1000000) # One cannot be sure of the exact compressed bytes, so round to KB self.assertEqual(t[1] // 2**10, 4354 // 2**10) self.assertEqual(t[2], 2**16)
def test_get_cbuffer_sizes(self): s = b'0123456789' * 100000 blosc.set_blocksize(2**16) c = blosc.compress(s, typesize=1) t = blosc.get_cbuffer_sizes(c) self.assertEqual(t, (1000000, 4354, 2**16))