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

Method to_record_batch

nodedb/src/engine/graph/algo/result.rs:131–149  ·  view source on GitHub ↗

Convert to an Arrow `RecordBatch`. Consumes the batch. Returns `Err` if column lengths are inconsistent (should never happen with correct `push_*` usage).

(self)

Source from the content-addressed store, hash-verified

129 /// Consumes the batch. Returns `Err` if column lengths are inconsistent
130 /// (should never happen with correct `push_*` usage).
131 pub fn to_record_batch(self) -> Result<RecordBatch, crate::Error> {
132 let schema = Arc::new(self.arrow_schema());
133 let mut columns: Vec<ArrayRef> = Vec::with_capacity(self.column_map.len());
134
135 for &(col_type, idx) in &self.column_map {
136 let array: ArrayRef = match col_type {
137 AlgoColumnType::Text => Arc::new(StringArray::from(self.text_columns[idx].clone())),
138 AlgoColumnType::Float64 => {
139 Arc::new(Float64Array::from(self.f64_columns[idx].clone()))
140 }
141 AlgoColumnType::Int64 => Arc::new(Int64Array::from(self.i64_columns[idx].clone())),
142 };
143 columns.push(array);
144 }
145
146 RecordBatch::try_new(schema, columns).map_err(|e| crate::Error::Internal {
147 detail: format!("arrow result batch: {e}"),
148 })
149 }
150
151 /// Serialize the result batch as MessagePack bytes.
152 ///

Callers 7

sssp_to_record_batchFunction · 0.80
pagerank_to_record_batchFunction · 0.80
diameter_resultFunction · 0.80
empty_resultFunction · 0.80

Calls 4

arrow_schemaMethod · 0.80
lenMethod · 0.45
cloneMethod · 0.45
pushMethod · 0.45

Tested by 7

sssp_to_record_batchFunction · 0.64
pagerank_to_record_batchFunction · 0.64
diameter_resultFunction · 0.64
empty_resultFunction · 0.64