Returns a zero-copy slice of this array with the indicated offset and length.
(&self, offset: usize, len: usize)
| 299 | |
| 300 | /// Returns a zero-copy slice of this array with the indicated offset and length. |
| 301 | pub fn slice(&self, offset: usize, len: usize) -> Self { |
| 302 | assert!( |
| 303 | offset.saturating_add(len) <= self.len, |
| 304 | "the length + offset of the sliced FixedSizeBinaryArray cannot exceed the existing length" |
| 305 | ); |
| 306 | let offset_bytes = offset |
| 307 | .checked_mul(self.value_size) |
| 308 | .expect("offset overflow"); |
| 309 | let len_bytes = len.checked_mul(self.value_size).expect("offset overflow"); |
| 310 | |
| 311 | Self { |
| 312 | data_type: self.data_type.clone(), |
| 313 | nulls: self.nulls.as_ref().map(|n| n.slice(offset, len)), |
| 314 | value_size: self.value_size, |
| 315 | value_data: self.value_data.slice_with_length(offset_bytes, len_bytes), |
| 316 | len, |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | /// Create an array from an iterable argument of sparse byte slices. |
| 321 | /// Sparsity means that items returned by the iterator are optional, i.e input argument can |
no test coverage detected