mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-27 00:31:02 +00:00
[WIP] rebase on main
This commit is contained in:
@ -21,7 +21,7 @@ pub trait UuidStore {
|
||||
async fn list(&self) -> Result<Vec<(String, Uuid)>>;
|
||||
async fn insert(&self, name: String, uuid: Uuid) -> Result<()>;
|
||||
async fn snapshot(&self, path: PathBuf) -> Result<HashSet<Uuid>>;
|
||||
async fn dump(&self, path: PathBuf) -> Result<Vec<Uuid>>;
|
||||
async fn dump(&self, path: PathBuf) -> Result<HashSet<Uuid>>;
|
||||
async fn get_size(&self) -> Result<u64>;
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ impl HeedUuidStore {
|
||||
|
||||
// TODO: we should merge this function and the following function for the dump. it's exactly
|
||||
// the same code
|
||||
pub fn snapshot(&self, mut path: PathBuf) -> Result<Vec<Uuid>> {
|
||||
pub fn snapshot(&self, mut path: PathBuf) -> Result<HashSet<Uuid>> {
|
||||
let env = self.env.clone();
|
||||
let db = self.db;
|
||||
// Write transaction to acquire a lock on the database.
|
||||
@ -138,16 +138,16 @@ impl HeedUuidStore {
|
||||
Ok(entries)
|
||||
}
|
||||
|
||||
pub fn dump(&self, mut path: PathBuf) -> Result<Vec<Uuid>> {
|
||||
pub fn dump(&self, mut path: PathBuf) -> Result<HashSet<Uuid>> {
|
||||
let env = self.env.clone();
|
||||
let db = self.db;
|
||||
// Write transaction to acquire a lock on the database.
|
||||
let txn = env.write_txn()?;
|
||||
let mut entries = Vec::new();
|
||||
let mut entries = HashSet::new();
|
||||
for entry in db.iter(&txn)? {
|
||||
let (_, uuid) = entry?;
|
||||
let uuid = Uuid::from_slice(uuid)?;
|
||||
entries.push(uuid)
|
||||
entries.insert(uuid);
|
||||
}
|
||||
|
||||
// only perform dump if there are indexes
|
||||
@ -192,12 +192,12 @@ impl UuidStore for HeedUuidStore {
|
||||
tokio::task::spawn_blocking(move || this.insert(name, uuid)).await?
|
||||
}
|
||||
|
||||
async fn snapshot(&self, path: PathBuf) -> Result<Vec<Uuid>> {
|
||||
async fn snapshot(&self, path: PathBuf) -> Result<HashSet<Uuid>> {
|
||||
let this = self.clone();
|
||||
tokio::task::spawn_blocking(move || this.snapshot(path)).await?
|
||||
}
|
||||
|
||||
async fn dump(&self, path: PathBuf) -> Result<Vec<Uuid>> {
|
||||
async fn dump(&self, path: PathBuf) -> Result<HashSet<Uuid>> {
|
||||
let this = self.clone();
|
||||
tokio::task::spawn_blocking(move || this.dump(path)).await?
|
||||
}
|
||||
|
Reference in New Issue
Block a user