AutomaticCodec
authorNick Terrell <terrelln@fb.com>
Wed, 29 Mar 2017 04:21:02 +0000 (21:21 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 29 Mar 2017 04:37:58 +0000 (21:37 -0700)
commit2a60bc196ca0ec395b029ad1e066873fb0676bdb
treedb9cb19b92d53b7a1f120c56fd5b8182074c6848
parentcf6ef289c712ccd021fd9d66dc4cc509fc13c725
AutomaticCodec

Summary:
Add codec that does automatic format detection for decompression.
The codec returned by `getCodec(CodecType::AUTOMATIC)` can decompress codecs `LZ4_FRAME`, `ZSTD`, `ZLIB`, `GZIP`, and `LZMA2`.
Additionally, the function `getAutomaticCodec()` allows users to pass their own custom codecs, but the 5 default codecs must also be supported.
We force the default codecs on users because having a common subset of formats is in general useful, and because we want to be able to add codecs to this set.

When compiled in debug mode, on construction it checks that the codecs are compatible.
This helps make sure that users don't accidentally add ambiguous codecs, and if we add a new default codec in the future, tests will fail on ambiguity.

Reviewed By: yfeldblum

Differential Revision: D4760065

fbshipit-source-id: 9e65844aba9f1ae3d5c7b86643931782c06ab3eb
folly/io/Compression.cpp
folly/io/Compression.h
folly/io/test/CompressionTest.cpp