risingwave_stream/executor/aggregation/
mod.rspub use agg_group::*;
pub use agg_state::*;
pub use distinct::*;
use risingwave_common::array::ArrayImpl::Bool;
use risingwave_common::array::DataChunk;
use risingwave_common::bail;
use risingwave_common::bitmap::Bitmap;
use risingwave_expr::aggregate::{AggCall, AggType, PbAggKind};
use risingwave_expr::expr::{LogReport, NonStrictExpression};
use risingwave_storage::StateStore;
use crate::common::table::state_table::StateTable;
use crate::executor::error::StreamExecutorResult;
mod agg_group;
mod agg_state;
mod agg_state_cache;
mod distinct;
mod minput;
pub async fn agg_call_filter_res(
agg_call: &AggCall,
chunk: &DataChunk,
) -> StreamExecutorResult<Bitmap> {
let mut vis = chunk.visibility().clone();
if matches!(
agg_call.agg_type,
AggType::Builtin(PbAggKind::Min | PbAggKind::Max | PbAggKind::StringAgg)
) {
let agg_col_idx = agg_call.args.val_indices()[0]; let agg_col_bitmap = chunk.column_at(agg_col_idx).null_bitmap();
vis &= agg_col_bitmap;
}
if let Some(ref filter) = agg_call.filter {
if let Bool(filter_res) = NonStrictExpression::new_topmost(&**filter, LogReport)
.eval_infallible(chunk)
.await
.as_ref()
{
vis &= filter_res.to_bitmap();
} else {
bail!("Filter can only receive bool array");
}
}
Ok(vis)
}
pub fn iter_table_storage<S>(
state_storages: &mut [AggStateStorage<S>],
) -> impl Iterator<Item = &mut StateTable<S>>
where
S: StateStore,
{
state_storages
.iter_mut()
.filter_map(|storage| match storage {
AggStateStorage::Value => None,
AggStateStorage::MaterializedInput { table, .. } => Some(table),
})
}