Remove DocId restriction from TopKProvider
- Id
- 15cc861125f7af3ad493a17f6fa86758ee1fcc6c
- Author
- Caio
- Commit time
- 2020-01-24T09:00:43+01:00
Modified tique/src/conditional_collector/custom_score.rs
pub struct CustomScoreTopCollector<T, P, C, S>
where
T: PartialOrd,
- P: TopKProvider<T>,
+ P: TopKProvider<T, DocId>,
C: ConditionForSegment<T>,
{
limit: usize,
impl<T, P, C, S> CustomScoreTopCollector<T, P, C, S>
where
T: PartialOrd,
- P: TopKProvider<T>,
+ P: TopKProvider<T, DocId>,
C: ConditionForSegment<T>,
{
pub fn new(limit: usize, condition_for_segment: C, scorer_for_segment: S) -> Self {
impl<T, P, C, S> Collector for CustomScoreTopCollector<T, P, C, S>
where
T: 'static + PartialOrd + Copy + Send + Sync,
- P: 'static + Send + Sync + TopKProvider<T>,
+ P: 'static + Send + Sync + TopKProvider<T, DocId>,
C: Sync + ConditionForSegment<T>,
S: ScorerForSegment<T>,
{
Modified tique/src/conditional_collector/top_collector.rs
impl<T, P, CF> TopCollector<T, P, CF>
where
T: PartialOrd,
- P: TopKProvider<T>,
+ P: TopKProvider<T, DocId>,
CF: ConditionForSegment<T>,
{
pub fn new(limit: usize, condition_for_segment: CF) -> Self {
($type: ident, $err: literal) => {
impl<P, CF> TopCollector<$type, P, CF>
where
- P: 'static + Send + Sync + TopKProvider<$type>,
+ P: 'static + Send + Sync + TopKProvider<$type, DocId>,
CF: Send + Sync + ConditionForSegment<$type>,
{
pub fn top_fast_field(
impl<P, CF> Collector for TopCollector<Score, P, CF>
where
- P: 'static + Send + Sync + TopKProvider<Score>,
+ P: 'static + Send + Sync + TopKProvider<Score, DocId>,
CF: Sync + ConditionForSegment<Score>,
{
type Fruit = CollectionResult<Score>;
Modified tique/src/conditional_collector/topk.rs
use std::{
cmp::{Ordering, Reverse},
collections::BinaryHeap,
};
-use tantivy::DocId;
-
use super::CollectionResult;
pub trait TopK<T, D> {
fn into_vec(self) -> Vec<(T, D)>;
}
-pub trait TopKProvider<T: PartialOrd> {
- type Child: TopK<T, DocId>;
+pub trait TopKProvider<T: PartialOrd, D: Ord> {
+ type Child: TopK<T, D>;
fn new_topk(limit: usize) -> Self::Child;
fn merge_many(limit: usize, items: Vec<CollectionResult<T>>) -> CollectionResult<T>;
pub struct Ascending;
-impl<T: PartialOrd> TopKProvider<T> for Ascending {
- type Child = AscendingTopK<T, DocId>;
+impl<T: PartialOrd, D: Ord> TopKProvider<T, D> for Ascending {
+ type Child = AscendingTopK<T, D>;
fn new_topk(limit: usize) -> Self::Child {
AscendingTopK::new(limit)
pub struct Descending;
-impl<T: PartialOrd> TopKProvider<T> for Descending {
- type Child = DescendingTopK<T, DocId>;
+impl<T: PartialOrd, D: Ord> TopKProvider<T, D> for Descending {
+ type Child = DescendingTopK<T, D>;
fn new_topk(limit: usize) -> Self::Child {
DescendingTopK {