Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Fixed issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao committed Oct 2, 2021
1 parent be85c24 commit 8bf843a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/array/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn Array> {
let offset = self.offsets[i];
Expand All @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ pub fn new_empty_array(data_type: DataType) -> Box<dyn Array> {
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))
Expand Down Expand Up @@ -309,7 +309,7 @@ pub fn new_null_array(data_type: DataType, length: usize) -> Box<dyn Array> {
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))
Expand Down Expand Up @@ -347,7 +347,7 @@ pub fn clone(array: &dyn Array) -> Box<dyn Array> {
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>)
Expand Down
6 changes: 5 additions & 1 deletion src/compute/aggregate/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<MapArray>().unwrap();
let offsets = array.offsets().len() * std::mem::size_of::<i32>();
offsets + estimated_bytes_size(array.field().as_ref()) + validity_size(array.validity())
}
}
}
2 changes: 1 addition & 1 deletion src/io/json_integration/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ fn to_data_type(item: &Value, mut children: Vec<Field>) -> Result<DataType> {
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)
}
Expand Down

0 comments on commit 8bf843a

Please sign in to comment.