/// Takes a term_scorers sorted by their current doc() and a threshold and returns
/// Returns (pivot_len, pivot_ord) defined as follows:
/// - `pivot_doc` lowest document that has a chance of exceeding (>) the threshold score.
/// - `before_pivot_len` number of term_scorers such that term_scorer.doc() < pivot.
/// - `pivot_len` number of term_scorers such that term_scorer.doc() <= pivot.
///
/// We always have `before_pivot_len` < `pivot_len`.
///
/// None is returned if we establish that no document can exceed the threshold.
Takes a term_scorers sorted by their current doc() and a threshold and returns
Returns (pivot_len, pivot_ord) defined as follows:
`pivot_doc` lowest document that has a chance of exceeding (>) the threshold score.



None is returned if we establish that no document can exceed the threshold.
Takes a term_scorers sorted by their current doc () and a threshold and returns Returns ( pivot_len pivot_ord ) defined as follows : ` pivot_doc ` lowest document that has a chance of exceeding ( > ) the threshold score . None is returned if we establish that no document can exceed the threshold .
fn find_pivot_doc(
    term_scorers: &[TermScorerWithMaxScore],
    threshold: Score,
) -> Option<(usize, usize, DocId)> {
    let mut max_score = 0.0;
    let mut before_pivot_len = 0;
    let mut pivot_doc = TERMINATED;
    while before_pivot_len < term_scorers.len() {
        let term_scorer = &term_scorers[before_pivot_len];
        max_score += term_scorer.max_score;
        if max_score > threshold {
            pivot_doc = term_scorer.doc();
            break;
        }
        before_pivot_len += 1;
    }
    if pivot_doc == TERMINATED {
        return None;
    }
    // Right now i is an ordinal, we want a len.
    let mut pivot_len = before_pivot_len + 1;
    // Some other term_scorer may be positioned on the same document.
    pivot_len += term_scorers[pivot_len..]
        .iter()
        .take_while(|term_scorer| term_scorer.doc() == pivot_doc)
        .count();
    Some((before_pivot_len, pivot_len, pivot_doc))
}
fn find_pivot_doc ( term_scorers : & [ TermScorerWithMaxScore ] , threshold : Score , ) -> Option < ( usize , usize , DocId ) > { let mut max_score = 0.0 ; let mut before_pivot_len = 0 ; let mut pivot_doc = TERMINATED ; while before_pivot_len < term_scorers . len ( ) { let term_scorer = & term_scorers [ before_pivot_len ] ; max_score += term_scorer . max_score ; if max_score > threshold { pivot_doc = term_scorer . doc ( ) ; break ; } before_pivot_len += 1 ; } if pivot_doc == TERMINATED { return None ; } // Right now i is an ordinal, we want a len. let mut pivot_len = before_pivot_len + 1 ; // Some other term_scorer may be positioned on the same document. pivot_len += term_scorers [ pivot_len .. ] . iter ( ) . take_while ( | term_scorer | term_scorer . doc ( ) == pivot_doc ) . count ( ) ; Some ( ( before_pivot_len , pivot_len , pivot_doc ) ) }
Takes a term_scorers sorted by their current doc() and a threshold and returns
Returns (pivot_len, pivot_ord) defined as follows:
 `pivot_doc` lowest document that has a chance of exceeding (>) the threshold score.
Takes a term_scorers sorted by their current doc () and a threshold and returns Returns ( pivot_len pivot_ord ) defined as follows : ` pivot_doc ` lowest document that has a chance of exceeding ( > ) the threshold score .
term_scorers
&[TermScorerWithMaxScore]
threshold
Score