Skip to content

Commit f1cdeef

Browse files
committed
address comments
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
1 parent 48c165f commit f1cdeef

6 files changed

Lines changed: 258 additions & 446 deletions

File tree

vortex-array/public-api.lock

Lines changed: 14 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -7044,13 +7044,13 @@ pub type vortex_array::extension::uuid::Uuid::Metadata = vortex_array::extension
70447044

70457045
pub type vortex_array::extension::uuid::Uuid::NativeValue<'a> = uuid::Uuid
70467046

7047-
pub fn vortex_array::extension::uuid::Uuid::deserialize_metadata(&self, _metadata: &[u8]) -> vortex_error::VortexResult<Self::Metadata>
7047+
pub fn vortex_array::extension::uuid::Uuid::deserialize_metadata(&self, metadata: &[u8]) -> vortex_error::VortexResult<Self::Metadata>
70487048

70497049
pub fn vortex_array::extension::uuid::Uuid::id(&self) -> vortex_array::dtype::extension::ExtId
70507050

7051-
pub fn vortex_array::extension::uuid::Uuid::serialize_metadata(&self, _metadata: &Self::Metadata) -> vortex_error::VortexResult<alloc::vec::Vec<u8>>
7051+
pub fn vortex_array::extension::uuid::Uuid::serialize_metadata(&self, metadata: &Self::Metadata) -> vortex_error::VortexResult<alloc::vec::Vec<u8>>
70527052

7053-
pub fn vortex_array::extension::uuid::Uuid::unpack_native<'a>(&self, _metadata: &'a Self::Metadata, _storage_dtype: &'a vortex_array::dtype::DType, storage_value: &'a vortex_array::scalar::ScalarValue) -> vortex_error::VortexResult<Self::NativeValue>
7053+
pub fn vortex_array::extension::uuid::Uuid::unpack_native<'a>(&self, metadata: &'a Self::Metadata, _storage_dtype: &'a vortex_array::dtype::DType, storage_value: &'a vortex_array::scalar::ScalarValue) -> vortex_error::VortexResult<Self::NativeValue>
70547054

70557055
pub fn vortex_array::extension::uuid::Uuid::validate_dtype(&self, _metadata: &Self::Metadata, storage_dtype: &vortex_array::dtype::DType) -> vortex_error::VortexResult<()>
70567056

@@ -11054,20 +11054,26 @@ pub type vortex_array::extension::uuid::Uuid::Metadata = vortex_array::extension
1105411054

1105511055
pub type vortex_array::extension::uuid::Uuid::NativeValue<'a> = uuid::Uuid
1105611056

11057-
pub fn vortex_array::extension::uuid::Uuid::deserialize_metadata(&self, _metadata: &[u8]) -> vortex_error::VortexResult<Self::Metadata>
11057+
pub fn vortex_array::extension::uuid::Uuid::deserialize_metadata(&self, metadata: &[u8]) -> vortex_error::VortexResult<Self::Metadata>
1105811058

1105911059
pub fn vortex_array::extension::uuid::Uuid::id(&self) -> vortex_array::dtype::extension::ExtId
1106011060

11061-
pub fn vortex_array::extension::uuid::Uuid::serialize_metadata(&self, _metadata: &Self::Metadata) -> vortex_error::VortexResult<alloc::vec::Vec<u8>>
11061+
pub fn vortex_array::extension::uuid::Uuid::serialize_metadata(&self, metadata: &Self::Metadata) -> vortex_error::VortexResult<alloc::vec::Vec<u8>>
1106211062

11063-
pub fn vortex_array::extension::uuid::Uuid::unpack_native<'a>(&self, _metadata: &'a Self::Metadata, _storage_dtype: &'a vortex_array::dtype::DType, storage_value: &'a vortex_array::scalar::ScalarValue) -> vortex_error::VortexResult<Self::NativeValue>
11063+
pub fn vortex_array::extension::uuid::Uuid::unpack_native<'a>(&self, metadata: &'a Self::Metadata, _storage_dtype: &'a vortex_array::dtype::DType, storage_value: &'a vortex_array::scalar::ScalarValue) -> vortex_error::VortexResult<Self::NativeValue>
1106411064

1106511065
pub fn vortex_array::extension::uuid::Uuid::validate_dtype(&self, _metadata: &Self::Metadata, storage_dtype: &vortex_array::dtype::DType) -> vortex_error::VortexResult<()>
1106611066

