simplify fetch block in column_block_accessor

This commit is contained in:
Pascal Seitz
2025-12-12 17:38:37 +08:00
parent 87fe3a311f
commit 3ddca31292
6 changed files with 32 additions and 48 deletions

View File

@@ -29,12 +29,20 @@ impl<T: PartialOrd + Copy + std::fmt::Debug + Send + Sync + 'static + Default>
}
}
#[inline]
pub fn fetch_block_with_missing(&mut self, docs: &[u32], accessor: &Column<T>, missing: T) {
pub fn fetch_block_with_missing(
&mut self,
docs: &[u32],
accessor: &Column<T>,
missing: Option<T>,
) {
self.fetch_block(docs, accessor);
// no missing values
if accessor.index.get_cardinality().is_full() {
return;
}
let Some(missing) = missing else {
return;
};
// We can compare docid_cache length with docs to find missing docs
// For multi value columns we can't rely on the length and always need to scan

View File

@@ -803,17 +803,11 @@ impl<TermMap: TermAggregationMap, const LOWCARD: bool> SegmentAggregationCollect
let req_data = &mut self.terms_req_data;
if let Some(missing) = req_data.missing_value_for_accessor {
agg_data.column_block_accessor.fetch_block_with_missing(
docs,
&req_data.accessor,
missing,
);
} else {
agg_data
.column_block_accessor
.fetch_block(docs, &req_data.accessor);
}
agg_data.column_block_accessor.fetch_block_with_missing(
docs,
&req_data.accessor,
req_data.missing_value_for_accessor,
);
if let Some(sub_agg) = &mut self.sub_agg {
let term_buckets = &mut self.parent_buckets[parent_bucket_id as usize];

View File

@@ -236,15 +236,11 @@ impl SegmentCardinalityCollector {
docs: &[crate::DocId],
agg_data: &mut AggregationsSegmentCtx,
) {
if let Some(missing) = self.missing_value_for_accessor {
agg_data
.column_block_accessor
.fetch_block_with_missing(docs, &self.accessor, missing);
} else {
agg_data
.column_block_accessor
.fetch_block(docs, &self.accessor);
}
agg_data.column_block_accessor.fetch_block_with_missing(
docs,
&self.accessor,
self.missing_value_for_accessor,
);
}
}

View File

@@ -373,15 +373,9 @@ impl SegmentAggregationCollector for SegmentExtendedStatsCollector {
) -> crate::Result<()> {
let mut extended_stats = self.buckets[parent_bucket_id as usize].clone();
if let Some(missing) = self.missing.as_ref() {
agg_data
.column_block_accessor
.fetch_block_with_missing(docs, &self.accessor, *missing);
} else {
agg_data
.column_block_accessor
.fetch_block(docs, &self.accessor);
}
agg_data
.column_block_accessor
.fetch_block_with_missing(docs, &self.accessor, self.missing);
for val in agg_data.column_block_accessor.iter_vals() {
let val1 = f64_from_fastfield_u64(val, self.field_type);
extended_stats.collect(val1);

View File

@@ -282,15 +282,11 @@ impl SegmentAggregationCollector for SegmentPercentilesCollector {
agg_data: &mut AggregationsSegmentCtx,
) -> crate::Result<()> {
let percentiles = &mut self.buckets[parent_bucket_id as usize];
if let Some(missing) = self.missing_u64.as_ref() {
agg_data
.column_block_accessor
.fetch_block_with_missing(docs, &self.accessor, *missing);
} else {
agg_data
.column_block_accessor
.fetch_block(docs, &self.accessor);
}
agg_data.column_block_accessor.fetch_block_with_missing(
docs,
&self.accessor,
self.missing_u64,
);
for val in agg_data.column_block_accessor.iter_vals() {
let val1 = f64_from_fastfield_u64(val, self.field_type);

View File

@@ -285,15 +285,11 @@ impl<const COLUMN_TYPE_ID: u8> SegmentAggregationCollector
return Ok(());
}
if let Some(missing) = self.missing_u64.as_ref() {
agg_data
.column_block_accessor
.fetch_block_with_missing(docs, &self.accessor, *missing);
} else {
agg_data
.column_block_accessor
.fetch_block(docs, &self.accessor);
}
agg_data.column_block_accessor.fetch_block_with_missing(
docs,
&self.accessor,
self.missing_u64,
);
collect_stats::<COLUMN_TYPE_ID>(
&mut self.buckets[parent_bucket_id as usize],
agg_data.column_block_accessor.iter_vals(),