From 3cd9011f874ff6ceef22d30cced94ac600afed5e Mon Sep 17 00:00:00 2001 From: alexanderbianchi <75697973+alexanderbianchi@users.noreply.github.com> Date: Thu, 9 Apr 2026 08:32:31 -0300 Subject: [PATCH] Make BucketEntries::iter, PercentileValuesVecEntry fields, and TopNComputer::threshold public (#2890) These items need to be accessible from the tantivy-datafusion crate: - BucketEntries::iter() for iterating aggregation bucket results - PercentileValuesVecEntry.key/.value for reading percentile results - TopNComputer.threshold for Block-WAND score pruning in the inverted index provider Co-authored-by: Claude Opus 4.6 (1M context) Co-authored-by: Paul Masurel --- src/aggregation/agg_result.rs | 3 ++- src/aggregation/metric/mod.rs | 5 ++--- src/collector/top_score_collector.rs | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/aggregation/agg_result.rs b/src/aggregation/agg_result.rs index bad0ea0f5..7755fe3b6 100644 --- a/src/aggregation/agg_result.rs +++ b/src/aggregation/agg_result.rs @@ -208,7 +208,8 @@ pub enum BucketEntries { } impl BucketEntries { - fn iter<'a>(&'a self) -> Box + 'a> { + /// Iterate over all bucket entries. + pub fn iter<'a>(&'a self) -> Box + 'a> { match self { BucketEntries::Vec(vec) => Box::new(vec.iter()), BucketEntries::HashMap(map) => Box::new(map.values()), diff --git a/src/aggregation/metric/mod.rs b/src/aggregation/metric/mod.rs index 517a2b9df..05ff861f2 100644 --- a/src/aggregation/metric/mod.rs +++ b/src/aggregation/metric/mod.rs @@ -107,10 +107,9 @@ pub enum PercentileValues { #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] /// The entry when requesting percentiles with keyed: false pub struct PercentileValuesVecEntry { - /// Percentile + /// The percentile key (e.g. 1.0, 5.0, 25.0). pub key: f64, - - /// Value at the percentile + /// The percentile value. `NaN` when there are no values. pub value: f64, } diff --git a/src/collector/top_score_collector.rs b/src/collector/top_score_collector.rs index 0ce1c611a..057df4bcc 100644 --- a/src/collector/top_score_collector.rs +++ b/src/collector/top_score_collector.rs @@ -513,7 +513,9 @@ pub struct TopNComputer { /// The buffer reverses sort order to get top-semantics instead of bottom-semantics buffer: Vec>, top_n: usize, - pub(crate) threshold: Option, + /// The current threshold for pruning. Documents with scores at or below + /// this value are skipped by `push()`. Updated when the buffer is truncated. + pub threshold: Option, comparator: C, }