nickva commented on issue #4400:
URL: https://github.com/apache/couchdb/issues/4400#issuecomment-4666167023

   Implementing basic zstd compression was fairly easy 
https://github.com/apache/couchdb/pull/6028
   
   Upstream Erlang/OTP had rejected a dictionary training API (for good reason) 
but it turns out zstd support "raw" dictionaries:
   
   ```erlang
   > Dict = ~"{\"type\":\"foo\",\"bar\":1,\"baz\":\"a\"}".
   <<"{\"type\":\"foo\",\"bar\":1,\"baz\":\"a\"}">>
   
   > {ok, C} = zstd:dict(compress, Dict).
   {ok,{cdict,#Ref<0.4075923125.4131520536.31325>}}
   
   > Doc = ~"{\"type\":\"foo\", \"bar\":2, \"baz\":\"b\"}".
   <<"{\"type\":\"foo\", \"bar\":2, \"baz\":\"b\"}">>
   
   > byte_size(iolist_to_binary(zstd:compress(Doc, #{dictionary=>C}))).
   29
   
   > byte_size(iolist_to_binary(zstd:compress(Doc))).
   43
   ```
   
   So we could have dictionaries after all


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to