Skip to content

Commit

Permalink
remove unneeded AsofJoin trait
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Oct 21, 2021
1 parent 50a93c7 commit 62fe1be
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 45 deletions.
21 changes: 2 additions & 19 deletions polars/polars-core/src/frame/asof_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,12 @@ use crate::utils::CustomIterTools;
use num::Bounded;
use polars_arrow::trusted_len::PushUnchecked;

pub(crate) trait JoinAsof<T: PolarsDataType> {
fn join_asof(&self, _other: &Series) -> Result<Vec<Option<u32>>> {
Err(PolarsError::InvalidOperation(
format!(
"asof join not implemented for key with dtype: {:?}",
T::get_dtype()
)
.into(),
))
}
}

impl<T> JoinAsof<T> for ChunkedArray<T>
impl<T> ChunkedArray<T>
where
T: PolarsNumericType,
T::Native: Bounded + PartialOrd,
{
fn join_asof(&self, other: &Series) -> Result<Vec<Option<u32>>> {
pub(crate) fn join_asof(&self, other: &Series) -> Result<Vec<Option<u32>>> {
let other = self.unpack_series_matching_type(other)?;
let mut rhs_iter = other.into_iter().peekable();
let mut tuples = Vec::with_capacity(self.len());
Expand Down Expand Up @@ -102,11 +90,6 @@ where
}
}

impl JoinAsof<BooleanType> for BooleanChunked {}
impl JoinAsof<Utf8Type> for Utf8Chunked {}
impl JoinAsof<ListType> for ListChunked {}
impl JoinAsof<CategoricalType> for CategoricalChunked {}

impl DataFrame {
/// This is similar to a left-join except that we match on nearest key rather than equal keys.
/// The keys must be sorted to perform an asof join
Expand Down
7 changes: 0 additions & 7 deletions polars/polars-core/src/series/implementations/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ use crate::chunked_array::{
AsSinglePtr, ChunkIdIter,
};
use crate::fmt::FmtList;
#[cfg(feature = "asof_join")]
use crate::frame::asof_join::JoinAsof;
#[cfg(feature = "pivot")]
use crate::frame::groupby::pivot::*;
use crate::frame::groupby::*;
Expand Down Expand Up @@ -43,11 +41,6 @@ impl private::PrivateSeries for SeriesWrap<BooleanChunked> {
self.0.explode_by_offsets(offsets)
}

#[cfg(feature = "asof_join")]
fn join_asof(&self, other: &Series) -> Result<Vec<Option<u32>>> {
self.0.join_asof(other)
}

fn set_sorted(&mut self, reverse: bool) {
self.0.set_sorted(reverse)
}
Expand Down
7 changes: 0 additions & 7 deletions polars/polars-core/src/series/implementations/categorical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ use crate::chunked_array::{
AsSinglePtr, ChunkIdIter,
};
use crate::fmt::FmtList;
#[cfg(feature = "asof_join")]
use crate::frame::asof_join::JoinAsof;
#[cfg(feature = "pivot")]
use crate::frame::groupby::pivot::*;
use crate::frame::groupby::*;
Expand Down Expand Up @@ -45,11 +43,6 @@ impl private::PrivateSeries for SeriesWrap<CategoricalChunked> {
self.0.explode_by_offsets(offsets)
}

#[cfg(feature = "asof_join")]
fn join_asof(&self, other: &Series) -> Result<Vec<Option<u32>>> {
self.0.join_asof(other)
}

fn set_sorted(&mut self, reverse: bool) {
self.0.set_sorted(reverse)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ macro_rules! impl_dyn_series {

#[cfg(feature = "asof_join")]
fn join_asof(&self, other: &Series) -> Result<Vec<Option<u32>>> {
use crate::frame::asof_join::JoinAsof;
self.0.deref().join_asof(other)
}

Expand Down
2 changes: 0 additions & 2 deletions polars/polars-core/src/series/implementations/floats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ use crate::chunked_array::{
AsSinglePtr, ChunkIdIter,
};
use crate::fmt::FmtList;
#[cfg(feature = "asof_join")]
use crate::frame::asof_join::JoinAsof;
#[cfg(feature = "pivot")]
use crate::frame::groupby::pivot::*;
use crate::frame::groupby::*;
Expand Down
2 changes: 0 additions & 2 deletions polars/polars-core/src/series/implementations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ use crate::chunked_array::{
AsSinglePtr, ChunkIdIter,
};
use crate::fmt::FmtList;
#[cfg(feature = "asof_join")]
use crate::frame::asof_join::JoinAsof;
#[cfg(feature = "pivot")]
use crate::frame::groupby::pivot::*;
use crate::frame::groupby::*;
Expand Down
7 changes: 0 additions & 7 deletions polars/polars-core/src/series/implementations/utf8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ use crate::chunked_array::{
AsSinglePtr, ChunkIdIter,
};
use crate::fmt::FmtList;
#[cfg(feature = "asof_join")]
use crate::frame::asof_join::JoinAsof;
#[cfg(feature = "pivot")]
use crate::frame::groupby::pivot::*;
use crate::frame::groupby::*;
Expand Down Expand Up @@ -41,11 +39,6 @@ impl private::PrivateSeries for SeriesWrap<Utf8Chunked> {
self.0.explode_by_offsets(offsets)
}

#[cfg(feature = "asof_join")]
fn join_asof(&self, other: &Series) -> Result<Vec<Option<u32>>> {
self.0.join_asof(other)
}

fn set_sorted(&mut self, reverse: bool) {
self.0.set_sorted(reverse)
}
Expand Down

0 comments on commit 62fe1be

Please sign in to comment.