-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
1,998 additions
and
1,767 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use super::*; | ||
use crate::prelude::*; | ||
|
||
pub type Date32Chunked = Logical<Date32Type, Int32Type>; | ||
|
||
impl From<Int32Chunked> for Date32Chunked { | ||
fn from(ca: Int32Chunked) -> Self { | ||
Date32Chunked::new(ca) | ||
} | ||
} | ||
|
||
impl Int32Chunked { | ||
pub fn into_date(self) -> Date32Chunked { | ||
Date32Chunked::new(self) | ||
} | ||
} | ||
|
||
impl LogicalType for Date32Chunked { | ||
fn dtype(&self) -> &'static DataType { | ||
&DataType::Date32 | ||
} | ||
} |
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,22 @@ | ||
use super::*; | ||
use crate::prelude::*; | ||
|
||
pub type Date64Chunked = Logical<Date64Type, Int64Type>; | ||
|
||
impl From<Int64Chunked> for Date64Chunked { | ||
fn from(ca: Int64Chunked) -> Self { | ||
Date64Chunked::new(ca) | ||
} | ||
} | ||
|
||
impl Int64Chunked { | ||
pub fn into_date(self) -> Date64Chunked { | ||
Date64Chunked::new(self) | ||
} | ||
} | ||
|
||
impl LogicalType for Date64Chunked { | ||
fn dtype(&self) -> &'static DataType { | ||
&DataType::Date64 | ||
} | ||
} |
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,53 @@ | ||
mod date32; | ||
mod date64; | ||
|
||
pub use {date32::*, date64::*}; | ||
|
||
use crate::prelude::*; | ||
use std::marker::PhantomData; | ||
use std::ops::{Deref, DerefMut}; | ||
|
||
/// Maps a logical type to a a chunked array implementation of the physical type. | ||
/// This saves a lot of compiler bloat and allows us to reuse functionality. | ||
pub struct Logical<K: PolarsDataType, T: PolarsDataType>(pub ChunkedArray<T>, PhantomData<K>); | ||
|
||
impl<K: PolarsDataType, T: PolarsDataType> Clone for Logical<K, T> { | ||
fn clone(&self) -> Self { | ||
Logical::<K, _>::new(self.0.clone()) | ||
} | ||
} | ||
|
||
impl<K: PolarsDataType, T: PolarsDataType> Deref for Logical<K, T> { | ||
type Target = ChunkedArray<T>; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl<K: PolarsDataType, T: PolarsDataType> DerefMut for Logical<K, T> { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.0 | ||
} | ||
} | ||
|
||
impl<K: PolarsDataType, T: PolarsDataType> Logical<K, T> { | ||
pub fn new<J: PolarsDataType>(ca: ChunkedArray<T>) -> Logical<J, T> { | ||
Logical(ca, PhantomData) | ||
} | ||
} | ||
|
||
pub trait LogicalType { | ||
/// Get data type of ChunkedArray. | ||
fn dtype(&self) -> &'static DataType; | ||
} | ||
|
||
impl<K: PolarsDataType, T: PolarsDataType> Logical<K, T> | ||
where | ||
Self: LogicalType, | ||
{ | ||
pub fn field(&self) -> Field { | ||
let name = self.0.ref_field().name(); | ||
Field::new(name, LogicalType::dtype(self).clone()) | ||
} | ||
} |
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
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
Oops, something went wrong.