Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion vortex-dtype/src/dtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ impl DType {
.all(|(l, r)| l.eq_ignore_nullability(&r)))
}
(Struct(..), _) => false,
(Extension(lhs_extdtype), Extension(rhs_extdtype)) => lhs_extdtype == rhs_extdtype,
(Extension(lhs_extdtype), Extension(rhs_extdtype)) => {
lhs_extdtype.as_ref().eq_ignore_nullability(rhs_extdtype)
}
(Extension(_), _) => false,
}
}
Expand Down
23 changes: 10 additions & 13 deletions vortex-dtype/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,14 @@ impl From<&[u8]> for ExtMetadata {
}

/// A type descriptor for an extension type
#[derive(Debug, Clone, PartialOrd, Eq)]
#[derive(Debug, Clone, PartialOrd, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ExtDType {
id: ExtID,
storage_dtype: Arc<DType>,
metadata: Option<ExtMetadata>,
}

impl PartialEq for ExtDType {
fn eq(&self, other: &Self) -> bool {
self.id == other.id
}
}

impl std::hash::Hash for ExtDType {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.id.hash(state);
}
}

impl ExtDType {
/// Creates a new `ExtDType`.
///
Expand Down Expand Up @@ -148,4 +136,13 @@ impl ExtDType {
pub fn metadata(&self) -> Option<&ExtMetadata> {
self.metadata.as_ref()
}

/// Check if `self` and `other` are equal, ignoring the storage nullability
pub fn eq_ignore_nullability(&self, other: &Self) -> bool {
self.id() == other.id()
&& self.metadata() == other.metadata()
&& self
.storage_dtype()
.eq_ignore_nullability(other.storage_dtype())
}
}