Path: blob/main/crates/polars-core/src/frame/column/series.rs
6940 views
use std::ops::{Deref, DerefMut};12use super::Series;34/// A very thin wrapper around [`Series`] that represents a [`Column`]ized version of [`Series`].5///6/// At the moment this just conditionally tracks where it was created so that materialization7/// problems can be tracked down.8#[derive(Debug, Clone)]9#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]10#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]11pub struct SeriesColumn {12inner: Series,1314#[cfg(debug_assertions)]15#[cfg_attr(feature = "serde", serde(skip, default))]16materialized_at: Option<std::sync::Arc<std::backtrace::Backtrace>>,17}1819impl SeriesColumn {20#[track_caller]21pub fn new(series: Series) -> Self {22Self {23inner: series,2425#[cfg(debug_assertions)]26materialized_at: if std::env::var("POLARS_TRACK_SERIES_MATERIALIZATION").as_deref()27== Ok("1")28{29Some(std::sync::Arc::new(30std::backtrace::Backtrace::force_capture(),31))32} else {33None34},35}36}3738pub fn materialized_at(&self) -> Option<&std::backtrace::Backtrace> {39#[cfg(debug_assertions)]40{41self.materialized_at.as_ref().map(|v| v.as_ref())42}4344#[cfg(not(debug_assertions))]45None46}4748pub fn take(self) -> Series {49self.inner50}51}5253impl From<Series> for SeriesColumn {54#[track_caller]55#[inline(always)]56fn from(value: Series) -> Self {57Self::new(value)58}59}6061impl Deref for SeriesColumn {62type Target = Series;6364fn deref(&self) -> &Self::Target {65&self.inner66}67}6869impl DerefMut for SeriesColumn {70fn deref_mut(&mut self) -> &mut Self::Target {71&mut self.inner72}73}747576