diff --git a/meilidb-core/Cargo.toml b/meilidb-core/Cargo.toml index 233243016..f0e6dc6e0 100644 --- a/meilidb-core/Cargo.toml +++ b/meilidb-core/Cargo.toml @@ -6,10 +6,8 @@ edition = "2018" [dependencies] byteorder = "1.3.1" -fst = "0.3.3" hashbrown = "0.1.8" lazy_static = "1.2.0" -levenshtein_automata = { version = "0.1.1", features = ["fst_automaton"] } log = "0.4.6" meilidb-tokenizer = { path = "../meilidb-tokenizer", version = "0.1.0" } rayon = "1.0.3" @@ -17,6 +15,15 @@ sdset = "0.3.1" serde = { version = "1.0.88", features = ["derive"] } slice-group-by = "0.2.4" +[dependencies.fst] +git = "https://github.com/Kerollmops/fst.git" +branch = "arc-byte-slice" + +[dependencies.levenshtein_automata] +git = "https://github.com/Kerollmops/levenshtein-automata.git" +branch = "arc-byte-slice" +features = ["fst_automaton"] + [features] i128 = ["byteorder/i128"] nightly = ["hashbrown/nightly", "slice-group-by/nightly"] diff --git a/meilidb-core/src/data/shared_data.rs b/meilidb-core/src/data/shared_data.rs index 100f837f7..fd505c6d9 100644 --- a/meilidb-core/src/data/shared_data.rs +++ b/meilidb-core/src/data/shared_data.rs @@ -1,9 +1,9 @@ use std::sync::Arc; use std::ops::Deref; -#[derive(Default, Clone)] +#[derive(Clone)] pub struct SharedData { - pub bytes: Arc>, + pub bytes: Arc<[u8]>, pub offset: usize, pub len: usize, } @@ -15,7 +15,7 @@ impl SharedData { SharedData::new(bytes, 0, len) } - pub fn new(bytes: Arc>, offset: usize, len: usize) -> SharedData { + pub fn new(bytes: Arc<[u8]>, offset: usize, len: usize) -> SharedData { SharedData { bytes, offset, len } } @@ -33,6 +33,16 @@ impl SharedData { } } +impl Default for SharedData { + fn default() -> SharedData { + SharedData { + bytes: Arc::from(Vec::new()), + offset: 0, + len: 0, + } + } +} + impl Deref for SharedData { type Target = [u8]; diff --git a/meilidb-core/src/shared_data_cursor.rs b/meilidb-core/src/shared_data_cursor.rs index 00d36884a..9eeac472f 100644 --- a/meilidb-core/src/shared_data_cursor.rs +++ b/meilidb-core/src/shared_data_cursor.rs @@ -7,12 +7,12 @@ pub struct SharedDataCursor(Cursor); impl SharedDataCursor { pub fn from_bytes(bytes: Vec) -> SharedDataCursor { let len = bytes.len(); - let bytes = Arc::new(bytes); + let bytes = Arc::from(bytes); SharedDataCursor::from_shared_bytes(bytes, 0, len) } - pub fn from_shared_bytes(bytes: Arc>, offset: usize, len: usize) -> SharedDataCursor { + pub fn from_shared_bytes(bytes: Arc<[u8]>, offset: usize, len: usize) -> SharedDataCursor { let data = SharedData::new(bytes, offset, len); let cursor = Cursor::new(data);