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

Method from_binary

arrow-row/src/lib.rs:1132–1150  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 ///

Callers 5

test_invalid_utf8_arrayFunction · 0.45
test_invalid_empty_arrayFunction · 0.45
fuzz_testFunction · 0.45

Calls 5

collectMethod · 0.80
as_usizeMethod · 0.80
into_vecMethod · 0.80
into_partsMethod · 0.45
iterMethod · 0.45

Tested by 4

test_invalid_utf8_arrayFunction · 0.36
test_invalid_empty_arrayFunction · 0.36