MCPcopy Create free account
hub / github.com/apache/datafusion / state

Method state

datafusion/functions-aggregate/src/first_last.rs:641–668  ·  view source on GitHub ↗
(&mut self, emit_to: EmitTo)

Source from the content-addressed store, hash-verified

639 }
640
641 fn state(&mut self, emit_to: EmitTo) -> Result<Vec<ArrayRef>> {
642 let (val_arr, orderings, is_sets) = self.take_state(emit_to)?;
643 let mut result = Vec::with_capacity(self.orderings.len() + 2);
644
645 result.push(val_arr);
646
647 let ordering_cols = {
648 let mut ordering_cols = Vec::with_capacity(self.ordering_req.len());
649 for _ in 0..self.ordering_req.len() {
650 ordering_cols.push(Vec::with_capacity(self.orderings.len()));
651 }
652 for row in orderings.into_iter() {
653 debug_assert!(row.len() == self.ordering_req.len());
654 for (col_idx, ordering) in row.into_iter().enumerate() {
655 ordering_cols[col_idx].push(ordering);
656 }
657 }
658
659 ordering_cols
660 };
661 for ordering_col in ordering_cols {
662 result.push(ScalarValue::iter_to_array(ordering_col)?);
663 }
664
665 result.push(Arc::new(BooleanArray::new(is_sets, None)));
666
667 Ok(result)
668 }
669
670 fn merge_batch(
671 &mut self,

Callers 4

test_first_group_accFunction · 0.45
test_last_group_accFunction · 0.45

Calls 9

newFunction · 0.85
take_stateMethod · 0.80
lenMethod · 0.45
pushMethod · 0.45
into_iterMethod · 0.45
extendMethod · 0.45
clonedMethod · 0.45
iterMethod · 0.45
cloneMethod · 0.45

Tested by 4

test_first_group_accFunction · 0.36
test_last_group_accFunction · 0.36