MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / arrow_sum

Function arrow_sum

nodedb/src/control/arrow_convert.rs:173–185  ·  view source on GitHub ↗

Compute SUM of a numeric column in a RecordBatch.

(batch: &RecordBatch, column_name: &str)

Source from the content-addressed store, hash-verified

171
172/// Compute SUM of a numeric column in a RecordBatch.
173pub fn arrow_sum(batch: &RecordBatch, column_name: &str) -> Option<f64> {
174 let idx = batch.schema().index_of(column_name).ok()?;
175 let array = batch.column(idx);
176
177 if let Some(f64_arr) = array.as_any().downcast_ref::<Float64Array>() {
178 Some(arrow::compute::kernels::aggregate::sum(f64_arr).unwrap_or(0.0))
179 } else if let Some(i64_arr) = array.as_any().downcast_ref::<Int64Array>() {
180 let sum = arrow::compute::kernels::aggregate::sum(i64_arr).unwrap_or(0);
181 Some(sum as f64)
182 } else {
183 None
184 }
185}
186
187/// Compute MIN of a numeric column using Arrow SIMD kernels.
188pub fn arrow_min(batch: &RecordBatch, column_name: &str) -> Option<f64> {

Callers 2

arrow_avgFunction · 0.85
arrow_sum_worksFunction · 0.85

Calls 4

sumFunction · 0.85
okMethod · 0.45
schemaMethod · 0.45
columnMethod · 0.45

Tested by 1

arrow_sum_worksFunction · 0.68