mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 23:04:26 +01:00
Fix compile errors/warnings in http-ui and infos
This commit is contained in:
parent
85824ee203
commit
68cbcdf08b
@ -82,7 +82,6 @@ mod test {
|
|||||||
use heed::{BytesDecode, BytesEncode, Env, RwTxn};
|
use heed::{BytesDecode, BytesEncode, Env, RwTxn};
|
||||||
use roaring::RoaringBitmap;
|
use roaring::RoaringBitmap;
|
||||||
use std::{fmt::Display, marker::PhantomData, rc::Rc};
|
use std::{fmt::Display, marker::PhantomData, rc::Rc};
|
||||||
use tempfile::TempDir;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
heed_codec::facet::new::{
|
heed_codec::facet::new::{
|
||||||
@ -113,8 +112,9 @@ mod test {
|
|||||||
for<'a> BoundCodec:
|
for<'a> BoundCodec:
|
||||||
BytesEncode<'a> + BytesDecode<'a, DItem = <BoundCodec as BytesEncode<'a>>::EItem>,
|
BytesEncode<'a> + BytesDecode<'a, DItem = <BoundCodec as BytesEncode<'a>>::EItem>,
|
||||||
{
|
{
|
||||||
|
#[cfg(all(test, fuzzing))]
|
||||||
pub fn open_from_tempdir(
|
pub fn open_from_tempdir(
|
||||||
tempdir: Rc<TempDir>,
|
tempdir: Rc<tempfile::TempDir>,
|
||||||
group_size: u8,
|
group_size: u8,
|
||||||
max_group_size: u8,
|
max_group_size: u8,
|
||||||
) -> FacetIndex<BoundCodec> {
|
) -> FacetIndex<BoundCodec> {
|
||||||
|
@ -2,7 +2,7 @@ use std::collections::btree_map::Entry;
|
|||||||
|
|
||||||
use fst::IntoStreamer;
|
use fst::IntoStreamer;
|
||||||
use heed::types::{ByteSlice, Str};
|
use heed::types::{ByteSlice, Str};
|
||||||
use heed::{Database, RwTxn};
|
use heed::Database;
|
||||||
use roaring::RoaringBitmap;
|
use roaring::RoaringBitmap;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
@ -10,6 +10,7 @@ use time::OffsetDateTime;
|
|||||||
|
|
||||||
use super::{ClearDocuments, FacetsUpdateBulk};
|
use super::{ClearDocuments, FacetsUpdateBulk};
|
||||||
use crate::error::{InternalError, UserError};
|
use crate::error::{InternalError, UserError};
|
||||||
|
use crate::facet::FacetType;
|
||||||
use crate::heed_codec::facet::new::{FacetGroupValueCodec, FacetKeyCodec, MyByteSlice};
|
use crate::heed_codec::facet::new::{FacetGroupValueCodec, FacetKeyCodec, MyByteSlice};
|
||||||
use crate::heed_codec::CboRoaringBitmapCodec;
|
use crate::heed_codec::CboRoaringBitmapCodec;
|
||||||
use crate::index::{db_name, main_key};
|
use crate::index::{db_name, main_key};
|
||||||
@ -185,9 +186,9 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
|
|||||||
prefix_word_pair_proximity_docids,
|
prefix_word_pair_proximity_docids,
|
||||||
word_position_docids,
|
word_position_docids,
|
||||||
word_prefix_position_docids,
|
word_prefix_position_docids,
|
||||||
facet_id_f64_docids,
|
facet_id_f64_docids: _,
|
||||||
facet_id_exists_docids,
|
facet_id_exists_docids,
|
||||||
facet_id_string_docids,
|
facet_id_string_docids: _,
|
||||||
field_id_docid_facet_f64s,
|
field_id_docid_facet_f64s,
|
||||||
field_id_docid_facet_strings,
|
field_id_docid_facet_strings,
|
||||||
documents,
|
documents,
|
||||||
@ -440,22 +441,16 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
|
|||||||
self.index.put_geo_faceted_documents_ids(self.wtxn, &geo_faceted_doc_ids)?;
|
self.index.put_geo_faceted_documents_ids(self.wtxn, &geo_faceted_doc_ids)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for facet_type in [FacetType::Number, FacetType::String] {
|
||||||
remove_docids_from_facet_id_docids(
|
remove_docids_from_facet_id_docids(
|
||||||
self.wtxn,
|
self.wtxn,
|
||||||
self.index,
|
self.index,
|
||||||
facet_id_f64_docids.remap_key_type::<FacetKeyCodec<MyByteSlice>>(),
|
|
||||||
&self.to_delete_docids,
|
&self.to_delete_docids,
|
||||||
fields_ids_map.clone(),
|
fields_ids_map.clone(),
|
||||||
Index::put_number_faceted_documents_ids,
|
facet_type,
|
||||||
)?;
|
|
||||||
remove_docids_from_facet_id_docids(
|
|
||||||
self.wtxn,
|
|
||||||
self.index,
|
|
||||||
facet_id_string_docids.remap_key_type::<FacetKeyCodec<MyByteSlice>>(),
|
|
||||||
&self.to_delete_docids,
|
|
||||||
fields_ids_map.clone(),
|
|
||||||
Index::put_string_faceted_documents_ids,
|
|
||||||
)?;
|
)?;
|
||||||
|
}
|
||||||
|
|
||||||
// We delete the documents ids that are under the facet field id values.
|
// We delete the documents ids that are under the facet field id values.
|
||||||
remove_docids_from_facet_id_exists_docids(
|
remove_docids_from_facet_id_exists_docids(
|
||||||
self.wtxn,
|
self.wtxn,
|
||||||
@ -613,11 +608,18 @@ where
|
|||||||
fn remove_docids_from_facet_id_docids<'a>(
|
fn remove_docids_from_facet_id_docids<'a>(
|
||||||
wtxn: &'a mut heed::RwTxn,
|
wtxn: &'a mut heed::RwTxn,
|
||||||
index: &Index,
|
index: &Index,
|
||||||
db: heed::Database<FacetKeyCodec<MyByteSlice>, FacetGroupValueCodec>,
|
|
||||||
to_remove: &RoaringBitmap,
|
to_remove: &RoaringBitmap,
|
||||||
fields_ids_map: FieldsIdsMap,
|
fields_ids_map: FieldsIdsMap,
|
||||||
put_faceted_docids_in_main: fn(&Index, &mut RwTxn, FieldId, &RoaringBitmap) -> heed::Result<()>,
|
facet_type: FacetType,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
let db = match facet_type {
|
||||||
|
FacetType::String => {
|
||||||
|
index.facet_id_string_docids.remap_key_type::<FacetKeyCodec<MyByteSlice>>()
|
||||||
|
}
|
||||||
|
FacetType::Number => {
|
||||||
|
index.facet_id_f64_docids.remap_key_type::<FacetKeyCodec<MyByteSlice>>()
|
||||||
|
}
|
||||||
|
};
|
||||||
let mut modified = false;
|
let mut modified = false;
|
||||||
for field_id in fields_ids_map.ids() {
|
for field_id in fields_ids_map.ids() {
|
||||||
let mut level0_prefix = vec![];
|
let mut level0_prefix = vec![];
|
||||||
@ -646,7 +648,7 @@ fn remove_docids_from_facet_id_docids<'a>(
|
|||||||
if !modified {
|
if !modified {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let builder = FacetsUpdateBulk::new(index, db, put_faceted_docids_in_main);
|
let builder = FacetsUpdateBulk::new(index, facet_type);
|
||||||
builder.execute(wtxn)?;
|
builder.execute(wtxn)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use crate::error::InternalError;
|
use crate::error::InternalError;
|
||||||
|
use crate::facet::FacetType;
|
||||||
use crate::heed_codec::facet::new::{
|
use crate::heed_codec::facet::new::{
|
||||||
FacetGroupValue, FacetGroupValueCodec, FacetKey, FacetKeyCodec, MyByteSlice,
|
FacetGroupValue, FacetGroupValueCodec, FacetKey, FacetKeyCodec, MyByteSlice,
|
||||||
};
|
};
|
||||||
@ -6,7 +7,7 @@ use crate::update::index_documents::{create_writer, write_into_lmdb_database, wr
|
|||||||
use crate::{FieldId, Index, Result};
|
use crate::{FieldId, Index, Result};
|
||||||
use grenad::CompressionType;
|
use grenad::CompressionType;
|
||||||
use heed::types::ByteSlice;
|
use heed::types::ByteSlice;
|
||||||
use heed::{BytesEncode, Error, RoTxn, RwTxn};
|
use heed::{BytesEncode, Error, RoTxn};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use roaring::RoaringBitmap;
|
use roaring::RoaringBitmap;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
@ -21,28 +22,26 @@ pub struct FacetsUpdateBulk<'i> {
|
|||||||
pub(crate) chunk_compression_level: Option<u32>,
|
pub(crate) chunk_compression_level: Option<u32>,
|
||||||
level_group_size: usize,
|
level_group_size: usize,
|
||||||
min_level_size: usize,
|
min_level_size: usize,
|
||||||
put_faceted_docids_in_main: fn(&Index, &mut RwTxn, FieldId, &RoaringBitmap) -> heed::Result<()>,
|
facet_type: FacetType,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'i> FacetsUpdateBulk<'i> {
|
impl<'i> FacetsUpdateBulk<'i> {
|
||||||
pub fn new(
|
pub fn new(index: &'i Index, facet_type: FacetType) -> FacetsUpdateBulk<'i> {
|
||||||
index: &'i Index,
|
|
||||||
database: heed::Database<FacetKeyCodec<MyByteSlice>, FacetGroupValueCodec>,
|
|
||||||
put_faceted_docids_in_main: fn(
|
|
||||||
&Index,
|
|
||||||
&mut RwTxn,
|
|
||||||
FieldId,
|
|
||||||
&RoaringBitmap,
|
|
||||||
) -> heed::Result<()>,
|
|
||||||
) -> FacetsUpdateBulk<'i> {
|
|
||||||
FacetsUpdateBulk {
|
FacetsUpdateBulk {
|
||||||
index,
|
index,
|
||||||
database,
|
database: match facet_type {
|
||||||
|
FacetType::String => {
|
||||||
|
index.facet_id_string_docids.remap_key_type::<FacetKeyCodec<MyByteSlice>>()
|
||||||
|
}
|
||||||
|
FacetType::Number => {
|
||||||
|
index.facet_id_f64_docids.remap_key_type::<FacetKeyCodec<MyByteSlice>>()
|
||||||
|
}
|
||||||
|
},
|
||||||
chunk_compression_type: CompressionType::None,
|
chunk_compression_type: CompressionType::None,
|
||||||
chunk_compression_level: None,
|
chunk_compression_level: None,
|
||||||
level_group_size: 4,
|
level_group_size: 4,
|
||||||
min_level_size: 5,
|
min_level_size: 5,
|
||||||
put_faceted_docids_in_main,
|
facet_type,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,12 +85,11 @@ impl<'i> FacetsUpdateBulk<'i> {
|
|||||||
let (level_readers, all_docids) =
|
let (level_readers, all_docids) =
|
||||||
self.compute_levels_for_field_id(field_id, &nested_wtxn)?;
|
self.compute_levels_for_field_id(field_id, &nested_wtxn)?;
|
||||||
|
|
||||||
(self.put_faceted_docids_in_main)(
|
let put_docids_fn = match self.facet_type {
|
||||||
&self.index,
|
FacetType::Number => Index::put_number_faceted_documents_ids,
|
||||||
&mut nested_wtxn,
|
FacetType::String => Index::put_string_faceted_documents_ids,
|
||||||
field_id,
|
};
|
||||||
&all_docids,
|
put_docids_fn(&self.index, &mut nested_wtxn, field_id, &all_docids)?;
|
||||||
)?;
|
|
||||||
|
|
||||||
for level_reader in level_readers {
|
for level_reader in level_readers {
|
||||||
// TODO: append instead of write with merge
|
// TODO: append instead of write with merge
|
||||||
|
Loading…
Reference in New Issue
Block a user