Skip to content

Commit 1a8b8aa

Browse files
committed
Initial boilerplate
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
1 parent dfe3699 commit 1a8b8aa

21 files changed

Lines changed: 155 additions & 7 deletions

File tree

vortex-array/src/arrays/arbitrary.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,10 @@ fn random_array_chunk(
162162
random_fixed_size_list(u, elem_dtype, *list_size, *null, chunk_len)
163163
}
164164
DType::Extension(..) => {
165-
todo!("Extension arrays are not implemented")
165+
unimplemented!("Extension arrays are not implemented")
166+
}
167+
DType::Variant => {
168+
unimplemented!("Variant arrays are not implemented")
166169
}
167170
}
168171
}

vortex-array/src/arrays/constant/vtable/canonical.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ pub(crate) fn constant_canonicalize(array: &ConstantArray) -> VortexResult<Canon
164164
let storage_self = ConstantArray::new(storage_scalar, array.len()).into_array();
165165
Canonical::Extension(ExtensionArray::new(ext_dtype.clone(), storage_self))
166166
}
167+
DType::Variant => todo!(),
167168
})
168169
}
169170

vortex-array/src/builders/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,5 +280,8 @@ pub fn builder_with_capacity(dtype: &DType, capacity: usize) -> Box<dyn ArrayBui
280280
DType::Extension(ext_dtype) => {
281281
Box::new(ExtensionBuilder::with_capacity(ext_dtype.clone(), capacity))
282282
}
283+
DType::Variant => {
284+
unimplemented!()
285+
}
283286
}
284287
}

vortex-array/src/canonical.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ impl Canonical {
222222
ext_dtype.clone(),
223223
Canonical::empty(ext_dtype.storage_dtype()).into_array(),
224224
)),
225+
DType::Variant => todo!(),
225226
}
226227
}
227228

vortex-array/src/dtype/dtype_impl.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl DType {
5454
#[inline]
5555
pub fn is_nullable(&self) -> bool {
5656
match self {
57-
Null => true,
57+
Null | Variant => true,
5858
Extension(ext_dtype) => ext_dtype.storage_dtype().is_nullable(),
5959
Bool(null)
6060
| Primitive(_, null)
@@ -90,6 +90,7 @@ impl DType {
9090
List(edt, _) => List(edt.clone(), nullability),
9191
FixedSizeList(edt, size, _) => FixedSizeList(edt.clone(), *size, nullability),
9292
Extension(ext) => Extension(ext.with_nullability(nullability)),
93+
Variant => Variant,
9394
}
9495
}
9596

@@ -284,6 +285,7 @@ impl DType {
284285
Some(sum)
285286
}
286287
Extension(ext) => ext.storage_dtype().element_size(),
288+
Variant => None,
287289
}
288290
}
289291

@@ -459,6 +461,7 @@ impl Display for DType {
459461
List(edt, null) => write!(f, "list({edt}){null}"),
460462
FixedSizeList(edt, size, null) => write!(f, "fixed_size_list({edt})[{size}]{null}"),
461463
Extension(ext) => write!(f, "{}", ext),
464+
Variant => write!(f, "variant"),
462465
}
463466
}
464467
}

vortex-array/src/dtype/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ pub enum DType {
100100
///
101101
/// See [`ExtDTypeRef`] for more information.
102102
Extension(ExtDTypeRef),
103+
104+
/// Variant type
105+
Variant,
103106
}
104107

105108
pub use bigint::*;

vortex-array/src/dtype/serde/flatbuffers.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use vortex_flatbuffers::FlatBuffer;
1616
use vortex_flatbuffers::FlatBufferRoot;
1717
use vortex_flatbuffers::WriteFlatBuffer;
1818
use vortex_flatbuffers::dtype as fbd;
19+
use vortex_flatbuffers::dtype::VariantArgs;
1920
use vortex_session::VortexSession;
2021

2122
use crate::dtype::DType;
@@ -349,6 +350,7 @@ impl WriteFlatBuffer for DType {
349350
)
350351
.as_union_value()
351352
}
353+
Self::Variant => fb::Variant::create(fbb, &fb::VariantArgs {}).as_union_value(),
352354
};
353355

354356
let dtype_type = match self {
@@ -362,6 +364,7 @@ impl WriteFlatBuffer for DType {
362364
Self::List(..) => fb::Type::List,
363365
Self::FixedSizeList(..) => fb::Type::FixedSizeList,
364366
Self::Extension { .. } => fb::Type::Extension,
367+
Self::Variant => fb::Type::Variant,
365368
};
366369

367370
Ok(fb::DType::create(

vortex-array/src/dtype/serde/proto.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ impl DType {
9999
let ext_dtype = vtable.deserialize(e.metadata(), storage_dtype)?;
100100
Ok(Self::Extension(ext_dtype))
101101
}
102+
DtypeType::Variant(..) => {
103+
unimplemented!()
104+
}
102105
}
103106
}
104107
}
@@ -152,6 +155,7 @@ impl TryFrom<&DType> for pb::DType {
152155
storage_dtype: Some(Box::new(e.storage_dtype().try_into()?)),
153156
metadata: Some(e.serialize_metadata()?),
154157
})),
158+
DType::Variant => todo!(),
155159
}),
156160
})
157161
}

vortex-array/src/dtype/serde/serde.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ impl Serialize for DType {
117117
DType::Extension(ext) => {
118118
serializer.serialize_newtype_variant("DType", 9, "Extension", ext)
119119
}
120+
DType::Variant => todo!(),
120121
}
121122
}
122123
}

vortex-array/src/scalar/arbitrary.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ pub fn random_scalar(u: &mut Unstructured, dtype: &DType) -> Result<Scalar> {
9898
DType::Extension(..) => {
9999
unreachable!("Can't yet generate arbitrary scalars for ext dtype")
100100
}
101+
DType::Variant => todo!(),
101102
})
102103
}
103104

0 commit comments

Comments
 (0)