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

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao committed Feb 3, 2022
1 parent 9c9bdf3 commit 5a07aa6
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 54 deletions.
2 changes: 1 addition & 1 deletion examples/parquet_read_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main() -> Result<()> {
let file_path = &args[1];

let reader = File::open(file_path)?;
let reader = read::RecordReader::try_new(reader, None, None, None, None)?;
let reader = read::FileReader::try_new(reader, None, None, None, None)?;

let start = SystemTime::now();
for maybe_chunk in reader {
Expand Down
10 changes: 0 additions & 10 deletions src/io/parquet/read/binary/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ impl<O: Offset> Pushable<O> for Offsets<O> {
self.0.len() - 1
}

#[inline]
fn reserve(&mut self, additional: usize) {
self.0.reserve(additional)
}

#[inline]
fn push(&mut self, value: O) {
self.0.push(value)
Expand Down Expand Up @@ -76,11 +71,6 @@ impl<'a, O: Offset> Pushable<&'a [u8]> for Binary<O> {
self.len()
}

#[inline]
fn reserve(&mut self, additional: usize) {
self.offsets.reserve(additional)
}

#[inline]
fn push_null(&mut self) {
self.push(&[])
Expand Down
5 changes: 0 additions & 5 deletions src/io/parquet/read/fixed_size_binary/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ impl FixedSizeBinary {
}

impl<'a> Pushable<&'a [u8]> for FixedSizeBinary {
#[inline]
fn reserve(&mut self, additional: usize) {
self.values.reserve(additional * self.size)
}

#[inline]
fn push(&mut self, value: &[u8]) {
debug_assert_eq!(value.len(), self.size);
Expand Down
38 changes: 1 addition & 37 deletions src/io/parquet/read/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub fn split_buffer<'a>(

/// A private trait representing structs that can receive elements.
pub(super) trait Pushable<T>: Sized {
fn reserve(&mut self, additional: usize);
//fn reserve(&mut self, additional: usize);
fn push(&mut self, value: T);
fn len(&self) -> usize;
fn push_null(&mut self);
Expand All @@ -83,11 +83,6 @@ impl Pushable<bool> for MutableBitmap {
self.len()
}

#[inline]
fn reserve(&mut self, additional: usize) {
self.reserve(additional)
}

#[inline]
fn push(&mut self, value: bool) {
self.push(value)
Expand All @@ -110,11 +105,6 @@ impl<A: Copy + Default> Pushable<A> for Vec<A> {
self.len()
}

#[inline]
fn reserve(&mut self, additional: usize) {
self.reserve(additional)
}

#[inline]
fn push_null(&mut self) {
self.push(A::default())
Expand Down Expand Up @@ -163,7 +153,6 @@ impl<'a> OptionalPageValidity<'a> {
}

/// Extends a [`Pushable`] from an iterator of non-null values and an hybrid-rle decoder
#[inline]
pub(super) fn extend_from_decoder<'a, T: Default, P: Pushable<T>, I: Iterator<Item = T>>(
validity: &mut MutableBitmap,
page_validity: &mut OptionalPageValidity<'a>,
Expand Down Expand Up @@ -240,31 +229,6 @@ pub(super) fn extend_from_decoder<'a, T: Default, P: Pushable<T>, I: Iterator<It
}
}

/*
pub(super) fn read_dict_optional<K>(
validity_buffer: &[u8],
indices_buffer: &[u8],
additional: usize,
indices: &mut Vec<K>,
validity: &mut MutableBitmap,
) where
K: DictionaryKey,
{
// SPEC: Data page format: the bit width used to encode the entry ids stored as 1 byte (max bit width = 32),
// SPEC: followed by the values encoded using RLE/Bit packed described above (with the given bit width).
let bit_width = indices_buffer[0];
let indices_buffer = &indices_buffer[1..];
let new_indices =
hybrid_rle::HybridRleDecoder::new(indices_buffer, bit_width as u32, additional);
let indices_iter = new_indices.map(|x| K::from_u32(x).unwrap());
let mut page_validity = OptionalPageValidity::new(validity_buffer, additional);
extend_from_decoder(validity, &mut page_validity, None, indices, indices_iter)
}
*/

/// The state of a partially deserialized page
pub(super) trait PageState<'a> {
fn len(&self) -> usize;
Expand Down
2 changes: 1 addition & 1 deletion tests/it/io/parquet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ fn test_file(version: &str, file_name: &str) -> Result<()> {
// empty batches are not written/read from parquet and can be ignored
let batches = batches
.into_iter()
.filter(|x| x.len() > 0)
.filter(|x| !x.is_empty())
.collect::<Vec<_>>();

let data = integration_write(&schema, &batches)?;
Expand Down

0 comments on commit 5a07aa6

Please sign in to comment.