Skip to content

Commit

Permalink
Remove redundant implementation of StringArrayType (#6743)
Browse files Browse the repository at this point in the history
Signed-off-by: Tai Le Manh <[email protected]>
  • Loading branch information
tlm365 authored Nov 17, 2024
1 parent f5b51ff commit 84cf0d9
Showing 1 changed file with 4 additions and 34 deletions.
38 changes: 4 additions & 34 deletions arrow-string/src/like.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@
//! Provide SQL's LIKE operators for Arrow's string arrays

use crate::predicate::Predicate;

use arrow_array::cast::AsArray;
use arrow_array::*;
use arrow_schema::*;
use arrow_select::take::take;
use iterator::ArrayIter;

use std::sync::Arc;

pub use arrow_array::StringArrayType;

#[derive(Debug)]
enum Op {
Like(bool),
Expand Down Expand Up @@ -150,39 +153,6 @@ fn like_op(op: Op, lhs: &dyn Datum, rhs: &dyn Datum) -> Result<BooleanArray, Arr
}
}

/// A trait for Arrow String Arrays, currently three types are supported:
/// - `StringArray`
/// - `LargeStringArray`
/// - `StringViewArray`
///
/// This trait helps to abstract over the different types of string arrays
/// so that we don't need to duplicate the implementation for each type.
pub trait StringArrayType<'a>: ArrayAccessor<Item = &'a str> + Sized {
/// Returns true if all data within this string array is ASCII
fn is_ascii(&self) -> bool;
/// Constructs a new iterator
fn iter(&self) -> ArrayIter<Self>;
}

impl<'a, O: OffsetSizeTrait> StringArrayType<'a> for &'a GenericStringArray<O> {
fn is_ascii(&self) -> bool {
GenericStringArray::<O>::is_ascii(self)
}

fn iter(&self) -> ArrayIter<Self> {
GenericStringArray::<O>::iter(self)
}
}
impl<'a> StringArrayType<'a> for &'a StringViewArray {
fn is_ascii(&self) -> bool {
StringViewArray::is_ascii(self)
}

fn iter(&self) -> ArrayIter<Self> {
StringViewArray::iter(self)
}
}

fn apply<'a, T: StringArrayType<'a> + 'a>(
op: Op,
l: T,
Expand Down

0 comments on commit 84cf0d9

Please sign in to comment.