From 8bf843af460f6aa22fd8c86395572b84699502db Mon Sep 17 00:00:00 2001 From: "Jorge C. Leitao" Date: Sat, 2 Oct 2021 09:58:10 +0000 Subject: [PATCH] Fixed issues. --- src/array/map/mod.rs | 4 ++-- src/array/mod.rs | 6 +++--- src/compute/aggregate/memory.rs | 6 +++++- src/io/json_integration/schema.rs | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/array/map/mod.rs b/src/array/map/mod.rs index 53538fe420f..0efc83e7a4e 100644 --- a/src/array/map/mod.rs +++ b/src/array/map/mod.rs @@ -130,7 +130,7 @@ impl MapArray { &self.field } - /// Returns the element at index `i` + /// Returns the element at index `i`. #[inline] pub fn value(&self, i: usize) -> Box { let offset = self.offsets[i]; @@ -143,7 +143,7 @@ impl MapArray { unsafe { self.field.slice_unchecked(offset.to_usize(), length) } } - /// Returns the element at index `i` as &str + /// Returns the element at index `i`. /// # Safety /// Assumes that the `i < self.len`. #[inline] diff --git a/src/array/mod.rs b/src/array/mod.rs index 22d4c9cbfea..f13b0a4eb00 100644 --- a/src/array/mod.rs +++ b/src/array/mod.rs @@ -279,7 +279,7 @@ pub fn new_empty_array(data_type: DataType) -> Box { FixedSizeList => Box::new(FixedSizeListArray::new_empty(data_type)), Struct => Box::new(StructArray::new_empty(data_type)), Union => Box::new(UnionArray::new_empty(data_type)), - Map => todo!(), + Map => Box::new(MapArray::new_empty(data_type)), Dictionary(key_type) => { with_match_physical_dictionary_key_type!(key_type, |$T| { Box::new(DictionaryArray::<$T>::new_empty(data_type)) @@ -309,7 +309,7 @@ pub fn new_null_array(data_type: DataType, length: usize) -> Box { FixedSizeList => Box::new(FixedSizeListArray::new_null(data_type, length)), Struct => Box::new(StructArray::new_null(data_type, length)), Union => Box::new(UnionArray::new_null(data_type, length)), - Map => todo!(), + Map => Box::new(MapArray::new_null(data_type, length)), Dictionary(key_type) => { with_match_physical_dictionary_key_type!(key_type, |$T| { Box::new(DictionaryArray::<$T>::new_null(data_type, length)) @@ -347,7 +347,7 @@ pub fn clone(array: &dyn Array) -> Box { FixedSizeList => clone_dyn!(array, FixedSizeListArray), Struct => clone_dyn!(array, StructArray), Union => clone_dyn!(array, UnionArray), - Map => todo!(), + Map => clone_dyn!(array, MapArray), Dictionary(key_type) => { with_match_physical_dictionary_key_type!(key_type, |$T| { clone_dyn!(array, DictionaryArray::<$T>) diff --git a/src/compute/aggregate/memory.rs b/src/compute/aggregate/memory.rs index 12d2bdbb3e3..036b2b5ebfe 100644 --- a/src/compute/aggregate/memory.rs +++ b/src/compute/aggregate/memory.rs @@ -109,6 +109,10 @@ pub fn estimated_bytes_size(array: &dyn Array) -> usize { Dictionary(key_type) => with_match_physical_dictionary_key_type!(key_type, |$T| { dyn_dict!(array, $T) }), - Map => todo!(), + Map => { + let array = array.as_any().downcast_ref::().unwrap(); + let offsets = array.offsets().len() * std::mem::size_of::(); + offsets + estimated_bytes_size(array.field().as_ref()) + validity_size(array.validity()) + } } } diff --git a/src/io/json_integration/schema.rs b/src/io/json_integration/schema.rs index f7d48993ec0..3b3d6b7c599 100644 --- a/src/io/json_integration/schema.rs +++ b/src/io/json_integration/schema.rs @@ -411,7 +411,7 @@ fn to_data_type(item: &Value, mut children: Vec) -> Result { let sorted_keys = if let Some(Value::Bool(sorted_keys)) = item.get("keysSorted") { *sorted_keys } else { - return Err(ArrowError::Schema("union requires mode".to_string())); + return Err(ArrowError::Schema("sorted keys not defined".to_string())); }; DataType::Map(Box::new(children.pop().unwrap()), sorted_keys) }