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

Commit

Permalink
Simplified code (#1183)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao authored Jul 25, 2022
1 parent e810d39 commit 5c745f4
Show file tree
Hide file tree
Showing 12 changed files with 456 additions and 552 deletions.
25 changes: 2 additions & 23 deletions src/io/parquet/read/deserialize/binary/dictionary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
bitmap::MutableBitmap,
datatypes::{DataType, PhysicalType},
error::Result,
io::parquet::read::deserialize::nested_utils::{InitNested, NestedArrayIter, NestedState},
io::parquet::read::deserialize::nested_utils::{InitNested, NestedState},
};

use super::super::dictionary::*;
Expand Down Expand Up @@ -108,6 +108,7 @@ where
}
}

/// An iterator adapter that converts [`DataPages`] into an [`Iterator`] of [`DictionaryArray`]
#[derive(Debug)]
pub struct NestedDictIter<K, O, I>
where
Expand Down Expand Up @@ -178,25 +179,3 @@ where
}
}
}

/// Converts [`DataPages`] to an [`Iterator`] of [`Array`]
pub fn iter_to_arrays_nested<'a, K, O, I>(
iter: I,
init: Vec<InitNested>,
data_type: DataType,
num_rows: usize,
chunk_size: Option<usize>,
) -> NestedArrayIter<'a>
where
I: 'a + DataPages,
O: Offset,
K: DictionaryKey,
{
Box::new(
NestedDictIter::<K, O, I>::new(iter, init, data_type, num_rows, chunk_size).map(|result| {
let (mut nested, array) = result?;
let _ = nested.nested.pop().unwrap(); // the primitive
Ok((nested, array.boxed()))
}),
)
}
5 changes: 2 additions & 3 deletions src/io/parquet/read/deserialize/binary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ mod dictionary;
mod nested;
mod utils;

pub use self::nested::NestedIter;
pub use basic::Iter;
pub use dictionary::{iter_to_arrays_nested as iter_to_dict_arrays_nested, DictIter};
pub use nested::iter_to_arrays_nested;
pub use dictionary::{DictIter, NestedDictIter};
pub use nested::NestedIter;
25 changes: 0 additions & 25 deletions src/io/parquet/read/deserialize/binary/nested.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use parquet2::{
schema::Repetition,
};

use crate::array::Array;
use crate::{
array::Offset, bitmap::MutableBitmap, datatypes::DataType, error::Result,
io::parquet::read::DataPages,
Expand Down Expand Up @@ -194,27 +193,3 @@ impl<O: Offset, A: TraitBinaryArray<O>, I: DataPages> Iterator for NestedIter<O,
}
}
}

/// Converts [`DataPages`] to an [`Iterator`] of [`TraitBinaryArray`]
pub fn iter_to_arrays_nested<'a, O, A, I>(
iter: I,
init: Vec<InitNested>,
data_type: DataType,
num_rows: usize,
chunk_size: Option<usize>,
) -> NestedArrayIter<'a>
where
I: 'a + DataPages,
A: TraitBinaryArray<O>,
O: Offset,
{
Box::new(
NestedIter::<O, A, I>::new(iter, init, data_type, num_rows, chunk_size).map(|x| {
x.map(|(mut nested, array)| {
let _ = nested.nested.pop().unwrap(); // the primitive
let values = Box::new(array) as Box<dyn Array>;
(nested, values)
})
}),
)
}
2 changes: 1 addition & 1 deletion src/io/parquet/read/deserialize/boolean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ mod basic;
mod nested;

pub use self::basic::Iter;
pub use nested::iter_to_arrays_nested;
pub use nested::NestedIter;
19 changes: 0 additions & 19 deletions src/io/parquet/read/deserialize/boolean/nested.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,22 +147,3 @@ impl<I: DataPages> Iterator for NestedIter<I> {
}
}
}

/// Converts [`DataPages`] to an [`Iterator`] of [`BooleanArray`]
pub fn iter_to_arrays_nested<'a, I: 'a>(
iter: I,
init: Vec<InitNested>,
num_rows: usize,
chunk_size: Option<usize>,
) -> NestedArrayIter<'a>
where
I: DataPages,
{
Box::new(NestedIter::new(iter, init, num_rows, chunk_size).map(|x| {
x.map(|(mut nested, array)| {
let _ = nested.nested.pop().unwrap(); // the primitive
let values = array.boxed();
(nested, values)
})
}))
}
24 changes: 2 additions & 22 deletions src/io/parquet/read/deserialize/fixed_size_binary/dictionary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
bitmap::MutableBitmap,
datatypes::DataType,
error::Result,
io::parquet::read::deserialize::nested_utils::{InitNested, NestedArrayIter, NestedState},
io::parquet::read::deserialize::nested_utils::{InitNested, NestedState},
};

use super::super::dictionary::*;
Expand Down Expand Up @@ -90,6 +90,7 @@ where
}
}

/// An iterator adapter that converts [`DataPages`] into an [`Iterator`] of [`DictionaryArray`].
#[derive(Debug)]
pub struct NestedDictIter<K, I>
where
Expand Down Expand Up @@ -155,24 +156,3 @@ where
}
}
}

/// Converts [`DataPages`] to an [`Iterator`] of [`Array`]
pub fn iter_to_arrays_nested<'a, K, I>(
iter: I,
init: Vec<InitNested>,
data_type: DataType,
num_rows: usize,
chunk_size: Option<usize>,
) -> NestedArrayIter<'a>
where
I: 'a + DataPages,
K: DictionaryKey,
{
Box::new(
NestedDictIter::<K, I>::new(iter, init, data_type, num_rows, chunk_size).map(|result| {
let (mut nested, array) = result?;
let _ = nested.nested.pop().unwrap(); // the primitive
Ok((nested, array.boxed()))
}),
)
}
2 changes: 1 addition & 1 deletion src/io/parquet/read/deserialize/fixed_size_binary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ mod dictionary;
mod utils;

pub use basic::Iter;
pub use dictionary::{iter_to_arrays_nested as iter_to_dict_arrays_nested, DictIter};
pub use dictionary::{DictIter, NestedDictIter};
Loading

0 comments on commit 5c745f4

Please sign in to comment.