Fix compile errors/warnings in http-ui and infos

This commit is contained in:
Loïc Lecrenier 2022-09-01 08:34:26 +02:00 committed by Loïc Lecrenier
parent 85824ee203
commit 68cbcdf08b
3 changed files with 44 additions and 44 deletions

View File

@ -82,7 +82,6 @@ mod test {
use heed::{BytesDecode, BytesEncode, Env, RwTxn};
use roaring::RoaringBitmap;
use std::{fmt::Display, marker::PhantomData, rc::Rc};
use tempfile::TempDir;
use crate::{
heed_codec::facet::new::{
@ -113,8 +112,9 @@ mod test {
for<'a> BoundCodec:
BytesEncode<'a> + BytesDecode<'a, DItem = <BoundCodec as BytesEncode<'a>>::EItem>,
{
#[cfg(all(test, fuzzing))]
pub fn open_from_tempdir(
tempdir: Rc<TempDir>,
tempdir: Rc<tempfile::TempDir>,
group_size: u8,
max_group_size: u8,
) -> FacetIndex<BoundCodec> {

View File

@ -2,7 +2,7 @@ use std::collections::btree_map::Entry;
use fst::IntoStreamer;
use heed::types::{ByteSlice, Str};
use heed::{Database, RwTxn};
use heed::Database;
use roaring::RoaringBitmap;
use serde::{Deserialize, Serialize};
use serde_json::Value;
@ -10,6 +10,7 @@ use time::OffsetDateTime;
use super::{ClearDocuments, FacetsUpdateBulk};
use crate::error::{InternalError, UserError};
use crate::facet::FacetType;
use crate::heed_codec::facet::new::{FacetGroupValueCodec, FacetKeyCodec, MyByteSlice};
use crate::heed_codec::CboRoaringBitmapCodec;
use crate::index::{db_name, main_key};
@ -185,9 +186,9 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
prefix_word_pair_proximity_docids,
word_position_docids,
word_prefix_position_docids,
facet_id_f64_docids,
facet_id_f64_docids: _,
facet_id_exists_docids,
facet_id_string_docids,
facet_id_string_docids: _,
field_id_docid_facet_f64s,
field_id_docid_facet_strings,
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)?;
}
remove_docids_from_facet_id_docids(
self.wtxn,
self.index,
facet_id_f64_docids.remap_key_type::<FacetKeyCodec<MyByteSlice>>(),
&self.to_delete_docids,
fields_ids_map.clone(),
Index::put_number_faceted_documents_ids,
)?;
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,
)?;
for facet_type in [FacetType::Number, FacetType::String] {
remove_docids_from_facet_id_docids(
self.wtxn,
self.index,
&self.to_delete_docids,
fields_ids_map.clone(),
facet_type,
)?;
}
// We delete the documents ids that are under the facet field id values.
remove_docids_from_facet_id_exists_docids(
self.wtxn,
@ -613,11 +608,18 @@ where
fn remove_docids_from_facet_id_docids<'a>(
wtxn: &'a mut heed::RwTxn,
index: &Index,
db: heed::Database<FacetKeyCodec<MyByteSlice>, FacetGroupValueCodec>,
to_remove: &RoaringBitmap,
fields_ids_map: FieldsIdsMap,
put_faceted_docids_in_main: fn(&Index, &mut RwTxn, FieldId, &RoaringBitmap) -> heed::Result<()>,
facet_type: FacetType,
) -> 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;
for field_id in fields_ids_map.ids() {
let mut level0_prefix = vec![];
@ -646,7 +648,7 @@ fn remove_docids_from_facet_id_docids<'a>(
if !modified {
return Ok(());
}
let builder = FacetsUpdateBulk::new(index, db, put_faceted_docids_in_main);
let builder = FacetsUpdateBulk::new(index, facet_type);
builder.execute(wtxn)?;
Ok(())

View File

@ -1,4 +1,5 @@
use crate::error::InternalError;
use crate::facet::FacetType;
use crate::heed_codec::facet::new::{
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 grenad::CompressionType;
use heed::types::ByteSlice;
use heed::{BytesEncode, Error, RoTxn, RwTxn};
use heed::{BytesEncode, Error, RoTxn};
use log::debug;
use roaring::RoaringBitmap;
use std::cmp;
@ -21,28 +22,26 @@ pub struct FacetsUpdateBulk<'i> {
pub(crate) chunk_compression_level: Option<u32>,
level_group_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> {
pub fn new(
index: &'i Index,
database: heed::Database<FacetKeyCodec<MyByteSlice>, FacetGroupValueCodec>,
put_faceted_docids_in_main: fn(
&Index,
&mut RwTxn,
FieldId,
&RoaringBitmap,
) -> heed::Result<()>,
) -> FacetsUpdateBulk<'i> {
pub fn new(index: &'i Index, facet_type: FacetType) -> FacetsUpdateBulk<'i> {
FacetsUpdateBulk {
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_level: None,
level_group_size: 4,
min_level_size: 5,
put_faceted_docids_in_main,
facet_type,
}
}
@ -86,12 +85,11 @@ impl<'i> FacetsUpdateBulk<'i> {
let (level_readers, all_docids) =
self.compute_levels_for_field_id(field_id, &nested_wtxn)?;
(self.put_faceted_docids_in_main)(
&self.index,
&mut nested_wtxn,
field_id,
&all_docids,
)?;
let put_docids_fn = match self.facet_type {
FacetType::Number => Index::put_number_faceted_documents_ids,
FacetType::String => Index::put_string_faceted_documents_ids,
};
put_docids_fn(&self.index, &mut nested_wtxn, field_id, &all_docids)?;
for level_reader in level_readers {
// TODO: append instead of write with merge