Create a [BinaryArray] from the [Rows] data without reallocating the underlying bytes. ``` # use std::sync::Arc; # use std::collections::HashSet; # use arrow_array::cast::AsArray; # use arrow_array::StringArray; # use arrow_row::{OwnedRow, Row, RowConverter, RowParser, SortField}; # use arrow_schema::DataType; # let converter = RowConverter::new(vec![SortField::new(DataType::Utf8)]).unwrap(); le
(self)
| 1348 | /// This function will return an error if there is more data than can be stored in |
| 1349 | /// a [BinaryArray] -- i.e. if the total data size is more than 2GiB. |
| 1350 | pub fn try_into_binary(self) -> Result<BinaryArray, ArrowError> { |
| 1351 | if self.buffer.len() > i32::MAX as usize { |
| 1352 | return Err(ArrowError::InvalidArgumentError(format!( |
| 1353 | "{}-byte rows buffer too long to convert into a i32-indexed BinaryArray", |
| 1354 | self.buffer.len() |
| 1355 | ))); |
| 1356 | } |
| 1357 | // We've checked that the buffer length fits in an i32; so all offsets into that buffer should fit as well. |
| 1358 | let offsets_scalar = ScalarBuffer::from_iter(self.offsets.into_iter().map(i32::usize_as)); |
| 1359 | // SAFETY: offsets buffer is nonempty, monotonically increasing, and all represent valid indexes into buffer. |
| 1360 | let array = unsafe { |
| 1361 | BinaryArray::new_unchecked( |
| 1362 | OffsetBuffer::new_unchecked(offsets_scalar), |
| 1363 | Buffer::from_vec(self.buffer), |
| 1364 | None, |
| 1365 | ) |
| 1366 | }; |
| 1367 | Ok(array) |
| 1368 | } |
| 1369 | } |
| 1370 | |
| 1371 | impl<'a> IntoIterator for &'a Rows { |