Skip to content

Commit

Permalink
refactor: categorical builder to categorical module
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Sep 30, 2021
1 parent 4752a35 commit ab36afb
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 10 deletions.
4 changes: 0 additions & 4 deletions polars/polars-core/src/chunked_array/builder/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#[cfg(feature = "dtype-categorical")]
pub mod categorical;
#[cfg(feature = "dtype-categorical")]
pub use self::categorical::CategoricalChunkedBuilder;
use crate::{
prelude::*,
utils::{get_iter_capacity, NoNull},
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-core/src/chunked_array/cast.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Implementations of the ChunkCast Trait.
#[cfg(feature = "dtype-categorical")]
use crate::chunked_array::builder::CategoricalChunkedBuilder;
use crate::chunked_array::categorical::CategoricalChunkedBuilder;
use crate::prelude::*;
use arrow::compute::cast;
use num::NumCast;
Expand Down
3 changes: 2 additions & 1 deletion polars/polars-core/src/chunked_array/categorical/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::chunked_array::RevMapping;
use crate::prelude::*;
use arrow::array::DictionaryArray;
use arrow::compute::cast::cast;
mod builder;
pub use builder::*;

impl From<&CategoricalChunked> for DictionaryArray<u32> {
fn from(ca: &CategoricalChunked) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-core/src/chunked_array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub(crate) mod list;
use polars_arrow::prelude::*;

#[cfg(feature = "dtype-categorical")]
use crate::chunked_array::builder::categorical::RevMapping;
use crate::chunked_array::categorical::RevMapping;
use crate::utils::{slice_offsets, CustomIterTools};
use std::mem;
use std::ops::{Deref, DerefMut};
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-core/src/chunked_array/ops/full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl ChunkFullNull for ListChunked {
#[cfg(feature = "dtype-categorical")]
impl ChunkFullNull for CategoricalChunked {
fn full_null(name: &str, length: usize) -> CategoricalChunked {
use crate::chunked_array::builder::CategoricalChunkedBuilder;
use crate::chunked_array::categorical::CategoricalChunkedBuilder;
let mut builder = CategoricalChunkedBuilder::new(name, length);
let iter = (0..length).map(|_| None);
builder.from_iter(iter);
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-core/src/chunked_array/ops/unique/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pub(crate) mod rank;

#[cfg(feature = "dtype-categorical")]
use crate::chunked_array::builder::categorical::RevMapping;
use crate::chunked_array::categorical::RevMapping;
#[cfg(feature = "object")]
use crate::chunked_array::object::ObjectType;
use crate::datatypes::PlHashSet;
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-core/src/series/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1880,7 +1880,7 @@ impl std::convert::TryFrom<(&str, Vec<ArrayRef>)> for Series {
}
#[cfg(feature = "dtype-categorical")]
ArrowDataType::Dictionary(key_type, value_type) => {
use crate::chunked_array::builder::CategoricalChunkedBuilder;
use crate::chunked_array::categorical::CategoricalChunkedBuilder;
use arrow::compute::cast::cast;
let chunks = chunks.iter().map(|arr| &**arr).collect::<Vec<_>>();
let arr = arrow::compute::concat::concatenate(&chunks)?;
Expand Down

0 comments on commit ab36afb

Please sign in to comment.