Skip to content

Commit

Permalink
Use bincode instead of serde_json
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiemh committed Sep 29, 2024
1 parent 03fb340 commit fc8a383
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ codegen-units = 1

[dependencies]
anyhow = "1.0.88"
bincode = "1.3.3"
clap = { version = "4.5.17", features = ["derive"] }
dashmap = "6.1.0"
env_logger = "0.11.5"
Expand All @@ -36,7 +37,6 @@ redb = { version = "2.1.3", optional = true }
redis = { version = "0.24.0", features = ["tokio-comp"], optional = true }
rocksdb = { git = "https://github.com/surrealdb/rust-rocksdb", features = ["lz4", "snappy"], optional = true }
serde = { version = "1.0.210", features = ["derive"] }
serde_json = "1.0.128"
speedb = { version = "0.0.5", features = ["lz4", "snappy"], optional = true }
surrealdb = { version = "2.0.1", optional = true }
surrealkv = { version = "0.3.6", optional = true }
Expand Down
4 changes: 2 additions & 2 deletions src/redb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl BenchmarkClient for ReDBClient {

async fn create(&mut self, key: i32, record: &Record) -> Result<()> {
let key = &key.to_ne_bytes();
let val = serde_json::to_vec(record)?;
let val = bincode::serialize(record)?;
// Create a new transaction
let txn = self.db.begin_write()?;
// Open the database table
Expand All @@ -72,7 +72,7 @@ impl BenchmarkClient for ReDBClient {

async fn update(&mut self, key: i32, record: &Record) -> Result<()> {
let key = &key.to_ne_bytes();
let val = serde_json::to_vec(record)?;
let val = bincode::serialize(record)?;
// Create a new transaction
let txn = self.db.begin_write()?;
// Open the database table
Expand Down
4 changes: 2 additions & 2 deletions src/redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(crate) struct RedisClient {
impl BenchmarkClient for RedisClient {
#[allow(dependency_on_unit_never_type_fallback)]
async fn create(&mut self, key: i32, record: &Record) -> Result<()> {
let val = serde_json::to_vec(record)?;
let val = bincode::serialize(record)?;
self.conn.set(key, val).await?;
Ok(())
}
Expand All @@ -47,7 +47,7 @@ impl BenchmarkClient for RedisClient {

#[allow(dependency_on_unit_never_type_fallback)]
async fn update(&mut self, key: i32, record: &Record) -> Result<()> {
let val = serde_json::to_vec(record)?;
let val = bincode::serialize(record)?;
self.conn.set(key, val).await?;
Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions src/rocksdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl BenchmarkClient for RocksDBClient {

async fn create(&mut self, key: i32, record: &Record) -> Result<()> {
let key = &key.to_ne_bytes();
let val = serde_json::to_vec(record)?;
let val = bincode::serialize(record)?;
// Set the transaction options
let mut to = OptimisticTransactionOptions::default();
to.set_snapshot(true);
Expand Down Expand Up @@ -125,7 +125,7 @@ impl BenchmarkClient for RocksDBClient {

async fn update(&mut self, key: i32, record: &Record) -> Result<()> {
let key = &key.to_ne_bytes();
let val = serde_json::to_vec(record)?;
let val = bincode::serialize(record)?;
// Set the transaction options
let mut to = OptimisticTransactionOptions::default();
to.set_snapshot(true);
Expand Down
4 changes: 2 additions & 2 deletions src/speedb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl BenchmarkClient for SpeeDBClient {

async fn create(&mut self, key: i32, record: &Record) -> Result<()> {
let key = &key.to_ne_bytes();
let val = serde_json::to_vec(record)?;
let val = bincode::serialize(record)?;
// Set the transaction options
let mut to = OptimisticTransactionOptions::default();
to.set_snapshot(true);
Expand Down Expand Up @@ -125,7 +125,7 @@ impl BenchmarkClient for SpeeDBClient {

async fn update(&mut self, key: i32, record: &Record) -> Result<()> {
let key = &key.to_ne_bytes();
let val = serde_json::to_vec(record)?;
let val = bincode::serialize(record)?;
// Set the transaction options
let mut to = OptimisticTransactionOptions::default();
to.set_snapshot(true);
Expand Down
4 changes: 2 additions & 2 deletions src/surrealkv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl BenchmarkClient for SurrealKVClient {

async fn create(&mut self, key: i32, record: &Record) -> Result<()> {
let key = &key.to_ne_bytes();
let val = serde_json::to_vec(record)?;
let val = bincode::serialize(record)?;
let mut txn = self.db.begin_with_mode(Mode::WriteOnly)?;
txn.set(key, &val)?;
txn.commit().await?;
Expand All @@ -68,7 +68,7 @@ impl BenchmarkClient for SurrealKVClient {

async fn update(&mut self, key: i32, record: &Record) -> Result<()> {
let key = &key.to_ne_bytes();
let val = serde_json::to_vec(record)?;
let val = bincode::serialize(record)?;
let mut txn = self.db.begin_with_mode(Mode::WriteOnly)?;
txn.set(key, &val)?;
txn.commit().await?;
Expand Down

0 comments on commit fc8a383

Please sign in to comment.