Path: blob/main/crates/polars-core/src/series/implementations/binary.rs
6940 views
use super::*;1use crate::chunked_array::cast::CastOptions;2use crate::chunked_array::comparison::*;3#[cfg(feature = "algorithm_group_by")]4use crate::frame::group_by::*;5use crate::prelude::*;67impl private::PrivateSeries for SeriesWrap<BinaryChunked> {8fn compute_len(&mut self) {9self.0.compute_len()10}11fn _field(&self) -> Cow<'_, Field> {12Cow::Borrowed(self.0.ref_field())13}14fn _dtype(&self) -> &DataType {15self.0.ref_field().dtype()16}17fn _get_flags(&self) -> StatisticsFlags {18self.0.get_flags()19}20fn _set_flags(&mut self, flags: StatisticsFlags) {21self.0.set_flags(flags)22}2324unsafe fn equal_element(&self, idx_self: usize, idx_other: usize, other: &Series) -> bool {25self.0.equal_element(idx_self, idx_other, other)26}2728#[cfg(feature = "zip_with")]29fn zip_with_same_type(&self, mask: &BooleanChunked, other: &Series) -> PolarsResult<Series> {30ChunkZip::zip_with(&self.0, mask, other.as_ref().as_ref()).map(|ca| ca.into_series())31}32fn into_total_eq_inner<'a>(&'a self) -> Box<dyn TotalEqInner + 'a> {33(&self.0).into_total_eq_inner()34}35fn into_total_ord_inner<'a>(&'a self) -> Box<dyn TotalOrdInner + 'a> {36(&self.0).into_total_ord_inner()37}3839fn vec_hash(40&self,41random_state: PlSeedableRandomStateQuality,42buf: &mut Vec<u64>,43) -> PolarsResult<()> {44self.0.vec_hash(random_state, buf)?;45Ok(())46}4748fn vec_hash_combine(49&self,50build_hasher: PlSeedableRandomStateQuality,51hashes: &mut [u64],52) -> PolarsResult<()> {53self.0.vec_hash_combine(build_hasher, hashes)?;54Ok(())55}5657#[cfg(feature = "algorithm_group_by")]58unsafe fn agg_list(&self, groups: &GroupsType) -> Series {59self.0.agg_list(groups)60}6162#[cfg(feature = "algorithm_group_by")]63unsafe fn agg_min(&self, groups: &GroupsType) -> Series {64self.0.agg_min(groups)65}6667#[cfg(feature = "algorithm_group_by")]68unsafe fn agg_max(&self, groups: &GroupsType) -> Series {69self.0.agg_max(groups)70}7172fn subtract(&self, rhs: &Series) -> PolarsResult<Series> {73NumOpsDispatch::subtract(&self.0, rhs)74}75fn add_to(&self, rhs: &Series) -> PolarsResult<Series> {76NumOpsDispatch::add_to(&self.0, rhs)77}78fn multiply(&self, rhs: &Series) -> PolarsResult<Series> {79NumOpsDispatch::multiply(&self.0, rhs)80}81fn divide(&self, rhs: &Series) -> PolarsResult<Series> {82NumOpsDispatch::divide(&self.0, rhs)83}84fn remainder(&self, rhs: &Series) -> PolarsResult<Series> {85NumOpsDispatch::remainder(&self.0, rhs)86}87#[cfg(feature = "algorithm_group_by")]88fn group_tuples(&self, multithreaded: bool, sorted: bool) -> PolarsResult<GroupsType> {89IntoGroupsType::group_tuples(&self.0, multithreaded, sorted)90}9192fn arg_sort_multiple(93&self,94by: &[Column],95options: &SortMultipleOptions,96) -> PolarsResult<IdxCa> {97self.0.arg_sort_multiple(by, options)98}99}100101impl SeriesTrait for SeriesWrap<BinaryChunked> {102fn rename(&mut self, name: PlSmallStr) {103self.0.rename(name);104}105106fn chunk_lengths(&self) -> ChunkLenIter<'_> {107self.0.chunk_lengths()108}109fn name(&self) -> &PlSmallStr {110self.0.name()111}112113fn chunks(&self) -> &Vec<ArrayRef> {114self.0.chunks()115}116unsafe fn chunks_mut(&mut self) -> &mut Vec<ArrayRef> {117self.0.chunks_mut()118}119fn shrink_to_fit(&mut self) {120self.0.shrink_to_fit()121}122123fn slice(&self, offset: i64, length: usize) -> Series {124self.0.slice(offset, length).into_series()125}126fn split_at(&self, offset: i64) -> (Series, Series) {127let (a, b) = self.0.split_at(offset);128(a.into_series(), b.into_series())129}130131fn append(&mut self, other: &Series) -> PolarsResult<()> {132polars_ensure!(self.0.dtype() == other.dtype(), append);133// todo! add object134self.0.append(other.as_ref().as_ref())?;135Ok(())136}137fn append_owned(&mut self, other: Series) -> PolarsResult<()> {138polars_ensure!(self.0.dtype() == other.dtype(), append);139self.0.append_owned(other.take_inner())140}141142fn extend(&mut self, other: &Series) -> PolarsResult<()> {143polars_ensure!(self.0.dtype() == other.dtype(), extend);144self.0.extend(other.as_ref().as_ref())?;145Ok(())146}147148fn filter(&self, filter: &BooleanChunked) -> PolarsResult<Series> {149ChunkFilter::filter(&self.0, filter).map(|ca| ca.into_series())150}151152fn take(&self, indices: &IdxCa) -> PolarsResult<Series> {153Ok(self.0.take(indices)?.into_series())154}155156unsafe fn take_unchecked(&self, indices: &IdxCa) -> Series {157self.0.take_unchecked(indices).into_series()158}159160fn take_slice(&self, indices: &[IdxSize]) -> PolarsResult<Series> {161Ok(self.0.take(indices)?.into_series())162}163164unsafe fn take_slice_unchecked(&self, indices: &[IdxSize]) -> Series {165self.0.take_unchecked(indices).into_series()166}167168fn len(&self) -> usize {169self.0.len()170}171172fn rechunk(&self) -> Series {173self.0.rechunk().into_owned().into_series()174}175176fn new_from_index(&self, index: usize, length: usize) -> Series {177ChunkExpandAtIndex::new_from_index(&self.0, index, length).into_series()178}179180fn cast(&self, dtype: &DataType, options: CastOptions) -> PolarsResult<Series> {181self.0.cast_with_options(dtype, options)182}183184#[inline]185unsafe fn get_unchecked(&self, index: usize) -> AnyValue<'_> {186self.0.get_any_value_unchecked(index)187}188189fn sort_with(&self, options: SortOptions) -> PolarsResult<Series> {190Ok(ChunkSort::sort_with(&self.0, options).into_series())191}192193fn arg_sort(&self, options: SortOptions) -> IdxCa {194ChunkSort::arg_sort(&self.0, options)195}196197fn null_count(&self) -> usize {198self.0.null_count()199}200201fn has_nulls(&self) -> bool {202self.0.has_nulls()203}204205#[cfg(feature = "algorithm_group_by")]206fn unique(&self) -> PolarsResult<Series> {207ChunkUnique::unique(&self.0).map(|ca| ca.into_series())208}209210#[cfg(feature = "algorithm_group_by")]211fn n_unique(&self) -> PolarsResult<usize> {212ChunkUnique::n_unique(&self.0)213}214215#[cfg(feature = "algorithm_group_by")]216fn arg_unique(&self) -> PolarsResult<IdxCa> {217ChunkUnique::arg_unique(&self.0)218}219220#[cfg(feature = "approx_unique")]221fn approx_n_unique(&self) -> PolarsResult<IdxSize> {222Ok(ChunkApproxNUnique::approx_n_unique(&self.0))223}224225fn is_null(&self) -> BooleanChunked {226self.0.is_null()227}228229fn is_not_null(&self) -> BooleanChunked {230self.0.is_not_null()231}232233fn reverse(&self) -> Series {234ChunkReverse::reverse(&self.0).into_series()235}236237fn as_single_ptr(&mut self) -> PolarsResult<usize> {238self.0.as_single_ptr()239}240241fn shift(&self, periods: i64) -> Series {242ChunkShift::shift(&self.0, periods).into_series()243}244245fn max_reduce(&self) -> PolarsResult<Scalar> {246Ok(ChunkAggSeries::max_reduce(&self.0))247}248fn min_reduce(&self) -> PolarsResult<Scalar> {249Ok(ChunkAggSeries::min_reduce(&self.0))250}251252fn clone_inner(&self) -> Arc<dyn SeriesTrait> {253Arc::new(SeriesWrap(Clone::clone(&self.0)))254}255256fn find_validity_mismatch(&self, other: &Series, idxs: &mut Vec<IdxSize>) {257self.0.find_validity_mismatch(other, idxs)258}259260fn as_any(&self) -> &dyn Any {261&self.0262}263264fn as_any_mut(&mut self) -> &mut dyn Any {265&mut self.0266}267268fn as_phys_any(&self) -> &dyn Any {269&self.0270}271272fn as_arc_any(self: Arc<Self>) -> Arc<dyn Any + Send + Sync> {273self as _274}275}276277278