clickhouse/compression/
mod.rs

1#[cfg(feature = "lz4")]
2pub(crate) mod lz4;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5#[non_exhaustive]
6pub enum Compression {
7    /// Disables any compression.
8    /// Used by default if the `lz4` feature is disabled.
9    None,
10    /// Uses `LZ4` codec to (de)compress.
11    /// Used by default if the `lz4` feature is enabled.
12    #[cfg(feature = "lz4")]
13    Lz4,
14    /// Uses `LZ4HC` codec to compress and `LZ4` to decompress.
15    /// High compression levels are useful in networks with low bandwidth.
16    /// Affects only `INSERT`s, because others are compressed by the server.
17    /// Possible levels: `[1, 12]`. Recommended level range: `[4, 9]`.
18    ///
19    /// Deprecated: `lz4_flex` doesn't support HC mode yet: [lz4_flex#165].
20    ///
21    /// [lz4_flex#165]: https://github.com/PSeitz/lz4_flex/issues/165
22    #[cfg(feature = "lz4")]
23    #[deprecated(note = "use `Compression::Lz4` instead")]
24    Lz4Hc(i32),
25}
26
27impl Default for Compression {
28    #[cfg(feature = "lz4")]
29    #[inline]
30    fn default() -> Self {
31        if cfg!(feature = "test-util") {
32            Compression::None
33        } else {
34            Compression::Lz4
35        }
36    }
37
38    #[cfg(not(feature = "lz4"))]
39    #[inline]
40    fn default() -> Self {
41        Compression::None
42    }
43}
44
45impl Compression {
46    pub(crate) fn is_lz4(&self) -> bool {
47        *self != Compression::None
48    }
49}