Skip to content

Commit 864c826

Browse files
committed
Remove support for Brotli and Snappy compression
LZ4 provides fast and simple compression whereas Zstd is exceptionally flexible so that the additional support for Brotli and Snappy does not really add any distinct functionality on top of those two algorithms. Removing them reduces our maintenance burden and reduces the number of choices users have to make when setting up their project based on Tantivy.
1 parent f7288b0 commit 864c826

8 files changed

+8
-137
lines changed

Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ aho-corasick = "1.0"
2525
tantivy-fst = "0.4.0"
2626
memmap2 = { version = "0.7.1", optional = true }
2727
lz4_flex = { version = "0.11", default-features = false, optional = true }
28-
brotli = { version = "3.3.4", optional = true }
2928
zstd = { version = "0.12", optional = true, default-features = false }
30-
snap = { version = "1.0.5", optional = true }
3129
tempfile = { version = "3.3.0", optional = true }
3230
log = "0.4.16"
3331
serde = { version = "1.0.136", features = ["derive"] }
@@ -107,9 +105,7 @@ default = ["mmap", "stopwords", "lz4-compression"]
107105
mmap = ["fs4", "tempfile", "memmap2"]
108106
stopwords = []
109107

110-
brotli-compression = ["brotli"]
111108
lz4-compression = ["lz4_flex"]
112-
snappy-compression = ["snap"]
113109
zstd-compression = ["zstd"]
114110

