mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 12:05:05 +08:00
add a little bit of documentation
This commit is contained in:
parent
2c4e5ce8be
commit
fe330e1be9
@ -70,6 +70,9 @@ pub struct IndexScheduler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl IndexScheduler {
|
impl IndexScheduler {
|
||||||
|
/// Return the index corresponding to the name. If it wasn't opened before
|
||||||
|
/// it'll be opened. But if it doesn't exist on disk it'll throw an
|
||||||
|
/// `IndexNotFound` error.
|
||||||
pub fn index(&self, name: &str) -> Result<Index> {
|
pub fn index(&self, name: &str) -> Result<Index> {
|
||||||
let rtxn = self.env.read_txn()?;
|
let rtxn = self.env.read_txn()?;
|
||||||
let uuid = self
|
let uuid = self
|
||||||
@ -105,18 +108,6 @@ impl IndexScheduler {
|
|||||||
Ok(index)
|
Ok(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn last_task_id(&self, rtxn: &RoTxn) -> Result<Option<TaskId>> {
|
|
||||||
Ok(self
|
|
||||||
.all_tasks
|
|
||||||
.remap_data_type::<DecodeIgnore>()
|
|
||||||
.last(rtxn)?
|
|
||||||
.map(|(k, _)| k.get() + 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn next_task_id(&self, rtxn: &RoTxn) -> Result<TaskId> {
|
|
||||||
Ok(self.last_task_id(rtxn)?.unwrap_or_default())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the tasks corresponding to the query.
|
/// Returns the tasks corresponding to the query.
|
||||||
pub fn get_tasks(&self, query: Query) -> Result<Vec<Task>> {
|
pub fn get_tasks(&self, query: Query) -> Result<Vec<Task>> {
|
||||||
let rtxn = self.env.read_txn()?;
|
let rtxn = self.env.read_txn()?;
|
||||||
@ -200,6 +191,7 @@ impl IndexScheduler {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Notify the scheduler there is or may be work to do.
|
||||||
pub fn notify(&self) {
|
pub fn notify(&self) {
|
||||||
self.wake_up
|
self.wake_up
|
||||||
.store(true, std::sync::atomic::Ordering::Relaxed);
|
.store(true, std::sync::atomic::Ordering::Relaxed);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//! Utility functions on the DBs. Mainly getter and setters.
|
//! Utility functions on the DBs. Mainly getter and setters.
|
||||||
|
|
||||||
use milli::{
|
use milli::{
|
||||||
heed::{RoTxn, RwTxn},
|
heed::{types::DecodeIgnore, RoTxn, RwTxn},
|
||||||
BEU32,
|
BEU32,
|
||||||
};
|
};
|
||||||
use roaring::RoaringBitmap;
|
use roaring::RoaringBitmap;
|
||||||
@ -12,6 +12,18 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
impl IndexScheduler {
|
impl IndexScheduler {
|
||||||
|
pub(crate) fn last_task_id(&self, rtxn: &RoTxn) -> Result<Option<TaskId>> {
|
||||||
|
Ok(self
|
||||||
|
.all_tasks
|
||||||
|
.remap_data_type::<DecodeIgnore>()
|
||||||
|
.last(rtxn)?
|
||||||
|
.map(|(k, _)| k.get() + 1))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn next_task_id(&self, rtxn: &RoTxn) -> Result<TaskId> {
|
||||||
|
Ok(self.last_task_id(rtxn)?.unwrap_or_default())
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn get_task(&self, rtxn: &RoTxn, task_id: TaskId) -> Result<Option<Task>> {
|
pub(crate) fn get_task(&self, rtxn: &RoTxn, task_id: TaskId) -> Result<Option<Task>> {
|
||||||
Ok(self.all_tasks.get(rtxn, &BEU32::new(task_id))?)
|
Ok(self.all_tasks.get(rtxn, &BEU32::new(task_id))?)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user