dora_arrow_convert/
into_impls.rs

1use arrow::array::{PrimitiveArray, StringArray};
2
3use crate::IntoArrow;
4
5impl IntoArrow for bool {
6    type A = arrow::array::BooleanArray;
7    fn into_arrow(self) -> Self::A {
8        std::iter::once(Some(self)).collect()
9    }
10}
11
12impl IntoArrow for u8 {
13    type A = PrimitiveArray<arrow::datatypes::UInt8Type>;
14    fn into_arrow(self) -> Self::A {
15        std::iter::once(self).collect()
16    }
17}
18impl IntoArrow for u16 {
19    type A = PrimitiveArray<arrow::datatypes::UInt16Type>;
20    fn into_arrow(self) -> Self::A {
21        std::iter::once(self).collect()
22    }
23}
24impl IntoArrow for u32 {
25    type A = PrimitiveArray<arrow::datatypes::UInt32Type>;
26    fn into_arrow(self) -> Self::A {
27        std::iter::once(self).collect()
28    }
29}
30impl IntoArrow for u64 {
31    type A = PrimitiveArray<arrow::datatypes::UInt64Type>;
32    fn into_arrow(self) -> Self::A {
33        std::iter::once(self).collect()
34    }
35}
36impl IntoArrow for i8 {
37    type A = PrimitiveArray<arrow::datatypes::Int8Type>;
38    fn into_arrow(self) -> Self::A {
39        std::iter::once(self).collect()
40    }
41}
42impl IntoArrow for i16 {
43    type A = PrimitiveArray<arrow::datatypes::Int16Type>;
44    fn into_arrow(self) -> Self::A {
45        std::iter::once(self).collect()
46    }
47}
48impl IntoArrow for i32 {
49    type A = PrimitiveArray<arrow::datatypes::Int32Type>;
50    fn into_arrow(self) -> Self::A {
51        std::iter::once(self).collect()
52    }
53}
54impl IntoArrow for i64 {
55    type A = PrimitiveArray<arrow::datatypes::Int64Type>;
56    fn into_arrow(self) -> Self::A {
57        std::iter::once(self).collect()
58    }
59}
60impl IntoArrow for f32 {
61    type A = PrimitiveArray<arrow::datatypes::Float32Type>;
62    fn into_arrow(self) -> Self::A {
63        std::iter::once(self).collect()
64    }
65}
66impl IntoArrow for f64 {
67    type A = PrimitiveArray<arrow::datatypes::Float64Type>;
68    fn into_arrow(self) -> Self::A {
69        std::iter::once(self).collect()
70    }
71}
72
73impl IntoArrow for &str {
74    type A = StringArray;
75    fn into_arrow(self) -> Self::A {
76        std::iter::once(Some(self)).collect()
77    }
78}
79
80impl IntoArrow for Vec<u8> {
81    type A = PrimitiveArray<arrow::datatypes::UInt8Type>;
82    fn into_arrow(self) -> Self::A {
83        self.into()
84    }
85}
86impl IntoArrow for Vec<u16> {
87    type A = PrimitiveArray<arrow::datatypes::UInt16Type>;
88    fn into_arrow(self) -> Self::A {
89        self.into()
90    }
91}
92impl IntoArrow for Vec<u32> {
93    type A = PrimitiveArray<arrow::datatypes::UInt32Type>;
94    fn into_arrow(self) -> Self::A {
95        self.into()
96    }
97}
98impl IntoArrow for Vec<u64> {
99    type A = PrimitiveArray<arrow::datatypes::UInt64Type>;
100    fn into_arrow(self) -> Self::A {
101        self.into()
102    }
103}
104impl IntoArrow for Vec<i8> {
105    type A = PrimitiveArray<arrow::datatypes::Int8Type>;
106    fn into_arrow(self) -> Self::A {
107        self.into()
108    }
109}
110impl IntoArrow for Vec<i16> {
111    type A = PrimitiveArray<arrow::datatypes::Int16Type>;
112    fn into_arrow(self) -> Self::A {
113        self.into()
114    }
115}
116impl IntoArrow for Vec<i32> {
117    type A = PrimitiveArray<arrow::datatypes::Int32Type>;
118    fn into_arrow(self) -> Self::A {
119        self.into()
120    }
121}
122impl IntoArrow for Vec<i64> {
123    type A = PrimitiveArray<arrow::datatypes::Int64Type>;
124    fn into_arrow(self) -> Self::A {
125        self.into()
126    }
127}
128impl IntoArrow for Vec<f32> {
129    type A = PrimitiveArray<arrow::datatypes::Float32Type>;
130    fn into_arrow(self) -> Self::A {
131        self.into()
132    }
133}
134impl IntoArrow for Vec<f64> {
135    type A = PrimitiveArray<arrow::datatypes::Float64Type>;
136    fn into_arrow(self) -> Self::A {
137        self.into()
138    }
139}
140
141impl IntoArrow for () {
142    type A = arrow::array::NullArray;
143
144    fn into_arrow(self) -> Self::A {
145        arrow::array::NullArray::new(0)
146    }
147}