From 87dd673fc5879ca4cc05519789ee793b7ac19d9e Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Fri, 20 Sep 2024 13:34:55 +0100 Subject: [PATCH] Remove clone when creating ArrayData to run validation --- vortex-array/src/data.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vortex-array/src/data.rs b/vortex-array/src/data.rs index e97b6192f..baf100ce8 100644 --- a/vortex-array/src/data.rs +++ b/vortex-array/src/data.rs @@ -40,12 +40,12 @@ impl ArrayData { stats_map: Arc::new(RwLock::new(statistics)), }; + let array = Array::from(data); // Validate here that the metadata correctly parses, so that an encoding can infallibly - let array = data.to_array(); - // FIXME(ngates): run some validation function + // FIXME(robert): Encoding::with_dyn no longer eagerly validates metadata, come up with a way to validate metadata encoding.with_dyn(&array, &mut |_| Ok(()))?; - Ok(data) + Ok(array.into()) } pub fn encoding(&self) -> EncodingRef { @@ -118,8 +118,8 @@ impl ToArray for ArrayData { impl From for ArrayData { fn from(value: Array) -> ArrayData { - match &value { - Array::Data(d) => d.clone(), + match value { + Array::Data(d) => d, Array::View(_) => value.with_dyn(|v| v.to_array_data()), } }