mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-27 04:25:06 +08:00
Add the pagination_limited_to setting to the database
This commit is contained in:
parent
69931e50d2
commit
445d5474cc
@ -1101,6 +1101,22 @@ impl Index {
|
|||||||
pub(crate) fn delete_max_values_per_facet(&self, txn: &mut RwTxn) -> heed::Result<bool> {
|
pub(crate) fn delete_max_values_per_facet(&self, txn: &mut RwTxn) -> heed::Result<bool> {
|
||||||
self.main.delete::<_, Str>(txn, main_key::MAX_VALUES_PER_FACET)
|
self.main.delete::<_, Str>(txn, main_key::MAX_VALUES_PER_FACET)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn pagination_limited_to(&self, txn: &RoTxn) -> heed::Result<Option<usize>> {
|
||||||
|
self.main.get::<_, Str, OwnedType<usize>>(txn, main_key::PAGINATION_LIMITED_TO)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn put_pagination_limited_to(
|
||||||
|
&self,
|
||||||
|
txn: &mut RwTxn,
|
||||||
|
val: usize,
|
||||||
|
) -> heed::Result<()> {
|
||||||
|
self.main.put::<_, Str, OwnedType<usize>>(txn, main_key::PAGINATION_LIMITED_TO, &val)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn delete_pagination_limited_to(&self, txn: &mut RwTxn) -> heed::Result<bool> {
|
||||||
|
self.main.delete::<_, Str>(txn, main_key::PAGINATION_LIMITED_TO)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -258,12 +258,12 @@ impl<'a, 't, 'u, 'i> Settings<'a, 't, 'u, 'i> {
|
|||||||
self.max_values_per_facet = Setting::Reset;
|
self.max_values_per_facet = Setting::Reset;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_limit_pagination_to(&mut self, value: usize) {
|
pub fn set_pagination_limited_to(&mut self, value: usize) {
|
||||||
self.limit_pagination_to = Setting::Set(value);
|
self.pagination_limited_to = Setting::Set(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reset_limit_pagination_to(&mut self) {
|
pub fn reset_pagination_limited_to(&mut self) {
|
||||||
self.limit_pagination_to = Setting::Reset;
|
self.pagination_limited_to = Setting::Reset;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reindex<F>(&mut self, cb: &F, old_fields_ids_map: FieldsIdsMap) -> Result<()>
|
fn reindex<F>(&mut self, cb: &F, old_fields_ids_map: FieldsIdsMap) -> Result<()>
|
||||||
@ -646,6 +646,20 @@ impl<'a, 't, 'u, 'i> Settings<'a, 't, 'u, 'i> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn update_pagination_limited_to(&mut self) -> Result<()> {
|
||||||
|
match self.pagination_limited_to {
|
||||||
|
Setting::Set(max) => {
|
||||||
|
self.index.put_pagination_limited_to(&mut self.wtxn, max)?;
|
||||||
|
}
|
||||||
|
Setting::Reset => {
|
||||||
|
self.index.delete_pagination_limited_to(&mut self.wtxn)?;
|
||||||
|
}
|
||||||
|
Setting::NotSet => (),
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn execute<F>(mut self, progress_callback: F) -> Result<()>
|
pub fn execute<F>(mut self, progress_callback: F) -> Result<()>
|
||||||
where
|
where
|
||||||
F: Fn(UpdateIndexingStep) + Sync,
|
F: Fn(UpdateIndexingStep) + Sync,
|
||||||
|
Loading…
Reference in New Issue
Block a user