From bea37e2834a5265035b960277ff27e5f8d74d079 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Fri, 21 Feb 2025 14:16:24 +0200 Subject: Start working in new schema logic to core --- log_db/src/engine.rs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'log_db/src/engine.rs') diff --git a/log_db/src/engine.rs b/log_db/src/engine.rs index c2f9a52..b06bfd2 100644 --- a/log_db/src/engine.rs +++ b/log_db/src/engine.rs @@ -1,7 +1,7 @@ use super::*; -pub struct Engine { - pub config: Config, +pub struct Engine { + pub config: Config, pub lock_manager: LockManager, data_dir_path: PathBuf, @@ -19,8 +19,8 @@ pub struct Engine { pub secondary_memtables: Vec, } -impl Engine { - pub fn initialize(config: Config) -> DBResult> { +impl Engine { + pub fn initialize(config: Config) -> DBResult> { info!("Initializing DB..."); // If data_dir does not exist or is empty, create it and any necessary files. // After creation, the directory should always be in a complete state without missing files. @@ -104,7 +104,7 @@ impl Engine { Path::new(&config.data_dir).join(active_metadata_header.uuid.to_string()); let active_data_file = APPEND_MODE.open(&active_data_path)?; - let mut engine = Engine:: { + let mut engine = Engine:: { config, lock_manager, data_dir_path, @@ -247,7 +247,7 @@ impl Engine { pub fn batch_find_by_records<'a>( &mut self, - field: &F, + field: &str, values: impl Iterator, params: &QueryParams, ) -> DBResult> { @@ -378,7 +378,7 @@ impl Engine { pub fn range_by_records>( &mut self, - field: &F, + field: &str, range: B, params: &QueryParams, ) -> DBResult> { @@ -458,7 +458,7 @@ impl Engine { } } - pub fn delete_by_field(&mut self, field: &F, value: &Value) -> DBResult> { + pub fn delete_by_field(&mut self, field: &str, value: &Value) -> DBResult> { let recs: Vec = self .batch_find_by_records(field, std::iter::once(value), &DEFAULT_QUERY_PARAMS)? .into_iter() @@ -737,6 +737,15 @@ mod tests { Name, } + impl Into for Field { + fn into(self) -> String { + match self { + Field::Id => "id".to_owned(), + Field::Name => "name".to_owned(), + } + } + } + #[derive(PartialEq, Eq, Debug, Clone)] struct TestInst2 { id: i64, -- cgit v1.3