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

Function last_value_no_list

src/expr/src/relation/func.rs:1036–1077  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

1034/// Like `last_value`, but doesn't perform the final wrapping in a list, returning an Iterator
1035/// instead.
1036fn last_value_no_list<'a: 'b, 'b, I>(
1037 datums: I,
1038 callers_temp_storage: &'b RowArena,
1039 order_by: &[ColumnOrder],
1040 window_frame: &WindowFrame,
1041) -> impl Iterator<Item = Datum<'b>>
1042where
1043 I: IntoIterator<Item = Datum<'a>>,
1044{
1045 // Sort the datums according to the ORDER BY expressions and return the ((OriginalRow, InputValue), OrderByRow) record
1046 // The OrderByRow is kept around because it is required to compute the peer groups in RANGE mode
1047 let datums = order_aggregate_datums_with_rank(datums, order_by);
1048
1049 // Decode the input (OriginalRow, InputValue) into separate datums, while keeping the OrderByRow
1050 let size_hint = datums.size_hint().0;
1051 let mut args = Vec::with_capacity(size_hint);
1052 let mut original_rows = Vec::with_capacity(size_hint);
1053 let mut order_by_rows = Vec::with_capacity(size_hint);
1054 for (d, order_by_row) in datums.into_iter() {
1055 let mut iter = d.unwrap_list().iter();
1056 let original_row = iter.next().unwrap();
1057 let arg = iter.next().unwrap();
1058 order_by_rows.push(order_by_row);
1059 original_rows.push(original_row);
1060 args.push(arg);
1061 }
1062
1063 let results = last_value_inner(args, &order_by_rows, window_frame);
1064
1065 callers_temp_storage.reserve(results.len());
1066 results
1067 .into_iter()
1068 .zip_eq(original_rows)
1069 .map(|(result_value, original_row)| {
1070 callers_temp_storage.make_datum(|packer| {
1071 packer.push_list_with(|packer| {
1072 packer.push(result_value);
1073 packer.push(original_row);
1074 });
1075 })
1076 })
1077}
1078
1079fn last_value_inner<'a>(
1080 args: Vec<Datum<'a>>,

Callers 2

last_valueFunction · 0.85
eval_with_unnest_listMethod · 0.85

Calls 14

last_value_innerFunction · 0.85
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

Tested by

no test coverage detected