mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 02:27:40 +08:00
makes the updates getters smoother to uses
This commit is contained in:
parent
7879189c6b
commit
72b2e68de4
@ -169,21 +169,16 @@ impl IndexScheduler {
|
|||||||
|
|
||||||
if let Some(indexes) = task.indexes() {
|
if let Some(indexes) = task.indexes() {
|
||||||
for index in indexes {
|
for index in indexes {
|
||||||
self.update_index(&mut wtxn, index, |mut bitmap| {
|
self.update_index(&mut wtxn, index, |bitmap| drop(bitmap.insert(task_id)))?;
|
||||||
bitmap.insert(task_id);
|
|
||||||
bitmap
|
|
||||||
})?;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.update_status(&mut wtxn, Status::Enqueued, |mut bitmap| {
|
self.update_status(&mut wtxn, Status::Enqueued, |bitmap| {
|
||||||
bitmap.insert(task_id);
|
bitmap.insert(task_id);
|
||||||
bitmap
|
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
self.update_kind(&mut wtxn, task.kind.as_kind(), |mut bitmap| {
|
self.update_kind(&mut wtxn, task.kind.as_kind(), |bitmap| {
|
||||||
bitmap.insert(task_id);
|
(bitmap.insert(task_id));
|
||||||
bitmap
|
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
// we persist the file in last to be sure everything before was applied successfuly
|
// we persist the file in last to be sure everything before was applied successfuly
|
||||||
|
@ -50,24 +50,20 @@ impl IndexScheduler {
|
|||||||
.ok_or(Error::CorruptedTaskQueue)?;
|
.ok_or(Error::CorruptedTaskQueue)?;
|
||||||
|
|
||||||
if old_task.status != task.status {
|
if old_task.status != task.status {
|
||||||
self.update_status(wtxn, old_task.status, |mut bitmap| {
|
self.update_status(wtxn, old_task.status, |bitmap| {
|
||||||
bitmap.remove(task.uid);
|
bitmap.remove(task.uid);
|
||||||
bitmap
|
|
||||||
})?;
|
})?;
|
||||||
self.update_status(wtxn, task.status, |mut bitmap| {
|
self.update_status(wtxn, task.status, |bitmap| {
|
||||||
bitmap.insert(task.uid);
|
bitmap.insert(task.uid);
|
||||||
bitmap
|
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if old_task.kind.as_kind() != task.kind.as_kind() {
|
if old_task.kind.as_kind() != task.kind.as_kind() {
|
||||||
self.update_kind(wtxn, old_task.kind.as_kind(), |mut bitmap| {
|
self.update_kind(wtxn, old_task.kind.as_kind(), |bitmap| {
|
||||||
bitmap.remove(task.uid);
|
bitmap.remove(task.uid);
|
||||||
bitmap
|
|
||||||
})?;
|
})?;
|
||||||
self.update_kind(wtxn, task.kind.as_kind(), |mut bitmap| {
|
self.update_kind(wtxn, task.kind.as_kind(), |bitmap| {
|
||||||
bitmap.insert(task.uid);
|
bitmap.insert(task.uid);
|
||||||
bitmap
|
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,10 +87,10 @@ impl IndexScheduler {
|
|||||||
&self,
|
&self,
|
||||||
wtxn: &mut RwTxn,
|
wtxn: &mut RwTxn,
|
||||||
index: &str,
|
index: &str,
|
||||||
f: impl Fn(RoaringBitmap) -> RoaringBitmap,
|
f: impl Fn(&mut RoaringBitmap),
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let tasks = self.get_index(&wtxn, index)?;
|
let mut tasks = self.get_index(&wtxn, index)?;
|
||||||
let tasks = f(tasks);
|
f(&mut tasks);
|
||||||
self.put_index(wtxn, index, &tasks)?;
|
self.put_index(wtxn, index, &tasks)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -117,10 +113,10 @@ impl IndexScheduler {
|
|||||||
&self,
|
&self,
|
||||||
wtxn: &mut RwTxn,
|
wtxn: &mut RwTxn,
|
||||||
status: Status,
|
status: Status,
|
||||||
f: impl Fn(RoaringBitmap) -> RoaringBitmap,
|
f: impl Fn(&mut RoaringBitmap),
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let tasks = self.get_status(&wtxn, status)?;
|
let mut tasks = self.get_status(&wtxn, status)?;
|
||||||
let tasks = f(tasks);
|
f(&mut tasks);
|
||||||
self.put_status(wtxn, status, &tasks)?;
|
self.put_status(wtxn, status, &tasks)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -143,10 +139,10 @@ impl IndexScheduler {
|
|||||||
&self,
|
&self,
|
||||||
wtxn: &mut RwTxn,
|
wtxn: &mut RwTxn,
|
||||||
kind: Kind,
|
kind: Kind,
|
||||||
f: impl Fn(RoaringBitmap) -> RoaringBitmap,
|
f: impl Fn(&mut RoaringBitmap),
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let tasks = self.get_kind(&wtxn, kind)?;
|
let mut tasks = self.get_kind(&wtxn, kind)?;
|
||||||
let tasks = f(tasks);
|
f(&mut tasks);
|
||||||
self.put_kind(wtxn, kind, &tasks)?;
|
self.put_kind(wtxn, kind, &tasks)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user