|
|
|
@@ -1,8 +1,8 @@ |
|
|
|
use arrow::array::{Array, Float32Array, Float64Array, Int32Array, Int64Array, UInt32Array}; |
|
|
|
use arrow::datatypes::DataType; |
|
|
|
use eyre::{eyre, ContextCompat, Result}; |
|
|
|
use std::ops::{Deref, DerefMut}; |
|
|
|
use num::NumCast; |
|
|
|
use std::ops::{Deref, DerefMut}; |
|
|
|
|
|
|
|
mod from_impls; |
|
|
|
mod into_impls; |
|
|
|
@@ -32,8 +32,8 @@ impl DerefMut for ArrowData { |
|
|
|
|
|
|
|
macro_rules! register_array_handlers { |
|
|
|
($(($variant:path, $array_type:ty, $type_name:expr)),* $(,)?) => { |
|
|
|
pub fn into_vec<T>(data: &ArrowData) -> Result<Vec<T>> |
|
|
|
where |
|
|
|
pub fn into_vec<T>(data: &ArrowData) -> Result<Vec<T>> |
|
|
|
where |
|
|
|
T: Copy + NumCast + 'static, |
|
|
|
{ |
|
|
|
match data.data_type() { |
|
|
|
@@ -43,10 +43,10 @@ macro_rules! register_array_handlers { |
|
|
|
.as_any() |
|
|
|
.downcast_ref() |
|
|
|
.context(concat!("series is not ", $type_name))?; |
|
|
|
|
|
|
|
|
|
|
|
let mut result = Vec::with_capacity(buffer.len()); |
|
|
|
for &v in buffer.values() { |
|
|
|
let converted = NumCast::from(v).ok_or_else(|| |
|
|
|
let converted = NumCast::from(v).ok_or_else(|| |
|
|
|
eyre!("Failed to cast value from {} to target type", $type_name))?; |
|
|
|
result.push(converted); |
|
|
|
} |
|
|
|
|