cargo fmt

This commit is contained in:
Loïc Lecrenier 2022-09-01 11:40:29 +02:00 committed by Loïc Lecrenier
parent 36296bbb20
commit a7201ece04
12 changed files with 99 additions and 94 deletions

View File

@ -1,6 +1,9 @@
use std::borrow::Cow;
use std::convert::TryFrom;
use std::marker::PhantomData;
use heed::{BytesDecode, BytesEncode}; use heed::{BytesDecode, BytesEncode};
use roaring::RoaringBitmap; use roaring::RoaringBitmap;
use std::{borrow::Cow, convert::TryFrom, marker::PhantomData};
pub mod ordered_f64_codec; pub mod ordered_f64_codec;
pub mod str_ref; pub mod str_ref;

View File

@ -1,4 +1,5 @@
use std::{borrow::Cow, convert::TryInto}; use std::borrow::Cow;
use std::convert::TryInto;
use heed::BytesDecode; use heed::BytesDecode;

View File

@ -1,9 +1,10 @@
use crate::heed_codec::facet::new::{FacetGroupValueCodec, FacetKey, FacetKeyCodec, MyByteSlice};
use heed::Result;
use roaring::RoaringBitmap;
use std::ops::ControlFlow; use std::ops::ControlFlow;
use heed::Result;
use roaring::RoaringBitmap;
use super::{get_first_facet_value, get_highest_level}; use super::{get_first_facet_value, get_highest_level};
use crate::heed_codec::facet::new::{FacetGroupValueCodec, FacetKey, FacetKeyCodec, MyByteSlice};
pub fn iterate_over_facet_distribution<'t, CB>( pub fn iterate_over_facet_distribution<'t, CB>(
rtxn: &'t heed::RoTxn<'t>, rtxn: &'t heed::RoTxn<'t>,
@ -108,16 +109,16 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::milli_snap; use std::ops::ControlFlow;
use crate::{
heed_codec::facet::new::ordered_f64_codec::OrderedF64Codec, search::facet::test::FacetIndex,
};
use heed::BytesDecode; use heed::BytesDecode;
use rand::{Rng, SeedableRng}; use rand::{Rng, SeedableRng};
use roaring::RoaringBitmap; use roaring::RoaringBitmap;
use std::ops::ControlFlow;
use super::iterate_over_facet_distribution; use super::iterate_over_facet_distribution;
use crate::heed_codec::facet::new::ordered_f64_codec::OrderedF64Codec;
use crate::milli_snap;
use crate::search::facet::test::FacetIndex;
fn get_simple_index() -> FacetIndex<OrderedF64Codec> { fn get_simple_index() -> FacetIndex<OrderedF64Codec> {
let index = FacetIndex::<OrderedF64Codec>::new(4, 8); let index = FacetIndex::<OrderedF64Codec>::new(4, 8);

View File

@ -1,18 +1,12 @@
use std::ops::{Bound, RangeBounds};
use heed::BytesEncode; use heed::BytesEncode;
use roaring::RoaringBitmap; use roaring::RoaringBitmap;
use std::ops::Bound;
use std::ops::RangeBounds;
use crate::heed_codec::facet::new::FacetGroupValueCodec; use super::{get_first_facet_value, get_highest_level, get_last_facet_value};
use crate::heed_codec::facet::new::FacetKey; use crate::heed_codec::facet::new::{FacetGroupValueCodec, FacetKey, FacetKeyCodec, MyByteSlice};
use crate::heed_codec::facet::new::FacetKeyCodec;
use crate::heed_codec::facet::new::MyByteSlice;
use crate::Result; use crate::Result;
use super::get_first_facet_value;
use super::get_highest_level;
use super::get_last_facet_value;
pub fn find_docids_of_facet_within_bounds<'t, BoundCodec>( pub fn find_docids_of_facet_within_bounds<'t, BoundCodec>(
rtxn: &'t heed::RoTxn<'t>, rtxn: &'t heed::RoTxn<'t>,
db: heed::Database<FacetKeyCodec<BoundCodec>, FacetGroupValueCodec>, db: heed::Database<FacetKeyCodec<BoundCodec>, FacetGroupValueCodec>,
@ -258,17 +252,17 @@ impl<'t, 'b, 'bitmap> FacetRangeSearch<'t, 'b, 'bitmap> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::milli_snap;
use crate::{
heed_codec::facet::new::{ordered_f64_codec::OrderedF64Codec, FacetKeyCodec},
search::facet::test::FacetIndex,
snapshot_tests::display_bitmap,
};
use rand::{Rng, SeedableRng};
use roaring::RoaringBitmap;
use std::ops::Bound; use std::ops::Bound;
use rand::{Rng, SeedableRng};
use roaring::RoaringBitmap;
use super::find_docids_of_facet_within_bounds; use super::find_docids_of_facet_within_bounds;
use crate::heed_codec::facet::new::ordered_f64_codec::OrderedF64Codec;
use crate::heed_codec::facet::new::FacetKeyCodec;
use crate::milli_snap;
use crate::search::facet::test::FacetIndex;
use crate::snapshot_tests::display_bitmap;
fn get_simple_index() -> FacetIndex<OrderedF64Codec> { fn get_simple_index() -> FacetIndex<OrderedF64Codec> {
let index = FacetIndex::<OrderedF64Codec>::new(4, 8); let index = FacetIndex::<OrderedF64Codec>::new(4, 8);

View File

@ -1,10 +1,10 @@
use crate::heed_codec::facet::new::{
FacetGroupValue, FacetGroupValueCodec, FacetKey, FacetKeyCodec, MyByteSlice,
};
use heed::Result; use heed::Result;
use roaring::RoaringBitmap; use roaring::RoaringBitmap;
use super::{get_first_facet_value, get_highest_level}; use super::{get_first_facet_value, get_highest_level};
use crate::heed_codec::facet::new::{
FacetGroupValue, FacetGroupValueCodec, FacetKey, FacetKeyCodec, MyByteSlice,
};
pub fn ascending_facet_sort<'t>( pub fn ascending_facet_sort<'t>(
rtxn: &'t heed::RoTxn<'t>, rtxn: &'t heed::RoTxn<'t>,
@ -83,16 +83,15 @@ impl<'t, 'e> Iterator for AscendingFacetSort<'t, 'e> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::milli_snap; use rand::{Rng, SeedableRng};
use crate::{
heed_codec::facet::new::ordered_f64_codec::OrderedF64Codec,
search::facet::{facet_sort_ascending::ascending_facet_sort, test::FacetIndex},
snapshot_tests::display_bitmap,
};
use rand::Rng;
use rand::SeedableRng;
use roaring::RoaringBitmap; use roaring::RoaringBitmap;
use crate::heed_codec::facet::new::ordered_f64_codec::OrderedF64Codec;
use crate::milli_snap;
use crate::search::facet::facet_sort_ascending::ascending_facet_sort;
use crate::search::facet::test::FacetIndex;
use crate::snapshot_tests::display_bitmap;
fn get_simple_index() -> FacetIndex<OrderedF64Codec> { fn get_simple_index() -> FacetIndex<OrderedF64Codec> {
let index = FacetIndex::<OrderedF64Codec>::new(4, 8); let index = FacetIndex::<OrderedF64Codec>::new(4, 8);
let mut txn = index.env.write_txn().unwrap(); let mut txn = index.env.write_txn().unwrap();

View File

@ -1,12 +1,12 @@
use std::ops::Bound; use std::ops::Bound;
use crate::heed_codec::facet::new::{
FacetGroupValue, FacetGroupValueCodec, FacetKey, FacetKeyCodec, MyByteSlice,
};
use heed::Result; use heed::Result;
use roaring::RoaringBitmap; use roaring::RoaringBitmap;
use super::{get_first_facet_value, get_highest_level, get_last_facet_value}; use super::{get_first_facet_value, get_highest_level, get_last_facet_value};
use crate::heed_codec::facet::new::{
FacetGroupValue, FacetGroupValueCodec, FacetKey, FacetKeyCodec, MyByteSlice,
};
pub fn descending_facet_sort<'t>( pub fn descending_facet_sort<'t>(
rtxn: &'t heed::RoTxn<'t>, rtxn: &'t heed::RoTxn<'t>,
@ -111,16 +111,16 @@ impl<'t> Iterator for DescendingFacetSort<'t> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::milli_snap; use rand::{Rng, SeedableRng};
use crate::{
heed_codec::facet::new::{ordered_f64_codec::OrderedF64Codec, FacetKeyCodec, MyByteSlice},
search::facet::{facet_sort_descending::descending_facet_sort, test::FacetIndex},
snapshot_tests::display_bitmap,
};
use rand::Rng;
use rand::SeedableRng;
use roaring::RoaringBitmap; use roaring::RoaringBitmap;
use crate::heed_codec::facet::new::ordered_f64_codec::OrderedF64Codec;
use crate::heed_codec::facet::new::{FacetKeyCodec, MyByteSlice};
use crate::milli_snap;
use crate::search::facet::facet_sort_descending::descending_facet_sort;
use crate::search::facet::test::FacetIndex;
use crate::snapshot_tests::display_bitmap;
fn get_simple_index() -> FacetIndex<OrderedF64Codec> { fn get_simple_index() -> FacetIndex<OrderedF64Codec> {
let index = FacetIndex::<OrderedF64Codec>::new(4, 8); let index = FacetIndex::<OrderedF64Codec>::new(4, 8);
let mut txn = index.env.write_txn().unwrap(); let mut txn = index.env.write_txn().unwrap();

View File

@ -1,18 +1,18 @@
use either::Either;
pub use filter_parser::{Condition, Error as FPError, FilterCondition, Span, Token};
use heed::types::DecodeIgnore;
use roaring::RoaringBitmap;
use std::collections::HashSet; use std::collections::HashSet;
use std::fmt::{Debug, Display}; use std::fmt::{Debug, Display};
use std::ops::Bound::{self, Excluded, Included}; use std::ops::Bound::{self, Excluded, Included};
use either::Either;
pub use filter_parser::{Condition, Error as FPError, FilterCondition, Span, Token};
use heed::types::DecodeIgnore;
use roaring::RoaringBitmap;
use super::facet_range_search;
use crate::error::{Error, UserError}; use crate::error::{Error, UserError};
use crate::heed_codec::facet::new::ordered_f64_codec::OrderedF64Codec; use crate::heed_codec::facet::new::ordered_f64_codec::OrderedF64Codec;
use crate::heed_codec::facet::new::{FacetGroupValueCodec, FacetKey, FacetKeyCodec}; use crate::heed_codec::facet::new::{FacetGroupValueCodec, FacetKey, FacetKeyCodec};
use crate::{distance_between_two_points, lat_lng_to_xyz, FieldId, Index, Result}; use crate::{distance_between_two_points, lat_lng_to_xyz, FieldId, Index, Result};
use super::facet_range_search;
/// The maximum number of filters the filter AST can process. /// The maximum number of filters the filter AST can process.
const MAX_FILTER_DEPTH: usize = 2000; const MAX_FILTER_DEPTH: usize = 2000;

View File

@ -1,10 +1,9 @@
use heed::types::ByteSlice; use heed::types::ByteSlice;
use heed::{BytesDecode, RoTxn}; use heed::{BytesDecode, RoTxn};
use crate::heed_codec::facet::new::{FacetGroupValueCodec, FacetKeyCodec, MyByteSlice};
pub use self::facet_distribution::{FacetDistribution, DEFAULT_VALUES_PER_FACET}; pub use self::facet_distribution::{FacetDistribution, DEFAULT_VALUES_PER_FACET};
pub use self::filter::Filter; pub use self::filter::Filter;
use crate::heed_codec::facet::new::{FacetGroupValueCodec, FacetKeyCodec, MyByteSlice};
mod facet_distribution; mod facet_distribution;
mod facet_distribution_iter; mod facet_distribution_iter;
@ -78,17 +77,18 @@ pub(crate) fn get_highest_level<'t>(
#[cfg(test)] #[cfg(test)]
pub mod test { pub mod test {
use crate::update::FacetsUpdateIncremental; use std::fmt::Display;
use std::marker::PhantomData;
use std::rc::Rc;
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 crate::{ use crate::heed_codec::facet::new::{
heed_codec::facet::new::{
FacetGroupValue, FacetGroupValueCodec, FacetKey, FacetKeyCodec, MyByteSlice, FacetGroupValue, FacetGroupValueCodec, FacetKey, FacetKeyCodec, MyByteSlice,
},
snapshot_tests::display_bitmap,
}; };
use crate::snapshot_tests::display_bitmap;
use crate::update::FacetsUpdateIncremental;
pub struct FacetIndex<BoundCodec> pub struct FacetIndex<BoundCodec>
where where

View File

@ -1,10 +1,12 @@
use crate::heed_codec::facet::new::{FacetGroupValue, FacetKey};
use crate::{make_db_snap_from_iter, ExternalDocumentsIds, Index};
use roaring::RoaringBitmap;
use std::borrow::Cow; use std::borrow::Cow;
use std::fmt::Write; use std::fmt::Write;
use std::path::Path; use std::path::Path;
use roaring::RoaringBitmap;
use crate::heed_codec::facet::new::{FacetGroupValue, FacetKey};
use crate::{make_db_snap_from_iter, ExternalDocumentsIds, Index};
#[track_caller] #[track_caller]
pub fn default_db_snapshot_settings_for_test(name: Option<&str>) -> (insta::Settings, String) { pub fn default_db_snapshot_settings_for_test(name: Option<&str>) -> (insta::Settings, String) {
let mut settings = insta::Settings::clone_current(); let mut settings = insta::Settings::clone_current();

View File

@ -1,3 +1,14 @@
use std::cmp;
use std::fs::File;
use std::num::NonZeroUsize;
use grenad::CompressionType;
use heed::types::ByteSlice;
use heed::{BytesEncode, Error, RoTxn};
use log::debug;
use roaring::RoaringBitmap;
use time::OffsetDateTime;
use crate::error::InternalError; use crate::error::InternalError;
use crate::facet::FacetType; use crate::facet::FacetType;
use crate::heed_codec::facet::new::{ use crate::heed_codec::facet::new::{
@ -5,15 +16,6 @@ use crate::heed_codec::facet::new::{
}; };
use crate::update::index_documents::{create_writer, write_into_lmdb_database, writer_into_reader}; use crate::update::index_documents::{create_writer, write_into_lmdb_database, writer_into_reader};
use crate::{FieldId, Index, Result}; use crate::{FieldId, Index, Result};
use grenad::CompressionType;
use heed::types::ByteSlice;
use heed::{BytesEncode, Error, RoTxn};
use log::debug;
use roaring::RoaringBitmap;
use std::cmp;
use std::fs::File;
use std::num::NonZeroUsize;
use time::OffsetDateTime;
pub struct FacetsUpdateBulk<'i> { pub struct FacetsUpdateBulk<'i> {
index: &'i Index, index: &'i Index,

View File

@ -1,11 +1,12 @@
use heed::types::ByteSlice;
use heed::{BytesDecode, Error, RoTxn, RwTxn};
use roaring::RoaringBitmap;
use crate::heed_codec::facet::new::{ use crate::heed_codec::facet::new::{
FacetGroupValue, FacetGroupValueCodec, FacetKey, FacetKeyCodec, MyByteSlice, FacetGroupValue, FacetGroupValueCodec, FacetKey, FacetKeyCodec, MyByteSlice,
}; };
use crate::search::facet::get_highest_level; use crate::search::facet::get_highest_level;
use crate::Result; use crate::Result;
use heed::Error;
use heed::{types::ByteSlice, BytesDecode, RoTxn, RwTxn};
use roaring::RoaringBitmap;
enum InsertionResult { enum InsertionResult {
InPlace, InPlace,
@ -462,19 +463,19 @@ impl FacetsUpdateIncremental {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::milli_snap; use heed::types::ByteSlice;
use crate::{ use heed::{BytesDecode, BytesEncode};
heed_codec::facet::new::{ use rand::seq::SliceRandom;
ordered_f64_codec::OrderedF64Codec, str_ref::StrRefCodec, FacetGroupValueCodec, use rand::{Rng, SeedableRng};
FacetKeyCodec, MyByteSlice,
},
search::facet::{get_highest_level, test::FacetIndex},
};
use heed::{types::ByteSlice, BytesDecode, BytesEncode};
use rand::Rng;
use rand::{seq::SliceRandom, SeedableRng};
use roaring::RoaringBitmap; use roaring::RoaringBitmap;
use crate::heed_codec::facet::new::ordered_f64_codec::OrderedF64Codec;
use crate::heed_codec::facet::new::str_ref::StrRefCodec;
use crate::heed_codec::facet::new::{FacetGroupValueCodec, FacetKeyCodec, MyByteSlice};
use crate::milli_snap;
use crate::search::facet::get_highest_level;
use crate::search::facet::test::FacetIndex;
pub fn verify_structure_validity<C>(index: &FacetIndex<C>, field_id: u16) pub fn verify_structure_validity<C>(index: &FacetIndex<C>, field_id: u16)
where where
for<'a> C: BytesDecode<'a> + BytesEncode<'a, EItem = <C as BytesDecode<'a>>::DItem>, for<'a> C: BytesDecode<'a> + BytesEncode<'a, EItem = <C as BytesDecode<'a>>::DItem>,

View File

@ -1,11 +1,13 @@
use std::fs::File;
use std::io;
use heed::BytesEncode;
use super::helpers::{create_sorter, sorter_into_reader, try_split_array_at, GrenadParameters}; use super::helpers::{create_sorter, sorter_into_reader, try_split_array_at, GrenadParameters};
use crate::heed_codec::facet::new::str_ref::StrRefCodec; use crate::heed_codec::facet::new::str_ref::StrRefCodec;
use crate::heed_codec::facet::new::{FacetKey, FacetKeyCodec}; use crate::heed_codec::facet::new::{FacetKey, FacetKeyCodec};
use crate::update::index_documents::merge_cbo_roaring_bitmaps; use crate::update::index_documents::merge_cbo_roaring_bitmaps;
use crate::{FieldId, Result}; use crate::{FieldId, Result};
use heed::BytesEncode;
use std::fs::File;
use std::io;
/// Extracts the facet string and the documents ids where this facet string appear. /// Extracts the facet string and the documents ids where this facet string appear.
/// ///