MCPcopy Create free account
hub / github.com/apache/arrow-rs / new_repeated

Method new_repeated

arrow-array/src/array/byte_array.rs:198–214  ·  view source on GitHub ↗

Create a new [`GenericByteArray`] where `value` is repeated `repeat_count` times. # Panics This will panic if value's length multiplied by `repeat_count` overflows usize.

(value: impl AsRef<T::Native>, repeat_count: usize)

Source from the content-addressed store, hash-verified

196 /// This will panic if value's length multiplied by `repeat_count` overflows usize.
197 ///
198 pub fn new_repeated(value: impl AsRef<T::Native>, repeat_count: usize) -> Self {
199 let s: &[u8] = value.as_ref().as_ref();
200 let value_offsets = OffsetBuffer::from_repeated_length(s.len(), repeat_count);
201 let bytes: Buffer = {
202 let mut mutable_buffer = MutableBuffer::with_capacity(0);
203 mutable_buffer.repeat_slice_n_times(s, repeat_count);
204
205 mutable_buffer.into()
206 };
207
208 Self {
209 data_type: T::DATA_TYPE,
210 value_data: bytes,
211 value_offsets,
212 nulls: None,
213 }
214 }
215
216 /// Creates a [`GenericByteArray`] based on an iterator of values without nulls
217 pub fn from_iter_values<Ptr, I>(iter: I) -> Self

Callers

nothing calls this directly

Calls 3

repeat_slice_n_timesMethod · 0.80
as_refMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected