@@ -27,10 +27,11 @@ use quickwit_proto::types::SplitId;
2727use serde:: Deserialize ;
2828use tantivy:: aggregation:: agg_req:: { Aggregations , get_fast_field_names} ;
2929use tantivy:: aggregation:: intermediate_agg_result:: IntermediateAggregationResults ;
30- use tantivy:: aggregation:: { AggregationLimitsGuard , AggregationSegmentCollector } ;
30+ use tantivy:: aggregation:: { AggContextParams , AggregationLimitsGuard , AggregationSegmentCollector } ;
3131use tantivy:: collector:: { Collector , SegmentCollector } ;
3232use tantivy:: columnar:: { ColumnType , MonotonicallyMappableToU64 } ;
3333use tantivy:: fastfield:: Column ;
34+ use tantivy:: tokenizer:: TokenizerManager ;
3435use tantivy:: { DateTime , DocId , Score , SegmentOrdinal , SegmentReader , TantivyError } ;
3536
3637use crate :: find_trace_ids_collector:: { FindTraceIdsCollector , FindTraceIdsSegmentCollector , Span } ;
@@ -715,7 +716,7 @@ pub(crate) struct QuickwitCollector {
715716 pub max_hits : usize ,
716717 pub sort_by : SortByPair ,
717718 pub aggregation : Option < QuickwitAggregations > ,
718- pub aggregation_limits : AggregationLimitsGuard ,
719+ pub agg_context_params : AggContextParams ,
719720 search_after : Option < PartialHit > ,
720721}
721722
@@ -785,7 +786,7 @@ impl Collector for QuickwitCollector {
785786 aggs,
786787 segment_reader,
787788 segment_ord,
788- & self . aggregation_limits ,
789+ & self . agg_context_params ,
789790 ) ?,
790791 ) ,
791792 ) ,
@@ -1033,7 +1034,7 @@ pub(crate) fn sort_by_from_request(search_request: &SearchRequest) -> SortByPair
10331034pub ( crate ) fn make_collector_for_split (
10341035 split_id : SplitId ,
10351036 search_request : & SearchRequest ,
1036- aggregation_limits : AggregationLimitsGuard ,
1037+ agg_context_params : AggContextParams ,
10371038) -> crate :: Result < QuickwitCollector > {
10381039 let aggregation = match & search_request. aggregation_request {
10391040 Some ( aggregation) => Some ( serde_json:: from_str ( aggregation) ?) ,
@@ -1046,16 +1047,23 @@ pub(crate) fn make_collector_for_split(
10461047 max_hits : search_request. max_hits as usize ,
10471048 sort_by,
10481049 aggregation,
1049- aggregation_limits ,
1050+ agg_context_params ,
10501051 search_after : search_request. search_after . clone ( ) ,
10511052 } )
10521053}
10531054
10541055/// Builds a QuickwitCollector that's only useful for merging fruits.
10551056pub ( crate ) fn make_merge_collector (
10561057 search_request : & SearchRequest ,
1057- aggregation_limits : & AggregationLimitsGuard ,
1058+ agg_limits : AggregationLimitsGuard ,
10581059) -> crate :: Result < QuickwitCollector > {
1060+ // Note: at this point the tokenizer manager is not used anymore by aggregations (filter query),
1061+ // so we can create an empty one. So if it will ever be used, it would panic.
1062+ let agg_context_params = AggContextParams {
1063+ limits : agg_limits,
1064+ tokenizers : TokenizerManager :: new ( ) ,
1065+ } ;
1066+
10591067 let aggregation = match & search_request. aggregation_request {
10601068 Some ( aggregation) => Some ( serde_json:: from_str ( aggregation) ?) ,
10611069 None => None ,
@@ -1067,7 +1075,7 @@ pub(crate) fn make_merge_collector(
10671075 max_hits : search_request. max_hits as usize ,
10681076 sort_by,
10691077 aggregation,
1070- aggregation_limits : aggregation_limits . clone ( ) ,
1078+ agg_context_params ,
10711079 search_after : search_request. search_after . clone ( ) ,
10721080 } )
10731081}
@@ -1748,7 +1756,7 @@ mod tests {
17481756 request : & SearchRequest ,
17491757 results : Vec < LeafSearchResponse > ,
17501758 ) -> LeafSearchResponse {
1751- let collector = make_merge_collector ( request, & Default :: default ( ) ) . unwrap ( ) ;
1759+ let collector = make_merge_collector ( request, Default :: default ( ) ) . unwrap ( ) ;
17521760 let mut incremental_collector = IncrementalCollector :: new ( collector. clone ( ) ) ;
17531761
17541762 let result = collector
0 commit comments