Skip to content

Commit

Permalink
moved MemStorage to #1463
Browse files Browse the repository at this point in the history
  • Loading branch information
luizirber committed Apr 16, 2021
1 parent f61e3ac commit 59a6dff
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 62 deletions.
3 changes: 3 additions & 0 deletions src/core/cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ rename_variants = "QualifiedScreamingSnakeCase"

[export]
exclude = ["HLL", "NoHashHasher", "HashIntersection"]

[fn]
sort_by = "Name"
1 change: 0 additions & 1 deletion src/core/src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pub mod index;
pub mod minhash;
pub mod nodegraph;
pub mod signature;
pub mod storage;

use std::ffi::CStr;
use std::os::raw::c_char;
Expand Down
20 changes: 0 additions & 20 deletions src/core/src/ffi/storage.rs

This file was deleted.

26 changes: 0 additions & 26 deletions src/core/src/storage.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::collections::HashMap;
use std::fs::{DirBuilder, File};
use std::io::{BufReader, BufWriter, Read, Write};
use std::path::PathBuf;
Expand Down Expand Up @@ -166,28 +165,3 @@ impl Storage for FSStorage {
}
}
}

#[derive(Default)]
pub struct MemStorage {
storage: Mutex<HashMap<String, Vec<u8>>>,
}

impl MemStorage {}

impl Storage for MemStorage {
fn save(&self, path: &str, content: &[u8]) -> Result<String, Error> {
let mut lock = self.storage.lock().unwrap();
lock.insert(path.into(), content.into());
Ok(path.into())
}

fn load(&self, path: &str) -> Result<Vec<u8>, Error> {
let lock = self.storage.lock().unwrap();
let v = lock.get(path).ok_or(ReadDataError::LoadError)?;
Ok(v.clone())
}

fn args(&self) -> StorageArgs {
unimplemented!()
}
}
15 changes: 0 additions & 15 deletions src/sourmash/sbt_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,18 +299,3 @@ def init_args(self):

def __exit__(self, type, value, traceback):
pass


class MemStorage(Storage):

def __init__(self):
self._storage = {}

def save(self, path, content):
if not isinstance(content, bytes):
content = bytes(content)
self._storage[path] = content
return path

def load(self, path):
return self._storage.get(path, None)

0 comments on commit 59a6dff

Please sign in to comment.