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

Method take_needed

datafusion/expr-common/src/groups_accumulator.rs:42–56  ·  view source on GitHub ↗

Removes the number of rows from `v` required to emit the right number of rows, returning a `Vec` with elements taken, and the remaining values in `v`. This avoids copying if Self::All

(&self, v: &mut Vec<T>)

Source from the content-addressed store, hash-verified

40 ///
41 /// This avoids copying if Self::All
42 pub fn take_needed<T>(&self, v: &mut Vec<T>) -> Vec<T> {
43 match self {
44 Self::All => {
45 // Take the entire vector, leave new (empty) vector
46 std::mem::take(v)
47 }
48 Self::First(n) => {
49 // get end n+1,.. values into t
50 let mut t = v.split_off(*n);
51 // leave n+1,.. in v
52 std::mem::swap(v, &mut t);
53 t
54 }
55 }
56 }
57}
58
59/// `GroupsAccumulator` implements a single aggregate (e.g. AVG) and

Callers 15

evaluateMethod · 0.80
stateMethod · 0.80
evaluateMethod · 0.80
stateMethod · 0.80
evaluateMethod · 0.80
stateMethod · 0.80
evaluateMethod · 0.80
stateMethod · 0.80
evaluateMethod · 0.80
stateMethod · 0.80
evaluateMethod · 0.80
evaluateMethod · 0.80

Calls 1

split_offMethod · 0.80

Tested by

no test coverage detected