diff --git a/src/core/src/index/revindex/disk_revindex.rs b/src/core/src/index/revindex/disk_revindex.rs index 5c34e58968..dbd38c5b33 100644 --- a/src/core/src/index/revindex/disk_revindex.rs +++ b/src/core/src/index/revindex/disk_revindex.rs @@ -161,7 +161,7 @@ impl RevIndex { }; let storage = if spec == "rocksdb://" { - todo!("init storage from db") + InnerStorage::new(RocksDBStorage::from_db(db.clone())) } else { InnerStorage::from_spec(spec)? }; @@ -184,7 +184,7 @@ impl RevIndex { } self.db.put_cf(&cf_metadata, MANIFEST, &wtr[..])?; - // write storage spec + // write storage specdisk_re let spec = self.collection.storage().spec(); // TODO: check if spec if memstorage, would probably have to @@ -489,6 +489,11 @@ impl RevIndexOps for RevIndex { .map(|v| v.set_storage_unchecked(InnerStorage::new(new_storage))); } + // write storage spec + let cf_metadata = self.db.cf_handle(METADATA).unwrap(); + let spec = "rocksdb://"; + self.db.put_cf(&cf_metadata, STORAGE_SPEC, spec)?; + Ok(()) } diff --git a/src/core/src/index/revindex/mod.rs b/src/core/src/index/revindex/mod.rs index 309f672121..b46db02b3b 100644 --- a/src/core/src/index/revindex/mod.rs +++ b/src/core/src/index/revindex/mod.rs @@ -912,23 +912,40 @@ mod test { Some(selection.clone()), )?; - let mut index = index; - index - .internalize_storage() - .expect("Error internalizing storage"); + { + let mut index = index; + index + .internalize_storage() + .expect("Error internalizing storage"); + + let (counter, query_colors, hash_to_color) = index.prepare_gather_counters(&query); + + let matches_internal = index.gather( + counter, + query_colors, + hash_to_color, + 0, + &query, + Some(selection.clone()), + )?; + assert_eq!(matches_external, matches_internal); + } + let new_path = outdir.path().join("new_index_path"); + std::fs::rename(output.as_path(), new_path.as_path()); + + let index = RevIndex::open(new_path, false, None)?; let (counter, query_colors, hash_to_color) = index.prepare_gather_counters(&query); - let matches_internal = index.gather( + let matches_moved = index.gather( counter, query_colors, hash_to_color, 0, &query, - Some(selection), + Some(selection.clone()), )?; - - assert_eq!(matches_external, matches_internal); + assert_eq!(matches_external, matches_moved); Ok(()) } diff --git a/src/core/src/storage/rocksdb.rs b/src/core/src/storage/rocksdb.rs index 122f933c62..a849a67633 100644 --- a/src/core/src/storage/rocksdb.rs +++ b/src/core/src/storage/rocksdb.rs @@ -33,6 +33,8 @@ impl RocksDBStorage { let db = Arc::new(DB::open_cf_descriptors(&opts, path, cfs).unwrap()); + // TODO: save storage_args + Self { db } }