@@ -53,7 +53,7 @@ use crate::TantivyError;
53
53
/// into segment_size.
54
54
///
55
55
/// Result type is [`BucketResult`](crate::aggregation::agg_result::BucketResult) with
56
- /// [`TermBucketEntry `](crate::aggregation::agg_result::BucketEntry) on the
56
+ /// [`BucketEntry `](crate::aggregation::agg_result::BucketEntry) on the
57
57
/// `AggregationCollector`.
58
58
///
59
59
/// Result type is
@@ -209,45 +209,6 @@ struct TermBuckets {
209
209
pub ( crate ) sub_aggs : FxHashMap < u64 , Box < dyn SegmentAggregationCollector > > ,
210
210
}
211
211
212
- #[ derive( Clone , Default ) ]
213
- struct TermBucketEntry {
214
- doc_count : u64 ,
215
- sub_aggregations : Option < Box < dyn SegmentAggregationCollector > > ,
216
- }
217
-
218
- impl Debug for TermBucketEntry {
219
- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
220
- f. debug_struct ( "TermBucketEntry" )
221
- . field ( "doc_count" , & self . doc_count )
222
- . finish ( )
223
- }
224
- }
225
-
226
- impl TermBucketEntry {
227
- fn from_blueprint ( blueprint : & Option < Box < dyn SegmentAggregationCollector > > ) -> Self {
228
- Self {
229
- doc_count : 0 ,
230
- sub_aggregations : blueprint. clone ( ) ,
231
- }
232
- }
233
-
234
- pub ( crate ) fn into_intermediate_bucket_entry (
235
- self ,
236
- agg_with_accessor : & AggregationsWithAccessor ,
237
- ) -> crate :: Result < IntermediateTermBucketEntry > {
238
- let sub_aggregation = if let Some ( sub_aggregation) = self . sub_aggregations {
239
- sub_aggregation. into_intermediate_aggregations_result ( agg_with_accessor) ?
240
- } else {
241
- Default :: default ( )
242
- } ;
243
-
244
- Ok ( IntermediateTermBucketEntry {
245
- doc_count : self . doc_count ,
246
- sub_aggregation,
247
- } )
248
- }
249
- }
250
-
251
212
impl TermBuckets {
252
213
fn force_flush ( & mut self , agg_with_accessor : & AggregationsWithAccessor ) -> crate :: Result < ( ) > {
253
214
for sub_aggregations in & mut self . sub_aggs . values_mut ( ) {
@@ -314,7 +275,7 @@ impl SegmentAggregationCollector for SegmentTermCollector {
314
275
if accessor. get_cardinality ( ) == Cardinality :: Full {
315
276
self . val_cache . resize ( docs. len ( ) , 0 ) ;
316
277
accessor. values . get_vals ( docs, & mut self . val_cache ) ;
317
- for ( doc , term_id) in docs . iter ( ) . zip ( self . val_cache . iter ( ) . cloned ( ) ) {
278
+ for term_id in self . val_cache . iter ( ) . cloned ( ) {
318
279
let entry = self . term_buckets . entries . entry ( term_id) . or_default ( ) ;
319
280
* entry += 1 ;
320
281
}
@@ -445,17 +406,19 @@ impl SegmentTermCollector {
445
406
446
407
let mut into_intermediate_bucket_entry =
447
408
|id, doc_count| -> crate :: Result < IntermediateTermBucketEntry > {
448
- let intermediate_entry = if let Some ( blueprint ) = self . blueprint . as_ref ( ) {
409
+ let intermediate_entry = if self . blueprint . as_ref ( ) . is_some ( ) {
449
410
IntermediateTermBucketEntry {
450
411
doc_count,
451
412
sub_aggregation : self
452
413
. term_buckets
453
414
. sub_aggs
454
415
. remove ( & id)
455
- . expect ( & format ! (
456
- "Internal Error: could not find subaggregation for id {}" ,
457
- id
458
- ) )
416
+ . unwrap_or_else ( || {
417
+ panic ! (
418
+ "Internal Error: could not find subaggregation for id {}" ,
419
+ id
420
+ )
421
+ } )
459
422
. into_intermediate_aggregations_result (
460
423
& agg_with_accessor. sub_aggregation ,
461
424
) ?,
@@ -525,21 +488,11 @@ impl SegmentTermCollector {
525
488
pub ( crate ) trait GetDocCount {
526
489
fn doc_count ( & self ) -> u64 ;
527
490
}
528
- impl GetDocCount for ( u32 , TermBucketEntry ) {
529
- fn doc_count ( & self ) -> u64 {
530
- self . 1 . doc_count
531
- }
532
- }
533
491
impl GetDocCount for ( u64 , u64 ) {
534
492
fn doc_count ( & self ) -> u64 {
535
493
self . 1
536
494
}
537
495
}
538
- impl GetDocCount for ( u64 , TermBucketEntry ) {
539
- fn doc_count ( & self ) -> u64 {
540
- self . 1 . doc_count
541
- }
542
- }
543
496
impl GetDocCount for ( String , IntermediateTermBucketEntry ) {
544
497
fn doc_count ( & self ) -> u64 {
545
498
self . 1 . doc_count
0 commit comments