polars_core/series/implementations/
binary.rs1use super::*;
2use crate::chunked_array::cast::CastOptions;
3#[cfg(feature = "algorithm_group_by")]
4use crate::frame::group_by::*;
5use crate::prelude::*;
6
7impl private::PrivateSeries for SeriesWrap<BinaryChunked> {
8 fn compute_len(&mut self) {
9 self.0.compute_len()
10 }
11 fn _field(&self) -> Cow<'_, Field> {
12 Cow::Borrowed(self.0.ref_field())
13 }
14 fn _dtype(&self) -> &DataType {
15 self.0.ref_field().dtype()
16 }
17 fn _get_flags(&self) -> StatisticsFlags {
18 self.0.get_flags()
19 }
20 fn _set_flags(&mut self, flags: StatisticsFlags) {
21 self.0.set_flags(flags)
22 }
23
24 #[cfg(feature = "zip_with")]
25 fn zip_with_same_type(&self, mask: &BooleanChunked, other: &Series) -> PolarsResult<Series> {
26 ChunkZip::zip_with(&self.0, mask, other.as_ref().as_ref()).map(|ca| ca.into_series())
27 }
28 fn into_total_eq_inner<'a>(&'a self) -> Box<dyn TotalEqInner + 'a> {
29 (&self.0).into_total_eq_inner()
30 }
31 fn into_total_ord_inner<'a>(&'a self) -> Box<dyn TotalOrdInner + 'a> {
32 (&self.0).into_total_ord_inner()
33 }
34
35 fn vec_hash(
36 &self,
37 random_state: PlSeedableRandomStateQuality,
38 buf: &mut Vec<u64>,
39 ) -> PolarsResult<()> {
40 self.0.vec_hash(random_state, buf)?;
41 Ok(())
42 }
43
44 fn vec_hash_combine(
45 &self,
46 build_hasher: PlSeedableRandomStateQuality,
47 hashes: &mut [u64],
48 ) -> PolarsResult<()> {
49 self.0.vec_hash_combine(build_hasher, hashes)?;
50 Ok(())
51 }
52
53 #[cfg(feature = "algorithm_group_by")]
54 unsafe fn agg_list(&self, groups: &GroupsType) -> Series {
55 self.0.agg_list(groups)
56 }
57
58 #[cfg(feature = "algorithm_group_by")]
59 unsafe fn agg_min(&self, groups: &GroupsType) -> Series {
60 self.0.agg_min(groups)
61 }
62
63 #[cfg(feature = "algorithm_group_by")]
64 unsafe fn agg_max(&self, groups: &GroupsType) -> Series {
65 self.0.agg_max(groups)
66 }
67
68 #[cfg(feature = "algorithm_group_by")]
69 unsafe fn agg_arg_min(&self, groups: &GroupsType) -> Series {
70 self.0.agg_arg_min(groups)
71 }
72
73 #[cfg(feature = "algorithm_group_by")]
74 unsafe fn agg_arg_max(&self, groups: &GroupsType) -> Series {
75 self.0.agg_arg_max(groups)
76 }
77
78 fn subtract(&self, rhs: &Series) -> PolarsResult<Series> {
79 NumOpsDispatch::subtract(&self.0, rhs)
80 }
81 fn add_to(&self, rhs: &Series) -> PolarsResult<Series> {
82 NumOpsDispatch::add_to(&self.0, rhs)
83 }
84 fn multiply(&self, rhs: &Series) -> PolarsResult<Series> {
85 NumOpsDispatch::multiply(&self.0, rhs)
86 }
87 fn divide(&self, rhs: &Series) -> PolarsResult<Series> {
88 NumOpsDispatch::divide(&self.0, rhs)
89 }
90 fn remainder(&self, rhs: &Series) -> PolarsResult<Series> {
91 NumOpsDispatch::remainder(&self.0, rhs)
92 }
93 #[cfg(feature = "algorithm_group_by")]
94 fn group_tuples(&self, multithreaded: bool, sorted: bool) -> PolarsResult<GroupsType> {
95 IntoGroupsType::group_tuples(&self.0, multithreaded, sorted)
96 }
97
98 fn arg_sort_multiple(
99 &self,
100 by: &[Column],
101 options: &SortMultipleOptions,
102 ) -> PolarsResult<IdxCa> {
103 self.0.arg_sort_multiple(by, options)
104 }
105}
106
107impl SeriesTrait for SeriesWrap<BinaryChunked> {
108 fn rename(&mut self, name: PlSmallStr) {
109 self.0.rename(name);
110 }
111
112 fn chunk_lengths(&self) -> ChunkLenIter<'_> {
113 self.0.chunk_lengths()
114 }
115 fn name(&self) -> &PlSmallStr {
116 self.0.name()
117 }
118
119 fn chunks(&self) -> &Vec<ArrayRef> {
120 self.0.chunks()
121 }
122 unsafe fn chunks_mut(&mut self) -> &mut Vec<ArrayRef> {
123 self.0.chunks_mut()
124 }
125 fn shrink_to_fit(&mut self) {
126 self.0.shrink_to_fit()
127 }
128
129 fn slice(&self, offset: i64, length: usize) -> Series {
130 self.0.slice(offset, length).into_series()
131 }
132 fn split_at(&self, offset: i64) -> (Series, Series) {
133 let (a, b) = self.0.split_at(offset);
134 (a.into_series(), b.into_series())
135 }
136
137 fn append(&mut self, other: &Series) -> PolarsResult<()> {
138 polars_ensure!(self.0.dtype() == other.dtype(), append);
139 self.0.append(other.as_ref().as_ref())?;
141 Ok(())
142 }
143 fn append_owned(&mut self, other: Series) -> PolarsResult<()> {
144 polars_ensure!(self.0.dtype() == other.dtype(), append);
145 self.0.append_owned(other.take_inner())
146 }
147
148 fn extend(&mut self, other: &Series) -> PolarsResult<()> {
149 polars_ensure!(self.0.dtype() == other.dtype(), extend);
150 self.0.extend(other.as_ref().as_ref())?;
151 Ok(())
152 }
153
154 fn filter(&self, filter: &BooleanChunked) -> PolarsResult<Series> {
155 ChunkFilter::filter(&self.0, filter).map(|ca| ca.into_series())
156 }
157
158 fn take(&self, indices: &IdxCa) -> PolarsResult<Series> {
159 Ok(self.0.take(indices)?.into_series())
160 }
161
162 unsafe fn take_unchecked(&self, indices: &IdxCa) -> Series {
163 self.0.take_unchecked(indices).into_series()
164 }
165
166 fn take_slice(&self, indices: &[IdxSize]) -> PolarsResult<Series> {
167 Ok(self.0.take(indices)?.into_series())
168 }
169
170 unsafe fn take_slice_unchecked(&self, indices: &[IdxSize]) -> Series {
171 self.0.take_unchecked(indices).into_series()
172 }
173
174 fn deposit(&self, validity: &Bitmap) -> Series {
175 self.0.deposit(validity).into_series()
176 }
177
178 fn len(&self) -> usize {
179 self.0.len()
180 }
181
182 fn rechunk(&self) -> Series {
183 self.0.rechunk().into_owned().into_series()
184 }
185
186 fn with_validity(&self, validity: Option<Bitmap>) -> Series {
187 self.0.clone().with_validity(validity).into_series()
188 }
189
190 fn new_from_index(&self, index: usize, length: usize) -> Series {
191 ChunkExpandAtIndex::new_from_index(&self.0, index, length).into_series()
192 }
193
194 fn cast(&self, dtype: &DataType, options: CastOptions) -> PolarsResult<Series> {
195 self.0.cast_with_options(dtype, options)
196 }
197
198 #[inline]
199 unsafe fn get_unchecked(&self, index: usize) -> AnyValue<'_> {
200 self.0.get_any_value_unchecked(index)
201 }
202
203 fn sort_with(&self, options: SortOptions) -> PolarsResult<Series> {
204 Ok(ChunkSort::sort_with(&self.0, options).into_series())
205 }
206
207 fn arg_sort(&self, options: SortOptions) -> IdxCa {
208 ChunkSort::arg_sort(&self.0, options)
209 }
210
211 fn null_count(&self) -> usize {
212 self.0.null_count()
213 }
214
215 fn has_nulls(&self) -> bool {
216 self.0.has_nulls()
217 }
218
219 #[cfg(feature = "algorithm_group_by")]
220 fn unique(&self) -> PolarsResult<Series> {
221 ChunkUnique::unique(&self.0).map(|ca| ca.into_series())
222 }
223
224 #[cfg(feature = "algorithm_group_by")]
225 fn n_unique(&self) -> PolarsResult<usize> {
226 ChunkUnique::n_unique(&self.0)
227 }
228
229 #[cfg(feature = "algorithm_group_by")]
230 fn arg_unique(&self) -> PolarsResult<IdxCa> {
231 ChunkUnique::arg_unique(&self.0)
232 }
233
234 #[cfg(feature = "algorithm_group_by")]
235 fn unique_id(&self) -> PolarsResult<(IdxSize, Vec<IdxSize>)> {
236 ChunkUnique::unique_id(&self.0)
237 }
238
239 #[cfg(feature = "approx_unique")]
240 fn approx_n_unique(&self) -> PolarsResult<IdxSize> {
241 Ok(ChunkApproxNUnique::approx_n_unique(&self.0))
242 }
243
244 fn is_null(&self) -> BooleanChunked {
245 self.0.is_null()
246 }
247
248 fn is_not_null(&self) -> BooleanChunked {
249 self.0.is_not_null()
250 }
251
252 fn reverse(&self) -> Series {
253 ChunkReverse::reverse(&self.0).into_series()
254 }
255
256 fn as_single_ptr(&mut self) -> PolarsResult<usize> {
257 self.0.as_single_ptr()
258 }
259
260 fn shift(&self, periods: i64) -> Series {
261 ChunkShift::shift(&self.0, periods).into_series()
262 }
263
264 fn max_reduce(&self) -> PolarsResult<Scalar> {
265 Ok(ChunkAggSeries::max_reduce(&self.0))
266 }
267 fn min_reduce(&self) -> PolarsResult<Scalar> {
268 Ok(ChunkAggSeries::min_reduce(&self.0))
269 }
270
271 fn clone_inner(&self) -> Arc<dyn SeriesTrait> {
272 Arc::new(SeriesWrap(Clone::clone(&self.0)))
273 }
274
275 fn find_validity_mismatch(&self, other: &Series, idxs: &mut Vec<IdxSize>) {
276 self.0.find_validity_mismatch(other, idxs)
277 }
278
279 fn as_any(&self) -> &dyn Any {
280 &self.0
281 }
282
283 fn as_any_mut(&mut self) -> &mut dyn Any {
284 &mut self.0
285 }
286
287 fn as_phys_any(&self) -> &dyn Any {
288 &self.0
289 }
290
291 fn as_arc_any(self: Arc<Self>) -> Arc<dyn Any + Send + Sync> {
292 self as _
293 }
294}