nevi-me commented on a change in pull request #9469:
URL: https://github.com/apache/arrow/pull/9469#discussion_r574794038
##########
File path: rust/arrow/src/array/array.rs
##########
@@ -326,6 +327,167 @@ pub fn new_empty_array(data_type: &DataType) -> ArrayRef {
let data = ArrayData::new_empty(data_type);
make_array(Arc::new(data))
}
+/// Creates a new array of `data_type` of length `length` filled entirely of
`NULL` values
+pub fn new_null_array(data_type: &DataType, length: usize) -> ArrayRef {
+ match data_type {
+ DataType::Null => Arc::new(NullArray::new(length)),
+ DataType::Boolean => {
+ let null_buf: Buffer = MutableBuffer::new_null(length).into();
+ make_array(Arc::new(ArrayData::new(
+ data_type.clone(),
+ length,
+ Some(length),
+ Some(null_buf.clone()),
+ 0,
+ vec![null_buf],
+ vec![],
+ )))
+ }
+ DataType::Int8 | DataType::UInt8 => {
+ new_null_sized_array::<Int8Type>(data_type, length)
+ }
+ DataType::Int16 | DataType::UInt16 => {
+ new_null_sized_array::<Int16Type>(data_type, length)
+ }
+ DataType::Float16 => unreachable!(),
+ DataType::Int32
+ | DataType::UInt32
Review comment:
I can change them, seemed tedious though because f32 and i32 use the
same underlying size. I was looking for a convenient way of getting the byte
size
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]