-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In-Memory Engine: WriteBatch with Skiplist Engine (#16433)
ref #16323 Update WriteBatch to assume a single skiplist and use RangeManager::contains. Implement and test `get_value_cf_opt` for `HybridEngineSnapshot`. Integrate single WriteBatch with HybridEngine. Signed-off-by: Alex Feinberg <alex@strlen.net> Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
b67dd09
commit 87d9a97
Showing
12 changed files
with
302 additions
and
133 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2024 TiKV Project Authors. Licensed under Apache-2.0. | ||
|
||
use std::sync::Arc; | ||
|
||
use engine_rocks::{util::new_engine, RocksEngine}; | ||
use engine_traits::{Result, CF_DEFAULT, CF_LOCK, CF_WRITE}; | ||
use region_cache_memory_engine::RangeCacheMemoryEngine; | ||
use tempfile::{Builder, TempDir}; | ||
|
||
use crate::HybridEngine; | ||
|
||
/// Create a [`HybridEngine`] using temporary storage in `prefix`. | ||
/// Once the memory engine is created, runs `configure_memory_engine_fn`. | ||
/// Returns the handle to temporary directory and HybridEngine. | ||
/// # Example | ||
/// | ||
/// ``` | ||
/// use hybrid_engine::util::hybrid_engine_for_tests; | ||
/// let (_path, _hybrid_engine) = hybrid_engine_for_tests("temp", |memory_engine| { | ||
/// let range = engine_traits::CacheRange::new(b"k00".to_vec(), b"k10".to_vec()); | ||
/// memory_engine.new_range(range.clone()); | ||
/// { | ||
/// let mut core = memory_engine.core().write().unwrap(); | ||
/// core.mut_range_manager().set_range_readable(&range, true); | ||
/// core.mut_range_manager().set_safe_ts(&range, 10); | ||
/// } | ||
/// }) | ||
/// .unwrap(); | ||
/// ``` | ||
pub 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)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.