Create a new [Rows] instance from the given binary data. ``` # 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(); let array = StringArray::from(vec
(&self, array: BinaryArray)
| 1130 | /// [RowConverter]. It will panic if any rows are null. Operations on the returned [Rows] may |
| 1131 | /// panic if the data is malformed. |
| 1132 | pub fn from_binary(&self, array: BinaryArray) -> Rows { |
| 1133 | assert_eq!( |
| 1134 | array.null_count(), |
| 1135 | 0, |
| 1136 | "can't construct Rows instance from array with nulls" |
| 1137 | ); |
| 1138 | let (offsets, values, _) = array.into_parts(); |
| 1139 | let offsets = offsets.iter().map(|&i| i.as_usize()).collect(); |
| 1140 | // Try zero-copy, if it does not succeed, fall back to copying the values. |
| 1141 | let buffer = values.into_vec().unwrap_or_else(|values| values.to_vec()); |
| 1142 | Rows { |
| 1143 | buffer, |
| 1144 | offsets, |
| 1145 | config: RowConfig { |
| 1146 | fields: Arc::clone(&self.fields), |
| 1147 | validate_utf8: true, |
| 1148 | }, |
| 1149 | } |
| 1150 | } |
| 1151 | |
| 1152 | /// Convert raw bytes into [`ArrayRef`] |
| 1153 | /// |