-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Migrate polars-expr AggregationContext to use
Column
(#19736
- Loading branch information
1 parent
869d1b9
commit 058491f
Showing
29 changed files
with
531 additions
and
357 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
use std::ops::{Deref, DerefMut}; | ||
|
||
use super::Series; | ||
|
||
/// A very thin wrapper around [`Series`] that represents a [`Column`]ized version of [`Series`]. | ||
/// | ||
/// At the moment this just conditionally tracks where it was created so that materialization | ||
/// problems can be tracked down. | ||
#[derive(Debug, Clone)] | ||
pub struct SeriesColumn { | ||
inner: Series, | ||
|
||
#[cfg(debug_assertions)] | ||
materialized_at: Option<std::sync::Arc<std::backtrace::Backtrace>>, | ||
} | ||
|
||
impl SeriesColumn { | ||
#[track_caller] | ||
pub fn new(series: Series) -> Self { | ||
Self { | ||
inner: series, | ||
|
||
#[cfg(debug_assertions)] | ||
materialized_at: if std::env::var("POLARS_TRACK_SERIES_MATERIALIZATION").as_deref() | ||
== Ok("1") | ||
{ | ||
Some(std::sync::Arc::new( | ||
std::backtrace::Backtrace::force_capture(), | ||
)) | ||
} else { | ||
None | ||
}, | ||
} | ||
} | ||
|
||
pub fn materialized_at(&self) -> Option<&std::backtrace::Backtrace> { | ||
#[cfg(debug_assertions)] | ||
{ | ||
self.materialized_at.as_ref().map(|v| v.as_ref()) | ||
} | ||
|
||
#[cfg(not(debug_assertions))] | ||
None | ||
} | ||
|
||
pub fn take(self) -> Series { | ||
self.inner | ||
} | ||
} | ||
|
||
impl From<Series> for SeriesColumn { | ||
#[track_caller] | ||
#[inline(always)] | ||
fn from(value: Series) -> Self { | ||
Self::new(value) | ||
} | ||
} | ||
|
||
impl Deref for SeriesColumn { | ||
type Target = Series; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.inner | ||
} | ||
} | ||
|
||
impl DerefMut for SeriesColumn { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.inner | ||
} | ||
} |
Oops, something went wrong.