From d4f9f958b1f5892290cf564e633f1193e03200df Mon Sep 17 00:00:00 2001 From: Tglman Date: Thu, 15 Jul 2021 00:23:19 +0100 Subject: [PATCH] fixed compilation issues after migration --- src/database/abstraction.rs | 34 +++++++++++++++++++--------------- src/error.rs | 1 + 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/database/abstraction.rs b/src/database/abstraction.rs index bfd7614..d89a18f 100644 --- a/src/database/abstraction.rs +++ b/src/database/abstraction.rs @@ -82,7 +82,7 @@ pub struct PersyEngine { impl DatabaseEngine for PersyEngine { fn open(config: &Config) -> Result> { let mut cfg = persy::Config::new(); - cfg.change_cache_size(config.cache_capacity as u64); + cfg.change_cache_size(config.db_cache_capacity_mb as u64 *1048576f64 as u64); let persy = OpenOptions::new() .create(true) @@ -123,6 +123,10 @@ impl DatabaseEngine for PersyEngine { write_cache: self.write_cache.clone(), })) } + + fn flush(self: &Arc) -> Result<()> { + Ok(()) + } } #[cfg(feature = "persy")] @@ -262,8 +266,8 @@ impl WriteCache { pub fn iter<'a>( &self, index: &str, - mut iter: Box, Box<[u8]>)> + Send + Sync + 'a>, - ) -> Box, Box<[u8]>)> + Send + Sync + 'a> { + mut iter: Box, Vec)> + Send + Sync + 'a>, + ) -> Box, Vec)> + Send + Sync + 'a> { if let Some(adds) = self.add_cache.get(index) { let added = adds.clone().into_iter().map(|(k, v)| (k.into(), v.into())); iter = Box::new(UnionIter::new(iter, added, false)) @@ -282,8 +286,8 @@ impl WriteCache { index: &str, from: &[u8], backwards: bool, - mut iter: Box, Box<[u8]>)> + 'a>, - ) -> Box, Box<[u8]>)> + 'a> { + mut iter: Box, Vec)> + Send+ 'a>, + ) -> Box, Vec)> + Send + 'a> { if let Some(adds) = self.add_cache.get(index) { let range = if backwards { adds.range(..from.to_owned()) @@ -292,8 +296,8 @@ impl WriteCache { }; let added = range .map(|(k, v)| (k.to_owned().into(), v.to_owned().into())) - .collect::, Box<[u8]>)>>(); - let add_iter: Box, Box<[u8]>)>> = if backwards { + .collect::, Vec)>>(); + let add_iter: Box, Vec)> + Send> = if backwards { Box::new(added.into_iter().rev()) } else { Box::new(added.into_iter()) @@ -324,15 +328,15 @@ impl WriteCache { &self, index: &str, prefix: Vec, - mut iter: Box, Box<[u8]>)> + Send + 'a>, - ) -> Box, Box<[u8]>)> + Send + 'a> { + mut iter: Box, Vec)> + Send + 'a>, + ) -> Box, Vec)> + Send + 'a> { if let Some(adds) = self.add_cache.get(index) { let owned_prefix = prefix.to_owned(); let added = adds .range(prefix.to_owned()..) .take_while(move |(k, _)| k.starts_with(&owned_prefix)) .map(|(k, v)| (k.to_owned().into(), v.to_owned().into())) - .collect::, Box<[u8]>)>>(); + .collect::, Vec)>>(); iter = Box::new(UnionIter::new(iter, added.into_iter(), false)) } @@ -472,7 +476,7 @@ impl Tree for PersyTree { Ok(()) } - fn iter<'a>(&'a self) -> Box, Box<[u8]>)> + Send + Sync + 'a> { + fn iter<'a>(&'a self) -> Box, Vec)> + Send + 'a> { let iter = self.persy.range::(&self.name, ..); match iter { Ok(iter) => { @@ -495,7 +499,7 @@ impl Tree for PersyTree { &'a self, from: &[u8], backwards: bool, - ) -> Box, Box<[u8]>)> + 'a> { + ) -> Box, Vec)> + Send + 'a> { let range = if backwards { self.persy .range::(&self.name, ..ByteVec(from.to_owned())) @@ -510,7 +514,7 @@ impl Tree for PersyTree { .map(|val| (k.0.to_owned().into(), val.0.to_owned().into())) .next() }); - let result: Box, Box<[u8]>)>> = if backwards { + let result: Box, Vec)> + Send+'a > = if backwards { Box::new(map.rev()) } else { Box::new(map) @@ -530,7 +534,7 @@ impl Tree for PersyTree { fn increment(&self, key: &[u8]) -> Result> { let old = self.get(key)?; - let new = utils::increment(old.as_deref()).unwrap(); + let new = crate::utils::increment(old.as_deref()).unwrap(); self.insert(key, &new)?; Ok(new) } @@ -538,7 +542,7 @@ impl Tree for PersyTree { fn scan_prefix<'a>( &'a self, prefix: Vec, - ) -> Box, Box<[u8]>)> + Send + 'a> { + ) -> Box, Vec)> + Send+ 'a> { let range_prefix = ByteVec(prefix.to_owned()); let range = self .persy diff --git a/src/error.rs b/src/error.rs index ba5ae76..63d3b21 100644 --- a/src/error.rs +++ b/src/error.rs @@ -35,6 +35,7 @@ pub enum Error { SqliteError { #[from] source: rusqlite::Error, + }, #[cfg(feature = "persy")] #[error("There was a problem with the connection to the persy database.")] PersyError {