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

Method pop

datafusion/functions-aggregate/src/min_max.rs:827–847  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

825 /// Removes and returns the last value of the sliding window.
826 #[inline]
827 pub fn pop(&mut self) -> Option<T> {
828 if self.pop_stack.is_empty() {
829 match self.push_stack.pop() {
830 Some((val, _)) => {
831 let mut last = (val.clone(), val);
832 self.pop_stack.push(last.clone());
833 while let Some((val, _)) = self.push_stack.pop() {
834 let min = if last.1 < val {
835 last.1.clone()
836 } else {
837 val.clone()
838 };
839 last = (val.clone(), min);
840 self.pop_stack.push(last.clone());
841 }
842 }
843 None => return None,
844 }
845 }
846 self.pop_stack.pop().map(|(val, _)| val)
847 }
848
849 /// Returns the number of elements stored in the sliding window.
850 #[inline]

Callers 6

simplifyMethod · 0.45
simplifyMethod · 0.45
merge_ordered_arraysFunction · 0.45
retract_batchMethod · 0.45
moving_min_i32Function · 0.45
moving_max_i32Function · 0.45

Calls 4

is_emptyMethod · 0.45
cloneMethod · 0.45
pushMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected