mirror of
https://github.com/NexVeridian/ark-invest-api-rust-data.git
synced 2025-09-02 09:59:12 +00:00
refactor: Box<LazyFrame>
This commit is contained in:
parent
723e649568
commit
b3b7087041
2 changed files with 7 additions and 7 deletions
|
@ -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,
|
||||
|
|
|
@ -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(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue