Skip to content

Commit 32ccf9f

Browse files
committed
make default
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
1 parent f1cdeef commit 32ccf9f

3 files changed

Lines changed: 17 additions & 24 deletions

File tree

vortex-array/public-api.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11070,10 +11070,6 @@ pub struct vortex_array::extension::uuid::UuidMetadata
1107011070

1107111071
pub vortex_array::extension::uuid::UuidMetadata::version: core::option::Option<uuid::Version>
1107211072

11073-
impl vortex_array::extension::uuid::UuidMetadata
11074-
11075-
pub fn vortex_array::extension::uuid::UuidMetadata::any() -> Self
11076-
1107711073
impl core::clone::Clone for vortex_array::extension::uuid::UuidMetadata
1107811074

1107911075
pub fn vortex_array::extension::uuid::UuidMetadata::clone(&self) -> vortex_array::extension::uuid::UuidMetadata
@@ -11084,6 +11080,10 @@ impl core::cmp::PartialEq for vortex_array::extension::uuid::UuidMetadata
1108411080

1108511081
pub fn vortex_array::extension::uuid::UuidMetadata::eq(&self, other: &Self) -> bool
1108611082

11083+
impl core::default::Default for vortex_array::extension::uuid::UuidMetadata
11084+
11085+
pub fn vortex_array::extension::uuid::UuidMetadata::default() -> vortex_array::extension::uuid::UuidMetadata
11086+
1108711087
impl core::fmt::Debug for vortex_array::extension::uuid::UuidMetadata
1108811088

1108911089
pub fn vortex_array::extension::uuid::UuidMetadata::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,17 @@ pub(crate) fn u8_to_version(b: u8) -> VortexResult<Version> {
3030
///
3131
/// Optionally records which UUID version the column contains (e.g. v4 random, v7
3232
/// sort-random). When `None`, the column may contain any mix of versions.
33-
#[derive(Clone, Debug)]
33+
#[derive(Clone, Debug, Default)]
3434
pub struct UuidMetadata {
3535
/// The UUID version, if known.
3636
pub version: Option<Version>,
3737
}
3838

39-
impl UuidMetadata {
40-
/// Creates metadata with no version constraint.
41-
pub fn any() -> Self {
42-
Self { version: None }
43-
}
44-
}
45-
4639
impl fmt::Display for UuidMetadata {
4740
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4841
match self.version {
49-
None => write!(f, "UUID"),
50-
Some(v) => write!(f, "UUID(v{})", v as u8),
42+
None => write!(f, ""),
43+
Some(v) => write!(f, "v{}", v as u8),
5144
}
5245
}
5346
}

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,27 +165,27 @@ mod tests {
165165
#[test]
166166
fn metadata_display_no_version() {
167167
let metadata = UuidMetadata { version: None };
168-
assert_eq!(metadata.to_string(), "UUID");
168+
assert_eq!(metadata.to_string(), "");
169169
}
170170

171171
#[test]
172172
fn metadata_display_with_version() {
173173
let metadata = UuidMetadata {
174174
version: Some(Version::Random),
175175
};
176-
assert_eq!(metadata.to_string(), "UUID(v4)");
176+
assert_eq!(metadata.to_string(), "v4");
177177

178178
let metadata = UuidMetadata {
179179
version: Some(Version::SortRand),
180180
};
181-
assert_eq!(metadata.to_string(), "UUID(v7)");
181+
assert_eq!(metadata.to_string(), "v7");
182182
}
183183

184184
#[rstest]
185185
#[case::non_nullable(Nullability::NonNullable)]
186186
#[case::nullable(Nullability::Nullable)]
187187
fn validate_correct_storage_dtype(#[case] nullability: Nullability) -> VortexResult<()> {
188-
let metadata = UuidMetadata::any();
188+
let metadata = UuidMetadata::default();
189189
let storage_dtype = uuid_storage_dtype(nullability);
190190
Uuid.validate_dtype(&metadata, &storage_dtype)
191191
}
@@ -198,7 +198,7 @@ mod tests {
198198
Nullability::NonNullable,
199199
);
200200
assert!(
201-
Uuid.validate_dtype(&UuidMetadata::any(), &storage_dtype)
201+
Uuid.validate_dtype(&UuidMetadata::default(), &storage_dtype)
202202
.is_err()
203203
);
204204
}
@@ -211,7 +211,7 @@ mod tests {
211211
Nullability::NonNullable,
212212
);
213213
assert!(
214-
Uuid.validate_dtype(&UuidMetadata::any(), &storage_dtype)
214+
Uuid.validate_dtype(&UuidMetadata::default(), &storage_dtype)
215215
.is_err()
216216
);
217217
}
@@ -224,7 +224,7 @@ mod tests {
224224
Nullability::NonNullable,
225225
);
226226
assert!(
227-
Uuid.validate_dtype(&UuidMetadata::any(), &storage_dtype)
227+
Uuid.validate_dtype(&UuidMetadata::default(), &storage_dtype)
228228
.is_err()
229229
);
230230
}
@@ -233,7 +233,7 @@ mod tests {
233233
fn validate_rejects_non_fsl() {
234234
let storage_dtype = DType::Primitive(PType::U8, Nullability::NonNullable);
235235
assert!(
236-
Uuid.validate_dtype(&UuidMetadata::any(), &storage_dtype)
236+
Uuid.validate_dtype(&UuidMetadata::default(), &storage_dtype)
237237
.is_err()
238238
);
239239
}
@@ -243,7 +243,7 @@ mod tests {
243243
let expected = uuid::Uuid::parse_str("550e8400-e29b-41d4-a716-446655440000")
244244
.map_err(|e| vortex_error::vortex_err!("{e}"))?;
245245

246-
let metadata = UuidMetadata::any();
246+
let metadata = UuidMetadata::default();
247247
let storage_dtype = uuid_storage_dtype(Nullability::NonNullable);
248248
let children: Vec<Scalar> = expected
249249
.as_bytes()
@@ -336,7 +336,7 @@ mod tests {
336336
let v4_uuid = uuid::Uuid::parse_str("550e8400-e29b-41d4-a716-446655440000")
337337
.map_err(|e| vortex_error::vortex_err!("{e}"))?;
338338

339-
let metadata = UuidMetadata::any();
339+
let metadata = UuidMetadata::default();
340340
let storage_value = uuid_storage_scalar(&v4_uuid);
341341
let storage_dtype = uuid_storage_dtype(Nullability::NonNullable);
342342

0 commit comments

Comments
 (0)