Skip to content

Commit aac0c08

Browse files
committed
+: compress feature for Fjall
1 parent 7f213fd commit aac0c08

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ sha3 = "0.10"
2222

2323
threadpool = "1.8.1" # used in a background cleaner
2424

25-
fjall = "2.11.2"
25+
fjall = { version = "2.11.2", default-features = false, features = ["single_writer_tx"] }
2626
rocksdb = { version = "0.24.0", default-features = false, features = ["bindgen-runtime"] }
2727

2828
vsdb = { path = "wrappers", version = "7.0.0", default-features = false }

core/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "vsdb_core"
3-
version = "7.0.0"
3+
version = "7.0.2"
44
authors = ["[email protected]"]
55
edition = "2024"
66
description = "A std-collection-like database"
@@ -32,7 +32,7 @@ default = ["compress", "fjall_backend"]
3232
fjall_backend = ["fjall"]
3333
rocks_backend = ["rocksdb"]
3434

35-
compress = ["rocksdb?/zstd"]
35+
compress = ["rocksdb?/zstd", "fjall?/lz4"]
3636

3737
# [[bench]]
3838
# name = "basic"

core/src/common/engines/fjall_backend.rs

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::common::{
22
Engine, PREFIX_SIZE, Pre, PreBytes, RESERVED_ID_CNT, RawKey, RawValue,
33
vsdb_get_base_dir, vsdb_set_base_dir,
44
};
5-
use fjall::{Config, Keyspace, Partition, PartitionCreateOptions};
5+
use fjall::{CompressionType, Config, Keyspace, Partition, PartitionCreateOptions};
66
use parking_lot::Mutex;
77
use ruc::*;
88
use std::{
@@ -74,22 +74,39 @@ impl Engine for FjallEngine {
7474

7575
let mut parts = Vec::with_capacity(DATA_SET_NUM);
7676
for j in 0..DATA_SET_NUM {
77-
let p = ks
78-
.open_partition(
79-
&format!("part_{}", j),
80-
PartitionCreateOptions::default(),
81-
)
82-
.c(d!())?;
77+
let mut opts = PartitionCreateOptions::default();
78+
79+
#[cfg(feature = "compress")]
80+
{
81+
opts = opts.compression(CompressionType::Lz4);
82+
}
83+
84+
#[cfg(not(feature = "compress"))]
85+
{
86+
opts = opts.compression(CompressionType::None);
87+
}
88+
89+
let p = ks.open_partition(&format!("part_{}", j), opts).c(d!())?;
8390
parts.push(p);
8491
}
8592
shards.push(ks);
8693
shards_parts.push(parts);
8794
}
8895

8996
// Use a dedicated partition in shard 0 for meta
90-
let meta = shards[0]
91-
.open_partition("meta", PartitionCreateOptions::default())
92-
.c(d!())?;
97+
let mut meta_opts = PartitionCreateOptions::default();
98+
99+
#[cfg(feature = "compress")]
100+
{
101+
meta_opts = meta_opts.compression(CompressionType::Lz4);
102+
}
103+
104+
#[cfg(not(feature = "compress"))]
105+
{
106+
meta_opts = meta_opts.compression(CompressionType::None);
107+
}
108+
109+
let meta = shards[0].open_partition("meta", meta_opts).c(d!())?;
93110

94111
let (prefix_allocator, initial_value) = PreAllocator::init();
95112

0 commit comments

Comments
 (0)