feat: Remove the FilterFunc alias type

This commit is contained in:
Clément Renault 2019-02-25 18:39:58 +01:00
parent 19e67dcf0b
commit 5d5bcf7011
No known key found for this signature in database
GPG Key ID: 0151CDAB43460DAE
3 changed files with 5 additions and 8 deletions

View File

@ -15,7 +15,7 @@ use slice_group_by::GroupBy;
use rayon::slice::ParallelSliceMut;
pub use self::index::{Index, IndexBuilder};
pub use self::query_builder::{FilterFunc, QueryBuilder, DistinctQueryBuilder};
pub use self::query_builder::{QueryBuilder, DistinctQueryBuilder};
/// Represent an internally generated document unique identifier.
///

View File

@ -35,16 +35,14 @@ fn generate_automatons(query: &str) -> Vec<DfaExt> {
automatons
}
pub type FilterFunc = fn(DocumentId) -> bool;
pub struct QueryBuilder<'i, 'c, FI> {
pub struct QueryBuilder<'i, 'c, FI = fn(DocumentId) -> bool> {
index: &'i Index,
criteria: Criteria<'c>,
searchable_attrs: Option<HashSet<u16>>,
filter: Option<FI>,
}
impl<'i, 'c> QueryBuilder<'i, 'c, FilterFunc> {
impl<'i, 'c> QueryBuilder<'i, 'c, fn(DocumentId) -> bool> {
pub fn new(index: &'i Index) -> Self {
QueryBuilder::with_criteria(index, Criteria::default())
}

View File

@ -6,8 +6,7 @@ use std::{fmt, marker};
use rocksdb::rocksdb_options::{ReadOptions, EnvOptions, ColumnFamilyOptions};
use rocksdb::rocksdb::{DB, DBVector, Snapshot, SeekKey, SstFileWriter};
use serde::de::DeserializeOwned;
use meilidb_core::{Index, QueryBuilder, FilterFunc};
use meilidb_core::DocumentId;
use meilidb_core::{Index, QueryBuilder, DocumentId};
use crate::database::{retrieve_data_schema, retrieve_data_index, retrieve_data_ranked_map, retrieve_config};
use crate::database::serde::deserializer::Deserializer;
@ -84,7 +83,7 @@ where D: Deref<Target=DB>
Ok(())
}
pub fn query_builder(&self) -> QueryBuilder<FilterFunc> {
pub fn query_builder(&self) -> QueryBuilder {
QueryBuilder::new(self.index())
}