115111
failpoints = ["fail", "fail/failpoints"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Details about the benchmark can be found at this [repository](https://github.com
4444
- Single valued and multivalued u64, i64, and f64 fast fields (equivalent of doc values in Lucene)
4545
- `&[u8]` fast fields
4646
- Text, i64, u64, f64, dates, ip, bool, and hierarchical facet fields
47-
- Compressed document store (LZ4, Zstd, None, Brotli, Snap)
47+
- Compressed document store (LZ4, Zstd, None)
4848
- Range queries
4949
- Faceted search
5050
- Configurable indexing (optional term frequency and position indexing)

src/core/index_meta.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -485,19 +485,14 @@ mod tests {
485485
}
486486

487487
#[test]
488-
#[cfg(all(
489-
feature = "lz4-compression",
490-
feature = "brotli-compression",
491-
feature = "snappy-compression",
492-
feature = "zstd-compression"
493-
))]
488+
#[cfg(all(feature = "lz4-compression", feature = "zstd-compression"))]
494489
fn test_serialize_metas_invalid_comp() {
495490
let json = r#"{"index_settings":{"sort_by_field":{"field":"text","order":"Asc"},"docstore_compression":"zsstd","docstore_blocksize":1000000},"segments":[],"schema":[{"name":"text","type":"text","options":{"indexing":{"record":"position","fieldnorms":true,"tokenizer":"default"},"stored":false,"fast":false}}],"opstamp":0}"#;
496491

497492
let err = serde_json::from_str::<UntrackedIndexMeta>(json).unwrap_err();
498493
assert_eq!(
499494
err.to_string(),
500-
"unknown variant `zsstd`, expected one of `none`, `lz4`, `brotli`, `snappy`, `zstd`, \
495+
"unknown variant `zsstd`, expected one of `none`, `lz4`, `zstd`, \
501496
`zstd(compression_level=5)` at line 1 column 96"
502497
.to_string()
503498
);

src/store/compression_brotli.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/store/compression_snap.rs

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/store/compressors.rs

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ pub enum Compressor {
1919
/// Use the lz4 compressor (block format)
2020
#[cfg(feature = "lz4-compression")]
2121
Lz4,
22-
/// Use the brotli compressor
23-
#[cfg(feature = "brotli-compression")]
24-
Brotli,
25-
/// Use the snap compressor
26-
#[cfg(feature = "snappy-compression")]
27-
Snappy,
2822
/// Use the zstd compressor
2923
#[cfg(feature = "zstd-compression")]
3024
Zstd(ZstdCompressor),
@@ -37,10 +31,6 @@ impl Serialize for Compressor {
3731
Compressor::None => serializer.serialize_str("none"),
3832
#[cfg(feature = "lz4-compression")]
3933
Compressor::Lz4 => serializer.serialize_str("lz4"),
40-
#[cfg(feature = "brotli-compression")]
41-
Compressor::Brotli => serializer.serialize_str("brotli"),
42-
#[cfg(feature = "snappy-compression")]
43-
Compressor::Snappy => serializer.serialize_str("snappy"),
4434
#[cfg(feature = "zstd-compression")]
4535
Compressor::Zstd(zstd) => serializer.serialize_str(&zstd.ser_to_string()),
4636
}
@@ -61,24 +51,6 @@ impl<'de> Deserialize<'de> for Compressor {
6151
"unsupported variant `lz4`, please enable Tantivy's `lz4-compression` feature",
6252
))
6353
}
64-
#[cfg(feature = "brotli-compression")]
65-
"brotli" => Compressor::Brotli,
66-
#[cfg(not(feature = "brotli-compression"))]
67-
"brotli" => {
68-
return Err(serde::de::Error::custom(
69-
"unsupported variant `brotli`, please enable Tantivy's `brotli-compression` \
70-
feature",
71-
))
72-
}
73-
#[cfg(feature = "snappy-compression")]
74-
"snappy" => Compressor::Snappy,
75-
#[cfg(not(feature = "snappy-compression"))]
76-
"snappy" => {
77-
return Err(serde::de::Error::custom(
78-
"unsupported variant `snappy`, please enable Tantivy's `snappy-compression` \
79-
feature",
80-
))
81-
}
8254
#[cfg(feature = "zstd-compression")]
8355
_ if buf.starts_with("zstd") => Compressor::Zstd(
8456
ZstdCompressor::deser_from_str(&buf).map_err(serde::de::Error::custom)?,
@@ -97,10 +69,6 @@ impl<'de> Deserialize<'de> for Compressor {
9769
"none",
9870
#[cfg(feature = "lz4-compression")]
9971
"lz4",
100-
#[cfg(feature = "brotli-compression")]
101-
"brotli",
102-
#[cfg(feature = "snappy-compression")]
103-
"snappy",
10472
#[cfg(feature = "zstd-compression")]
10573
"zstd",
10674
#[cfg(feature = "zstd-compression")]
@@ -173,12 +141,6 @@ impl Default for Compressor {
173141
#[cfg(feature = "lz4-compression")]
174142
return Compressor::Lz4;
175143

176-
#[cfg(feature = "brotli-compression")]
177-
return Compressor::Brotli;
178-
179-
#[cfg(feature = "snappy-compression")]
180-
return Compressor::Snappy;
181-
182144
#[cfg(feature = "zstd-compression")]
183145
return Compressor::Zstd(ZstdCompressor::default());
184146

@@ -201,10 +163,6 @@ impl Compressor {
201163
}
202164
#[cfg(feature = "lz4-compression")]
203165
Self::Lz4 => super::compression_lz4_block::compress(uncompressed, compressed),
204-
#[cfg(feature = "brotli-compression")]
205-
Self::Brotli => super::compression_brotli::compress(uncompressed, compressed),
206-
#[cfg(feature = "snappy-compression")]
207-
Self::Snappy => super::compression_snap::compress(uncompressed, compressed),
208166
#[cfg(feature = "zstd-compression")]
209167
Self::Zstd(_zstd_compressor) => super::compression_zstd_block::compress(
210168
uncompressed,

src/store/decompressors.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ pub enum Decompressor {
1818
/// Use the lz4 decompressor (block format)
1919
#[cfg(feature = "lz4-compression")]
2020
Lz4,
21-
/// Use the brotli decompressor
22-
#[cfg(feature = "brotli-compression")]
23-
Brotli,
24-
/// Use the snap decompressor
25-
#[cfg(feature = "snappy-compression")]
26-
Snappy,
2721
/// Use the zstd decompressor
2822
#[cfg(feature = "zstd-compression")]
2923
Zstd,
@@ -35,10 +29,6 @@ impl From<Compressor> for Decompressor {
3529
Compressor::None => Decompressor::None,
3630
#[cfg(feature = "lz4-compression")]
3731
Compressor::Lz4 => Decompressor::Lz4,
38-
#[cfg(feature = "brotli-compression")]
39-
Compressor::Brotli => Decompressor::Brotli,
40-
#[cfg(feature = "snappy-compression")]
41-
Compressor::Snappy => Decompressor::Snappy,
4232
#[cfg(feature = "zstd-compression")]
4333
Compressor::Zstd(_) => Decompressor::Zstd,
4434
}
@@ -51,10 +41,6 @@ impl Decompressor {
5141
0 => Decompressor::None,
5242
#[cfg(feature = "lz4-compression")]
5343
1 => Decompressor::Lz4,
54-
#[cfg(feature = "brotli-compression")]
55-
2 => Decompressor::Brotli,
56-
#[cfg(feature = "snappy-compression")]
57-
3 => Decompressor::Snappy,
5844
#[cfg(feature = "zstd-compression")]
5945
4 => Decompressor::Zstd,
6046
_ => panic!("unknown compressor id {id:?}"),
@@ -66,10 +52,6 @@ impl Decompressor {
6652
Self::None => 0,
6753
#[cfg(feature = "lz4-compression")]
6854
Self::Lz4 => 1,
69-
#[cfg(feature = "brotli-compression")]
70-
Self::Brotli => 2,
71-
#[cfg(feature = "snappy-compression")]
72-
Self::Snappy => 3,
7355
#[cfg(feature = "zstd-compression")]
7456
Self::Zstd => 4,
7557
}
@@ -95,10 +77,6 @@ impl Decompressor {
9577
}
9678
#[cfg(feature = "lz4-compression")]
9779
Self::Lz4 => super::compression_lz4_block::decompress(compressed, decompressed),
98-
#[cfg(feature = "brotli-compression")]
99-
Self::Brotli => super::compression_brotli::decompress(compressed, decompressed),
100-
#[cfg(feature = "snappy-compression")]
101-
Self::Snappy => super::compression_snap::decompress(compressed, decompressed),
10280
#[cfg(feature = "zstd-compression")]
10381
Self::Zstd => super::compression_zstd_block::decompress(compressed, decompressed),
10482
}
@@ -115,10 +93,6 @@ mod tests {
11593
assert_eq!(Decompressor::from(Compressor::None), Decompressor::None);
11694
#[cfg(feature = "lz4-compression")]
11795
assert_eq!(Decompressor::from(Compressor::Lz4), Decompressor::Lz4);
118-
#[cfg(feature = "brotli-compression")]
119-
assert_eq!(Decompressor::from(Compressor::Brotli), Decompressor::Brotli);
120-
#[cfg(feature = "snappy-compression")]
121-
assert_eq!(Decompressor::from(Compressor::Snappy), Decompressor::Snappy);
12296
#[cfg(feature = "zstd-compression")]
12397
assert_eq!(
12498
Decompressor::from(Compressor::Zstd(Default::default())),

src/store/mod.rs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
//! order to be handled in the `Store`.
55
//!
66
//! Internally, documents (or rather their stored fields) are serialized to a buffer.
7-
//! When the buffer exceeds `block_size` (defaults to 16K), the buffer is compressed using `brotli`,
8-
//! `LZ4` or `snappy` and the resulting block is written to disk.
7+
//! When the buffer exceeds `block_size` (defaults to 16K), the buffer is compressed
8+
//! using LZ4 or Zstd and the resulting block is written to disk.
99
//!
1010
//! One can then request for a specific `DocId`.
1111
//! A skip list helps navigating to the right block,
@@ -48,12 +48,6 @@ pub(crate) const DOC_STORE_VERSION: u32 = 1;
4848
#[cfg(feature = "lz4-compression")]
4949
mod compression_lz4_block;
5050

51-
#[cfg(feature = "brotli-compression")]
52-
mod compression_brotli;
53-
54-
#[cfg(feature = "snappy-compression")]
55-
mod compression_snap;
56-
5751
#[cfg(feature = "zstd-compression")]
5852
mod compression_zstd_block;
5953

@@ -200,16 +194,6 @@ pub mod tests {
200194
fn test_store_lz4_block() -> crate::Result<()> {
201195
test_store(Compressor::Lz4, BLOCK_SIZE, true)
202196
}
203-
#[cfg(feature = "snappy-compression")]
204-
#[test]
205-
fn test_store_snap() -> crate::Result<()> {
206-
test_store(Compressor::Snappy, BLOCK_SIZE, true)
207-
}
208-
#[cfg(feature = "brotli-compression")]
209-
#[test]
210-
fn test_store_brotli() -> crate::Result<()> {
211-
test_store(Compressor::Brotli, BLOCK_SIZE, true)
212-
}
213197

214198
#[cfg(feature = "zstd-compression")]
215199
#[test]
@@ -261,8 +245,8 @@ pub mod tests {
261245
Ok(())
262246
}
263247

264-
#[cfg(feature = "snappy-compression")]
265248
#[cfg(feature = "lz4-compression")]
249+
#[cfg(feature = "zstd-compression")]
266250
#[test]
267251
fn test_merge_with_changed_compressor() -> crate::Result<()> {
268252
let mut schema_builder = schema::Schema::builder();
@@ -294,7 +278,7 @@ pub mod tests {
294278
);
295279
// Change compressor, this disables stacking on merging
296280
let index_settings = index.settings_mut();
297-
index_settings.docstore_compression = Compressor::Snappy;
281+
index_settings.docstore_compression = Compressor::Zstd(Default::default());
298282
// Merging the segments
299283
{
300284
let segment_ids = index
@@ -316,7 +300,7 @@ pub mod tests {
316300
LOREM.to_string()
317301
);
318302
}
319-
assert_eq!(store.decompressor(), Decompressor::Snappy);
303+
assert_eq!(store.decompressor(), Decompressor::Zstd);
320304

321305
Ok(())
322306
}

0 commit comments

Comments
 (0)