jacksparrow007
jacksparrow007

Reputation: 1328

ruby thrift serialization compression

I am using the thrift ruby gem and am doing the following

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

and I am storing this binary_string in a file, but I noticed there is no compression at all. Is there any way I can compress my_thrift_obj while serializing?

Also, is there a way to serialize arbitrary ruby hashes to thrift objects?

Upvotes: 2

Views: 686

Answers (1)

jacksparrow007
jacksparrow007

Reputation: 1328

I got the following reply from the thrift author 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.

Upvotes: 2

Related Questions