This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3fc5882
commit 68ee80b
Showing
49 changed files
with
792 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use parquet2::indexes::PageIndex; | ||
|
||
use crate::{ | ||
array::{Array, BinaryArray, PrimitiveArray, Utf8Array}, | ||
datatypes::{DataType, PhysicalType}, | ||
error::ArrowError, | ||
trusted_len::TrustedLen, | ||
}; | ||
|
||
use super::ColumnIndex; | ||
|
||
pub fn deserialize( | ||
indexes: &[PageIndex<Vec<u8>>], | ||
data_type: &DataType, | ||
) -> Result<ColumnIndex, ArrowError> { | ||
Ok(ColumnIndex { | ||
min: deserialize_binary_iter(indexes.iter().map(|index| index.min.as_ref()), data_type)?, | ||
max: deserialize_binary_iter(indexes.iter().map(|index| index.max.as_ref()), data_type)?, | ||
null_count: PrimitiveArray::from_trusted_len_iter( | ||
indexes | ||
.iter() | ||
.map(|index| index.null_count.map(|x| x as u64)), | ||
), | ||
}) | ||
} | ||
|
||
fn deserialize_binary_iter<'a, I: TrustedLen<Item = Option<&'a Vec<u8>>>>( | ||
iter: I, | ||
data_type: &DataType, | ||
) -> Result<Box<dyn Array>, ArrowError> { | ||
match data_type.to_physical_type() { | ||
PhysicalType::LargeBinary => Ok(Box::new(BinaryArray::<i64>::from_iter(iter))), | ||
PhysicalType::Utf8 => { | ||
let iter = iter.map(|x| x.map(|x| std::str::from_utf8(x)).transpose()); | ||
Ok(Box::new(Utf8Array::<i32>::try_from_trusted_len_iter(iter)?)) | ||
} | ||
PhysicalType::LargeUtf8 => { | ||
let iter = iter.map(|x| x.map(|x| std::str::from_utf8(x)).transpose()); | ||
Ok(Box::new(Utf8Array::<i64>::try_from_trusted_len_iter(iter)?)) | ||
} | ||
_ => Ok(Box::new(BinaryArray::<i32>::from_iter(iter))), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use parquet2::indexes::PageIndex; | ||
|
||
use crate::array::{BooleanArray, PrimitiveArray}; | ||
|
||
use super::ColumnIndex; | ||
|
||
pub fn deserialize(indexes: &[PageIndex<bool>]) -> ColumnIndex { | ||
ColumnIndex { | ||
min: Box::new(BooleanArray::from_trusted_len_iter( | ||
indexes.iter().map(|index| index.min), | ||
)), | ||
max: Box::new(BooleanArray::from_trusted_len_iter( | ||
indexes.iter().map(|index| index.max), | ||
)), | ||
null_count: PrimitiveArray::from_trusted_len_iter( | ||
indexes | ||
.iter() | ||
.map(|index| index.null_count.map(|x| x as u64)), | ||
), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use parquet2::indexes::PageIndex; | ||
|
||
use crate::{ | ||
array::{Array, FixedSizeBinaryArray, MutableFixedSizeBinaryArray, PrimitiveArray}, | ||
datatypes::{DataType, PhysicalType, PrimitiveType}, | ||
trusted_len::TrustedLen, | ||
}; | ||
|
||
use super::ColumnIndex; | ||
|
||
pub fn deserialize(indexes: &[PageIndex<Vec<u8>>], data_type: DataType) -> ColumnIndex { | ||
ColumnIndex { | ||
min: deserialize_binary_iter( | ||
indexes.iter().map(|index| index.min.as_ref()), | ||
data_type.clone(), | ||
), | ||
max: deserialize_binary_iter(indexes.iter().map(|index| index.max.as_ref()), data_type), | ||
null_count: PrimitiveArray::from_trusted_len_iter( | ||
indexes | ||
.iter() | ||
.map(|index| index.null_count.map(|x| x as u64)), | ||
), | ||
} | ||
} | ||
|
||
fn deserialize_binary_iter<'a, I: TrustedLen<Item = Option<&'a Vec<u8>>>>( | ||
iter: I, | ||
data_type: DataType, | ||
) -> Box<dyn Array> { | ||
match data_type.to_physical_type() { | ||
PhysicalType::Primitive(PrimitiveType::Int128) => { | ||
Box::new(PrimitiveArray::from_trusted_len_iter(iter.map(|v| { | ||
v.map(|x| { | ||
// Copy the fixed-size byte value to the start of a 16 byte stack | ||
// allocated buffer, then use an arithmetic right shift to fill in | ||
// MSBs, which accounts for leading 1's in negative (two's complement) | ||
// values. | ||
let n = x.len(); | ||
let mut bytes = [0u8; 16]; | ||
bytes[..n].copy_from_slice(x); | ||
i128::from_be_bytes(bytes) >> (8 * (16 - n)) | ||
}) | ||
}))) | ||
} | ||
_ => { | ||
let mut a = MutableFixedSizeBinaryArray::from_data( | ||
data_type, | ||
Vec::with_capacity(iter.size_hint().0), | ||
None, | ||
); | ||
for item in iter { | ||
a.push(item); | ||
} | ||
let a: FixedSizeBinaryArray = a.into(); | ||
Box::new(a) | ||
} | ||
} | ||
} |
Oops, something went wrong.