Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove useless SeriesTrait::get implementations #20136

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions crates/polars-core/src/series/implementations/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,6 @@ impl SeriesTrait for SeriesWrap<ArrayChunked> {
self.0.cast_with_options(dtype, options)
}

fn get(&self, index: usize) -> PolarsResult<AnyValue> {
self.0.get_any_value(index)
}

#[inline]
unsafe fn get_unchecked(&self, index: usize) -> AnyValue {
self.0.get_any_value_unchecked(index)
Expand Down
4 changes: 0 additions & 4 deletions crates/polars-core/src/series/implementations/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,6 @@ impl SeriesTrait for SeriesWrap<BinaryChunked> {
self.0.cast_with_options(dtype, options)
}

fn get(&self, index: usize) -> PolarsResult<AnyValue> {
self.0.get_any_value(index)
}

#[inline]
unsafe fn get_unchecked(&self, index: usize) -> AnyValue {
self.0.get_any_value_unchecked(index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@ impl SeriesTrait for SeriesWrap<BinaryOffsetChunked> {
self.0.cast_with_options(dtype, options)
}

fn get(&self, index: usize) -> PolarsResult<AnyValue> {
self.0.get_any_value(index)
}

#[inline]
unsafe fn get_unchecked(&self, index: usize) -> AnyValue {
self.0.get_any_value_unchecked(index)
Expand Down
4 changes: 0 additions & 4 deletions crates/polars-core/src/series/implementations/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,6 @@ impl SeriesTrait for SeriesWrap<BooleanChunked> {
self.0.cast_with_options(dtype, options)
}

fn get(&self, index: usize) -> PolarsResult<AnyValue> {
self.0.get_any_value(index)
}

#[inline]
unsafe fn get_unchecked(&self, index: usize) -> AnyValue {
self.0.get_any_value_unchecked(index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,6 @@ impl SeriesTrait for SeriesWrap<CategoricalChunked> {
self.0.cast_with_options(dtype, options)
}

fn get(&self, index: usize) -> PolarsResult<AnyValue> {
self.0.get_any_value(index)
}

#[inline]
unsafe fn get_unchecked(&self, index: usize) -> AnyValue {
self.0.get_any_value_unchecked(index)
Expand Down
4 changes: 0 additions & 4 deletions crates/polars-core/src/series/implementations/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,6 @@ impl SeriesTrait for SeriesWrap<DateChunked> {
}
}

fn get(&self, index: usize) -> PolarsResult<AnyValue> {
self.0.get_any_value(index)
}

#[inline]
unsafe fn get_unchecked(&self, index: usize) -> AnyValue {
self.0.get_any_value_unchecked(index)
Expand Down
4 changes: 0 additions & 4 deletions crates/polars-core/src/series/implementations/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,6 @@ impl SeriesTrait for SeriesWrap<DatetimeChunked> {
}
}

fn get(&self, index: usize) -> PolarsResult<AnyValue> {
self.0.get_any_value(index)
}

#[inline]
unsafe fn get_unchecked(&self, index: usize) -> AnyValue {
self.0.get_any_value_unchecked(index)
Expand Down
4 changes: 0 additions & 4 deletions crates/polars-core/src/series/implementations/decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,6 @@ impl SeriesTrait for SeriesWrap<DecimalChunked> {
self.0.cast_with_options(dtype, cast_options)
}

fn get(&self, index: usize) -> PolarsResult<AnyValue> {
self.0.get_any_value(index)
}

#[inline]
unsafe fn get_unchecked(&self, index: usize) -> AnyValue {
self.0.get_any_value_unchecked(index)
Expand Down
4 changes: 0 additions & 4 deletions crates/polars-core/src/series/implementations/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,6 @@ impl SeriesTrait for SeriesWrap<DurationChunked> {
self.0.cast_with_options(dtype, cast_options)
}

fn get(&self, index: usize) -> PolarsResult<AnyValue> {
self.0.get_any_value(index)
}

#[inline]
unsafe fn get_unchecked(&self, index: usize) -> AnyValue {
self.0.get_any_value_unchecked(index)
Expand Down
4 changes: 0 additions & 4 deletions crates/polars-core/src/series/implementations/floats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,6 @@ macro_rules! impl_dyn_series {
self.0.cast_with_options(dtype, cast_options)
}

fn get(&self, index: usize) -> PolarsResult<AnyValue> {
self.0.get_any_value(index)
}

#[inline]
unsafe fn get_unchecked(&self, index: usize) -> AnyValue {
self.0.get_any_value_unchecked(index)
Expand Down
4 changes: 0 additions & 4 deletions crates/polars-core/src/series/implementations/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@ impl SeriesTrait for SeriesWrap<ListChunked> {
self.0.cast_with_options(dtype, cast_options)
}

fn get(&self, index: usize) -> PolarsResult<AnyValue> {
self.0.get_any_value(index)
}

#[inline]
unsafe fn get_unchecked(&self, index: usize) -> AnyValue {
self.0.get_any_value_unchecked(index)
Expand Down
4 changes: 0 additions & 4 deletions crates/polars-core/src/series/implementations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,6 @@ macro_rules! impl_dyn_series {
self.0.cast_with_options(dtype, options)
}

fn get(&self, index: usize) -> PolarsResult<AnyValue> {
self.0.get_any_value(index)
}

#[inline]
unsafe fn get_unchecked(&self, index: usize) -> AnyValue {
self.0.get_any_value_unchecked(index)
Expand Down
5 changes: 0 additions & 5 deletions crates/polars-core/src/series/implementations/null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,6 @@ impl SeriesTrait for NullChunked {
NullChunked::new(self.name.clone(), length).into_series()
}

fn get(&self, index: usize) -> PolarsResult<AnyValue> {
polars_ensure!(index < self.len(), oob = index, self.len());
Ok(AnyValue::Null)
}

unsafe fn get_unchecked(&self, _index: usize) -> AnyValue {
AnyValue::Null
}
Expand Down
4 changes: 0 additions & 4 deletions crates/polars-core/src/series/implementations/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,6 @@ impl SeriesTrait for SeriesWrap<StringChunked> {
self.0.cast_with_options(dtype, cast_options)
}

fn get(&self, index: usize) -> PolarsResult<AnyValue> {
self.0.get_any_value(index)
}

#[inline]
unsafe fn get_unchecked(&self, index: usize) -> AnyValue {
self.0.get_any_value_unchecked(index)
Expand Down
4 changes: 0 additions & 4 deletions crates/polars-core/src/series/implementations/struct_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,6 @@ impl SeriesTrait for SeriesWrap<StructChunked> {
self.0.cast_with_options(dtype, cast_options)
}

fn get(&self, index: usize) -> PolarsResult<AnyValue> {
self.0.get_any_value(index)
}

unsafe fn get_unchecked(&self, index: usize) -> AnyValue {
self.0.get_any_value_unchecked(index)
}
Expand Down
4 changes: 0 additions & 4 deletions crates/polars-core/src/series/implementations/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,6 @@ impl SeriesTrait for SeriesWrap<TimeChunked> {
}
}

fn get(&self, index: usize) -> PolarsResult<AnyValue> {
self.0.get_any_value(index)
}

#[inline]
unsafe fn get_unchecked(&self, index: usize) -> AnyValue {
self.0.get_any_value_unchecked(index)
Expand Down
11 changes: 7 additions & 4 deletions crates/polars-core/src/series/series_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,12 @@ pub trait SeriesTrait:

/// Get a single value by index. Don't use this operation for loops as a runtime cast is
/// needed for every iteration.
fn get(&self, _index: usize) -> PolarsResult<AnyValue>;
fn get(&self, index: usize) -> PolarsResult<AnyValue> {
polars_ensure!(index < self.len(), oob = index, self.len());
// SAFETY: Just did bounds check
let value = unsafe { self.get_unchecked(index) };
Ok(value)
}

/// Get a single value by index. Don't use this operation for loops as a runtime cast is
/// needed for every iteration.
Expand All @@ -407,9 +412,7 @@ pub trait SeriesTrait:
///
/// # Safety
/// Does not do any bounds checking
unsafe fn get_unchecked(&self, _index: usize) -> AnyValue {
invalid_operation_panic!(get_unchecked, self)
}
unsafe fn get_unchecked(&self, _index: usize) -> AnyValue;

fn sort_with(&self, _options: SortOptions) -> PolarsResult<Series> {
polars_bail!(opq = sort_with, self._dtype());
Expand Down
Loading