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

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Oct 10, 2021
1 parent e77d4e1 commit c31a543
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 38 deletions.
4 changes: 3 additions & 1 deletion src/array/utf8/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ impl<O: Offset, A: ffi::ArrowArrayRef> FromFfi<A> for Utf8Array<O> {
validity = validity.map(|x| x.slice(offset, length))
}
let data_type = Self::default_data_type();
Ok(Self::from_data_unchecked(data_type, offsets, values, validity))
Ok(Self::from_data_unchecked(
data_type, offsets, values, validity,
))
}
}
72 changes: 41 additions & 31 deletions src/io/parquet/read/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
//! APIs to read from Parquet format.
use std::{convert::TryInto, io::{Read, Seek}, sync::Arc};
use std::{
convert::TryInto,
io::{Read, Seek},
sync::Arc,
};

use futures::{AsyncRead, AsyncSeek, Stream};
pub use parquet2::{
Expand All @@ -18,7 +22,11 @@ pub use parquet2::{
types::int96_to_i64_ns,
};

use crate::{array::{Array, DictionaryKey, PrimitiveArray}, datatypes::{DataType, IntervalUnit, TimeUnit}, error::{ArrowError, Result}};
use crate::{
array::{Array, DictionaryKey, PrimitiveArray},
datatypes::{DataType, IntervalUnit, TimeUnit},
error::{ArrowError, Result},
};

mod binary;
mod boolean;
Expand Down Expand Up @@ -205,45 +213,47 @@ pub fn page_iter_to_array<
iter, data_type, metadata,
)?)),
Decimal(_, _) => match metadata.descriptor().type_() {
ParquetType::PrimitiveType { physical_type, ..} => match physical_type{
PhysicalType::Int32 => primitive::iter_to_array(
iter,
metadata,
data_type,
|x: i32| x as i128,
),
PhysicalType::Int64 => primitive::iter_to_array(
iter,
metadata,
data_type,
|x: i64| x as i128,
),
ParquetType::PrimitiveType { physical_type, .. } => match physical_type {
PhysicalType::Int32 => {
primitive::iter_to_array(iter, metadata, data_type, |x: i32| x as i128)
}
PhysicalType::Int64 => {
primitive::iter_to_array(iter, metadata, data_type, |x: i64| x as i128)
}
PhysicalType::FixedLenByteArray(n) => {
if *n > 16 {
Err(ArrowError::NotYetImplemented(format!(
"Can't decode Decimal128 type from Fixed Size Byte Array of len {:?}",
n
)))
} else {
let paddings = (0..(16-*n)).map(|_| 0u8).collect::<Vec<_>>();
fixed_size_binary::iter_to_array(iter, DataType::FixedSizeBinary(*n), metadata)
.map(|e|{
let a = e.into_iter().map(|v|
v.and_then(|v1| {
[&paddings, v1].concat().try_into().map(
|pad16| i128::from_be_bytes(pad16)
).ok()
}
)
).collect::<Vec<_>>();
Box::new(PrimitiveArray::<i128>::from(a).to(data_type)) as Box<dyn Array>
}
let paddings = (0..(16 - *n)).map(|_| 0u8).collect::<Vec<_>>();
fixed_size_binary::iter_to_array(
iter,
DataType::FixedSizeBinary(*n),
metadata,
)
.map(|e| {
let a = e
.into_iter()
.map(|v| {
v.and_then(|v1| {
[&paddings, v1]
.concat()
.try_into()
.map(|pad16| i128::from_be_bytes(pad16))
.ok()
})
})
.collect::<Vec<_>>();
Box::new(PrimitiveArray::<i128>::from(a).to(data_type))
as Box<dyn Array>
})
}
},
_ => unreachable!()
}
_ => unreachable!(),
},
_ => unreachable!()
_ => unreachable!(),
},
List(ref inner) => match inner.data_type() {
UInt8 => primitive::iter_to_array_nested(iter, metadata, data_type, |x: i32| x as u8),
Expand Down
2 changes: 1 addition & 1 deletion src/io/parquet/read/schema/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub fn from_int64(
ParquetTimeUnit::MICROS(_) => DataType::Time64(TimeUnit::Microsecond),
ParquetTimeUnit::NANOS(_) => DataType::Time64(TimeUnit::Nanosecond),
},
(Some(PrimitiveConvertedType::Decimal(precision,scale)), _) => {
(Some(PrimitiveConvertedType::Decimal(precision, scale)), _) => {
DataType::Decimal(*precision as usize, *scale as usize)
}
(c, l) => {
Expand Down
8 changes: 4 additions & 4 deletions src/io/parquet/write/fixed_len_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use parquet2::{
encoding::Encoding,
metadata::ColumnDescriptor,
page::CompressedDataPage,
statistics::{serialize_statistics, deserialize_statistics, ParquetStatistics},
statistics::{deserialize_statistics, serialize_statistics, ParquetStatistics},
write::WriteOptions,
};

Expand Down Expand Up @@ -98,7 +98,7 @@ pub(super) fn build_statistics(
.min_by(|x, y| ord_binary(x, y))
.map(|x| x.to_vec()),
};
deserialize_statistics(pq_statistics,descriptor).map(
|e| serialize_statistics(&*e)
).ok()
deserialize_statistics(pq_statistics, descriptor)
.map(|e| serialize_statistics(&*e))
.ok()
}
2 changes: 1 addition & 1 deletion src/scalar/primitive.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
datatypes::DataType,
types::{NativeType, NaturalDataType},
error::ArrowError,
types::{NativeType, NaturalDataType},
};

use super::Scalar;
Expand Down

0 comments on commit c31a543

Please sign in to comment.