chore: Using a fork of the fst library that support Arc<[u8]>

This commit is contained in:
Clément Renault 2019-04-08 16:16:31 +02:00
parent 9be7c02461
commit f7eced03fd
No known key found for this signature in database
GPG Key ID: 0151CDAB43460DAE
3 changed files with 24 additions and 7 deletions

View File

@ -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"]

View File

@ -1,9 +1,9 @@
use std::sync::Arc;
use std::ops::Deref;
#[derive(Default, Clone)]
#[derive(Clone)]
pub struct SharedData {
pub bytes: Arc<Vec<u8>>,
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<Vec<u8>>, 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];

View File

@ -7,12 +7,12 @@ pub struct SharedDataCursor(Cursor<SharedData>);
impl SharedDataCursor {
pub fn from_bytes(bytes: Vec<u8>) -> 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<Vec<u8>>, 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);