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, VectorMut};
19
20mod scalar;
21mod types;
22mod vector;
23mod vector_mut;
24mod view;
25
26pub type BinaryVector = BinaryViewVector<BinaryType>;
28pub type BinaryVectorMut = BinaryViewVectorMut<BinaryType>;
30pub type StringVector = BinaryViewVector<StringType>;
32pub type StringVectorMut = BinaryViewVectorMut<StringType>;
34pub type BinaryScalar = BinaryViewScalar<BinaryType>;
36pub type StringScalar = BinaryViewScalar<StringType>;
38
39impl BinaryViewDowncast for Vector {
40 type Output<T: BinaryViewType> = BinaryViewVector<T>;
41
42 fn into_binary(self) -> Self::Output<BinaryType> {
43 if let Vector::Binary(v) = self {
44 return v;
45 }
46 vortex_panic!("Expected BinaryVector, got {self:?}");
47 }
48
49 fn into_string(self) -> Self::Output<StringType> {
50 if let Vector::String(v) = self {
51 return v;
52 }
53 vortex_panic!("Expected StringVector, got {self:?}");
54 }
55}
56
57impl BinaryViewTypeUpcast for Vector {
58 type Input<T: BinaryViewType> = BinaryViewVector<T>;
59
60 fn from_binary(input: Self::Input<BinaryType>) -> Self {
61 Vector::Binary(input)
62 }
63
64 fn from_string(input: Self::Input<StringType>) -> Self {
65 Vector::String(input)
66 }
67}
68
69impl BinaryViewDowncast for VectorMut {
70 type Output<T: BinaryViewType> = BinaryViewVectorMut<T>;
71
72 fn into_binary(self) -> Self::Output<BinaryType> {
73 if let VectorMut::Binary(v) = self {
74 return v;
75 }
76 vortex_panic!("Expected BinaryVector, got {self:?}");
77 }
78
79 fn into_string(self) -> Self::Output<StringType> {
80 if let VectorMut::String(v) = self {
81 return v;
82 }
83 vortex_panic!("Expected StringVector, got {self:?}");
84 }
85}
86
87impl BinaryViewTypeUpcast for VectorMut {
88 type Input<T: BinaryViewType> = BinaryViewVectorMut<T>;
89
90 fn from_binary(input: Self::Input<BinaryType>) -> Self {
91 VectorMut::Binary(input)
92 }
93
94 fn from_string(input: Self::Input<StringType>) -> Self {
95 VectorMut::String(input)
96 }
97}