Skip to content

Commit

Permalink
add doc comments and clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
nevi-me committed Jul 11, 2021
1 parent 85cda50 commit f52d13e
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 38 deletions.
5 changes: 5 additions & 0 deletions arrow/src/array/array_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ use super::{
use crate::datatypes::{ArrowNativeType, DataType};
use crate::error::ArrowError;

/// A nested array type where each record is a key-value map.
/// Keys should always be non-null, but values can be null.
///
/// [MapArray] is physically a [ListArray] that has a [StructArray]
/// with 2 child fields.
pub struct MapArray {
data: ArrayData,
values: ArrayRef,
Expand Down
32 changes: 0 additions & 32 deletions arrow/src/array/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1644,38 +1644,6 @@ impl<K: ArrayBuilder, V: ArrayBuilder> MapBuilder<K, V> {
}
}

// /// Try to create a `MapBuilder` from a [Field].
// ///
// /// Returns an error if the fild is not a Struct, or keys are nullable
// pub fn try_from_field(field: Field, capacity: usize) -> Result<Self> {
// if let DataType::Struct(fields) = field.data_type() {
// if fields.len() != 2 {
// return Err(ArrowError::InvalidArgumentError(format!(
// "MapArray's struct field should have 2 child fields, found {}",
// fields.len()
// )));
// }
// let keys_field = &fields[0];
// let values_field = &fields[1];
// let field_names = MapFieldNames {
// entry: field.name().clone(),
// key: keys_field.name().clone(),
// value: values_field.name().clone(),
// };
// Ok(Self::with_capacity(
// Some(field_names),
// *make_builder(keys_field.data_type(), capacity),
// *make_builder(values_field.data_type(), capacity),
// capacity,
// ))
// } else {
// Err(ArrowError::InvalidArgumentError(format!(
// "Cannot create MapArray from {:?}",
// field.data_type()
// )))
// }
// }

pub fn keys(&mut self) -> &mut K {
&mut self.key_builder
}
Expand Down
2 changes: 1 addition & 1 deletion arrow/src/ipc/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ pub(crate) fn get_data_type(field: ipc::Field, may_be_dictionary: bool) -> DataT
let map = field.type_as_map().unwrap();
let children = field.children().unwrap();
if children.len() != 1 {
panic!("expect a list to have one child")
panic!("expect a map to have one child")
}
DataType::Map(Box::new(children.get(0).into()), map.keysSorted())
}
Expand Down
2 changes: 1 addition & 1 deletion arrow/src/ipc/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ fn create_list_array(
}
make_array(builder.build())
} else {
panic!("Cannot create list array from {:?}", data_type)
panic!("Cannot create list or map array from {:?}", data_type)
}
}

Expand Down
2 changes: 0 additions & 2 deletions parquet/src/arrow/array_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1047,8 +1047,6 @@ impl ArrayReader for MapArrayReader {
.add_child_data(entry_data)
.build();

// self.def_level_buffer = Some(def_level_data_buffer.into());
// self.rep_level_buffer = rep_level_data;
Ok(Arc::new(MapArray::from(array_data)))
}

Expand Down
2 changes: 0 additions & 2 deletions parquet/src/arrow/arrow_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -952,8 +952,6 @@ mod tests {
{"stocks":{"long": null, "long": "$CCC", "short": null}}
{"stocks":{"hedged": "$YYY", "long": null, "short": "$D"}}
"#;
// let value_list_type =
// DataType::List(Box::new(Field::new("item", DataType::Utf8, false)));
let entries_struct_type = DataType::Struct(vec![
Field::new("key", DataType::Utf8, false),
Field::new("value", DataType::Utf8, true),
Expand Down

0 comments on commit f52d13e

Please sign in to comment.