Skip to content

Commit

Permalink
improve categorical::full_null (#2706)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Feb 20, 2022
1 parent 5fe8aeb commit f741284
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ pub enum RevMapping {
Local(Utf8Array<i64>),
}

impl Default for RevMapping {
fn default() -> Self {
let slice: &[Option<&str>] = &[];
RevMapping::Local(Utf8Array::<i64>::from(slice))
}
}

#[allow(clippy::len_without_is_empty)]
impl RevMapping {
/// Get the length of the [`RevMapping`]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ use super::*;

impl CategoricalChunked {
pub fn full_null(name: &str, length: usize) -> CategoricalChunked {
// TODO! implement proper, can be faster
let mut builder = CategoricalChunkedBuilder::new(name, length);
let iter = (0..length).map(|_| None);
builder.drain_iter(iter);
builder.finish()
let cats = UInt32Chunked::full_null(name, length);
CategoricalChunked::from_cats_and_rev_map(cats, Arc::new(RevMapping::default()))
}
}

0 comments on commit f741284

Please sign in to comment.