pub use crate::core::types::NullEquality;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum NullableJoin {
MaybeNull,
NoNulls,
}
impl NullableJoin {
pub(crate) fn to_raw(self) -> cudf_sys::cudf_nullable_join_t {
match self {
NullableJoin::MaybeNull => cudf_sys::CUDF_NULLABLE_JOIN_YES,
NullableJoin::NoNulls => cudf_sys::CUDF_NULLABLE_JOIN_NO,
}
}
}
#[derive(Debug, Clone, Copy)]
pub(crate) struct HashJoinOptions {
nullable_join: NullableJoin,
null_eq: NullEquality,
load_factor: f64,
}
impl Default for HashJoinOptions {
fn default() -> Self {
Self::new()
}
}
impl HashJoinOptions {
pub fn new() -> Self {
Self { nullable_join: NullableJoin::MaybeNull, null_eq: NullEquality::Equal, load_factor: 0.5 }
}
pub fn nullable_join(mut self, nullable_join: NullableJoin) -> Self {
self.nullable_join = nullable_join;
self
}
pub fn null_equality(mut self, null_eq: NullEquality) -> Self {
self.null_eq = null_eq;
self
}
pub fn load_factor(mut self, load_factor: f64) -> Self {
self.load_factor = load_factor;
self
}
pub fn nullable_join_setting(&self) -> NullableJoin {
self.nullable_join
}
pub fn null_eq(&self) -> NullEquality {
self.null_eq
}
pub fn load_factor_value(&self) -> f64 {
self.load_factor
}
}
#[derive(Debug, Clone, Copy)]
pub(crate) struct FilteredJoinOptions {
null_eq: NullEquality,
load_factor: f64,
}
impl Default for FilteredJoinOptions {
fn default() -> Self {
Self::new()
}
}
impl FilteredJoinOptions {
pub fn new() -> Self {
Self { null_eq: NullEquality::Equal, load_factor: 0.5 }
}
pub fn null_equality(mut self, null_eq: NullEquality) -> Self {
self.null_eq = null_eq;
self
}
pub fn load_factor(mut self, load_factor: f64) -> Self {
self.load_factor = load_factor;
self
}
pub fn null_eq(&self) -> NullEquality {
self.null_eq
}
pub fn load_factor_value(&self) -> f64 {
self.load_factor
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum JoinType {
Inner,
Left,
Full,
}
#[derive(Debug, Clone)]
pub struct MergeOptions {
join_type: JoinType,
on: Option<Vec<String>>,
left_on: Option<Vec<String>>,
right_on: Option<Vec<String>>,
null_eq: NullEquality,
suffix_left: String,
suffix_right: String,
}
impl Default for MergeOptions {
fn default() -> Self {
Self::new()
}
}
impl MergeOptions {
pub fn new() -> Self {
Self {
join_type: JoinType::Inner,
on: None,
left_on: None,
right_on: None,
null_eq: NullEquality::Equal,
suffix_left: "_left".to_string(),
suffix_right: "_right".to_string(),
}
}
pub fn on<I, S>(mut self, keys: I) -> Self
where
I: IntoIterator<Item = S>,
S: AsRef<str>,
{
self.on = Some(keys.into_iter().map(|s| s.as_ref().to_string()).collect());
self
}
pub fn left_on<I, S>(mut self, keys: I) -> Self
where
I: IntoIterator<Item = S>,
S: AsRef<str>,
{
self.left_on = Some(keys.into_iter().map(|s| s.as_ref().to_string()).collect());
self
}
pub fn right_on<I, S>(mut self, keys: I) -> Self
where
I: IntoIterator<Item = S>,
S: AsRef<str>,
{
self.right_on = Some(keys.into_iter().map(|s| s.as_ref().to_string()).collect());
self
}
pub fn how(mut self, join_type: JoinType) -> Self {
self.join_type = join_type;
self
}
pub fn how_inner(self) -> Self {
self.how(JoinType::Inner)
}
pub fn how_left(self) -> Self {
self.how(JoinType::Left)
}
pub fn how_full(self) -> Self {
self.how(JoinType::Full)
}
pub fn null_equality(mut self, null_eq: NullEquality) -> Self {
self.null_eq = null_eq;
self
}
pub fn suffixes(mut self, left: &str, right: &str) -> Self {
self.suffix_left = left.to_string();
self.suffix_right = right.to_string();
self
}
pub fn join_type(&self) -> JoinType {
self.join_type
}
pub fn on_keys(&self) -> Option<&[String]> {
self.on.as_deref()
}
pub fn left_on_keys(&self) -> Option<&[String]> {
self.left_on.as_deref()
}
pub fn right_on_keys(&self) -> Option<&[String]> {
self.right_on.as_deref()
}
pub fn suffix_left(&self) -> &str {
&self.suffix_left
}
pub fn suffix_right(&self) -> &str {
&self.suffix_right
}
pub fn null_eq(&self) -> NullEquality {
self.null_eq
}
}