From 347029ed51fd45f2cebf3c8bc1af9365d09b3c7b Mon Sep 17 00:00:00 2001 From: Luiz Irber Date: Thu, 25 Jul 2024 06:22:07 -0700 Subject: [PATCH] impl load for memstorage --- Cargo.lock | 2 +- src/core/Cargo.toml | 2 +- src/core/src/index/revindex/disk_revindex.rs | 7 +++++-- src/core/src/storage/mod.rs | 12 ++++++++++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f7b01f5e7d..ab39463133 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1668,7 +1668,7 @@ checksum = "9f1341053f34bb13b5e9590afb7d94b48b48d4b87467ec28e3c238693bb553de" [[package]] name = "sourmash" -version = "0.14.1" +version = "0.15.0" dependencies = [ "az", "byteorder", diff --git a/src/core/Cargo.toml b/src/core/Cargo.toml index be30374229..7823a100e1 100644 --- a/src/core/Cargo.toml +++ b/src/core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sourmash" -version = "0.14.1" +version = "0.15.0" authors = ["Luiz Irber ", "N. Tessa Pierce-Ward "] description = "tools for comparing biological sequences with k-mer sketches" repository = "https://github.com/sourmash-bio/sourmash" diff --git a/src/core/src/index/revindex/disk_revindex.rs b/src/core/src/index/revindex/disk_revindex.rs index 9f324189f8..91ee29cdab 100644 --- a/src/core/src/index/revindex/disk_revindex.rs +++ b/src/core/src/index/revindex/disk_revindex.rs @@ -174,7 +174,7 @@ impl RevIndex { } self.db.put_cf(&cf_metadata, MANIFEST, &wtr[..])?; - // write storage specdisk_re + // write storage spec let spec = self.collection.storage().spec(); // TODO: check if spec if memstorage, would probably have to @@ -459,7 +459,10 @@ impl RevIndexOps for RevIndex { } fn internalize_storage(&mut self) -> Result<()> { - // TODO: check if collection is already internal, if so return + // check if collection is already internal, if so return + if self.collection.storage().spec() == "rocksdb://" { + return Ok(()) + } // build new rocksdb storage from db let new_storage = RocksDBStorage::from_db(self.db.clone()); diff --git a/src/core/src/storage/mod.rs b/src/core/src/storage/mod.rs index 7dfb88f79d..c476baff56 100644 --- a/src/core/src/storage/mod.rs +++ b/src/core/src/storage/mod.rs @@ -639,8 +639,16 @@ impl Storage for MemStorage { unimplemented!() } - fn load(&self, _path: &str) -> Result> { - unimplemented!() + fn load(&self, path: &str) -> Result> { + let store = self.sigs.read().unwrap(); + let sig = store.get(path).unwrap(); + + let mut buffer = vec![]; + { + sig.to_writer(&mut buffer).unwrap(); + } + + Ok(buffer) } fn args(&self) -> StorageArgs {