Skip to content

Commit d951fd0

Browse files
committed
Create deserializer with headerless format
1 parent 2c39568 commit d951fd0

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/meta_memcache/serializer.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def __init__(
141141
else:
142142
self._default_zstd_compressor = None
143143

144-
self._zstd_decompressors[0] = zstd.ZstdDecompressor()
144+
self._zstd_decompressors[0] = zstd.ZstdDecompressor(format=zstd.FORMAT_ZSTD1_MAGICLESS)
145145

146146
def _build_dict(self, dictionary: bytes) -> Tuple[int, zstd.ZstdCompressionDict]:
147147
zstd_dict = zstd.ZstdCompressionDict(dictionary)
@@ -151,7 +151,7 @@ def _build_dict(self, dictionary: bytes) -> Tuple[int, zstd.ZstdCompressionDict]
151151
def _add_dict_decompressor(
152152
self, dict_id: int, zstd_dict: zstd.ZstdCompressionDict
153153
) -> zstd.ZstdDecompressor:
154-
self._zstd_decompressors[dict_id] = zstd.ZstdDecompressor(dict_data=zstd_dict)
154+
self._zstd_decompressors[dict_id] = zstd.ZstdDecompressor(dict_data=zstd_dict, format=zstd.FORMAT_ZSTD1_MAGICLESS)
155155
return self._zstd_decompressors[dict_id]
156156

157157
def _add_dict_compressor(
@@ -174,8 +174,7 @@ def _compress(self, key: Key, data: bytes) -> Tuple[bytes, int]:
174174
return zlib.compress(data), self.ZLIB_COMPRESSED
175175

176176
def _decompress(self, data: bytes) -> bytes:
177-
data = self.ZSTD_MAGIC + data
178-
dict_id = zstd.get_frame_parameters(data).dict_id
177+
dict_id = zstd.get_frame_parameters(self.ZSTD_MAGIC + data).dict_id
179178
if decompressor := self._zstd_decompressors.get(dict_id):
180179
return decompressor.decompress(data)
181180
raise ValueError(f"Unknown dictionary id: {dict_id}")

0 commit comments

Comments
 (0)