mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-08-18 12:08:22 +00:00
const assert, unreachable
This commit is contained in:
@@ -857,7 +857,7 @@ struct TermBucketWithLanes<B, const LANES: usize> {
|
||||
impl<B: BucketIdSlot, const LANES: usize> TermBucketWithLanes<B, LANES> {
|
||||
#[inline(always)]
|
||||
fn new(bucket_id_provider: &mut BucketIdProvider) -> Self {
|
||||
assert!(LANES > 0, "a term bucket needs at least one count lane");
|
||||
const { assert!(LANES > 0, "a term bucket needs at least one count lane") };
|
||||
Self {
|
||||
count_lanes: [0; LANES],
|
||||
bucket_id: B::assign(bucket_id_provider),
|
||||
@@ -918,7 +918,7 @@ impl<B: BucketIdSlot, const LANES: usize> TermAggregationMap for VecTermBucketsW
|
||||
}
|
||||
|
||||
fn new(num_terms: u64, bucket_id_provider: &mut BucketIdProvider) -> Self {
|
||||
assert!(LANES > 0, "a term map needs at least one count lane");
|
||||
const { assert!(LANES > 0, "a term map needs at least one count lane") };
|
||||
let buckets =
|
||||
std::iter::repeat_with(|| TermBucketWithLanes::<B, LANES>::new(bucket_id_provider))
|
||||
.take(num_terms as usize)
|
||||
|
||||
@@ -55,16 +55,13 @@ trait BucketResolver: Debug + 'static {
|
||||
counts: &mut [[u32; LANES]],
|
||||
);
|
||||
|
||||
/// Bounded variant. Only the computed resolver is constructed for binding hard bounds; the
|
||||
/// default remains useful for the statically unbounded resolvers.
|
||||
/// Resolves values with hard bounds while preserving each term's total document count.
|
||||
fn collect_block_with_bounds<const LANES: usize>(
|
||||
&mut self,
|
||||
term_ids: impl Iterator<Item = u64>,
|
||||
counts: &mut [[u32; LANES]],
|
||||
_term_counts: &mut [[u32; LANES]],
|
||||
) {
|
||||
self.collect_block(term_ids, counts);
|
||||
}
|
||||
term_counts: &mut [[u32; LANES]],
|
||||
);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -109,6 +106,15 @@ impl BucketResolver for SingleBucketResolver {
|
||||
increment_grid_count(counts, term_id, 0, 1, self.next_count_lane);
|
||||
}
|
||||
}
|
||||
|
||||
fn collect_block_with_bounds<const LANES: usize>(
|
||||
&mut self,
|
||||
_term_ids: impl Iterator<Item = u64>,
|
||||
_counts: &mut [[u32; LANES]],
|
||||
_term_counts: &mut [[u32; LANES]],
|
||||
) {
|
||||
unreachable!("SingleBucketResolver is only constructed without hard bounds");
|
||||
}
|
||||
}
|
||||
|
||||
/// The general resolver. It preserves the existing field conversion and floating-point bucket
|
||||
@@ -284,6 +290,18 @@ impl<const NUM_BUCKETS: usize> BucketResolver for LinearBucketResolver<NUM_BUCKE
|
||||
increment_grid_count(counts, term_id, bucket, num_buckets, self.next_count_lane);
|
||||
}
|
||||
}
|
||||
|
||||
fn collect_block_with_bounds<const LANES: usize>(
|
||||
&mut self,
|
||||
_term_ids: impl Iterator<Item = u64>,
|
||||
_counts: &mut [[u32; LANES]],
|
||||
_term_counts: &mut [[u32; LANES]],
|
||||
) {
|
||||
panic!(
|
||||
"LinearBucketResolver does not support hard bounds and should not be constructed with \
|
||||
them"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Finds the first monotonic fast-field value assigned to `target_bucket` or a later bucket. Doing
|
||||
@@ -570,7 +588,7 @@ fn build_collector<const LANES: usize>(
|
||||
num_time_buckets: usize,
|
||||
base_pos: i64,
|
||||
) -> crate::Result<Box<dyn SegmentAggregationCollector>> {
|
||||
assert!(LANES > 0, "a fused grid needs at least one count lane");
|
||||
const { assert!(LANES > 0, "a fused grid needs at least one count lane") };
|
||||
|
||||
let all_docs_in_bounds =
|
||||
hist_req_data.bounds.min == f64::MIN && hist_req_data.bounds.max == f64::MAX;
|
||||
|
||||
Reference in New Issue
Block a user