@@ -34,35 +34,6 @@ pub trait SharedThreshold<T>: Send + Sync {
3434 expected_threshold : & Option < ( T , SegmentOrdinal ) > ,
3535 new_threshold : ( T , SegmentOrdinal ) ,
3636 ) -> Result < ( ) , Option < ( T , SegmentOrdinal ) > > ;
37-
38- /// Returns a threshold value `T` that is strictly better than the current shared threshold
39- /// if the given `segment_ord` would lose a tie-break against the `threshold_ord`.
40- ///
41- /// This is used for Block-Max WAND pruning to ensure determinism when multiple segments
42- /// have documents with the same score. Currently, this is only used for score-based
43- /// pushdown; for other types, it can safely return the value unchanged.
44- ///
45- /// # Tie-breaking Logic
46- /// Tantivy breaks ties on sort keys by favoring documents with a lower [`DocAddress`].
47- /// A [`DocAddress`] is composed of a `segment_ord` and a `doc_id`. Since documents within
48- /// a segment are processed in ascending `doc_id` order, any new document in a segment
49- /// with `segment_ord >= threshold_ord` will have a strictly higher [`DocAddress`] than the
50- /// document that set the threshold.
51- ///
52- /// Therefore, if `segment_ord >= threshold_ord`, this method should return a threshold that
53- /// is "one step better" than `value`. For floating-point scores, this is typically
54- /// `value.next_up()`. If `segment_ord < threshold_ord`, the document could still win the
55- /// tie-break, so the `value` should be returned unchanged.
56- fn competitive_threshold (
57- & self ,
58- value : T ,
59- threshold_ord : SegmentOrdinal ,
60- segment_ord : SegmentOrdinal ,
61- ) -> T {
62- let _ = threshold_ord;
63- let _ = segment_ord;
64- value
65- }
6637}
6738
6839#[ inline]
@@ -151,25 +122,6 @@ impl SharedThreshold<Score> for AtomicSharedThreshold {
151122 }
152123 }
153124 }
154-
155- fn competitive_threshold (
156- & self ,
157- value : Score ,
158- threshold_ord : SegmentOrdinal ,
159- segment_ord : SegmentOrdinal ,
160- ) -> Score {
161- if segment_ord < threshold_ord {
162- // If our segment wins tie-breaks against the threshold setter, we want to accept
163- // documents with a score GREATER THAN OR EQUAL to the threshold.
164- // Since Tantivy's pruning loop uses a strict `score > threshold` check, we
165- // return `next_down()` to effectively relax the check to `>=`.
166- value. next_down ( )
167- } else {
168- // If our segment loses tie-breaks, we demand a score STRICTLY GREATER than the
169- // threshold. The pruning loop's `score > threshold` check already achieves this.
170- value
171- }
172- }
173125}
174126
175127/// A shared threshold for `Option<u64>` values.
@@ -215,15 +167,6 @@ impl SharedThreshold<Option<u64>> for RwLockSharedThresholdOptionU64 {
215167 Err ( * guard)
216168 }
217169 }
218-
219- fn competitive_threshold (
220- & self ,
221- value : Option < u64 > ,
222- _threshold_ord : SegmentOrdinal ,
223- _segment_ord : SegmentOrdinal ,
224- ) -> Option < u64 > {
225- value
226- }
227170}
228171
229172#[ cfg( test) ]
@@ -305,34 +248,6 @@ mod tests {
305248 assert_eq ! ( t. load( ) , Some ( ( 0.9 , 10 ) ) ) ;
306249 }
307250
308- #[ test]
309- fn test_competitive_threshold ( ) {
310- let t = AtomicSharedThreshold :: default ( ) ;
311- let is_better = |a : & Score , a_ord : SegmentOrdinal , b : & Score , b_ord : SegmentOrdinal | {
312- if a > b {
313- true
314- } else if a == b {
315- a_ord < b_ord
316- } else {
317- false
318- }
319- } ;
320- update_helper ( & t, 0.5 , 5 , & ( ) , & is_better) ;
321-
322- // Segment 5 itself: should require strictly greater score for new docs.
323- // The pruning loop uses `score > threshold`, so returning 0.5 unchanged
324- // means we only accept scores > 0.5.
325- assert_eq ! ( t. competitive_threshold( 0.5 , 5 , 5 ) , 0.5 ) ;
326-
327- // Segment 6 (later): should require strictly greater score.
328- assert_eq ! ( t. competitive_threshold( 0.5 , 5 , 6 ) , 0.5 ) ;
329-
330- // Segment 4 (earlier): can accept equal score (>= 0.5).
331- // Since pruning loop is `score > threshold`, we must return `next_down(0.5)`
332- // so that `0.5 > next_down(0.5)` is true.
333- assert_eq ! ( t. competitive_threshold( 0.5 , 5 , 4 ) , 0.5f32 . next_down( ) ) ;
334- }
335-
336251 #[ test]
337252 fn test_rwlock_shared_threshold_option_u64_asc ( ) {
338253 let t = RwLockSharedThresholdOptionU64 :: new ( ) ;
0 commit comments