Skip to content

Commit

Permalink
Remove redundant implementation of StringArrayType
Browse files Browse the repository at this point in the history
Signed-off-by: Tai Le Manh <[email protected]>
  • Loading branch information
tlm365 committed Nov 17, 2024
1 parent 008b5fe commit df4e07d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 36 deletions.
36 changes: 2 additions & 34 deletions arrow-string/src/like.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
//! 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;

#[derive(Debug)]
Expand Down Expand Up @@ -150,39 +151,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
2 changes: 0 additions & 2 deletions arrow-string/src/regexp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
//! Defines kernel to extract substrings based on a regular
//! expression of a \[Large\]StringArray

use crate::like::StringArrayType;

use arrow_array::builder::{BooleanBufferBuilder, GenericStringBuilder, ListBuilder};
use arrow_array::cast::AsArray;
use arrow_array::*;
Expand Down

0 comments on commit df4e07d

Please sign in to comment.