Convert to an Arrow `RecordBatch`. Consumes the batch. Returns `Err` if column lengths are inconsistent (should never happen with correct `push_*` usage).
(self)
| 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 | /// |