refactor: Box<LazyFrame>

This commit is contained in:
Elijah McMorris 2025-03-28 15:44:34 -07:00
parent 723e649568
commit b3b7087041
Signed by: NexVeridian
SSH key fingerprint: SHA256:bsA1SKZxuEcEVHAy3gY1HUeM5ykRJl0U0kQHQn0hMg8
2 changed files with 7 additions and 7 deletions

View file

@ -46,7 +46,7 @@ impl Ark {
let mut ark = Self {
df: match existing_file {
true => Self::read_parquet(&ticker, path.as_ref())?,
false => DF::DataFrame(df!["date" => [""],]?),
false => DF::DataFrame(Box::new(df!["date" => [""],]?)),
},
ticker,
path,

View file

@ -4,19 +4,19 @@ use polars::prelude::{IntoLazy, LazyFrame};
#[derive(Clone)]
pub enum DF {
LazyFrame(LazyFrame),
DataFrame(DataFrame),
LazyFrame(Box<LazyFrame>),
DataFrame(Box<DataFrame>),
}
impl From<LazyFrame> for DF {
fn from(lf: LazyFrame) -> Self {
Self::LazyFrame(lf)
Self::LazyFrame(Box::new(lf))
}
}
impl From<DataFrame> for DF {
fn from(df: DataFrame) -> Self {
Self::DataFrame(df)
Self::DataFrame(Box::new(df))
}
}
@ -24,12 +24,12 @@ impl DF {
pub fn collect(self) -> anyhow::Result<DataFrame, Error> {
match self {
Self::LazyFrame(x) => Ok(x.collect()?),
Self::DataFrame(x) => Ok(x),
Self::DataFrame(x) => Ok(*x),
}
}
pub fn lazy(self) -> LazyFrame {
match self {
Self::LazyFrame(x) => x,
Self::LazyFrame(x) => *x,
Self::DataFrame(x) => x.lazy(),
}
}