1106711067
pub fn vortex_array::extension::uuid::Uuid::validate_scalar_value(&self, metadata: &Self::Metadata, storage_dtype: &vortex_array::dtype::DType, storage_value: &vortex_array::scalar::ScalarValue) -> vortex_error::VortexResult<()>
1106811068

1106911069
pub struct vortex_array::extension::uuid::UuidMetadata
1107011070

11071+
pub vortex_array::extension::uuid::UuidMetadata::version: core::option::Option<uuid::Version>
11072+
11073+
impl vortex_array::extension::uuid::UuidMetadata
11074+
11075+
pub fn vortex_array::extension::uuid::UuidMetadata::any() -> Self
11076+
1107111077
impl core::clone::Clone for vortex_array::extension::uuid::UuidMetadata
1107211078

1107311079
pub fn vortex_array::extension::uuid::UuidMetadata::clone(&self) -> vortex_array::extension::uuid::UuidMetadata
@@ -11076,11 +11082,7 @@ impl core::cmp::Eq for vortex_array::extension::uuid::UuidMetadata
1107611082

1107711083
impl core::cmp::PartialEq for vortex_array::extension::uuid::UuidMetadata
1107811084

11079-
pub fn vortex_array::extension::uuid::UuidMetadata::eq(&self, other: &vortex_array::extension::uuid::UuidMetadata) -> bool
11080-
11081-
impl core::default::Default for vortex_array::extension::uuid::UuidMetadata
11082-
11083-
pub fn vortex_array::extension::uuid::UuidMetadata::default() -> vortex_array::extension::uuid::UuidMetadata
11085+
pub fn vortex_array::extension::uuid::UuidMetadata::eq(&self, other: &Self) -> bool
1108411086

1108511087
impl core::fmt::Debug for vortex_array::extension::uuid::UuidMetadata
1108611088

