2018-10-10 16:57:21 +02:00
|
|
|
pub mod criterion;
|
2018-12-07 11:53:17 +01:00
|
|
|
mod query_builder;
|
2018-11-28 17:12:24 +01:00
|
|
|
mod distinct_map;
|
2018-07-07 14:43:29 +02:00
|
|
|
|
2018-09-09 11:13:58 +02:00
|
|
|
use crate::{Match, DocumentId};
|
2018-05-27 15:23:43 +02:00
|
|
|
|
2018-12-29 20:16:29 +01:00
|
|
|
pub use self::query_builder::{FilterFunc, QueryBuilder, DistinctQueryBuilder};
|
2018-05-27 15:23:43 +02:00
|
|
|
|
2018-06-25 22:26:49 +02:00
|
|
|
#[inline]
|
|
|
|
fn match_query_index(a: &Match, b: &Match) -> bool {
|
|
|
|
a.query_index == b.query_index
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
2018-05-27 15:23:43 +02:00
|
|
|
pub struct Document {
|
2018-10-10 16:57:21 +02:00
|
|
|
pub id: DocumentId,
|
2018-07-06 22:05:51 +02:00
|
|
|
pub matches: Vec<Match>,
|
2018-05-27 15:23:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Document {
|
|
|
|
pub fn new(doc: DocumentId, match_: Match) -> Self {
|
2018-10-11 14:04:41 +02:00
|
|
|
unsafe { Self::from_sorted_matches(doc, vec![match_]) }
|
2018-05-27 15:23:43 +02:00
|
|
|
}
|
|
|
|
|
2018-10-21 16:42:19 +02:00
|
|
|
pub fn from_matches(doc: DocumentId, mut matches: Vec<Match>) -> Self {
|
|
|
|
matches.sort_unstable();
|
|
|
|
unsafe { Self::from_sorted_matches(doc, matches) }
|
|
|
|
}
|
|
|
|
|
2018-10-11 14:04:41 +02:00
|
|
|
pub unsafe fn from_sorted_matches(id: DocumentId, matches: Vec<Match>) -> Self {
|
2018-10-10 16:57:21 +02:00
|
|
|
Self { id, matches }
|
2018-05-27 15:23:43 +02:00
|
|
|
}
|
|
|
|
}
|