Skip to content

Commit bce85b5

Browse files
authored
Chore: rename some things (#6290)
Prep work for #6289 Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
1 parent 06e8364 commit bce85b5

File tree

11 files changed

+55
-42
lines changed

11 files changed

+55
-42
lines changed

vortex-array/src/arrays/extension/vtable/rules.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ mod tests {
7373
use crate::expr::Operator;
7474
use crate::optimizer::ArrayOptimizer;
7575

76-
#[derive(Clone, Debug, Default)]
76+
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
7777
struct TestExt;
7878
impl ExtDTypeVTable for TestExt {
7979
type Metadata = EmptyMetadata;
@@ -82,7 +82,11 @@ mod tests {
8282
ExtID::new_ref("test_ext")
8383
}
8484

85-
fn validate(&self, _options: &Self::Metadata, _storage_dtype: &DType) -> VortexResult<()> {
85+
fn validate_dtype(
86+
&self,
87+
_options: &Self::Metadata,
88+
_storage_dtype: &DType,
89+
) -> VortexResult<()> {
8690
Ok(())
8791
}
8892
}
@@ -153,7 +157,7 @@ mod tests {
153157

154158
#[test]
155159
fn test_scalar_fn_no_pushdown_different_ext_types() {
156-
#[derive(Clone, Debug, Default)]
160+
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
157161
struct TestExt2;
158162
impl ExtDTypeVTable for TestExt2 {
159163
type Metadata = EmptyMetadata;
@@ -162,7 +166,7 @@ mod tests {
162166
ExtID::new_ref("test_ext_2")
163167
}
164168

165-
fn validate(
169+
fn validate_dtype(
166170
&self,
167171
_options: &Self::Metadata,
168172
_storage_dtype: &DType,

vortex-dtype/src/datetime/date.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::extension::ExtDTypeVTable;
1515
use crate::extension::ExtID;
1616

1717
/// Date DType.
18-
#[derive(Clone, Debug, Default)]
18+
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
1919
pub struct Date;
2020

2121
impl Date {
@@ -54,7 +54,7 @@ impl ExtDTypeVTable for Date {
5454
TimeUnit::try_from(tag)
5555
}
5656

57-
fn validate(&self, metadata: &Self::Metadata, storage_dtype: &DType) -> VortexResult<()> {
57+
fn validate_dtype(&self, metadata: &Self::Metadata, storage_dtype: &DType) -> VortexResult<()> {
5858
let ptype = date_ptype(metadata)
5959
.ok_or_else(|| vortex_err!("Date type does not support time unit {}", metadata))?;
6060

vortex-dtype/src/datetime/time.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::extension::ExtDTypeVTable;
1515
use crate::extension::ExtID;
1616

1717
/// Time DType.
18-
#[derive(Clone, Debug, Default)]
18+
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
1919
pub struct Time;
2020

2121
impl Time {
@@ -50,7 +50,7 @@ impl ExtDTypeVTable for Time {
5050
TimeUnit::try_from(tag)
5151
}
5252

53-
fn validate(&self, metadata: &Self::Metadata, storage_dtype: &DType) -> VortexResult<()> {
53+
fn validate_dtype(&self, metadata: &Self::Metadata, storage_dtype: &DType) -> VortexResult<()> {
5454
let ptype = time_ptype(metadata)
5555
.ok_or_else(|| vortex_err!("Time type does not support time unit {}", metadata))?;
5656

vortex-dtype/src/datetime/timestamp.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ use crate::extension::ExtDTypeVTable;
2222
use crate::extension::ExtID;
2323

2424
/// Timestamp DType.
25-
#[derive(Clone, Debug, Default)]
25+
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
2626
pub struct Timestamp;
2727

2828
impl Timestamp {
29-
/// Creates a new Timestamp extension dtype with the given time unit and nullability.
29+
/// Creates a new Timestamp extension =dtype with the given time unit and nullability.
3030
pub fn new(time_unit: TimeUnit, nullability: Nullability) -> ExtDType<Self> {
3131
Self::new_with_tz(time_unit, None, nullability)
3232
}
@@ -120,7 +120,11 @@ impl ExtDTypeVTable for Timestamp {
120120
})
121121
}
122122

123-
fn validate(&self, _metadata: &Self::Metadata, storage_dtype: &DType) -> VortexResult<()> {
123+
fn validate_dtype(
124+
&self,
125+
_metadata: &Self::Metadata,
126+
storage_dtype: &DType,
127+
) -> VortexResult<()> {
124128
vortex_ensure!(
125129
matches!(storage_dtype, DType::Primitive(PType::I64, _)),
126130
"Timestamp storage dtype must be i64"

vortex-dtype/src/extension/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<V: ExtDTypeVTable> ExtDType<V> {
4747
metadata: V::Metadata,
4848
storage_dtype: DType,
4949
) -> VortexResult<Self> {
50-
vtable.validate(&metadata, &storage_dtype)?;
50+
vtable.validate_dtype(&metadata, &storage_dtype)?;
5151
Ok(Self(Arc::new(ExtDTypeAdapter::<V> {
5252
vtable,
5353
metadata,

vortex-dtype/src/extension/vtable.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::ExtID;
1414
use crate::extension::ExtDTypeRef;
1515

1616
/// The public API for defining new extension DTypes.
17-
pub trait ExtDTypeVTable: 'static + Sized + Send + Sync + Clone + Debug {
17+
pub trait ExtDTypeVTable: 'static + Sized + Send + Sync + Clone + Debug + Eq + Hash {
1818
/// Associated type containing the deserialized metadata for this extension type
1919
type Metadata: 'static + Send + Sync + Clone + Debug + Display + Eq + Hash;
2020

@@ -40,23 +40,20 @@ pub trait ExtDTypeVTable: 'static + Sized + Send + Sync + Clone + Debug {
4040
}
4141

4242
/// Validate that the given storage type is compatible with this extension type.
43-
fn validate(&self, metadata: &Self::Metadata, storage_dtype: &DType) -> VortexResult<()>;
43+
fn validate_dtype(&self, metadata: &Self::Metadata, storage_dtype: &DType) -> VortexResult<()>;
4444
}
4545

4646
/// A dynamic vtable for extension types, used for type-erased deserialization.
4747
// TODO(ngates): consider renaming this to ExtDTypePlugin or similar?
48-
pub trait DynVTable: 'static + Send + Sync + Debug {
48+
pub trait DynExtDTypeVTable: 'static + Send + Sync + Debug {
4949
/// Returns the ID for this extension type.
5050
fn id(&self) -> ExtID;
5151

5252
/// Deserialize an extension type from serialized metadata.
5353
fn deserialize(&self, data: &[u8], storage_dtype: DType) -> VortexResult<ExtDTypeRef>;
54-
55-
/// Clones this vtable into a boxed trait object.
56-
fn clone_box(&self) -> Box<dyn DynVTable>;
5754
}
5855

59-
impl<V: ExtDTypeVTable> DynVTable for V {
56+
impl<V: ExtDTypeVTable> DynExtDTypeVTable for V {
6057
fn id(&self) -> ExtID {
6158
ExtDTypeVTable::id(self)
6259
}
@@ -65,10 +62,6 @@ impl<V: ExtDTypeVTable> DynVTable for V {
6562
let metadata = ExtDTypeVTable::deserialize(self, data)?;
6663
Ok(ExtDType::try_with_vtable(self.clone(), metadata, storage_dtype)?.erased())
6764
}
68-
69-
fn clone_box(&self) -> Box<dyn DynVTable> {
70-
Box::new(self.clone())
71-
}
7265
}
7366

7467
/// An empty metadata struct for extension dtypes that do not require any metadata.

vortex-dtype/src/session.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ use vortex_session::registry::Registry;
1212
use crate::datetime::Date;
1313
use crate::datetime::Time;
1414
use crate::datetime::Timestamp;
15-
use crate::extension::DynVTable;
15+
use crate::extension::DynExtDTypeVTable;
1616
use crate::extension::ExtDTypeVTable;
1717

1818
/// Registry for extension dtypes.
19-
pub type ExtDTypeRegistry = Registry<Arc<dyn DynVTable>>;
19+
pub type ExtDTypeRegistry = Registry<Arc<dyn DynExtDTypeVTable>>;
2020

2121
/// Session for managing extension dtypes.
2222
#[derive(Debug)]
@@ -43,7 +43,7 @@ impl DTypeSession {
4343
/// Register an extension DType with the Vortex session.
4444
pub fn register<V: ExtDTypeVTable>(&self, vtable: V) {
4545
self.registry
46-
.register(vtable.id(), Arc::new(vtable) as Arc<dyn DynVTable>);
46+
.register(vtable.id(), Arc::new(vtable) as Arc<dyn DynExtDTypeVTable>);
4747
}
4848

4949
/// Return the registry of extension dtypes.

vortex-duckdb/src/convert/dtype.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ mod tests {
567567
use vortex::dtype::ExtID;
568568
use vortex::dtype::PType;
569569

570-
#[derive(Clone, Debug, Default)]
570+
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
571571
struct TestExt;
572572
impl ExtDTypeVTable for TestExt {
573573
type Metadata = EmptyMetadata;
@@ -576,7 +576,7 @@ mod tests {
576576
ExtID::new_ref("unknown.extension")
577577
}
578578

579-
fn validate(
579+
fn validate_dtype(
580580
&self,
581581
_options: &Self::Metadata,
582582
_storage_dtype: &DType,

vortex-scalar/src/arrow/tests.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ fn test_list_scalar_to_arrow_todo() {
262262
fn test_non_temporal_extension_to_arrow_todo() {
263263
use vortex_dtype::ExtID;
264264

265-
#[derive(Debug, Clone, Default)]
265+
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
266266
struct SomeExt;
267267
impl ExtDTypeVTable for SomeExt {
268268
type Metadata = String;
@@ -279,7 +279,11 @@ fn test_non_temporal_extension_to_arrow_todo() {
279279
vortex_bail!("not implemented")
280280
}
281281

282-
fn validate(&self, _options: &Self::Metadata, _storage_dtype: &DType) -> VortexResult<()> {
282+
fn validate_dtype(
283+
&self,
284+
_options: &Self::Metadata,
285+
_storage_dtype: &DType,
286+
) -> VortexResult<()> {
283287
Ok(())
284288
}
285289
}

vortex-scalar/src/extension.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ mod tests {
167167
use crate::Scalar;
168168
use crate::ScalarValue;
169169

170-
#[derive(Debug, Clone, Default)]
170+
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
171171
struct TestExt;
172172
impl ExtDTypeVTable for TestExt {
173173
type Metadata = EmptyMetadata;
@@ -176,7 +176,11 @@ mod tests {
176176
ExtID::new_ref("test_ext")
177177
}
178178

179-
fn validate(&self, _options: &Self::Metadata, _storage_dtype: &DType) -> VortexResult<()> {
179+
fn validate_dtype(
180+
&self,
181+
_options: &Self::Metadata,
182+
_storage_dtype: &DType,
183+
) -> VortexResult<()> {
180184
Ok(())
181185
}
182186
}
@@ -234,7 +238,7 @@ mod tests {
234238

235239
#[test]
236240
fn test_ext_scalar_partial_ord_different_types() {
237-
#[derive(Clone, Debug, Default)]
241+
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
238242
struct TestExt2;
239243
impl ExtDTypeVTable for TestExt2 {
240244
type Metadata = EmptyMetadata;
@@ -243,7 +247,7 @@ mod tests {
243247
ExtID::new_ref("test_ext_2")
244248
}
245249

246-
fn validate(
250+
fn validate_dtype(
247251
&self,
248252
_options: &Self::Metadata,
249253
_storage_dtype: &DType,
@@ -413,7 +417,7 @@ mod tests {
413417

414418
#[test]
415419
fn test_ext_scalar_with_metadata() {
416-
#[derive(Clone, Debug, Default)]
420+
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
417421
struct TestExtMetadata;
418422
impl ExtDTypeVTable for TestExtMetadata {
419423
type Metadata = usize;
@@ -422,7 +426,7 @@ mod tests {
422426
ExtID::new_ref("test_ext_metadata")
423427
}
424428

425-
fn validate(
429+
fn validate_dtype(
426430
&self,
427431
_options: &Self::Metadata,
428432
_storage_dtype: &DType,

0 commit comments

Comments
 (0)