mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-01-03 07:42:54 +00:00
Compare commits
1 Commits
update_exa
...
straightfo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad0a7a78fd |
@@ -123,6 +123,15 @@ impl AggregationWithAccessor {
|
|||||||
column_block_accessor: Default::default(),
|
column_block_accessor: Default::default(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Swaps the accessor and field type with the second accessor and field type.
|
||||||
|
/// This way we can use the same code for both aggregations.
|
||||||
|
pub(crate) fn swap_accessor(&mut self) {
|
||||||
|
if let Some(accessor) = self.accessor2.as_mut() {
|
||||||
|
std::mem::swap(&mut accessor.0, &mut self.accessor);
|
||||||
|
std::mem::swap(&mut accessor.1, &mut self.field_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_numeric_or_date_column_types() -> &'static [ColumnType] {
|
fn get_numeric_or_date_column_types() -> &'static [ColumnType] {
|
||||||
|
|||||||
@@ -263,9 +263,9 @@ impl SegmentAggregationCollector for SegmentTermCollectorComposite {
|
|||||||
agg_with_accessor: &mut AggregationsWithAccessor,
|
agg_with_accessor: &mut AggregationsWithAccessor,
|
||||||
) -> crate::Result<()> {
|
) -> crate::Result<()> {
|
||||||
self.term_agg1.collect_block(&[doc], agg_with_accessor)?;
|
self.term_agg1.collect_block(&[doc], agg_with_accessor)?;
|
||||||
self.swap_accessor(&mut agg_with_accessor.aggs.values[self.accessor_idx]);
|
agg_with_accessor.aggs.values[self.accessor_idx].swap_accessor();
|
||||||
self.term_agg2.collect_block(&[doc], agg_with_accessor)?;
|
self.term_agg2.collect_block(&[doc], agg_with_accessor)?;
|
||||||
self.swap_accessor(&mut agg_with_accessor.aggs.values[self.accessor_idx]);
|
agg_with_accessor.aggs.values[self.accessor_idx].swap_accessor();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,33 +276,22 @@ impl SegmentAggregationCollector for SegmentTermCollectorComposite {
|
|||||||
agg_with_accessor: &mut AggregationsWithAccessor,
|
agg_with_accessor: &mut AggregationsWithAccessor,
|
||||||
) -> crate::Result<()> {
|
) -> crate::Result<()> {
|
||||||
self.term_agg1.collect_block(docs, agg_with_accessor)?;
|
self.term_agg1.collect_block(docs, agg_with_accessor)?;
|
||||||
self.swap_accessor(&mut agg_with_accessor.aggs.values[self.accessor_idx]);
|
agg_with_accessor.aggs.values[self.accessor_idx].swap_accessor();
|
||||||
self.term_agg2.collect_block(docs, agg_with_accessor)?;
|
self.term_agg2.collect_block(docs, agg_with_accessor)?;
|
||||||
self.swap_accessor(&mut agg_with_accessor.aggs.values[self.accessor_idx]);
|
agg_with_accessor.aggs.values[self.accessor_idx].swap_accessor();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flush(&mut self, agg_with_accessor: &mut AggregationsWithAccessor) -> crate::Result<()> {
|
fn flush(&mut self, agg_with_accessor: &mut AggregationsWithAccessor) -> crate::Result<()> {
|
||||||
self.term_agg1.flush(agg_with_accessor)?;
|
self.term_agg1.flush(agg_with_accessor)?;
|
||||||
self.swap_accessor(&mut agg_with_accessor.aggs.values[self.accessor_idx]);
|
agg_with_accessor.aggs.values[self.accessor_idx].swap_accessor();
|
||||||
self.term_agg2.flush(agg_with_accessor)?;
|
self.term_agg2.flush(agg_with_accessor)?;
|
||||||
self.swap_accessor(&mut agg_with_accessor.aggs.values[self.accessor_idx]);
|
agg_with_accessor.aggs.values[self.accessor_idx].swap_accessor();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SegmentTermCollectorComposite {
|
impl SegmentTermCollectorComposite {
|
||||||
/// Swaps the accessor and field type with the second accessor and field type.
|
|
||||||
/// This way we can use the same code for both aggregations.
|
|
||||||
fn swap_accessor(&self, aggregations: &mut AggregationWithAccessor) {
|
|
||||||
if let Some(accessor) = aggregations.accessor2.as_mut() {
|
|
||||||
std::mem::swap(&mut accessor.0, &mut aggregations.accessor);
|
|
||||||
std::mem::swap(&mut accessor.1, &mut aggregations.field_type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn from_req_and_validate(
|
pub(crate) fn from_req_and_validate(
|
||||||
req: &TermsAggregation,
|
req: &TermsAggregation,
|
||||||
sub_aggregations: &mut AggregationsWithAccessor,
|
sub_aggregations: &mut AggregationsWithAccessor,
|
||||||
|
|||||||
Reference in New Issue
Block a user