gpt4 book ai didi

ruby thrift序列化压缩

转载 作者:太空宇宙 更新时间:2023-11-03 16:07:16 25 4
gpt4 key购买 nike

我正在使用 thrift ruby​​ gem 并正在执行以下操作

serializer = Thrift::Serializer.new()
binary_string=serializer.serialize(my_thrift_obj)

我将这个 binary_string 存储在一个文件中,但我注意到根本没有压缩。有什么方法可以在序列化时压缩 my_thrift_obj 吗?

此外,有没有办法将任意 ruby​​ 哈希序列化为 thrift 对象?

最佳答案

我从 thrift 作者 Mark Slee 那里得到了以下回复。

The compact protocol doesn't do compression, the word compact refers to the way it encodes structure and type metadata.

Thrift is intended for strongly-typed structured data serialization, not compression. A file is already serialized - it sounds like what you really want is to compress serialized data. Would recommend using zlib or gzip for that.

关于ruby thrift序列化压缩,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10979907/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com