@@ -11092,9 +11094,7 @@ pub fn vortex_array::extension::uuid::UuidMetadata::fmt(&self, f: &mut core::fmt
1109211094

1109311095
impl core::hash::Hash for vortex_array::extension::uuid::UuidMetadata
1109411096

11095-
pub fn vortex_array::extension::uuid::UuidMetadata::hash<__H: core::hash::Hasher>(&self, state: &mut __H)
11096-
11097-
impl core::marker::StructuralPartialEq for vortex_array::extension::uuid::UuidMetadata
11097+
pub fn vortex_array::extension::uuid::UuidMetadata::hash<H: core::hash::Hasher>(&self, state: &mut H)
1109811098

1109911099
pub struct vortex_array::extension::EmptyMetadata
1110011100

@@ -15192,50 +15192,6 @@ pub fn vortex_array::scalar_fn::fns::select::Select::stat_falsification(&self, o
1519215192

1519315193
pub fn vortex_array::scalar_fn::fns::select::Select::validity(&self, options: &Self::Options, expression: &vortex_array::expr::Expression) -> vortex_error::VortexResult<core::option::Option<vortex_array::expr::Expression>>
1519415194

15195-
pub mod vortex_array::scalar_fn::fns::uuid_from_string
15196-
15197-
pub struct vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString
15198-
15199-
impl core::clone::Clone for vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString
15200-
15201-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::clone(&self) -> vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString
15202-
15203-
impl vortex_array::scalar_fn::ScalarFnVTable for vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString
15204-
15205-
pub type vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::Options = vortex_array::scalar_fn::EmptyOptions
15206-
15207-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::arity(&self, _options: &Self::Options) -> vortex_array::scalar_fn::Arity
15208-
15209-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::child_name(&self, _options: &Self::Options, child_idx: usize) -> vortex_array::scalar_fn::ChildName
15210-
15211-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::deserialize(&self, _metadata: &[u8], _session: &vortex_session::VortexSession) -> vortex_error::VortexResult<Self::Options>
15212-
15213-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::execute(&self, _options: &Self::Options, args: &dyn vortex_array::scalar_fn::ExecutionArgs, _ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::ArrayRef>
15214-
15215-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::fmt_sql(&self, _options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
15216-
15217-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::id(&self) -> vortex_array::scalar_fn::ScalarFnId
15218-
15219-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::is_fallible(&self, _options: &Self::Options) -> bool
15220-
15221-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::is_null_sensitive(&self, _options: &Self::Options) -> bool
15222-
15223-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::reduce(&self, options: &Self::Options, node: &dyn vortex_array::scalar_fn::ReduceNode, ctx: &dyn vortex_array::scalar_fn::ReduceCtx) -> vortex_error::VortexResult<core::option::Option<vortex_array::scalar_fn::ReduceNodeRef>>
15224-
15225-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::return_dtype(&self, _options: &Self::Options, arg_dtypes: &[vortex_array::dtype::DType]) -> vortex_error::VortexResult<vortex_array::dtype::DType>
15226-
15227-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::serialize(&self, options: &Self::Options) -> vortex_error::VortexResult<core::option::Option<alloc::vec::Vec<u8>>>
15228-
15229-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::simplify(&self, options: &Self::Options, expr: &vortex_array::expr::Expression, ctx: &dyn vortex_array::scalar_fn::SimplifyCtx) -> vortex_error::VortexResult<core::option::Option<vortex_array::expr::Expression>>
15230-
15231-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::simplify_untyped(&self, options: &Self::Options, expr: &vortex_array::expr::Expression) -> vortex_error::VortexResult<core::option::Option<vortex_array::expr::Expression>>
15232-
15233-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::stat_expression(&self, options: &Self::Options, expr: &vortex_array::expr::Expression, stat: vortex_array::expr::stats::Stat, catalog: &dyn vortex_array::expr::pruning::StatsCatalog) -> core::option::Option<vortex_array::expr::Expression>
15234-
15235-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::stat_falsification(&self, options: &Self::Options, expr: &vortex_array::expr::Expression, catalog: &dyn vortex_array::expr::pruning::StatsCatalog) -> core::option::Option<vortex_array::expr::Expression>
15236-
15237-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::validity(&self, _options: &Self::Options, expression: &vortex_array::expr::Expression) -> vortex_error::VortexResult<core::option::Option<vortex_array::expr::Expression>>
15238-
1523915195
pub mod vortex_array::scalar_fn::fns::zip
1524015196

1524115197
pub struct vortex_array::scalar_fn::fns::zip::Zip
@@ -16264,42 +16220,6 @@ pub fn vortex_array::scalar_fn::fns::select::Select::stat_falsification(&self, o
1626416220

1626516221
pub fn vortex_array::scalar_fn::fns::select::Select::validity(&self, options: &Self::Options, expression: &vortex_array::expr::Expression) -> vortex_error::VortexResult<core::option::Option<vortex_array::expr::Expression>>
1626616222

16267-
impl vortex_array::scalar_fn::ScalarFnVTable for vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString
16268-
16269-
pub type vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::Options = vortex_array::scalar_fn::EmptyOptions
16270-
16271-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::arity(&self, _options: &Self::Options) -> vortex_array::scalar_fn::Arity
16272-
16273-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::child_name(&self, _options: &Self::Options, child_idx: usize) -> vortex_array::scalar_fn::ChildName
16274-
16275-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::deserialize(&self, _metadata: &[u8], _session: &vortex_session::VortexSession) -> vortex_error::VortexResult<Self::Options>
16276-
16277-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::execute(&self, _options: &Self::Options, args: &dyn vortex_array::scalar_fn::ExecutionArgs, _ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::ArrayRef>
16278-
16279-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::fmt_sql(&self, _options: &Self::Options, expr: &vortex_array::expr::Expression, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
16280-
16281-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::id(&self) -> vortex_array::scalar_fn::ScalarFnId
16282-
16283-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::is_fallible(&self, _options: &Self::Options) -> bool
16284-
16285-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::is_null_sensitive(&self, _options: &Self::Options) -> bool
16286-
16287-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::reduce(&self, options: &Self::Options, node: &dyn vortex_array::scalar_fn::ReduceNode, ctx: &dyn vortex_array::scalar_fn::ReduceCtx) -> vortex_error::VortexResult<core::option::Option<vortex_array::scalar_fn::ReduceNodeRef>>
16288-
16289-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::return_dtype(&self, _options: &Self::Options, arg_dtypes: &[vortex_array::dtype::DType]) -> vortex_error::VortexResult<vortex_array::dtype::DType>
16290-
16291-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::serialize(&self, options: &Self::Options) -> vortex_error::VortexResult<core::option::Option<alloc::vec::Vec<u8>>>
16292-
16293-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::simplify(&self, options: &Self::Options, expr: &vortex_array::expr::Expression, ctx: &dyn vortex_array::scalar_fn::SimplifyCtx) -> vortex_error::VortexResult<core::option::Option<vortex_array::expr::Expression>>
16294-
16295-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::simplify_untyped(&self, options: &Self::Options, expr: &vortex_array::expr::Expression) -> vortex_error::VortexResult<core::option::Option<vortex_array::expr::Expression>>
16296-
16297-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::stat_expression(&self, options: &Self::Options, expr: &vortex_array::expr::Expression, stat: vortex_array::expr::stats::Stat, catalog: &dyn vortex_array::expr::pruning::StatsCatalog) -> core::option::Option<vortex_array::expr::Expression>
16298-
16299-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::stat_falsification(&self, options: &Self::Options, expr: &vortex_array::expr::Expression, catalog: &dyn vortex_array::expr::pruning::StatsCatalog) -> core::option::Option<vortex_array::expr::Expression>
16300-
16301-
pub fn vortex_array::scalar_fn::fns::uuid_from_string::UuidFromString::validity(&self, _options: &Self::Options, expression: &vortex_array::expr::Expression) -> vortex_error::VortexResult<core::option::Option<vortex_array::expr::Expression>>
16302-
1630316223
impl vortex_array::scalar_fn::ScalarFnVTable for vortex_array::scalar_fn::fns::zip::Zip
1630416224

1630516225
pub type vortex_array::scalar_fn::fns::zip::Zip::Options = vortex_array::scalar_fn::EmptyOptions
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+
use std::fmt;
5+
use std::hash::Hash;
6+
use std::hash::Hasher;
7+
8+
use uuid::Version;
9+
use vortex_error::VortexResult;
10+
use vortex_error::vortex_bail;
11+
12+
/// Converts a `u8` discriminant back to a [`uuid::Version`].
13+
pub(crate) fn u8_to_version(b: u8) -> VortexResult<Version> {
14+
match b {
15+
0 => Ok(Version::Nil),
16+
1 => Ok(Version::Mac),
17+
2 => Ok(Version::Dce),
18+
3 => Ok(Version::Md5),
19+
4 => Ok(Version::Random),
20+
5 => Ok(Version::Sha1),
21+
6 => Ok(Version::SortMac),
22+
7 => Ok(Version::SortRand),
23+
8 => Ok(Version::Custom),
24+
0xff => Ok(Version::Max),
25+
_ => vortex_bail!("unknown UUID version discriminant: {b}"),
26+
}
27+
}
28+
29+
/// Metadata for the UUID extension type.
30+
///
31+
/// Optionally records which UUID version the column contains (e.g. v4 random, v7
32+
/// sort-random). When `None`, the column may contain any mix of versions.
33+
#[derive(Clone, Debug)]
34+
pub struct UuidMetadata {
35+
/// The UUID version, if known.
36+
pub version: Option<Version>,
37+
}
38+
39+
impl UuidMetadata {
40+
/// Creates metadata with no version constraint.
41+
pub fn any() -> Self {
42+
Self { version: None }
43+
}
44+
}
45+
46+
impl fmt::Display for UuidMetadata {
47+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
48+
match self.version {
49+
None => write!(f, "UUID"),
50+
Some(v) => write!(f, "UUID(v{})", v as u8),
51+
}
52+
}
53+
}
54+
55+
// `uuid::Version` derives `PartialEq` but not `Eq` or `Hash`, so we implement these
56+
// manually using the `#[repr(u8)]` discriminant.
57+
58+
impl PartialEq for UuidMetadata {
59+
fn eq(&self, other: &Self) -> bool {
60+
self.version.map(|v| v as u8) == other.version.map(|v| v as u8)
61+
}
62+
}
63+
64+
impl Eq for UuidMetadata {}
65+
66+
impl Hash for UuidMetadata {
67+
fn hash<H: Hasher>(&self, state: &mut H) {
68+
self.version.map(|v| v as u8).hash(state);
69+
}
70+
}

vortex-array/src/extension/uuid/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
//! [RFC 4122]: https://www.rfc-editor.org/rfc/rfc4122
1111
//! [canonical UUID extension]: https://arrow.apache.org/docs/format/CanonicalExtensions.html#uuid
1212
13+
mod metadata;
14+
pub use metadata::UuidMetadata;
15+
1316
pub(crate) mod vtable;
1417

1518
/// The VTable for the UUID extension type.

0 commit comments

Comments
 (0)