Skip to content

Commit

Permalink
refactor(rust): remove rev-map from ChunkedArray (#5721)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Dec 5, 2022
1 parent e6b33ce commit 05afe5b
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 20 deletions.
1 change: 0 additions & 1 deletion polars/polars-core/src/chunked_array/builder/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ impl BinaryChunkedBuilder {
field: Arc::new(self.field),
chunks: vec![arr],
phantom: PhantomData,
categorical_map: None,
bit_settings: Default::default(),
length,
}
Expand Down
1 change: 0 additions & 1 deletion polars/polars-core/src/chunked_array/builder/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ impl ChunkedBuilder<bool, BooleanType> for BooleanChunkedBuilder {
field: Arc::new(self.field),
chunks: vec![arr],
phantom: PhantomData,
categorical_map: None,
bit_settings: Default::default(),
length,
}
Expand Down
1 change: 0 additions & 1 deletion polars/polars-core/src/chunked_array/builder/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ macro_rules! finish_list_builder {
field: Arc::new($self.field.clone()),
chunks: vec![arr],
phantom: PhantomData,
categorical_map: None,
..Default::default()
};
ca.compute_len();
Expand Down
1 change: 0 additions & 1 deletion polars/polars-core/src/chunked_array/builder/primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ where
field: Arc::new(self.field),
chunks: vec![arr],
phantom: PhantomData,
categorical_map: None,
bit_settings: Default::default(),
length,
}
Expand Down
1 change: 0 additions & 1 deletion polars/polars-core/src/chunked_array/builder/utf8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ impl Utf8ChunkedBuilder {
field: Arc::new(self.field),
chunks: vec![arr],
phantom: PhantomData,
categorical_map: None,
bit_settings: Default::default(),
length,
}
Expand Down
3 changes: 0 additions & 3 deletions polars/polars-core/src/chunked_array/from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ where
field,
chunks,
phantom: PhantomData,
categorical_map: None,
bit_settings: Default::default(),
length: 0,
};
Expand All @@ -81,7 +80,6 @@ impl Int32Chunked {
field,
chunks,
phantom: PhantomData,
categorical_map: None,
bit_settings: Default::default(),
length: 0,
};
Expand Down Expand Up @@ -111,7 +109,6 @@ where
field: Arc::new(Field::new(name, T::get_dtype())),
chunks: vec![arr],
phantom: PhantomData,
categorical_map: None,
..Default::default()
};
out.compute_len();
Expand Down
7 changes: 0 additions & 7 deletions polars/polars-core/src/chunked_array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ use std::slice::Iter;
use bitflags::bitflags;
use polars_arrow::prelude::*;

#[cfg(feature = "dtype-categorical")]
use crate::chunked_array::categorical::RevMapping;
use crate::series::IsSorted;
use crate::utils::{first_non_null, last_non_null, CustomIterTools};

Expand Down Expand Up @@ -151,9 +149,6 @@ pub struct ChunkedArray<T: PolarsDataType> {
pub(crate) field: Arc<Field>,
pub(crate) chunks: Vec<ArrayRef>,
phantom: PhantomData<T>,
/// TODO! remove this. Should be in the DataType
/// maps categorical u32 indexes to String values
pub(crate) categorical_map: Option<Arc<RevMapping>>,
pub(crate) bit_settings: Settings,
length: IdxSize,
}
Expand Down Expand Up @@ -337,7 +332,6 @@ impl<T: PolarsDataType> ChunkedArray<T> {
field: self.field.clone(),
chunks,
phantom: PhantomData,
categorical_map: self.categorical_map.clone(),
bit_settings: self.bit_settings,
length: 0,
};
Expand Down Expand Up @@ -546,7 +540,6 @@ impl<T: PolarsDataType> Clone for ChunkedArray<T> {
field: self.field.clone(),
chunks: self.chunks.clone(),
phantom: PhantomData,
categorical_map: self.categorical_map.clone(),
bit_settings: self.bit_settings,
length: self.length,
}
Expand Down
2 changes: 0 additions & 2 deletions polars/polars-core/src/chunked_array/object/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ where
field: Arc::new(self.field),
chunks: vec![arr],
phantom: PhantomData,
categorical_map: None,
bit_settings: Default::default(),
length: len as IdxSize,
}
Expand Down Expand Up @@ -139,7 +138,6 @@ where
field,
chunks: vec![arr],
phantom: PhantomData,
categorical_map: None,
bit_settings: Default::default(),
length: len as IdxSize,
}
Expand Down
2 changes: 0 additions & 2 deletions polars/polars-core/src/chunked_array/upstream_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ impl<T: PolarsDataType> Default for ChunkedArray<T> {
field: Arc::new(Field::new("default", DataType::Null)),
chunks: Default::default(),
phantom: PhantomData,
categorical_map: None,
bit_settings: Default::default(),
length: 0,
}
Expand Down Expand Up @@ -341,7 +340,6 @@ impl<T: PolarsObject> FromIterator<Option<T>> for ObjectChunked<T> {
field: Arc::new(Field::new("", DataType::Object(T::type_name()))),
chunks: vec![arr],
phantom: PhantomData,
categorical_map: None,
bit_settings: Default::default(),
length: 0,
};
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-core/src/frame/groupby/into_groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ where
{
// set group size hint
#[cfg(feature = "dtype-categorical")]
let group_size_hint = if let Some(m) = &ca.categorical_map {
let group_size_hint = if let DataType::Categorical(Some(m)) = ca.dtype() {
ca.len() / m.len()
} else {
0
Expand Down

0 comments on commit 05afe5b

Please sign in to comment.