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

Function window_aggr_no_list

src/expr/src/relation/func.rs:1313–1363  ·  view source on GitHub ↗

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

(
    input_datums: I,
    callers_temp_storage: &'b RowArena,
    wrapped_aggregate: &AggregateFunc,
    order_by: &[ColumnOrder],
    window_frame: &WindowFrame,
)

Source from the content-addressed store, hash-verified

1311/// Like `window_aggr`, but doesn't perform the final wrapping in a list, returning an Iterator
1312/// instead.
1313fn window_aggr_no_list<'a: 'b, 'b, I, A>(
1314 input_datums: I,
1315 callers_temp_storage: &'b RowArena,
1316 wrapped_aggregate: &AggregateFunc,
1317 order_by: &[ColumnOrder],
1318 window_frame: &WindowFrame,
1319) -> impl Iterator<Item = Datum<'b>>
1320where
1321 I: IntoIterator<Item = Datum<'a>>,
1322 A: OneByOneAggr,
1323{
1324 // Sort the datums according to the ORDER BY expressions and return the ((OriginalRow, InputValue), OrderByRow) record
1325 // The OrderByRow is kept around because it is required to compute the peer groups in RANGE mode
1326 let datums = order_aggregate_datums_with_rank(input_datums, order_by);
1327
1328 // Decode the input (OriginalRow, InputValue) into separate datums, while keeping the OrderByRow
1329 let size_hint = datums.size_hint().0;
1330 let mut args: Vec<Datum> = Vec::with_capacity(size_hint);
1331 let mut original_rows: Vec<Datum> = Vec::with_capacity(size_hint);
1332 let mut order_by_rows = Vec::with_capacity(size_hint);
1333 for (d, order_by_row) in datums.into_iter() {
1334 let mut iter = d.unwrap_list().iter();
1335 let original_row = iter.next().unwrap();
1336 let arg = iter.next().unwrap();
1337 order_by_rows.push(order_by_row);
1338 original_rows.push(original_row);
1339 args.push(arg);
1340 }
1341
1342 let results = window_aggr_inner::<A>(
1343 args,
1344 &order_by_rows,
1345 wrapped_aggregate,
1346 order_by,
1347 window_frame,
1348 callers_temp_storage,
1349 );
1350
1351 callers_temp_storage.reserve(results.len());
1352 results
1353 .into_iter()
1354 .zip_eq(original_rows)
1355 .map(|(result_value, original_row)| {
1356 callers_temp_storage.make_datum(|packer| {
1357 packer.push_list_with(|packer| {
1358 packer.push(result_value);
1359 packer.push(original_row);
1360 });
1361 })
1362 })
1363}
1364
1365fn window_aggr_inner<'a, A>(
1366 mut args: Vec<Datum<'a>>,

Callers

nothing calls this directly

Calls 13

unwrap_listMethod · 0.80
unwrapMethod · 0.80
make_datumMethod · 0.80
push_list_withMethod · 0.80
size_hintMethod · 0.45
into_iterMethod · 0.45
iterMethod · 0.45
nextMethod · 0.45
pushMethod · 0.45
reserveMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected