MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / fused_value_window_func_no_list

Function fused_value_window_func_no_list

src/expr/src/relation/func.rs:1191–1277  ·  view source on GitHub ↗

Like `fused_value_window_func`, but doesn't perform the final wrapping in a list, returning an Iterator instead.

(
    input_datums: I,
    callers_temp_storage: &'b RowArena,
    funcs: &Vec<AggregateFunc>,
    order_by: &Vec<ColumnOrder>,
)

Source from the content-addressed store, hash-verified

1189/// Like `fused_value_window_func`, but doesn't perform the final wrapping in a list, returning an
1190/// Iterator instead.
1191fn fused_value_window_func_no_list<'a: 'b, 'b, I>(
1192 input_datums: I,
1193 callers_temp_storage: &'b RowArena,
1194 funcs: &Vec<AggregateFunc>,
1195 order_by: &Vec<ColumnOrder>,
1196) -> impl Iterator<Item = Datum<'b>>
1197where
1198 I: IntoIterator<Item = Datum<'a>>,
1199{
1200 let has_last_value = funcs
1201 .iter()
1202 .any(|f| matches!(f, AggregateFunc::LastValue { .. }));
1203
1204 let input_datums_with_ranks = order_aggregate_datums_with_rank(input_datums, order_by);
1205
1206 let size_hint = input_datums_with_ranks.size_hint().0;
1207 let mut encoded_argsss = vec![Vec::with_capacity(size_hint); funcs.len()];
1208 let mut original_rows = Vec::with_capacity(size_hint);
1209 let mut order_by_rows = Vec::with_capacity(size_hint);
1210 for (d, order_by_row) in input_datums_with_ranks {
1211 let mut iter = d.unwrap_list().iter();
1212 let original_row = iter.next().unwrap();
1213 original_rows.push(original_row);
1214 let mut argss_iter = iter.next().unwrap().unwrap_list().iter();
1215 for i in 0..funcs.len() {
1216 let encoded_args = argss_iter.next().unwrap();
1217 encoded_argsss[i].push(encoded_args);
1218 }
1219 if has_last_value {
1220 order_by_rows.push(order_by_row);
1221 }
1222 }
1223
1224 let mut results_per_row = vec![Vec::with_capacity(funcs.len()); original_rows.len()];
1225 for (func, encoded_argss) in funcs.iter().zip_eq(encoded_argsss) {
1226 let results = match func {
1227 AggregateFunc::LagLead {
1228 order_by: inner_order_by,
1229 lag_lead,
1230 ignore_nulls,
1231 } => {
1232 assert_eq!(order_by, inner_order_by);
1233 let unwrapped_argss = encoded_argss
1234 .into_iter()
1235 .map(|encoded_args| unwrap_lag_lead_encoded_args(encoded_args))
1236 .collect();
1237 lag_lead_inner(unwrapped_argss, lag_lead, ignore_nulls)
1238 }
1239 AggregateFunc::FirstValue {
1240 order_by: inner_order_by,
1241 window_frame,
1242 } => {
1243 assert_eq!(order_by, inner_order_by);
1244 // (No unwrapping to do on the args here, because there is only 1 arg, so it's not
1245 // wrapped into a record.)
1246 first_value_inner(encoded_argss, window_frame)
1247 }
1248 AggregateFunc::LastValue {

Callers 2

fused_value_window_funcFunction · 0.85
eval_with_unnest_listMethod · 0.85

Calls 15

lag_lead_innerFunction · 0.85
first_value_innerFunction · 0.85
last_value_innerFunction · 0.85
anyMethod · 0.80
unwrap_listMethod · 0.80
unwrapMethod · 0.80
enumerateMethod · 0.80
make_datumMethod · 0.80
push_list_withMethod · 0.80
push_listMethod · 0.80

Tested by

no test coverage detected