vortex_vector/binaryview/
mod.rs1pub use scalar::*;
12pub use types::*;
13pub use vector::*;
14pub use vector_mut::*;
15pub use view::*;
16use vortex_error::vortex_panic;
17
18use crate::Vector;
19use crate::VectorMut;
20
21mod scalar;
22mod types;
23mod vector;
24mod vector_mut;
25mod view;
26
27pub type BinaryVector = BinaryViewVector<BinaryType>;
29pub type BinaryVectorMut = BinaryViewVectorMut<BinaryType>;
31pub type StringVector = BinaryViewVector<StringType>;
33pub type StringVectorMut = BinaryViewVectorMut<StringType>;
35pub type BinaryScalar = BinaryViewScalar<BinaryType>;
37pub type StringScalar = BinaryViewScalar<StringType>;
39
40impl BinaryViewDowncast for Vector {
41 type Output<T: BinaryViewType> = BinaryViewVector<T>;
42
43 fn into_binary(self) -> Self::Output<BinaryType> {
44 if let Vector::Binary(v) = self {
45 return v;
46 }
47 vortex_panic!("Expected BinaryVector, got {self:?}");
48 }
49
50 fn into_string(self) -> Self::Output<StringType> {
51 if let Vector::String(v) = self {
52 return v;
53 }
54 vortex_panic!("Expected StringVector, got {self:?}");
55 }
56}
57
58impl BinaryViewTypeUpcast for Vector {
59 type Input<T: BinaryViewType> = BinaryViewVector<T>;
60
61 fn from_binary(input: Self::Input<BinaryType>) -> Self {
62 Vector::Binary(input)
63 }
64
65 fn from_string(input: Self::Input<StringType>) -> Self {
66 Vector::String(input)
67 }
68}
69
70impl BinaryViewDowncast for VectorMut {
71 type Output<T: BinaryViewType> = BinaryViewVectorMut<T>;
72
73 fn into_binary(self) -> Self::Output<BinaryType> {
74 if let VectorMut::Binary(v) = self {
75 return v;
76 }
77 vortex_panic!("Expected BinaryVector, got {self:?}");
78 }
79
80 fn into_string(self) -> Self::Output<StringType> {
81 if let VectorMut::String(v) = self {
82 return v;
83 }
84 vortex_panic!("Expected StringVector, got {self:?}");
85 }
86}
87
88impl BinaryViewTypeUpcast for VectorMut {
89 type Input<T: BinaryViewType> = BinaryViewVectorMut<T>;
90
91 fn from_binary(input: Self::Input<BinaryType>) -> Self {
92 VectorMut::Binary(input)
93 }
94
95 fn from_string(input: Self::Input<StringType>) -> Self {
96 VectorMut::String(input)
97 }
98}