feat: Make the DatabaseView become Sync + Send

This commit is contained in:
Clément Renault
2018-12-07 17:59:03 +01:00
parent bec463a61a
commit 0e825e05bb
11 changed files with 147 additions and 72 deletions

View File

@ -1,5 +1,7 @@
use std::cmp::Ordering;
use std::ops::Deref;
use rocksdb::DB;
use group_by::GroupBy;
use crate::database::DatabaseView;
@ -19,8 +21,10 @@ fn sum_matches_attribute_index(matches: &[Match]) -> u32 {
#[derive(Debug, Clone, Copy)]
pub struct SumOfWordsPosition;
impl Criterion for SumOfWordsPosition {
fn evaluate(&self, lhs: &Document, rhs: &Document, _: &DatabaseView) -> Ordering {
impl<D> Criterion<D> for SumOfWordsPosition
where D: Deref<Target=DB>
{
fn evaluate(&self, lhs: &Document, rhs: &Document, _: &DatabaseView<D>) -> Ordering {
let lhs = sum_matches_attribute_index(&lhs.matches);
let rhs = sum_matches_attribute_index(&rhs.matches);