Skip to content

Commit

Permalink
Further cleanup, docs.
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Feinberg <alex@strlen.net>
  • Loading branch information
afeinberg committed Jan 26, 2024
1 parent 5b4e744 commit e129e3a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 27 deletions.
1 change: 1 addition & 0 deletions components/hybrid_engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ txn_types = { workspace = true }
tikv_util = { workspace = true }
engine_rocks = { workspace = true }
region_cache_memory_engine = { workspace = true }
tempfile = "3.0"

[dev-dependencies]
tempfile = "3.0"
1 change: 1 addition & 0 deletions components/hybrid_engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ mod snapshot;
mod sst;
mod table_properties;
mod ttl_properties;
pub mod util;
mod write_batch;

pub use engine::HybridEngine;
Expand Down
1 change: 1 addition & 0 deletions components/hybrid_engine/src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ where
}
}

/// TODO: May be possible to replace this with an Either.
pub struct HybridDbVector(Box<dyn DbVector>);

impl DbVector for HybridDbVector {}
Expand Down
29 changes: 2 additions & 27 deletions components/hybrid_engine/src/write_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,36 +124,11 @@ impl<EK: KvEngine> Mutable for HybridEngineWriteBatch<EK> {

#[cfg(test)]
mod tests {
use std::sync::Arc;

use engine_rocks::{util::new_engine, RocksEngine};
use engine_traits::{
CacheRange, KvEngine, Mutable, Peekable, SnapshotContext, WriteBatch, WriteBatchExt,
CF_DEFAULT, CF_LOCK, CF_WRITE,
};
use region_cache_memory_engine::RangeCacheMemoryEngine;
use tempfile::{Builder, TempDir};

use super::Result;
use crate::HybridEngine;

fn hybrid_engine_for_tests<F>(
prefix: &str,
configure_memory_engine_fn: F,
) -> Result<(TempDir, HybridEngine<RocksEngine, RangeCacheMemoryEngine>)>
where
F: FnOnce(&RangeCacheMemoryEngine) -> (),
{
let path = Builder::new().prefix(prefix).tempdir()?;
let disk_engine = new_engine(
path.path().to_str().unwrap(),
&[CF_DEFAULT, CF_LOCK, CF_WRITE],
)?;
let memory_engine = RangeCacheMemoryEngine::new(Arc::default());
configure_memory_engine_fn(&memory_engine);
let hybrid_engine = HybridEngine::new(disk_engine, memory_engine);
Ok((path, hybrid_engine))
}

use crate::util::hybrid_engine_for_tests;

#[test]
fn test_write_to_both_engines() {
Expand Down

0 comments on commit e129e3a

Please sign in to comment.